diff --git a/Bin/AIPSignApplet.txt b/Bin/AIPSignApplet.txt index 3fe1e38b6f0c23112c4171734a7ffbf673baefd7..06ee6075c3874414f66d04e725ba60b8e1b5783e 100644 --- a/Bin/AIPSignApplet.txt +++ b/Bin/AIPSignApplet.txt @@ -56,7 +56,7 @@ B、{"event":"Wrl_Listen","aid":2,"data":{"SID":"123","PID":"62978E9A-9B00-4E42- 2)、请求控制AIP电子签章内嵌网页小程序: 当前端不再需要小程序时可指定关闭,或者显示/隐藏及全屏显示等 -ID为Wrl_AIPSignApplet启动小程序时返回的ID值,Code代表控制类型掩码:1关闭 2全屏显示 4自动隐藏 8还原显示 16自动适配网页高度和宽度显示模式切换 32强制隐藏。其中全屏显示2,可直接通过热键ESC或取消,4和32隐藏后可通过8恢复显示 +ID为Wrl_AIPSignApplet或Wrl_AppletStart启动小程序时返回的ID值,Code代表控制类型掩码:1关闭 2全屏显示 4自动隐藏 8还原显示 16自动适配网页高度和宽度显示模式切换 32强制隐藏。其中全屏显示2,可直接通过热键ESC或取消,4和32隐藏后可通过8恢复显示 {"req":"Wrl_AppletControl","rid":2,"para":{"ID":"1","Code":4}} 3)、请求滚动网页中AIP电子签章内嵌小程序: @@ -68,7 +68,7 @@ Left为横向滚动条位置,Top为纵向滚动条位置 4)、请求改变网页中AIP电子签章内嵌网页小程序显示位置或大小: 当前端网页显示区域缩放时,可动态修改小程序的显示位置或大小 -ID为Wrl_AIPSignApplet启动小程序时返回JSON中的ID值,Width和Height分别为新的宽度和高度 +ID为Wrl_AIPSignApplet或Wrl_AppletStart启动小程序时返回JSON中的ID值,Width和Height分别为新的宽度和高度 X和Y分别为新的显示位置,不指定时保持不变,指定时原设置的IframeX和IframeY失效 {"req":"Wrl_AppletResize","rid":4,"para":{"ID":1,"Width":500,"Height":600}} 或,同时修改小程序显示起始坐标 @@ -81,21 +81,31 @@ Code 1代表有水平滚动条,2代表有垂直滚动条,3代表都有 ScrollTop垂直滚动条位置 ScrollTop水平滚动条位置 {"req":"Wrl_ScrollBar","rid":6,"para":{"ID":"1","Code":2,"BarW":0,"BarH":0,"ScrollTop":0,"ScrollLeft":0}} -6)、请求缩放网页中AIP电子签章内嵌网页小程序,用于浏览器网页按比例缩放时响应,一般不需要处理: -ID为Wrl_AIPSignApplet启动小程序时返回JSON中的ID值,Scall为缩放百分比 -{"req":"Wrl_AppletScale","rid":7,"para":{"ID":1,"Scale":120}} +6)、请求对小程序窗口做Alpha透明处理,便于前端临时显示覆盖到小程序窗口的菜单等: +ID为Wrl_AIPSignApplet或Wrl_AppletStart启动小程序时返回的ID值,Alpha为透明度百分比,1-100 +{"req":"Wrl_AppletAlpha","rid":7,"para":{"ID":1,"Alpha":30}} + +7)、请求对小程序窗口内容进行截图: +ID为启动小程序时返回JSON中的ID值, +File为指定截图文件保存路径或扩展名 +Base64指定为1时代表返回BASE64编码的图像内容 +{"req":"Wrl_AppletSnap","rid":10,"para":{"ID":1,"Base64":1,"File":".png"}} + +8)、请求缩放IE控件内嵌网页小程序,用于浏览器网页按比例缩放,一般不需要处理: +ID为启动小程序时返回JSON中的ID值,Scall为缩放百分比 +{"req":"Wrl_AppletScale","rid":11,"para":{"ID":1,"Scale":120}} 3、小程序安装、升级、卸载 1)、请求安装AIP电子签章内嵌网页小程序 请在输入框中,输入如下请求,然后点击发送,完成安装: -{"req":"Plugin_Install","rid":1,"para":{"Name":"AIP电子签章内嵌网页小程序","PID":"62978E9A-9B00-4E42-9E70-0BE7526E14C0","Date":"2020-12-12","Desc":"PluginOK之上跨浏览器的AIP电子签章内嵌网页小程序,支持在Chrome、Firefox、Edge、IE、Oprea、360、QQ等最新版本浏览器网页中内嵌使用","DownAddr":"http://local.zorrosoft.com/Files/Plugin/AIPSignApplet.pid","MD5":"E9776C1B985FD12042F72A91C8B6A260","Version":"2.0.3.11","Size":557056,"HideIns":0,"Type":8,"Cookie":"","Auth":"","TK":"BA7B2EFC0542E033769FB1D8B7626D7754723779FA110E31EC77413D3D484E68B1ABDF143325F80D0D161E8D0FFC57F7E53668F8F5C7736EEC1D6F2A1EB12E0EC4F5C4148B051F542DCF6ECA8038FBB3F1E3340E92920344A46D54F44BAF41E09D8375CEF4EF278C1ED27C7C439486ABAF2BBA79176F198918E4DA378D76CCEAAE8822FC086CD8BD568AED5080E772C9A23833782CF8C8DC797327BB61A46DA303A059B96A7E7946E389EA465A9FCFFE35838BBF9AF6571F583CB83184EECCC2152B3C7E179E7853C2C5C0B2BEF648B6D97A1DA4AB113FBAC15287B5AD921908B105975E80450892EFF148F42520A1E3BE361B319E3E5C7CFE3C4F84F927BF4B"}} +{"req":"Plugin_Install","rid":1,"para":{"Name":"AIP电子签章内嵌网页小程序","PID":"62978E9A-9B00-4E42-9E70-0BE7526E14C0","Date":"2021-01-20","Desc":"PluginOK之上跨浏览器的AIP电子签章内嵌网页小程序,支持在Chrome、Edge、Firefox、IE、Oprea、360、QQ等最新版本浏览器网页中内嵌使用","DownAddr":"http://local.zorrosoft.com/Files/Plugin/AIPSignApplet.pid","MD5":"9626E062E906454A234B4A7CD6810AC6","Version":"2.1.1.1","Size":557056,"HideIns":0,"Type":8,"Cookie":"","Auth":"","TK":"24FD9CE6002FEB5F21466A1C460EF7718CB51B1454C4D88907949925FB445E57046A1ED56D359333904B1C90261DC419B0552454CF8E21DB7DD2760F1C19CD7740B208DA1997EB7D277316ABDEF7F34C683B6AD9453D1123D7051891CC891A753ABDDC26DB2F05B255D83E7BE07A65FFD65B8D005582613A0D6E4ADED166286EB3BC6E074C15842AF91F754489145621CCB93840FF72D7AFC608ED285C0A6ACC8FEB965039D5A4266D84E22A51A9C6B0C8F0A2CEBC59252BF59BBDCD718DAD1842AF17349A4AB2D3DE30E544F0B14604A3CCC89FF6E51BDA618CE2444326D47961AC7709C1FF8A372530A5F61100851033D025831102E373297B299F10ADCFC1"}} 启动安装后,会不断收到安装进度直到安装结束。 2)、请求升级点聚AIP电子签章内嵌网页小程序: -{"req":"Plugin_Update","rid":1,"para":{"Name":"AIP电子签章内嵌网页小程序","PID":"62978E9A-9B00-4E42-9E70-0BE7526E14C0","Date":"2020-12-12","Desc":"PluginOK之上跨浏览器的AIP电子签章内嵌网页小程序,支持在Chrome、Firefox、Edge、IE、Oprea、360、QQ等最新版本浏览器网页中内嵌使用","DownAddr":"http://local.zorrosoft.com/Files/Plugin/AIPSignApplet_Update.pid","MD5":"644F2ED14DD21A3AC4F2D08FA96D57E0","Version":"2.0.3.11","Size":557056,"HideIns":0,"Type":8,"Cookie":"","Auth":"","TK":"21635E8644A58A60CACABA80484A7BDAF027189D404EE343C65D87FF880FD05CCC669F3F708ED794AD28082B7E56485DFF114074E0F9C8AFAC1E0AFB1907499CFE12BB67CB9499B0F53BD5C9726C5BC6EBC772020CDB54DE1751593C002C7925162FA258AF3F0545AEC2D3081E2C5F3D1FA5DC3943845D55B0ADF8B266E6B75B4A98536159CE2745846E526062B6BA6A95156765897AD5FF84B1F719AA22EFEAD55EA41BABBE0A9DEA703DBE8022785187F407F0B16375B93B210AAE3CF5C4B32A15AE2CC34A639C9B33372BA173027F66D3B623834CE4E28B6BBD382DFE7C3F9A49500B80EC032E4B75B0C40BFDFBF36A079BC353A71E606EC6B99ACBDC927A"}} +{"req":"Plugin_Update","rid":1,"para":{"Name":"AIP电子签章内嵌网页小程序","PID":"62978E9A-9B00-4E42-9E70-0BE7526E14C0","Date":"2021-01-20","Desc":"PluginOK之上跨浏览器的AIP电子签章内嵌网页小程序,支持在Chrome、Edge、Firefox、IE、Oprea、360、QQ等最新版本浏览器网页中内嵌使用","DownAddr":"http://local.zorrosoft.com/Files/Plugin/AIPSignApplet_Update.pid","MD5":"BC911A7A2DC330867AABB70FB59479B4","Version":"2.1.1.1","Size":557056,"HideIns":0,"Type":8,"Cookie":"","Auth":"","TK":"530A1208C3F04DFDFA3FA7C86828B50BD277823872CB79ADA9C5335F61543E52534ABE440F67DBA2414D2F24BDE0DBF4354E97759379E2ACE8AC046391B17FAE4B685D17633C4115D0542FCB87733272C439E6C65E6625CA3ED168C6E4F72F0E4159723B4FB04DB735D970BB075B6377B8DB543208FC960A4F23863E7A82AB66CF27C1B1EBE4952C4C73BC71163F84770DC24DF512CC64BDE764681BC9B9A89400B41A00EA49EC0C81EE10E4D19E3D57C8B84762DC55A356730A0106069B106E1B2BC488BD16993037C40508EAEA56FC06C5F4C70119F2028E09AF457BE6C8CF6CBE82FA2AC02DD13470987D9324AB5BD4C0BB69CCAF17EE12120FBD627F5873"}} 以上安装和升级的JSON请求包,可能因版本升级导致内容不同,如遇安装或升级时报错,请联系客服获取最新的请求包。 @@ -1309,4 +1319,4 @@ B、PluginOK支持的事件通知: 6、其它 请求参数的JSON数据包,请确保是UTF-8无签名的编码。 更多接口请求说明,请参考安装目录中的文档TestWrl.txt、SDK包中的“PluginOK开发者手册.doc”及“PluginOK中间件安全解决方案”。 -如还有疑问请直接联系客服 加微信:ZorroSoft,或加QQ群:23126938 \ No newline at end of file +如还有疑问请直接联系客服 加微信:ZorroSoft,或加QQ群:23126938 diff --git a/Bin/AutodeskApplet.txt b/Bin/AutodeskApplet.txt index 9b2cce50464e9c6c8b03fc2d2d4bb10a598d812f..e778bfca3df27f16dc4758678a1ad8990e7c61b1 100644 --- a/Bin/AutodeskApplet.txt +++ b/Bin/AutodeskApplet.txt @@ -1,4 +1,4 @@ -Autodesk内嵌网页小程序:基于跨浏览器的小程序系统-PluginOK(牛插)中间件( https://github.com/wangzuohuai/WebRunLocal )开发,底层调用Autodesk的AutoCAD软件VBA接口及DWG True View或Design Review的OCX控件实现可程序化驱动的dwg等工程图在线查看、编辑、审阅等,可分别将AutoCAD、DWG True View、Design Review软件窗口内嵌到网页指定区域运行并操控。最低可用在Chrome 41、Firefox 52、Edge 80(Chromium内核)、360极速/安全、IE 8、Oprea 36、QQ等浏览器,也兼容运行于这些浏览器的最新版本。 +Autodesk内嵌网页小程序:基于跨浏览器的小程序系统-PluginOK(牛插)中间件( https://github.com/wangzuohuai/WebRunLocal )开发,底层调用Autodesk的AutoCAD软件VBA接口及DWG TrueView或Design Review的OCX控件实现可程序化驱动的dwg等工程图在线查看、编辑、审阅等,可分别将AutoCAD、DWG TrueView、Design Review软件窗口内嵌到网页指定区域运行并操控。最低可用在Chrome 41、Firefox 52、Edge 80(Chromium内核)、360极速/安全、IE 8、Oprea 36、QQ等浏览器,也兼容运行于这些浏览器的最新版本。 1、PluginOK(牛插)中间件的安装: 1)、如果是exe的安装程序,请直接运行安装; @@ -39,7 +39,7 @@ Flag掩码标记:1指定新标签加载(1和16都不指定时为当前页加 IframeX和IframeY分别为iframe嵌套的横竖偏移修正坐标 BarW和BarH分别是网页右侧和底部预留区域 小程序实际显示首先会基于网页中指定的坐标和大小,再根据IframeX、IframeY、BarW、BarH设定的值做修正 -App:0启动AutoCAD实现在线编辑(推荐用2015及以上版本,可根据具体版本定制) 1启动DWG True View在线查看和转换 2启动Design Review在线审阅 +App:0启动AutoCAD实现在线编辑(推荐用2015及以上版本,可根据具体版本定制) 1启动DWG TrueView在线查看和转换 2启动Design Review在线审阅 Url:加载小程序所在的网页实际地址 Open:为需要打开的文档路径,磁盘目录斜杠用/ 注意:Open和Url如果有特殊字符或中文等,需要用URL编码处理后传递 @@ -47,7 +47,7 @@ Open:为需要打开的文档路径,磁盘目录斜杠用/ 自动识别当前浏览器并启动AutoCAD程序在线编辑dwg、dxf等文档 {"req":"Wrl_ACADApplet","rid":5,"para":{"Type":"0","Title":"Autodesk Applet","Flag":1,"IframeX":0,"IframeY":0,"BarW":0,"BarH":0,"Url": "http://zorrosoft.com/acadframe.html","App":"0","Open":"D:/Zorro/test.dwg"}} -自动识别当前浏览器并启动DWG True View程序在线查看或转换dwg文档 +自动识别当前浏览器并启动DWG TrueView程序在线查看或转换dwg文档 {"req":"Wrl_ACADApplet","rid":6,"para":{"Type":"0","Title":"Autodesk Applet","Flag":1,"IframeX":0,"IframeY":0,"BarW":0,"BarH":0,"Url": "http://zorrosoft.com/acadframe.html","App":"1","Open":"D:/Zorro/test.dwg"}} 自动识别当前浏览器并启动Design Review程序在线审阅dwg、dxf文档 @@ -91,22 +91,32 @@ Code 1代表有水平滚动条,2代表有垂直滚动条,3代表都有 ScrollTop垂直滚动条位置 ScrollTop水平滚动条位置 {"req":"Wrl_ScrollBar","rid":6,"para":{"ID":"1","Code":2,"BarW":0,"BarH":0,"ScrollTop":0,"ScrollLeft":0}} -6)、请求缩放微软Autodesk内嵌网页小程序,用于浏览器网页按比例缩放,一般不需要处理: +6)、请求对小程序窗口做Alpha透明处理,便于前端临时显示覆盖到小程序窗口的菜单等: +ID为Wrl_ACADApplet启动小程序时返回的ID值,Alpha为透明度百分比,1-100 +{"req":"Wrl_AppletAlpha","rid":7,"para":{"ID":1,"Alpha":30}} + +7)、请求对小程序窗口内容进行截图: +ID为启动小程序时返回JSON中的ID值, +File为指定截图文件保存路径或扩展名 +Base64指定为1时代表返回BASE64编码的图像内容 +{"req":"Wrl_AppletSnap","rid":10,"para":{"ID":1,"Base64":1,"File":".png"}} + +8)、请求缩放IE控件内嵌网页小程序,用于浏览器网页按比例缩放,一般不需要处理: ID为启动小程序时返回JSON中的ID值,Scall为缩放百分比 -{"req":"Wrl_AppletScale","rid":7,"para":{"ID":1,"Scale":120}} +{"req":"Wrl_AppletScale","rid":11,"para":{"ID":1,"Scale":120}} 3、小程序安装、升级、卸载 1)、请求安装Autodesk内嵌网页小程序 请在输入框中,输入如下请求,然后点击发送,完成安装: -{"req":"Plugin_Install","rid":1,"para":{"Name":"Autodesk内嵌网页小程序","PID":"997599C3-3C4D-445E-B741-0AD934B45459","Date":"2020-12-12","Desc":"PluginOK之上跨浏览器的Autodesk内嵌网页小程序,支持在Chrome、Firefox、Edge、IE、Oprea、360、QQ等最新版本浏览器网页中内嵌AutoCAD等程序进行在线编辑、查看或审阅工程图","DownAddr":"http://local.zorrosoft.com/Files/Plugin/ACadApplet.pid","MD5":"8707024DADD8A827F01EF1FE6B3DAB16","Version":"2.0.3.11","Size":688128,"HideIns":0,"Type":8,"Cookie":"","Auth":"","TK":"65E092DAA42BCC40348F9779A7798E508F68BFCC13FEEF79B377FD82CD709FFA0064E5F1740D2A54D13FD500257496B34CA38A158E3F90824E97E999DE63934582653E1936247142B98CF4B86BF416324975567FB0B486EB741CD1FE67103437C18F2996C176BFD374F5CEAD49A8DFF595B607393004087E9E8CB3DA67579544FD4D69F610144192F82193EB867B00A0B74AE26BD6C2D3F671B76A8D405C2DFFBD778F16B65443DE38C8BE2B3DE027B177FE7319AC23E0F2B269BCCE2E916CAEAB9F3DFB713906A0AEE06A32B6421354349AFB6742C21337358A2EB7EC4A1655A4F4C618D7AA74A56F41C27ED59E202CDC235BA3F5A36027DAFBCEA26480757A"}} +{"req":"Plugin_Install","rid":1,"para":{"Name":"Autodesk内嵌网页小程序","PID":"997599C3-3C4D-445E-B741-0AD934B45459","Date":"2021-01-20","Desc":"PluginOK之上跨浏览器的Autodesk内嵌网页小程序,支持在Chrome、Edge、Firefox、IE、Oprea、360、QQ等最新版本浏览器网页中内嵌AutoCAD等程序进行在线编辑、查看或审阅工程图","DownAddr":"http://local.zorrosoft.com/Files/Plugin/ACadApplet.pid","MD5":"392966D882D464DCAB4417D4166C30BD","Version":"2.1.1.1","Size":688128,"HideIns":0,"Type":8,"Cookie":"","Auth":"","TK":"C8A020716D8AB09C3450B088DB38C4BED248D4CF872F80549FF22F02D131C683A32225E35A88DDE7D3B3A9509158E9580420965E61120DB5AA2BA2833C7982CD596FF2CAA349F70DFA900328067DE9F2F0446165E15CF85CC369D6F7A6DE0E80D18DD7F9A122E4FDAA353A25831BC98BBA3E494A3B1ED85AC30EBC24485DEDF000FCDA4F8FE24AC25745FFBBF80D6A08CE8193E8D21569BFA93710C0E606453DE4B3E937B49FC058653206033A1E9DA98B13367E6BAC00C3C6C93FF9FB163BC35D3A4CCF372E0524F11A8517E324AD67A286FA82B5A5CC35A8195661D8A16C9C1DBB213BA2F0BB582C8C5217358B28C1B5DAFE6064FB8D8133217C11978BC922"}} 启动安装后,会不断收到安装进度直到安装结束。 在发布时,也可以把此小程序目录文件和中间件一起打包后发布,不用单独分发。 2)、请求升级Autodesk内嵌网页小程序: -{"req":"Plugin_Update","rid":1,"para":{"Name":"Autodesk内嵌网页小程序","PID":"997599C3-3C4D-445E-B741-0AD934B45459","Date":"2020-12-12","Desc":"PluginOK之上跨浏览器的Autodesk内嵌网页小程序,支持在Chrome、Firefox、Edge、IE、Oprea、360、QQ等最新版本浏览器网页中内嵌AutoCAD等程序进行在线编辑、查看或审阅工程图","DownAddr":"http://local.zorrosoft.com/Files/Plugin/ACadApplet_Update.pid","MD5":"092BDB17DA72FE833E602A85C0A930FD","Version":"2.0.3.11","Size":688128,"HideIns":0,"Type":8,"Cookie":"","Auth":"","TK":"AF873AE213CFAB5C7C21C65670BF9A43B64D9544F44E0B109F1F712BFE912B41E333357F9A4F59D20E286C28F8E806CAAE13705385015C213E9BDC415701EDD7865A93FF3E8A366BD0992F8E833D9692626834B5278D98BD7F0B0D1892AB8B3B2B34AEA0A213726E5FAA4AB8FB5E0723FC8A8B01F518D9F1CA58836A7B4F2DF01D30D6C7F0452C124FD95EF12625092022BF721580AEC7C3221A2722074F3C767FD2009CAA2AA7B685BFFBC7ABE61C75E2F87739241F393F9328A441895061BE3E4333F7FC1C6124DA08CF307E00EAE69792AC423D790D425F5AABE5BE794A949F03B3B4A38815DBA0FFD336603D099D9BB1BA06F932FF6381A20473461FBE3D"}} +{"req":"Plugin_Update","rid":1,"para":{"Name":"Autodesk内嵌网页小程序","PID":"997599C3-3C4D-445E-B741-0AD934B45459","Date":"2021-01-20","Desc":"PluginOK之上跨浏览器的Autodesk内嵌网页小程序,支持在Chrome、Edge、Firefox、IE、Oprea、360、QQ等最新版本浏览器网页中内嵌AutoCAD等程序进行在线编辑、查看或审阅工程图","DownAddr":"http://local.zorrosoft.com/Files/Plugin/ACadApplet_Update.pid","MD5":"736F100F85C1B2FB4F758AA1CED42D2D","Version":"2.1.1.1","Size":688128,"HideIns":0,"Type":8,"Cookie":"","Auth":"","TK":"8B2A89DD5A4E5F285C76547F12DF5CECF787D67AFC8ABA131898F8EEECEA028DA4B4F15A6D538D0910939273F5A610D2D4B8897025241E85E88B9BA307B62C8864DB43129D41B688D6DB2698B95CA723324465B9EABA4D46488BFCA47DE581104FD49A281072226ED73FCC1625850294CA270AFBB0C85C38F703194520985E9ED3D3389D1BC1C05F38CB6E0143D16415D2F61BEE68C175736A6CDEA10B8BB3AD03D8A885C5A5D8E1E663997A4D48B4EFEC43E6ADE7754BB9C741408E4968EA8AEF541B637F2092A9E6A54AC854FE8057E6D012D46980C527433F0E5FCD531876D3132A5FA89EA379029E58F85FBE7A11500B3EF253F35BF1CCC85AA8CCFBFE69"}} 以上安装和升级的JSON请求包,可能因版本升级导致内容不同,如遇安装或升级时报错,请联系客服获取最新的请求包。 @@ -114,18 +124,32 @@ ID为启动小程序时返回JSON中的ID值,Scall为缩放百分比 {"req":"Plugin_Remove","rid":3,"para":{"PID":"997599C3-3C4D-445E-B741-0AD934B45459","Type":8}} -4、Autodesk内嵌网页小程序转调用Autodesk的AutoCAD软件VBA接口及DWG True View或Design Review的OCX控件接口,先根据Wrl_ACADApplet请求启动后返回的端口号,新建立一个WebSocket连接后可执行如下指令: +4、Autodesk内嵌网页小程序转调用Autodesk的AutoCAD软件VBA接口及DWG TrueView或Design Review的OCX控件接口,先根据Wrl_ACADApplet请求启动后返回的端口号,新建立一个WebSocket连接后可执行如下指令: A、常用功能请求: -请求退出小程序 +1)、请求退出小程序 {"req":"ACAD_Exit","rid":1,"para":{}} -请求关闭文档 +返回: {"ret":0,"rid":1",data":{"Ret":"0"}} Ret为0代表成功 + +2)、请求关闭当前打开的文档 {"req":"ACAD_Close","rid":2,"para":{}} -请求打开文档 -{"req":"ACAD_Open","rid":3,"para":{"Open":"D:/Zorro/test.dwg"}} +返回: {"ret":0,"rid":2,"data":{"Ret":"0"}} Ret为0代表成功 + +3)、请求打开文档 +Open打开文档路径,如有特殊字符或中文的需要用URLCode先编码 PW打开密码 Read为1代表只读打开 +{"req":"ACAD_Open","rid":3,"para":{"Open":"D:/Zorro/test.dwg","PW":"","Read":0}} +返回: {"ret":0,"rid":3,"data":{"Ret":"0"}} Ret为0代表成功 + +4)、打开文档转换到PDF +SrcFile打开文档路径,如有特殊字符或中文的需要用URLCode先编码 PW打开密码,如已打开可不设置 +DestFile转换目标路径,如有特殊字符或中文的需要用URLCode先编码 +{"req":"ACAD_ConvertTo","rid":4,"para":{"SrcFile":"D:/Zorro/test1.dwg","DestFile":"D:/Zorro/test1.pdf","PW":""}} +返回: {"ret":0,"rid":4,"data":{"Ret":"0"}} Ret为0代表成功 + 5、事件通知: -A、 +A、文档激活 +{"event":"ACAD_DocActivate","data":{"Name":""}} Name为激活文档 B、PluginOK支持的事件通知: diff --git a/Bin/ChangeLog.txt b/Bin/ChangeLog.txt index 3014632e40b7aec0d546d63f1f248c2fca872ad2..73570d56103b6177339284ee04d895c8d4e2b3f0 100644 --- a/Bin/ChangeLog.txt +++ b/Bin/ChangeLog.txt @@ -1,4 +1,21 @@ -2020-12-12 PluginOK升级网络版2.0.7.6(单机版1.2.18.6) +2021-01-22 PluginOK重要升级网络版2.1.1.1(单机版1.3.1.1) + 1、增加HTTP及HTTPS侦听服务GET协议支持同步请求; + 2、内嵌小程序窗口支持Alpha透明,切换显示自动恢复; + 3、发布腾讯微信、企业微信等桌面软件内嵌网页体验版; + 4、优化网络版授权服务端,不允许修改网卡MAC地址使用; + 5、网络版有效授权支持可排除指定期限未登录终端; + 6、支持对高级版内嵌小程序窗口截图并返回到前端; + 7、优化IE控件及标签小程序对各快捷键的处理; + 8、Autodesk小程序优化并支持打印输出到PDF、PNG等; + 9、VLC网页播放小程序截图支持设置自定义保存路径; + 10、服务启动时自动输出可用配置项目到文件; + 11、解决网络版打包工具生成移机校验码错误问题; + 12、解决中间件安装到中文等目录时执行Wrl_RegCom异常问题; + 13、解决高级版解析HTML网页小程序Left坐标错误问题; + 14、解决IE标签页小程序启动后切换标签页显示错误问题; + 15、解决C#非DLL小程序无法收到WS连接关闭通知等问题。 + +2020-12-12 PluginOK升级网络版2.0.7.6(单机版1.2.18.6) 1、发布Autodesk公司内嵌网页小程序体验版,支持内嵌AutoCAD软件、DWG True View及Design Review的OCX控件实现可程序化驱动的dwg等工程图在线编辑、查看、审阅等,搭配文件操作小程序可实现工程图文件的下载后自动打开编辑、保存后自动上传服务器管理; 2、网络版支持前端请求自动移除指定终端电脑授权并卸载,回收可用授权数量; 3、小程序侦听IP可设置为实际IP,而非127.0.0.1并输出日志; diff --git a/Bin/FileApplet.txt b/Bin/FileApplet.txt index 0ab96ed142f033cfb30cac14163128ca01defc91..74020680c9d10303875210051ca26ceb5d49be0b 100644 --- a/Bin/FileApplet.txt +++ b/Bin/FileApplet.txt @@ -7,11 +7,11 @@ 2װļС -{"req":"Plugin_Install","rid":1,"para":{"Name":"ļС","PID":"199BB8A7-9DD5-41F5-AE9D-2AA94300B0B3","Date":"2020-12-12","Desc":"PluginOKм֮ϿļСṩļHTTPЭϴءͼļתļʡسеȷ񣬿ChromeEdgeFirefoxIEOpera360QQȵ°е","DownAddr":"http://local.zorrosoft.com/Files/Plugin/WrlFileApplet.pid","MD5":"371D26B8C6A35A5A48317C04D9EE1735","Version":"2.0.3.11","Size":491520,"HideIns":0,"Type":1,"Cookie":"","Auth":"","TK":"532632DC918676470FC065990C284015B3AD370E260707A7B97A205D6F237BA0011E989380B23F62F6D6BD53451066C85D17EF7317FA564639326F9A411FBD4F9742DAE05A2CADC431511C7FB64247F410547FE68F43D2FDCA799F42B9138D7364A0107590DB17223AC7C3C5AACDDE3755DE2D45BD525B514012F821F8295DB2D95876853CEA999E52EBF36BB544F9DE3F8BE118472C04E8CA26226C294827DC1D53DEBF6241F6DCDE09AC69B537A414BE900ADD9483A0FA94AA8EB1CCFC49C0439AE877B7E0D71AD28E858E7B7234F7388C7AC0D37CE3BFE4E97ACDC1095D939DD520344DFB4CDA531178855413CA6669E44A5637C17E531A022A64E419092E"}} +{"req":"Plugin_Install","rid":1,"para":{"Name":"ļС","PID":"199BB8A7-9DD5-41F5-AE9D-2AA94300B0B3","Date":"2021-01-22","Desc":"PluginOKм֮ϿļСṩļHTTPЭϴءͼļתļʡسеȷ񣬿ChromeEdgeFirefoxIEOpera360QQȵ°е","DownAddr":"http://local.zorrosoft.com/Files/Plugin/WrlFileApplet.pid","MD5":"0A169C026A1E43889B9D6E777D636A37","Version":"2.1.1.1","Size":491520,"HideIns":0,"Type":1,"Cookie":"","Auth":"","TK":"3F4CA380181A4AA4E71E83C0F2B31ED8C7D3EEE5DCA31AEB9D826B411E7BC4F3D3A9125BB4DDBCA99C1B1A010B1741327652926451142F15664EA990ADFA75477C723393FCCA94B44D0B63C71854F501EF1FDE8EDF808AF0EC40D09B8581A89564DAC915813233C972AF60FE21120AA347EBAECF6D55AF7509D33EBCFC1DCFDC28D210619B9146E14ACF5A31F4D0CB61D42531E269FDCEEA7D57D14C7CD1991EE0B16B6186409ABE423B2AC090107F8D6A58BDB64F052DCA3C0C12724B4B77B54A41EA92A46A048251CC8706402875F581394565E53CDC8494D9E69CBFF4554D8719880B57024845A9B0FB7B5D86BE87720F9B4D74B5B0C35F0C4D501BF243A4"}} 3ļС -{"req":"Plugin_Update","rid":1,"para":{"Name":"ļС","PID":"199BB8A7-9DD5-41F5-AE9D-2AA94300B0B3","Date":"2020-12-12","Desc":"PluginOKм֮ϿļСṩļHTTPЭϴءͼļתļʡسеȷ񣬿ChromeEdgeFirefoxIEOpera360QQȵ°е","DownAddr":"http://local.zorrosoft.com/Files/Plugin/WrlFileApplet_Update.pid","MD5":"7BF5F7F1AA6D6CBA7A040513B8C7D413","Version":"2.0.3.11","Size":491520,"HideIns":0,"Type":1,"Cookie":"","Auth":"","TK":"0DD9E2269A0C5D610AB44C6DB87C883A4BC272EE525320909465B6FDB65DE951E9ACE4B311149B163CA7A42C28DDB22BADA3F157E4886E6F12334BB841C9CA093F7239F478B6ED927D9E9B13BC0DC3C5C5F7C733B9AA0894C5E32B086FD7F6EB934B1609A6786B843FAF5A1CE69AB00D3B8F55DF0D06B997B140F53562F74EF0C0033130C14F248C7D72E753C85A67933D9E7ABA454B03773FFF805EC1CBF06A6310568BCA3C16D8759F21B9EEDB0780F7C66F646E14DEBA9B1F597E9F40C4748215B9908FEF9C7BA0D058A885EEC5F1B4CC33E92224893282F57841A66DEDD5852AC7440C3EFDA8A518D3A8FB1B8BA4159773ED7B83F7A3EB16F81FA809B681"}} +{"req":"Plugin_Update","rid":1,"para":{"Name":"ļС","PID":"199BB8A7-9DD5-41F5-AE9D-2AA94300B0B3","Date":"2021-01-22","Desc":"PluginOKм֮ϿļСṩļHTTPЭϴءͼļתļʡسеȷ񣬿ChromeEdgeFirefoxIEOpera360QQȵ°е","DownAddr":"http://local.zorrosoft.com/Files/Plugin/WrlFileApplet_Update.pid","MD5":"164B9F396DE013B8BD5848607DC88F5D","Version":"2.1.1.1","Size":491520,"HideIns":0,"Type":1,"Cookie":"","Auth":"","TK":"0454FCFE681C919931AF565C5E9196EB315DBE09E10390CDD7255E267F46D0688662735BF9997CADB3506E87901A079F74064BED38E7C98A3BABA220E498ACE928CEEB31D332B62EE190287395312C4BACD25E23A7DDF2C234EB03D0B16F703A06195C633DA216A263F9F25442BBC60B303BAB78E848D7E3A094295B76D0F38FCA1118D0F6195F448F82324AEC3E97DA7DE89F66D1B23AD025A3166D7668ACB4C79C845696DEC5D8127B039C64559ED51C5152235680ADD197CC6A9BFFDEA06FBFE8D5BDEBE838188A6D6C40C6ADBB9B7255C6050A6520457495407E0DAEBEA2313EB478CA07B8790528C6400E19469C88315509A5B8451CF02E3C6B561E5E6A"}} ϰװJSON汾ݲͬװʱϵͷȡµ diff --git a/Bin/FlashPlayerApplet.txt b/Bin/FlashPlayerApplet.txt index 245d3a7235b669db2a74ca5ac036a9b8f72910db..73b91757fff513ec43e9483dfa3e21af4a74a24b 100644 --- a/Bin/FlashPlayerApplet.txt +++ b/Bin/FlashPlayerApplet.txt @@ -44,7 +44,7 @@ Open:为需要播放的多媒体路径,磁盘目录斜杠用/ 注意:Open和Url如果有特殊字符或中文等,需要用URL编码处理后传递 举例: 自动识别当前浏览器指定位置和大小启动: -{"req":"Wrl_FlashApplet","rid":1,"para":{"Type":"0","Title":"Flash Applet","Flag":1,"IframeX":0,"IframeY":0,"BarW":0,"BarH":0,"Url":"http://zorrosoft.com/FlashApplet.html","Open":"http://zorrosoft.com/Files/test.swf"}} +{"req":"Wrl_FlashApplet","rid":1,"para":{"Type":"0","Title":"Flash Applet","Flag":1,"IframeX":0,"IframeY":0,"BarW":0,"BarH":0,"Url":"http://zorrosoft.com/FlashApplet.html","Open":"http://zorrosoft.com/Files.swf"}} 自动识别当前浏览器自动适配网页大小启动: {"req":"Wrl_FlashApplet","rid":3,"para":{"Type":"0","Title":"Flash Applet","Flag":9,"IframeX":0,"IframeY":0,"BarW":0,"BarH":0,"Url":"http://zorrosoft.com/FlashApplet.html","Open":"http://zorrosoft.com/Files/test.swf"}} @@ -85,22 +85,31 @@ Code 1代表有水平滚动条,2代表有垂直滚动条,3代表都有 ScrollTop垂直滚动条位置 ScrollTop水平滚动条位置 {"req":"Wrl_ScrollBar","rid":6,"para":{"ID":"1","Code":2,"BarW":0,"BarH":0,"ScrollTop":0,"ScrollLeft":0}} -6)、请求缩放网页中Flash Player内嵌网页小程序,用于浏览器网页按比例缩放时响应,一般不需要处理: -ID为Wrl_FlashApplet启动小程序时返回的ID值,Scall为缩放百分比 -{"req":"Wrl_AppletScale","rid":7,"para":{"ID":1,"Scale":120}} +6)、请求对小程序窗口做Alpha透明处理,便于前端临时显示覆盖到小程序窗口的菜单等: +ID为Wrl_FlashApplet启动小程序时返回的ID值,Alpha为透明度百分比,1-100 +{"req":"Wrl_AppletAlpha","rid":7,"para":{"ID":1,"Alpha":30}} +7)、请求对小程序窗口内容进行截图: +ID为启动小程序时返回JSON中的ID值, +File为指定截图文件保存路径或扩展名 +Base64指定为1时代表返回BASE64编码的图像内容 +{"req":"Wrl_AppletSnap","rid":10,"para":{"ID":1,"Base64":1,"File":".png"}} + +8)、请求缩放IE控件内嵌网页小程序,用于浏览器网页按比例缩放,一般不需要处理: +ID为启动小程序时返回JSON中的ID值,Scall为缩放百分比 +{"req":"Wrl_AppletScale","rid":11,"para":{"ID":1,"Scale":120}} 3、小程序安装、升级、卸载 1)、请求安装Flash Player内嵌网页小程序 请在输入框中,输入如下请求,然后点击发送,完成安装: -{"req":"Plugin_Install","rid":1,"para":{"Name":"Flash Player内嵌网页小程序","PID":"E7C7BDA6-C828-46F1-A7BA-B4C572A01100","Date":"2020-12-12","Desc":"PluginOK之上跨浏览器的Flash Player内嵌网页小程序,支持在Chrome、Firefox、Edge、IE、Oprea、360、QQ等最新版本浏览器网页中内嵌使用","DownAddr":"http://local.zorrosoft.com/Files/Plugin/FlashApplet.pid","MD5":"8BC01FA1DB86B9A0D04F247790229A1E","Version":"2.0.3.11","Size":524288,"HideIns":0,"Type":8,"Cookie":"","Auth":"","TK":"2DA27288A218FABF06D6AB8735F009D7236516290AAE5E9719608670FD97FC5503C0275AFC2F051949464199D4386A9A3E1531291D1A5CE6F137B8A4CD2165D235290A6EA162306777E9F10E7EB6F354B3C15AA00F56568E40D55B3C9F99484B1B2EB63119B995990DDD50F1528D44B54CA5E00669BCD55DFB47A22A2F1B9B8A557B895EAE65EC90C3727C52042D1B4DFD9276D3B382C56F1690974ACD9B219750349647B8A45C7CC9E37DF63B8D56721BD3CF2CDEB133043EE2D243EECD3EFBA6CF6094CCA0521F49252A63E0446B27B4C5E41A826A58B6B365F00213BBDB682682166A169E7E17B55FC39A86F663492235CD36594CB7BA2319CE08C30C8D98"}} +{"req":"Plugin_Install","rid":1,"para":{"Name":"Flash Player内嵌网页小程序","PID":"E7C7BDA6-C828-46F1-A7BA-B4C572A01100","Date":"2021-01-20","Desc":"PluginOK之上跨浏览器的Flash Player网页小程序,支持在Chrome、Edge、Firefox、IE、Oprea、360、QQ等最新版本浏览器网页中内嵌使用","DownAddr":"http://local.zorrosoft.com/Files/Plugin/FlashApplet.pid","MD5":"803BE4D5537B07886E79E2B6E8E49CD3","Version":"2.1.1.1","Size":10354688,"HideIns":0,"Type":8,"Cookie":"","Auth":"","TK":"6E502B2A4914C9F1A7F8CD26851A49E9C8250DA286AA60A2809452AA6E44A2541EE3AA5116BAEB5B0D2307D8D1E8ABC72C4F43EAC14F93D7DCCDEB2298D5310C11BFD8F1E0EC2E32C77E2E18A896B881C2D54D3FE29379F0B411A8DF174625D28A52E2BA976C5F731F8AD061AB0F5B270B302D8B75FCEBC696142576F1932E2444E061426D1900522F281F64149DBA0D04CA5E27751B137C5F9FFE0C2ADFA14A514CEC03E00FE8999D49037092B404D5FCD63FEAAE039E04B5A72A661E3C67587CCD27FB9814518C5134B4E3E9B09A9D657215F212EC03207E48CE88C6D4A7E9A2AA04082719321086681949C437D8E802F5ADEBB952880B80D43CC3110985D9"}} 启动安装后,会不断收到安装进度直到安装结束。 2)、请求升级Flash Player内嵌网页小程序: -{"req":"Plugin_Update","rid":1,"para":{"Name":"Flash Player内嵌网页小程序","PID":"E7C7BDA6-C828-46F1-A7BA-B4C572A01100","Date":"2020-12-12","Desc":"PluginOK之上跨浏览器的Flash Player内嵌网页小程序,支持在Chrome、Firefox、Edge、IE、Oprea、360、QQ等最新版本浏览器网页中内嵌使用","DownAddr":"http://local.zorrosoft.com/Files/Plugin/FlashApplet_Update.pid","MD5":"82AC72E2BA176EA2884143C7ABBA07CE","Version":"2.0.3.11","Size":524288,"HideIns":0,"Type":8,"Cookie":"","Auth":"","TK":"77144F52D980B80B04DD1E3EC7FAD6BE50BE1DE747EF1D1C6EB169A301F1CC541182D2817AE059230485DAD69B9864D8115863A4BAFAD185B81379DC9DB90807DA5864AE9645F36796A273FBB0A41CD0772F539BDF0FDA04F9B530A466C201C564151A23DD0477CA0F3A4BDD37D507F6195794107195207AD4D3B89DA4CAC6FCB77B4D48ABA077387E778F1F0DE17B411E16B200AF2AEC3C5C196EC5D4A154DC409E9F4394C3930EC8FB4E1EB95C416A7867F90910F74AFC0721815011795B8A44BE41A6B0CDD29449AE7A41FF3D2A56D972C55F573BE6F18A72E4552DCBCC7573F341A0DE08F5287D67106729C6571AD93D0C212D6A21605635216355122C0A"}} +{"req":"Plugin_Update","rid":1,"para":{"Name":"Flash Player内嵌网页小程序","PID":"E7C7BDA6-C828-46F1-A7BA-B4C572A01100","Date":"2021-01-20","Desc":"PluginOK之上跨浏览器的Flash Player网页小程序,支持在Chrome、Edge、Firefox、IE、Oprea、360、QQ等最新版本浏览器网页中内嵌使用","DownAddr":"http://local.zorrosoft.com/Files/Plugin/FlashApplet_Update.pid","MD5":"02B1995BFB1BFC83A60E56749EB1C863","Version":"2.1.1.1","Size":10354688,"HideIns":0,"Type":8,"Cookie":"","Auth":"","TK":"93DEEC155DC4A129EB95A06B9E6A06CD5701B9614E49E399E2936259130946BE4B8778BC460B1D2AECCD563F0E2E4119EEDEB8DA64C6064381FE3F5E4F482303DA48D8D493493487FB05AC39AD9CFCCDF53D987BCFB0B3C2B76E434D0EA5F7EA64D9902CEF6B64FF4F83D91E733CE0607E893F473841851061062C1840EE4A67CBE1FDF98D12C4BE9CED8D354BFD5A0C3F91B39545AC2AF2A4D22FC3F3A4DEABA9DBFDDCF4FB110F88336ABE10D8CEC583A5B7703ADF0595F3E0B538DFF2CFE4435742F8C8035886E47FDF17F75871CC9C15CFBBE8696D5B3AEFF874F263BCBAE1EBC53563FF00C2B25814AACD825F883339A7E29818051EF7EBB01682D69835"}} 以上安装和升级的JSON请求包,可能因版本升级导致内容不同,如遇安装或升级时报错,请联系客服获取最新的请求包。 diff --git a/Bin/IEApplet.txt b/Bin/IEApplet.txt index 1096bffb60d5346c0aae577ec918424ec61093eb..7611580b92d2e13606e9bc1032842d51ac71ddec 100644 --- a/Bin/IEApplet.txt +++ b/Bin/IEApplet.txt @@ -87,22 +87,32 @@ Code 1代表有水平滚动条,2代表有垂直滚动条,3代表都有 ScrollTop垂直滚动条位置 ScrollTop水平滚动条位置 {"req":"Wrl_ScrollBar","rid":6,"para":{"ID":"1","Code":2,"BarW":0,"BarH":0,"ScrollTop":0,"ScrollLeft":0}} -6)、请求缩放IE控件内嵌网页小程序,用于浏览器网页按比例缩放,一般不需要处理: +6)、请求对小程序窗口做Alpha透明处理,便于前端临时显示覆盖到小程序窗口的菜单等: +ID为Wrl_IEApplet启动小程序时返回的ID值,Alpha为透明度百分比,1-100 +{"req":"Wrl_AppletAlpha","rid":7,"para":{"ID":1,"Alpha":30}} + +7)、请求对小程序窗口内容进行截图: +ID为启动小程序时返回JSON中的ID值, +File为指定截图文件保存路径或扩展名 +Base64指定为1时代表返回BASE64编码的图像内容 +{"req":"Wrl_AppletSnap","rid":10,"para":{"ID":1,"Base64":1,"File":".png"}} + +8)、请求缩放IE控件内嵌网页小程序,用于浏览器网页按比例缩放,一般不需要处理: ID为启动小程序时返回JSON中的ID值,Scall为缩放百分比 -{"req":"Wrl_AppletScale","rid":7,"para":{"ID":1,"Scale":120}} +{"req":"Wrl_AppletScale","rid":11,"para":{"ID":1,"Scale":120}} 3、小程序安装、升级、卸载 1)、请求安装IE控件内嵌网页小程序 请在输入框中,输入如下请求,然后点击发送,完成安装: -{"req":"Plugin_Install","rid":1,"para":{"Name":"IE控件小程序","PID":"18BDC030-AF37-50E1-B0AE-E5EF336BE282","Date":"2020-12-12","Desc":"PluginOK之上跨浏览器的IE控件内嵌网页小程序,支持在Chrome、Edge、Firefox、IE、Oprea、360、QQ等最新版本浏览器网页中内嵌使用","DownAddr":"http://local.zorrosoft.com/Files/Plugin/IEApplet.pid","MD5":"F6E95C632B79D29951FB07BB9111D31F","Version":"2.0.3.11","Size":753664,"HideIns":0,"Type":8,"Cookie":"","Auth":"","TK":"63746BE3DCBCAB381B0734CF901178EB1732153DB2D9362D0A0E02A6DB988D2AE3E9CAF3CFD8F592B64B5774DA31E29A47DB5F0184AE93EE33D9763E92B883E3F0DE415EC51BD47E56F16C1EEF2A9ABB9490F85374530DE648129B677E070E5689408BE40A87A5C4A7094ECD4F9B672C1A9FEA14A6E2CA920276C5E3AF74C412E00F3B11FF99C37105C5B14BA141AFEE3E0F1F9A1A14D69E6C02B286410319609215137598E6B26F065360C78303D5E1C3AB7264160619400A51B40A3C052FAD87A418BD399E775BCF832123B4BBF3E541295E25858C909F4892B071D21F1DA15AF24B24098FC34E3E52CF3B9C3BA147ED98F5BC448647592B5DAB0B9A80551D"}} +{"req":"Plugin_Install","rid":1,"para":{"Name":"IE控件小程序","PID":"18BDC030-AF37-50E1-B0AE-E5EF336BE282","Date":"2021-01-20","Desc":"PluginOK之上跨浏览器的IE控件内嵌网页小程序,支持在Chrome、Edge、Firefox、IE、Oprea、360、QQ等最新版本浏览器网页中内嵌使用","DownAddr":"http://local.zorrosoft.com/Files/Plugin/IEApplet.pid","MD5":"E5DC12F7DEF38C5907D49F4A6F9F89C2","Version":"2.1.1.1","Size":753664,"HideIns":0,"Type":8,"Cookie":"","Auth":"","TK":"11DAD1F053B3E03CD963EF6432FC546CE679CB45F02EDA33327E4F8F531131C9A8D958DA7F7CE3096FA5104B06E181D636050A1DCB99AE9E13EFFDE8675253BE8B676211DE5359353988D5A669B6ED055881E5305CA456C3FD6D44BF9FBBBBD632E9C8A5F0CB084F91D1D9F689789D313EAF09A3E2DB870037F20E6A26970F2D1D5AAC92D8E8E0501C8311257BE0AFD6F9A1BACDAA7284D34C24B1F1CBD7B1739B99013DA9D77E8FBC75627A8623E8A513C71889D0BDF3209D36F0F40B968CAD555EF4ED1FEF26F92A76C3A710E5437F207E560C583D2C202F3D615AA55AC8799F8CB2A58821086EF282DE34ADD87529F33CDE8CD48DE181E907CA2BDFA6F919"}} 启动安装后,会不断收到安装进度直到安装结束。 在发布时,也可以把此小程序目录文件和中间件一起打包后发布,不用单独分发。 2)、请求升级IE内核内嵌小程序: -{"req":"Plugin_Update","rid":1,"para":{"Name":"IE控件小程序","PID":"18BDC030-AF37-50E1-B0AE-E5EF336BE282","Date":"2020-12-12","Desc":"PluginOK之上跨浏览器的IE控件内嵌网页小程序,支持在Chrome、Edge、Firefox、IE、Oprea、360、QQ等最新版本浏览器网页中内嵌使用","DownAddr":"http://local.zorrosoft.com/Files/Plugin/IEApplet_Update.pid","MD5":"189EF6FA72F2F861E1115AF548E83115","Version":"2.0.3.11","Size":753664,"HideIns":0,"Type":8,"Cookie":"","Auth":"","TK":"92B8F79F52D566062AE98A3C2FAA994133EF42175C2F6945A681082F1FCA8EE63FBD2C37BD76B34312E0F6D498B17FAD8DBFEF14FE901A697885698EA46BA6073C991C04AF651C662F36F78FF962D14679AA2669DEAE186F353D642B4796A06DAA6905248D32EA0240717410A5AFF43B238056C3C91F41578FBE6A48453251CC57C5204A1CAABCA2B6CC0DD3B60802A307639E5B538A5CE4D26F5E1D789E979AC4BAEA0E5D0EAAD05473D7AF668E5104189BB8C458B2BDB3642E887E7E58031854A4161254DBC7D00BDC7CFAF3C5927CD59B0D525B775F3750C95F8316848CC1A687939382D821100CFEB62B528231326AE93BE388488E4D0F7320409D5C485D"}} +{"req":"Plugin_Update","rid":1,"para":{"Name":"IE控件小程序","PID":"18BDC030-AF37-50E1-B0AE-E5EF336BE282","Date":"2021-01-20","Desc":"PluginOK之上跨浏览器的IE控件内嵌网页小程序,支持在Chrome、Edge、Firefox、IE、Oprea、360、QQ等最新版本浏览器网页中内嵌使用","DownAddr":"http://local.zorrosoft.com/Files/Plugin/IEApplet_Update.pid","MD5":"4C5900F3F175EFB094D10B6A166B46E4","Version":"2.1.1.1","Size":753664,"HideIns":0,"Type":8,"Cookie":"","Auth":"","TK":"817124BCD7B9BADC5D0A06464A5E5E9DF3E96D063FCA9B0E78221F6536BEB4C83600209BEA835195AA2A53CECD04D30CAEFF348CD4FE6F1AEBCED122C1A73456AA1E52731C27125C3F030BB942FF16A1DB5B3C4381477518D7DA210CC8217ECAE164CE7FB237D4626AD078A61BF84B3743A55C181BD1DAB63EFE99336F1597102B0202B6CD235C66B1011ECF86C6D28F0D7DE403ACB026E1D0AB1D03813AFF35EDDDF95404915DD8C8E976329EE134D09F8AC4C72B6AEC283A92F4EC44FA2CF036D4D96EB55EA058B78506F5EAC041A049A6002E4A95E26CD24D44EC12E34211E47A6D2EE8DECB07B208A89F4D62DE25DD77690636B2FB8355A5309C66DC0FB8"}} 以上安装和升级的JSON请求包,可能因版本升级导致内容不同,如遇安装或升级时报错,请联系客服获取最新的请求包。 @@ -139,6 +149,7 @@ Ret为调用ActiveX对应函数返回值,0代表正常 Ret为调用ActiveX对应函数返回值,0代表正常 6) 导航到指定网页 +Url为网页地址,需进行URLCode编码,如额外指定Type为0或具体的浏览器类型,代表用非IE浏览器新标签页来打开 请求:{"req":"IE_Navigate","rid":55,"para":{"Url":"http://www.baidu.com"}} 返回:{"ret":0,"rid":55,"data":{"Ret":"0"}} Ret为调用ActiveX对应函数返回值,0代表正常 diff --git a/Bin/IETabApplet.txt b/Bin/IETabApplet.txt index bb518408bd2b1398afea0adac83c6a14d296b259..73a3c4073759c6ab58077595331e5c48fac4625a 100644 --- a/Bin/IETabApplet.txt +++ b/Bin/IETabApplet.txt @@ -41,13 +41,13 @@ ID为Wrl_IETab启动小程序时返回的ID值,Code代表控制类型掩码: 1)、请求安装IE标签页小程序 请在输入框中,输入如下请求,然后点击发送,完成安装: -{"req":"Plugin_Install","rid":1,"para":{"Name":"IE标签页小程序","PID":"18BDC030-AF37-50E1-B0AE-E5EF336BE281","Date":"2020-12-12","Desc":"PluginOK之上跨浏览器的IE标签页内嵌小程序,支持在Chrome、Edge、Firefox、IE、Oprea、360、QQ等最新版本浏览器网页中内嵌使用","DownAddr":"http://local.zorrosoft.com/Files/Plugin/IENewTab.pid","MD5":"93CFD040B121A10C77CB4A0563E93690","Version":"2.0.3.11","Size":753664,"HideIns":0,"Type":8,"Cookie":"","Auth":"","TK":"A27E174AD1FBCF4844BA88D9A18C701E522BBE7681D66579215D1879E33D8D5B36DF7C8457F2F831E0F0A2C3F1A809A39A6EB0E20E2DA6A80A833DF0EE5CE5216ACA09A4FF670F43ADA0AB537DAE6A3429795EBEAB8CCD3A8B878ACB9C5595EA0E6F64C9DB4900F8D3F36260F3BA4EC53B2B1A78599F461A7841AC2A45DD2FF11B89A42720853A490EA668489F1B5CE15C72B48C06185F898A77D054B095806CA4D033249029876E0DE6A1D9ED37A428B959CEED2DBC1B5D5EBC18556F557230FA0FE942072749C2592375D985C3228D7EC55727030DD4496F13E551101588BE3BD3F4888DDA346E1F0D4BE5213D13814CA1D33AA0633B9D43A212507D9900B4"}} +{"req":"Plugin_Install","rid":1,"para":{"Name":"IE标签页小程序","PID":"18BDC030-AF37-50E1-B0AE-E5EF336BE281","Date":"2021-01-20","Desc":"PluginOK之上跨浏览器的IE标签页内嵌小程序,支持在Chrome、Edge、Firefox、IE、Oprea、360、QQ等最新版本浏览器网页中内嵌使用","DownAddr":"http://local.zorrosoft.com/Files/Plugin/IENewTab.pid","MD5":"B2399851FF5FA69D5B82AE1B7493CF7A","Version":"2.1.1.1","Size":753664,"HideIns":0,"Type":8,"Cookie":"","Auth":"","TK":"1172AB5AE4DD773338EA60C768EAA2853BE304715DCCC27A8FD0F50F053190F12898EDD399609FFFE881179895A21F9F4AE0E1C2FED84086E10E47C31D9E36D9AEF51FF73CDD786A0ABE9A32FEE951C3ABA69F2E09F57B787CAF0DE6519F871FBE3A964979352E739C2A9B9860010056B8A41B1D4C6644DC151E59744A94E2B334F60F6D6BE2ED0A801978AED02C03E66A1F716CBE2C7F0F426E3248987FC416F02FEA6918C726EFEA7AEDB692BD22454B3916C75A5563A52064E2ADACC0ED29ADDB74F290F29DE85E72E1BFA1761F91C34A558CCF78781F5CDA21CBCED08561946B1C95FDE56749DF9F5C27D431948D022866CC7FC46728FB4B1FF7BD1BA0CA"}} 启动安装后,会不断收到安装进度直到安装结束。 2)、请求升级IE标签页小程序: -{"req":"Plugin_Update","rid":1,"para":{"Name":"IE标签页小程序","PID":"18BDC030-AF37-50E1-B0AE-E5EF336BE281","Date":"2020-12-12","Desc":"PluginOK之上跨浏览器的IE标签页内嵌小程序,支持在Chrome、Edge、Firefox、IE、Oprea、360、QQ等最新版本浏览器网页中内嵌使用","DownAddr":"http://local.zorrosoft.com/Files/Plugin/IENewTab_Update.pid","MD5":"8D5D3EFD60AE53D4757BF270DF1374D3","Version":"2.0.3.11","Size":753664,"HideIns":0,"Type":8,"Cookie":"","Auth":"","TK":"65B230C51C1CB33DFBC2F3BC42077B8DA2BF09C678C4FA871C936486802D562BEC92C2FD51F0977645B9B777345DC08D60860830CC547C1BED2F3582B54FAD3871581AB1C4AB2C205ECA759E6AE5433B30AB26F7B1EEA6FE585DE7F28FEDD69A94A80D7BA20B3DF91E3E6C2468AB4FCF1D1001A3A2D84072565AE2EFFB6E86AF360DEFA262CDF7BAB032971C4FC480B7338D2B966E918D9EAC1E483EBF1993E5435978DC174EB8A2895FB61B66A23DD7D3C26DD69EB6BD0BC95A655ECBA7E2487D5823F47D56CE19A9FA71FB0844B342127DAB14FC8E3124314857FD10A585C80E3DB3194FB275A6A8EC2F6FE713112DAA3005D543095D98840911020088D05B"}} +{"req":"Plugin_Update","rid":1,"para":{"Name":"IE标签页小程序","PID":"18BDC030-AF37-50E1-B0AE-E5EF336BE281","Date":"2021-01-20","Desc":"PluginOK之上跨浏览器的IE标签页内嵌小程序,支持在Chrome、Edge、Firefox、IE、Oprea、360、QQ等最新版本浏览器网页中内嵌使用","DownAddr":"http://local.zorrosoft.com/Files/Plugin/IENewTab_Update.pid","MD5":"7CDA22F4883EE835416991529B70A348","Version":"2.1.1.1","Size":753664,"HideIns":0,"Type":8,"Cookie":"","Auth":"","TK":"82959F925B16D291B38B68C99444691A4E4C65BA1B0460243A4A839420ECEAC2ED12357720AF1C315E2F90A18CA1B9C180E7A17CB608EE2B1E68163BE2F514DCBC2E3B68BEFD855BB116B867C1AFDD47BFCDF48428F3B29561A9B00A86FBD9E061ACB715C53FC1654E4E13A63E888F5F06CC6CF81C592F9A09E04FF9764568286A157BEBAD497D574E7972C7EBEC695FBF25D89949FEB9BC31241C5D7873C7FA91B6850D0BD65752DE8B2CCA5A49F1A2629AAF311531D74F34F2563C65BE73FCBE014D92C78FBD3D147693AD226FAC378673C9B082D448F7DC0DFC139A7C9A6953D6C6861B72FB7BCA5292B1470808DCD694C99711BEC4FBE37DC9E6638B30C2"}} 以上安装和升级的JSON请求包,可能因版本升级导致内容不同,如遇安装或升级时报错,请联系客服获取最新的请求包。 @@ -84,6 +84,7 @@ Ret为调用ActiveX对应函数返回值,0代表正常 Ret为调用ActiveX对应函数返回值,0代表正常 6) 导航到指定网页 +Url为网页地址,需进行URLCode编码,如额外指定Type为0或具体的浏览器类型,代表用非IE浏览器新标签页来打开 请求:{"req":"IE_Navigate","rid":55,"para":{"Url":"http://www.baidu.com"}} 返回:{"ret":0,"rid":55,"data":{"Ret":"0"}} Ret为调用ActiveX对应函数返回值,0代表正常 diff --git a/Bin/Interop.WrlApplet.dll b/Bin/Interop.WrlApplet.dll index e61022c3ce7760c12a18a795cb5eaa7a4a8c0749..5faaaaedd6b8663bf019a33b2923f8507a162c3b 100644 Binary files a/Bin/Interop.WrlApplet.dll and b/Bin/Interop.WrlApplet.dll differ diff --git a/Bin/Interop.WrlBase.dll b/Bin/Interop.WrlBase.dll index 81db1a23a4395ed35e9628f3a11b1490d97c98ae..2ab43953409faf1f69711a2299ec23fe40bb51a7 100644 Binary files a/Bin/Interop.WrlBase.dll and b/Bin/Interop.WrlBase.dll differ diff --git a/Bin/Interop.WrlEngine.dll b/Bin/Interop.WrlEngine.dll index db46d5caafce838d55bd6288f0ba915bd3310322..b2f7212ed15fb530e5d2179bd008addb171686d0 100644 Binary files a/Bin/Interop.WrlEngine.dll and b/Bin/Interop.WrlEngine.dll differ diff --git a/Bin/MSOfficeApplet.txt b/Bin/MSOfficeApplet.txt index b98a6b2851e3ca4dc5bde3b9d20ad7b6c26fd26b..a5bfacf7d703bcdaf12f138df525edce0a68afcb 100644 --- a/Bin/MSOfficeApplet.txt +++ b/Bin/MSOfficeApplet.txt @@ -91,22 +91,32 @@ Code 1代表有水平滚动条,2代表有垂直滚动条,3代表都有 ScrollTop垂直滚动条位置 ScrollTop水平滚动条位置 {"req":"Wrl_ScrollBar","rid":6,"para":{"ID":"1","Code":2,"BarW":0,"BarH":0,"ScrollTop":0,"ScrollLeft":0}} -6)、请求缩放微软Office内嵌网页小程序,用于浏览器网页按比例缩放,一般不需要处理: +6)、请求对小程序窗口做Alpha透明处理,便于前端临时显示覆盖到小程序窗口的菜单等: +ID为Wrl_OfficeApplet启动小程序时返回的ID值,Alpha为透明度百分比,1-100 +{"req":"Wrl_AppletAlpha","rid":7,"para":{"ID":1,"Alpha":30}} + +7)、请求对小程序窗口内容进行截图: +ID为启动小程序时返回JSON中的ID值, +File为指定截图文件保存路径或扩展名 +Base64指定为1时代表返回BASE64编码的图像内容 +{"req":"Wrl_AppletSnap","rid":10,"para":{"ID":1,"Base64":1,"File":".png"}} + +8)、请求缩放IE控件内嵌网页小程序,用于浏览器网页按比例缩放,一般不需要处理: ID为启动小程序时返回JSON中的ID值,Scall为缩放百分比 -{"req":"Wrl_AppletScale","rid":7,"para":{"ID":1,"Scale":120}} +{"req":"Wrl_AppletScale","rid":11,"para":{"ID":1,"Scale":120}} 3、小程序安装、升级、卸载 1)、请求安装微软Office内嵌网页小程序 请在输入框中,输入如下请求,然后点击发送,完成安装: -{"req":"Plugin_Install","rid":1,"para":{"Name":"微软Office内嵌网页小程序","PID":"EF720B55-787B-4CBC-AD0A-AE219CFD52C9","Date":"2020-12-12","Desc":"PluginOK之上跨浏览器的微软Office内嵌网页小程序,支持在Chrome、Firefox、Edge、IE、Oprea、360、QQ等最新版本浏览器网页中内嵌Word、Excel、PowerPoint等程序进行在线编辑或审阅各类办公文档","DownAddr":"http://local.zorrosoft.com/Files/Plugin/OfficeApplet.pid","MD5":"E3252299F94130E12DC79BA959A6302F","Version":"2.0.3.11","Size":753664,"HideIns":0,"Type":8,"Cookie":"","Auth":"","TK":"676DE1A347AA5718DD7A1170DE9D096CBFED9C9ABB68FD6070AE1CBF81B3B011542F65740C788D4084E634CFD5952E77D52E4C82B9E1CB34A6906FFB5DD0C348FFAC0F466AA8C75D0C88841F4AFDDB2697377DE129CF53262E123505DF5928AC5016FE22AB7CA52341B9708C72C5ECE23000ED968532A18020F82C7AD2C77012EEDE48BC696DFACC167B2ECCEA01E8012783848B8B4CEC71EF96713E77929CAD8BF8D8B875DF62DECABDBC3072E70534B879A7208C52088D95A84D6C9D659C04852CA0039EEE8DDEFC96AF12645ADA73637F286A125C813EC383A3F4A8549BE8681138341D2845768DADA9A7E0B3303FC3D7046562ECD9793F3B11F97D85167D"}} +{"req":"Plugin_Install","rid":1,"para":{"Name":"微软Office内嵌网页小程序","PID":"EF720B55-787B-4CBC-AD0A-AE219CFD52C9","Date":"2021-01-20","Desc":"PluginOK之上跨浏览器的微软Office内嵌网页小程序,支持在Chrome、Edge、Firefox、IE、Oprea、360、QQ等最新版本浏览器网页中内嵌Word、Excel、PowerPoint等程序进行在线编辑或审阅各类办公文档","DownAddr":"http://local.zorrosoft.com/Files/Plugin/OfficeApplet.pid","MD5":"7D89770576C0D8BA221070464777E8A6","Version":"2.1.1.1","Size":688128,"HideIns":0,"Type":8,"Cookie":"","Auth":"","TK":"6C2207F0BF7A5E3F9DB00BA5AA0C2FAA0D2187028DE8F701DAFAA4057593342AD5C673E4AC3154E2C18D4B39533E843E3D1866719DEAD7E4B402076F719C9E7CC2EEC8A2640490D30EE751FF8FC8B9FD29449781FE377E24BE3D1BF2F910EEFAED8032C7B55B98AE2146FA804AE3BBF15CD89AB8652D034FCFFBED0C655A21FA8B926DD2CDEE4FB57E09523263E1DCB710BBE35FF6FB3D85D6EB2F9E36C2ACB066B4A369F2E459B08D853675F713E611E021CAC86F2A42B2D376CE2411E9FA3C3B3D212D416450765454B58314BCCBC29595D9CFF03C3047D01C434C47D82BEE60E1476D9A28CEED77A3EDD451D2D2C799AF0D7E2EC1FAB15E13CC92A187B7B0"}} 启动安装后,会不断收到安装进度直到安装结束。 在发布时,也可以把此小程序目录文件和中间件一起打包后发布,不用单独分发。 2)、请求升级微软Office内嵌网页小程序: -{"req":"Plugin_Update","rid":1,"para":{"Name":"微软Office内嵌网页小程序","PID":"EF720B55-787B-4CBC-AD0A-AE219CFD52C9","Date":"2020-12-12","Desc":"PluginOK之上跨浏览器的微软Office内嵌网页小程序,支持在Chrome、Firefox、Edge、IE、Oprea、360、QQ等最新版本浏览器网页中内嵌Word、Excel、PowerPoint等程序进行在线编辑或审阅各类办公文档","DownAddr":"http://local.zorrosoft.com/Files/Plugin/OfficeApplet_Update.pid","MD5":"37D8373EB2F68005B0C3D27938562FE7","Version":"2.0.3.11","Size":753664,"HideIns":0,"Type":8,"Cookie":"","Auth":"","TK":"9D996D3F9910A141E175B1227C57104F327784E6152B6BE0CFC3255E7CE2B7D12A71ECFE5C926905CBD6B448D8A4F4B438FCD7E2E52362EACC6C7863F64BE827942FB7C5432F69E5A6C37CB48AE24EF11D66DBC5CAFD53E2DC94D63F1EBBDF014E3317C60A86F17A5B140077A27B91BBA4F36498E08064BD82676B0AF4947920C5A2CD7C245E5B744A9EA22EDA2FCF30A841CDD2DE3CED387F0BD2A19D10F373D77095F1A922AFC26303FE00EA8EDB4482221C8F7A3E1D42865D14BE0F4C105A43D651555F02F0268716C2952B055C98EB7294AC80B50E780517D920CD13A5D4CE25E396DAA29F189057C8787D572B58BF9150E5AE58C72FA26D7E7E64F03364"}} +{"req":"Plugin_Update","rid":1,"para":{"Name":"微软Office内嵌网页小程序","PID":"EF720B55-787B-4CBC-AD0A-AE219CFD52C9","Date":"2021-01-20","Desc":"PluginOK之上跨浏览器的微软Office内嵌网页小程序,支持在Chrome、Edge、Firefox、IE、Oprea、360、QQ等最新版本浏览器网页中内嵌Word、Excel、PowerPoint等程序进行在线编辑或审阅各类办公文档","DownAddr":"http://local.zorrosoft.com/Files/Plugin/OfficeApplet_Update.pid","MD5":"2470413408486CC77550BD43C94ABF67","Version":"2.1.1.1","Size":688128,"HideIns":0,"Type":8,"Cookie":"","Auth":"","TK":"72ED836FBB991257C92FEAAA6D465FFCCB3236325542A891E1BE32910FB11B4CDC18C51C856F382D0790AF12FC7FB247B215F42579AAF5B16532E4896D5A41099A3A7E4B73DF57412FFF04A7741AFDA81FCE58804ABD0C445A5450C0968EFCBAB17C45AEC5B00DC943F28E6ADB865AF803FBEF1571C07D6F56137BA978523869AD1E3F554D65516E0974A8762D911DFD664C6FAE092D5D0C13D99E50BA4F205AA1D1018623E2F02233C2BACEAFF7C87C4C99360975F81F33772D7108F62CCF25D322227D484DFBA3A4C1722B99DA0D798F9C8CED973C24A6A94D7C0D1002DCD7F85789DD1F8BC48A6F8A6C158DA21CF159EF2B258C2D7BB77A7DAA16C22E025E"}} 以上安装和升级的JSON请求包,可能因版本升级导致内容不同,如遇安装或升级时报错,请联系客服获取最新的请求包。 diff --git a/Bin/PluginNetDll.dll b/Bin/PluginNetDll.dll index 9d59e6e9b1003438b26dd09d79a90c45376d5a89..716e13f92fa6188b39450dcf38f81f6993a890dd 100644 Binary files a/Bin/PluginNetDll.dll and b/Bin/PluginNetDll.dll differ diff --git a/Bin/Plugins/18BDC030-AF37-50E1-B0AE-E5EF336BE281/IENewTab.exe b/Bin/Plugins/18BDC030-AF37-50E1-B0AE-E5EF336BE281/IENewTab.exe index cc9916666c90f3634a275d83204430d0276a8311..bf78f958bc8a618c46b21919e935867e32b1d854 100644 Binary files a/Bin/Plugins/18BDC030-AF37-50E1-B0AE-E5EF336BE281/IENewTab.exe and b/Bin/Plugins/18BDC030-AF37-50E1-B0AE-E5EF336BE281/IENewTab.exe differ diff --git a/Bin/Plugins/18BDC030-AF37-50E1-B0AE-E5EF336BE281/PluginAuth.paf b/Bin/Plugins/18BDC030-AF37-50E1-B0AE-E5EF336BE281/PluginAuth.paf index 9aaee36c4bd7628fd5cde887d7d09866a50f9be7..16ee8de5bac6ffc8803634fb42c08c736bf5fc07 100644 Binary files a/Bin/Plugins/18BDC030-AF37-50E1-B0AE-E5EF336BE281/PluginAuth.paf and b/Bin/Plugins/18BDC030-AF37-50E1-B0AE-E5EF336BE281/PluginAuth.paf differ diff --git a/Bin/Plugins/18BDC030-AF37-50E1-B0AE-E5EF336BE281/X64/IENewTab.exe b/Bin/Plugins/18BDC030-AF37-50E1-B0AE-E5EF336BE281/X64/IENewTab.exe index c48515af67686d823b632547118ef5dd1f861fb4..0b7050803fbf025112b0e24fd833b59253828226 100644 Binary files a/Bin/Plugins/18BDC030-AF37-50E1-B0AE-E5EF336BE281/X64/IENewTab.exe and b/Bin/Plugins/18BDC030-AF37-50E1-B0AE-E5EF336BE281/X64/IENewTab.exe differ diff --git a/Bin/Plugins/18BDC030-AF37-50E1-B0AE-E5EF336BE282/IEApplet.exe b/Bin/Plugins/18BDC030-AF37-50E1-B0AE-E5EF336BE282/IEApplet.exe index 93c4c4d5a2ad759927a6a39d385ca5025b492889..eb5e3b9701d928e8423aa03ed0afe4577942240b 100644 Binary files a/Bin/Plugins/18BDC030-AF37-50E1-B0AE-E5EF336BE282/IEApplet.exe and b/Bin/Plugins/18BDC030-AF37-50E1-B0AE-E5EF336BE282/IEApplet.exe differ diff --git a/Bin/Plugins/18BDC030-AF37-50E1-B0AE-E5EF336BE282/PluginAuth.paf b/Bin/Plugins/18BDC030-AF37-50E1-B0AE-E5EF336BE282/PluginAuth.paf index 799b33817663dd7ff25cf63bf9cf68046e84f267..0bb865bce2f369453dc4c98c872f046479534c07 100644 Binary files a/Bin/Plugins/18BDC030-AF37-50E1-B0AE-E5EF336BE282/PluginAuth.paf and b/Bin/Plugins/18BDC030-AF37-50E1-B0AE-E5EF336BE282/PluginAuth.paf differ diff --git a/Bin/Plugins/18BDC030-AF37-50E1-B0AE-E5EF336BE282/X64/IEApplet.exe b/Bin/Plugins/18BDC030-AF37-50E1-B0AE-E5EF336BE282/X64/IEApplet.exe index f2e861f4cfaf8a911b6737a33a59f8513a1c97e4..26ec93586807388a884734493cd4e707d54de782 100644 Binary files a/Bin/Plugins/18BDC030-AF37-50E1-B0AE-E5EF336BE282/X64/IEApplet.exe and b/Bin/Plugins/18BDC030-AF37-50E1-B0AE-E5EF336BE282/X64/IEApplet.exe differ diff --git a/Bin/Plugins/199BB8A7-9DD5-41F5-AE9D-2AA94300B0B3/PluginAuth.paf b/Bin/Plugins/199BB8A7-9DD5-41F5-AE9D-2AA94300B0B3/PluginAuth.paf index 08ca00819638a787d4334aeff97e2c53ef1a7354..f3a9e069da189ffb5defa66981bd4ec60d6e32b5 100644 Binary files a/Bin/Plugins/199BB8A7-9DD5-41F5-AE9D-2AA94300B0B3/PluginAuth.paf and b/Bin/Plugins/199BB8A7-9DD5-41F5-AE9D-2AA94300B0B3/PluginAuth.paf differ diff --git a/Bin/Plugins/199BB8A7-9DD5-41F5-AE9D-2AA94300B0B3/WrlFileApplet.dll b/Bin/Plugins/199BB8A7-9DD5-41F5-AE9D-2AA94300B0B3/WrlFileApplet.dll index 04e3c432e1e2e0b21331a25931fc0baf09d312c6..352bd6a9a763049fca4a0478f221026f42a645db 100644 Binary files a/Bin/Plugins/199BB8A7-9DD5-41F5-AE9D-2AA94300B0B3/WrlFileApplet.dll and b/Bin/Plugins/199BB8A7-9DD5-41F5-AE9D-2AA94300B0B3/WrlFileApplet.dll differ diff --git a/Bin/Plugins/5620219A-E6A5-4C31-AABD-A90C9A57D5E0/Config.json b/Bin/Plugins/5620219A-E6A5-4C31-AABD-A90C9A57D5E0/Config.json new file mode 100644 index 0000000000000000000000000000000000000000..5163d8ccc0ed9125e151c45e9b78d5d92e5447b8 --- /dev/null +++ b/Bin/Plugins/5620219A-E6A5-4C31-AABD-A90C9A57D5E0/Config.json @@ -0,0 +1,3 @@ +{ + "PORT": 955 +} \ No newline at end of file diff --git a/Bin/Plugins/5620219A-E6A5-4C31-AABD-A90C9A57D5E0/PluginAuth.paf b/Bin/Plugins/5620219A-E6A5-4C31-AABD-A90C9A57D5E0/PluginAuth.paf new file mode 100644 index 0000000000000000000000000000000000000000..566a11f2d52f49dc5b7433285dcb869a0f2f00be Binary files /dev/null and b/Bin/Plugins/5620219A-E6A5-4C31-AABD-A90C9A57D5E0/PluginAuth.paf differ diff --git a/Bin/Plugins/5620219A-E6A5-4C31-AABD-A90C9A57D5E0/Remove.json b/Bin/Plugins/5620219A-E6A5-4C31-AABD-A90C9A57D5E0/Remove.json new file mode 100644 index 0000000000000000000000000000000000000000..fe51488c7066f6687ef680d6bfaa4f7768ef205c --- /dev/null +++ b/Bin/Plugins/5620219A-E6A5-4C31-AABD-A90C9A57D5E0/Remove.json @@ -0,0 +1 @@ +[] diff --git a/Bin/Plugins/5620219A-E6A5-4C31-AABD-A90C9A57D5E0/TXWebApplet.exe b/Bin/Plugins/5620219A-E6A5-4C31-AABD-A90C9A57D5E0/TXWebApplet.exe new file mode 100644 index 0000000000000000000000000000000000000000..321220cecc33e98f48069cab271b16d5ba823f8b Binary files /dev/null and b/Bin/Plugins/5620219A-E6A5-4C31-AABD-A90C9A57D5E0/TXWebApplet.exe differ diff --git a/Bin/Plugins/60E61D43-503A-470B-9DAA-8E703E1F8BE8/PluginAuth.paf b/Bin/Plugins/60E61D43-503A-470B-9DAA-8E703E1F8BE8/PluginAuth.paf index 5bef10b2c7f5a3d2a140c7543685c89aec690b9b..73a4bd567597b39673c5fceaa6a2d76c7b9a55ad 100644 Binary files a/Bin/Plugins/60E61D43-503A-470B-9DAA-8E703E1F8BE8/PluginAuth.paf and b/Bin/Plugins/60E61D43-503A-470B-9DAA-8E703E1F8BE8/PluginAuth.paf differ diff --git a/Bin/Plugins/60E61D43-503A-470B-9DAA-8E703E1F8BE8/WpsApplet.exe b/Bin/Plugins/60E61D43-503A-470B-9DAA-8E703E1F8BE8/WpsApplet.exe index d30cee43f07b8670da89f5868a52311f93e4cb3c..ff313c385494a6a312def72550652140566f3915 100644 Binary files a/Bin/Plugins/60E61D43-503A-470B-9DAA-8E703E1F8BE8/WpsApplet.exe and b/Bin/Plugins/60E61D43-503A-470B-9DAA-8E703E1F8BE8/WpsApplet.exe differ diff --git a/Bin/Plugins/60E61D43-503A-470B-9DAA-8E703E1F8BE8/X64/WpsApplet.exe b/Bin/Plugins/60E61D43-503A-470B-9DAA-8E703E1F8BE8/X64/WpsApplet.exe index 2c965ec477c3bb2b04613a611203e6ce7b219911..02733a389f1e02aeea442e16a4e1f0a57f7fcf29 100644 Binary files a/Bin/Plugins/60E61D43-503A-470B-9DAA-8E703E1F8BE8/X64/WpsApplet.exe and b/Bin/Plugins/60E61D43-503A-470B-9DAA-8E703E1F8BE8/X64/WpsApplet.exe differ diff --git a/Bin/Plugins/62978E9A-9B00-4E42-9E70-0BE7526E14C0/AIPSignApplet.exe b/Bin/Plugins/62978E9A-9B00-4E42-9E70-0BE7526E14C0/AIPSignApplet.exe index 0d190eba3ab2e6ce2f07a51a2c5da4a6c9087f9e..0a2a7882f30228829da6737fc83c7014b02a87b1 100644 Binary files a/Bin/Plugins/62978E9A-9B00-4E42-9E70-0BE7526E14C0/AIPSignApplet.exe and b/Bin/Plugins/62978E9A-9B00-4E42-9E70-0BE7526E14C0/AIPSignApplet.exe differ diff --git a/Bin/Plugins/62978E9A-9B00-4E42-9E70-0BE7526E14C0/PluginAuth.paf b/Bin/Plugins/62978E9A-9B00-4E42-9E70-0BE7526E14C0/PluginAuth.paf index b758f3b3071c0c1e441d72dda85a641e22ee3710..5a60d3b03198475b7db96597b0a7773193f55f56 100644 Binary files a/Bin/Plugins/62978E9A-9B00-4E42-9E70-0BE7526E14C0/PluginAuth.paf and b/Bin/Plugins/62978E9A-9B00-4E42-9E70-0BE7526E14C0/PluginAuth.paf differ diff --git a/Bin/Plugins/90FC7E0E-0D2F-4C38-9875-B06407CE4556/PluginAuth.paf b/Bin/Plugins/90FC7E0E-0D2F-4C38-9875-B06407CE4556/PluginAuth.paf index a1950c5700a48e3e9ac4d40926a1865e6a71fafd..4c2bf0c255ca38d403584db429e179b00f2a6a6b 100644 Binary files a/Bin/Plugins/90FC7E0E-0D2F-4C38-9875-B06407CE4556/PluginAuth.paf and b/Bin/Plugins/90FC7E0E-0D2F-4C38-9875-B06407CE4556/PluginAuth.paf differ diff --git a/Bin/Plugins/90FC7E0E-0D2F-4C38-9875-B06407CE4556/VlcWebPlayer.exe b/Bin/Plugins/90FC7E0E-0D2F-4C38-9875-B06407CE4556/VlcWebPlayer.exe index 4172f543d22fcc56d5249c4e33cc5e8cdfa2690d..5a03de4b8db16d5cd4093a0960af843a7511db25 100644 Binary files a/Bin/Plugins/90FC7E0E-0D2F-4C38-9875-B06407CE4556/VlcWebPlayer.exe and b/Bin/Plugins/90FC7E0E-0D2F-4C38-9875-B06407CE4556/VlcWebPlayer.exe differ diff --git a/Bin/Plugins/90FC7E0E-0D2F-4C38-9875-B06407CE4556/X64/VlcWebPlayer.exe b/Bin/Plugins/90FC7E0E-0D2F-4C38-9875-B06407CE4556/X64/VlcWebPlayer.exe index 291ba4c0ce93ed07c426cb5e7244e1003c52f5ee..56999465bb4781d1c4539046f73ce6629f47c69e 100644 Binary files a/Bin/Plugins/90FC7E0E-0D2F-4C38-9875-B06407CE4556/X64/VlcWebPlayer.exe and b/Bin/Plugins/90FC7E0E-0D2F-4C38-9875-B06407CE4556/X64/VlcWebPlayer.exe differ diff --git a/Bin/Plugins/99225C6D-B7A3-441c-AEFB-3EE23ACA2209/Config.json b/Bin/Plugins/99225C6D-B7A3-441c-AEFB-3EE23ACA2209/Config.json index df74b525d165ee7b8baad558dea3de7cfdcab49c..7753acb85d59d9832d235bbd6a15ba63518255f7 100644 --- a/Bin/Plugins/99225C6D-B7A3-441c-AEFB-3EE23ACA2209/Config.json +++ b/Bin/Plugins/99225C6D-B7A3-441c-AEFB-3EE23ACA2209/Config.json @@ -1,3 +1,4 @@ { - "PORT": 12900 + "PORT": 12900, + "HTTP": 12903 } \ No newline at end of file diff --git a/Bin/Plugins/99225C6D-B7A3-441c-AEFB-3EE23ACA2209/Interop.WrlApplet.dll b/Bin/Plugins/99225C6D-B7A3-441c-AEFB-3EE23ACA2209/Interop.WrlApplet.dll index e61022c3ce7760c12a18a795cb5eaa7a4a8c0749..5faaaaedd6b8663bf019a33b2923f8507a162c3b 100644 Binary files a/Bin/Plugins/99225C6D-B7A3-441c-AEFB-3EE23ACA2209/Interop.WrlApplet.dll and b/Bin/Plugins/99225C6D-B7A3-441c-AEFB-3EE23ACA2209/Interop.WrlApplet.dll differ diff --git a/Bin/Plugins/99225C6D-B7A3-441c-AEFB-3EE23ACA2209/Interop.WrlBase.dll b/Bin/Plugins/99225C6D-B7A3-441c-AEFB-3EE23ACA2209/Interop.WrlBase.dll index 81db1a23a4395ed35e9628f3a11b1490d97c98ae..2ab43953409faf1f69711a2299ec23fe40bb51a7 100644 Binary files a/Bin/Plugins/99225C6D-B7A3-441c-AEFB-3EE23ACA2209/Interop.WrlBase.dll and b/Bin/Plugins/99225C6D-B7A3-441c-AEFB-3EE23ACA2209/Interop.WrlBase.dll differ diff --git a/Bin/Plugins/99225C6D-B7A3-441c-AEFB-3EE23ACA2209/Interop.WrlEngine.dll b/Bin/Plugins/99225C6D-B7A3-441c-AEFB-3EE23ACA2209/Interop.WrlEngine.dll index db46d5caafce838d55bd6288f0ba915bd3310322..b2f7212ed15fb530e5d2179bd008addb171686d0 100644 Binary files a/Bin/Plugins/99225C6D-B7A3-441c-AEFB-3EE23ACA2209/Interop.WrlEngine.dll and b/Bin/Plugins/99225C6D-B7A3-441c-AEFB-3EE23ACA2209/Interop.WrlEngine.dll differ diff --git a/Bin/Plugins/99225C6D-B7A3-441c-AEFB-3EE23ACA2209/PluginAuth.paf b/Bin/Plugins/99225C6D-B7A3-441c-AEFB-3EE23ACA2209/PluginAuth.paf index 9b4d49265bffb5d3f070b8dbbe38f93c41d233d5..d6d22a89b5a4cd57451e5d3a02559fd31b921bff 100644 Binary files a/Bin/Plugins/99225C6D-B7A3-441c-AEFB-3EE23ACA2209/PluginAuth.paf and b/Bin/Plugins/99225C6D-B7A3-441c-AEFB-3EE23ACA2209/PluginAuth.paf differ diff --git a/Bin/Plugins/99225C6D-B7A3-441c-AEFB-3EE23ACA2209/PluginExeDemo.exe b/Bin/Plugins/99225C6D-B7A3-441c-AEFB-3EE23ACA2209/PluginExeDemo.exe index e3ffdcf2fe65b7e2106ee5d8b06aada0eba08ad4..6a86090e64ef75cc8babf98f41435766d6938359 100644 Binary files a/Bin/Plugins/99225C6D-B7A3-441c-AEFB-3EE23ACA2209/PluginExeDemo.exe and b/Bin/Plugins/99225C6D-B7A3-441c-AEFB-3EE23ACA2209/PluginExeDemo.exe differ diff --git a/Bin/Plugins/99225C6D-B7A3-441c-AEFB-3EE23ACA2209/PluginExeDemo.vshost.exe b/Bin/Plugins/99225C6D-B7A3-441c-AEFB-3EE23ACA2209/PluginExeDemo.vshost.exe index 46ae6c9b3650a13612fe68c0fd092a4cf2084cab..bb84a51ac4f20534146c09f2fd9c928d15a903b2 100644 Binary files a/Bin/Plugins/99225C6D-B7A3-441c-AEFB-3EE23ACA2209/PluginExeDemo.vshost.exe and b/Bin/Plugins/99225C6D-B7A3-441c-AEFB-3EE23ACA2209/PluginExeDemo.vshost.exe differ diff --git a/Bin/Plugins/997599C3-3C4D-445E-B741-0AD934B45459/ACadApplet.exe b/Bin/Plugins/997599C3-3C4D-445E-B741-0AD934B45459/ACadApplet.exe index 5839b4a0f688cb8492b1fb8aedaf8db32adadb46..89f50fb747efda29c41b9567149764722b57229f 100644 Binary files a/Bin/Plugins/997599C3-3C4D-445E-B741-0AD934B45459/ACadApplet.exe and b/Bin/Plugins/997599C3-3C4D-445E-B741-0AD934B45459/ACadApplet.exe differ diff --git a/Bin/Plugins/997599C3-3C4D-445E-B741-0AD934B45459/PluginAuth.paf b/Bin/Plugins/997599C3-3C4D-445E-B741-0AD934B45459/PluginAuth.paf index d9219838d35c8426a6c5af3be7f9b43c003cba17..7a2aed827560c0bb0eaf0ee2c390c16052e1d982 100644 Binary files a/Bin/Plugins/997599C3-3C4D-445E-B741-0AD934B45459/PluginAuth.paf and b/Bin/Plugins/997599C3-3C4D-445E-B741-0AD934B45459/PluginAuth.paf differ diff --git a/Bin/Plugins/997599C3-3C4D-445E-B741-0AD934B45459/X64/ACadApplet.exe b/Bin/Plugins/997599C3-3C4D-445E-B741-0AD934B45459/X64/ACadApplet.exe index 0b891f3b968f830e0fabed83918afbe198a33d1d..2ea5e2b35fdb87ec0e9933e60dc3d37bf2903064 100644 Binary files a/Bin/Plugins/997599C3-3C4D-445E-B741-0AD934B45459/X64/ACadApplet.exe and b/Bin/Plugins/997599C3-3C4D-445E-B741-0AD934B45459/X64/ACadApplet.exe differ diff --git a/Bin/Plugins/A22E18F1-95F8-4FDB-99D2-188E5FB12B23/PluginAuth.paf b/Bin/Plugins/A22E18F1-95F8-4FDB-99D2-188E5FB12B23/PluginAuth.paf index 3b406f6f1e37d8a5641946df96ddf4ac9f3e6486..0e6815cc11d661f96bb8aeba134c64e82dcf8487 100644 Binary files a/Bin/Plugins/A22E18F1-95F8-4FDB-99D2-188E5FB12B23/PluginAuth.paf and b/Bin/Plugins/A22E18F1-95F8-4FDB-99D2-188E5FB12B23/PluginAuth.paf differ diff --git a/Bin/Plugins/A22E18F1-95F8-4FDB-99D2-188E5FB12B23/PluginComDll.dll b/Bin/Plugins/A22E18F1-95F8-4FDB-99D2-188E5FB12B23/PluginComDll.dll index 981332032da1547f893e64c23326c3a96118be84..251ce0cb110f87dd5c198b73c711b59c000f1af0 100644 Binary files a/Bin/Plugins/A22E18F1-95F8-4FDB-99D2-188E5FB12B23/PluginComDll.dll and b/Bin/Plugins/A22E18F1-95F8-4FDB-99D2-188E5FB12B23/PluginComDll.dll differ diff --git a/Bin/Plugins/AE023C55-E408-45DB-BF58-8B11C4E8D945/PluginAuth.paf b/Bin/Plugins/AE023C55-E408-45DB-BF58-8B11C4E8D945/PluginAuth.paf index 072ac778545a5f56cabfe6ff44f2d2cf3f8ede56..cfd5301c3a52753c86e4323d7dbbbe057ff8e703 100644 Binary files a/Bin/Plugins/AE023C55-E408-45DB-BF58-8B11C4E8D945/PluginAuth.paf and b/Bin/Plugins/AE023C55-E408-45DB-BF58-8B11C4E8D945/PluginAuth.paf differ diff --git a/Bin/Plugins/AE023C55-E408-45DB-BF58-8B11C4E8D945/WrlSpVoice.dll b/Bin/Plugins/AE023C55-E408-45DB-BF58-8B11C4E8D945/WrlSpVoice.dll index a79d5d447755dd418b52b89276399cb51105e929..fd2f23d4c15c953800e5ad1c4dfc23195d57f3a2 100644 Binary files a/Bin/Plugins/AE023C55-E408-45DB-BF58-8B11C4E8D945/WrlSpVoice.dll and b/Bin/Plugins/AE023C55-E408-45DB-BF58-8B11C4E8D945/WrlSpVoice.dll differ diff --git a/Bin/Plugins/C0B01CD6-7DD9-4D3C-B668-04168D5236FC/PluginAuth.paf b/Bin/Plugins/C0B01CD6-7DD9-4D3C-B668-04168D5236FC/PluginAuth.paf index 938c54c627f364db5e3da97892a249b34b6115a9..c176aeaba6e0e3ba680e1f6c711c9755cac66100 100644 Binary files a/Bin/Plugins/C0B01CD6-7DD9-4D3C-B668-04168D5236FC/PluginAuth.paf and b/Bin/Plugins/C0B01CD6-7DD9-4D3C-B668-04168D5236FC/PluginAuth.paf differ diff --git a/Bin/Plugins/C0B01CD6-7DD9-4D3C-B668-04168D5236FC/WrlComm.dll b/Bin/Plugins/C0B01CD6-7DD9-4D3C-B668-04168D5236FC/WrlComm.dll index 8606fdd3802515ef39b5716d8b9b4bfa40e51a62..87c8e23483b8c3765fabaecaf0fa182982a1f446 100644 Binary files a/Bin/Plugins/C0B01CD6-7DD9-4D3C-B668-04168D5236FC/WrlComm.dll and b/Bin/Plugins/C0B01CD6-7DD9-4D3C-B668-04168D5236FC/WrlComm.dll differ diff --git a/Bin/Plugins/D10495F4-DF0F-44FA-8647-91275347214A/PluginAuth.paf b/Bin/Plugins/D10495F4-DF0F-44FA-8647-91275347214A/PluginAuth.paf new file mode 100644 index 0000000000000000000000000000000000000000..2b95bead36b71f422742c073c6fa4e655a80aee3 Binary files /dev/null and b/Bin/Plugins/D10495F4-DF0F-44FA-8647-91275347214A/PluginAuth.paf differ diff --git a/Bin/Plugins/D10495F4-DF0F-44FA-8647-91275347214A/Remove.json b/Bin/Plugins/D10495F4-DF0F-44FA-8647-91275347214A/Remove.json new file mode 100644 index 0000000000000000000000000000000000000000..1e56778ce5754db42a47c6a5e7eb6dcfa43ed23b --- /dev/null +++ b/Bin/Plugins/D10495F4-DF0F-44FA-8647-91275347214A/Remove.json @@ -0,0 +1,6 @@ +[ + { + "File" : "[WRL]PluginNetDll.dll", + "Remove" : 1 + } +] diff --git a/Bin/Plugins/E7C7BDA6-C828-46F1-A7BA-B4C572A01100/FlashApplet.exe b/Bin/Plugins/E7C7BDA6-C828-46F1-A7BA-B4C572A01100/FlashApplet.exe index 762ef42d22f3f81f2414391796afe9ddd39238d4..ff9de395440746cb6315b6fc6e449f5a3c2d8c2a 100644 Binary files a/Bin/Plugins/E7C7BDA6-C828-46F1-A7BA-B4C572A01100/FlashApplet.exe and b/Bin/Plugins/E7C7BDA6-C828-46F1-A7BA-B4C572A01100/FlashApplet.exe differ diff --git a/Bin/Plugins/E7C7BDA6-C828-46F1-A7BA-B4C572A01100/PluginAuth.paf b/Bin/Plugins/E7C7BDA6-C828-46F1-A7BA-B4C572A01100/PluginAuth.paf index 4d3327659abab43e89303724e114fb8b9f9999d0..cddc84b9a4b36e2e66c2f234d049a29089418235 100644 Binary files a/Bin/Plugins/E7C7BDA6-C828-46F1-A7BA-B4C572A01100/PluginAuth.paf and b/Bin/Plugins/E7C7BDA6-C828-46F1-A7BA-B4C572A01100/PluginAuth.paf differ diff --git a/Bin/Plugins/EF720B55-787B-4CBC-AD0A-AE219CFD52C9/OfficeApplet.exe b/Bin/Plugins/EF720B55-787B-4CBC-AD0A-AE219CFD52C9/OfficeApplet.exe index f2fc75a8381ebe0e4519693dc8a2ef98f1d6c613..ec3ccb49edc2e9441b57809f10abe9c0c5079d44 100644 Binary files a/Bin/Plugins/EF720B55-787B-4CBC-AD0A-AE219CFD52C9/OfficeApplet.exe and b/Bin/Plugins/EF720B55-787B-4CBC-AD0A-AE219CFD52C9/OfficeApplet.exe differ diff --git a/Bin/Plugins/EF720B55-787B-4CBC-AD0A-AE219CFD52C9/PluginAuth.paf b/Bin/Plugins/EF720B55-787B-4CBC-AD0A-AE219CFD52C9/PluginAuth.paf index 3dc16c29f6d8823858cc4c8c9dc354c7b2ec0986..68453520566e34d0e6f788ee5c0560e017f50a8a 100644 Binary files a/Bin/Plugins/EF720B55-787B-4CBC-AD0A-AE219CFD52C9/PluginAuth.paf and b/Bin/Plugins/EF720B55-787B-4CBC-AD0A-AE219CFD52C9/PluginAuth.paf differ diff --git a/Bin/Plugins/EF720B55-787B-4CBC-AD0A-AE219CFD52C9/X64/OfficeApplet.exe b/Bin/Plugins/EF720B55-787B-4CBC-AD0A-AE219CFD52C9/X64/OfficeApplet.exe index 405e0afd0572b6bee05f11d168f77928e2a5e6c6..a31e42fe07bea7a762990496eea1010ce9acc27b 100644 Binary files a/Bin/Plugins/EF720B55-787B-4CBC-AD0A-AE219CFD52C9/X64/OfficeApplet.exe and b/Bin/Plugins/EF720B55-787B-4CBC-AD0A-AE219CFD52C9/X64/OfficeApplet.exe differ diff --git a/Bin/Plugins/F90B1CF0-8485-40ec-B4E8-B87598AAB35D/Config.json b/Bin/Plugins/F90B1CF0-8485-40ec-B4E8-B87598AAB35D/Config.json index e2f2dd527d5554394a59853a7365a2da79276429..f6b1b05e329c52a2d0e4c36ba0c9be4e06aadcb8 100644 --- a/Bin/Plugins/F90B1CF0-8485-40ec-B4E8-B87598AAB35D/Config.json +++ b/Bin/Plugins/F90B1CF0-8485-40ec-B4E8-B87598AAB35D/Config.json @@ -1,3 +1,4 @@ { - "PORT": 12800 + "PORT": 12800, + "HTTP": 12803 } \ No newline at end of file diff --git a/Bin/Plugins/F90B1CF0-8485-40ec-B4E8-B87598AAB35D/PluginAuth.paf b/Bin/Plugins/F90B1CF0-8485-40ec-B4E8-B87598AAB35D/PluginAuth.paf index 12319a37ab7c65b697b6e657423d2b6bc8039669..8ec9d1caa17ea06a27124a63504099b58b9d5e17 100644 Binary files a/Bin/Plugins/F90B1CF0-8485-40ec-B4E8-B87598AAB35D/PluginAuth.paf and b/Bin/Plugins/F90B1CF0-8485-40ec-B4E8-B87598AAB35D/PluginAuth.paf differ diff --git a/Bin/Plugins/F90B1CF0-8485-40ec-B4E8-B87598AAB35D/PluginWinExe.exe b/Bin/Plugins/F90B1CF0-8485-40ec-B4E8-B87598AAB35D/PluginWinExe.exe index 9f19bb0249004e7c96ac97127ffaef8faeac9dae..1163a6e55a6e208524915c06a13a2c4eabac4390 100644 Binary files a/Bin/Plugins/F90B1CF0-8485-40ec-B4E8-B87598AAB35D/PluginWinExe.exe and b/Bin/Plugins/F90B1CF0-8485-40ec-B4E8-B87598AAB35D/PluginWinExe.exe differ diff --git a/Bin/SApiApplet .txt b/Bin/SApiApplet .txt index 6d7aa7d67bde9cce58cfe1610625cc58403aed83..a9e6885d9c74a5a5812012e94cc61d01e9f9c80c 100644 --- a/Bin/SApiApplet .txt +++ b/Bin/SApiApplet .txt @@ -8,11 +8,11 @@ 2װ΢С -{"req":"Plugin_Install","rid":1,"para":{"Name":"΢С","PID":"AE023C55-E408-45DB-BF58-8B11C4E8D945","Date":"2020-12-18","Desc":"PluginOKм֮Ͽ΢С򣬿ChromeEdgeFirefoxIEOpera360QQѹȵ°ʵʶָֹ","DownAddr":"http://local.zorrosoft.com/Files/Plugin/WrlSpVoice.pid","MD5":"3A3F91ED95C7EBC8D07F4DA03EA069EE","Version":"2.0.3.11","Size":458752,"HideIns":0,"Type":1,"Cookie":"","Auth":"","TK":"AFE0F076A6C0E2B2F5B1FFA26B18658B4DB1528EBDD3339C68A2BC3A7DC7F93928B68111405DF90505B30F91276145B24241D5651EA18E95FDA7BA2DAE177994C65DAC5605345575556658B4BCE618E3D2800BB25AE5481E493B53428968512E4618C70B854D62EAA184F7D4BF33C4853311E66C5F9D58591894B9CCEEBA49161CEB7917D10081F43C1635A9C6C27B0569AF8EBD2EAEE98E88F6D3988F10062068E8B77BBD602D8F89A16D4141D68785E5E1B2634F51FFE4B6DF426B7A78492BBA85C6FFB0E5BDFA3CB47FA924649C228744DA785AD2F0B2A0FFC0F536953055A89E8D2CE9A0126087152A645404813BE64CED46A00F5C98C1843A42ECFD663F"}} +{"req":"Plugin_Install","rid":1,"para":{"Name":"΢С","PID":"AE023C55-E408-45DB-BF58-8B11C4E8D945","Date":"2021-01-20","Desc":"PluginOKм֮Ͽ΢С򣬿ChromeEdgeFirefoxIEOpera360QQѹȵ°ʵʶָֹ","DownAddr":"http://local.zorrosoft.com/Files/Plugin/WrlSpVoice.pid","MD5":"B563DCCFE4981B755878C946243F994D","Version":"2.1.1.1","Size":458752,"HideIns":0,"Type":1,"Cookie":"","Auth":"","TK":"02A63D1DDDC4035125A7F383F8F7D0972BED93759C7EE468C66BE99A979A6321241BDF7B12144976466E6BBA5B544B1F0E639A221EB2B29FCD1ED36D9E1D154D1538833DF7BF16F5308BBA293D46F9086EE6F12A4C4FFB0ED7274E53333B04A17CD80A753631B2CC1E5F44555033C8B8503A4C9B939B78A8852F3524C8AB1BA431DBE65F428E4EACA8590B2EDF98538C04B2F18E672AD71E93540D42F23BCEF075C0CCD6DA352CE2C6A00795EE3B9981857CDC374F34F3E5B84ECFFE4FF31CD57011E21005BF9401A73105294A22E36D9EBCFAFD9E9B4102152CDC25735AE27079F51BC7A0749BE5D0B4B8C033A0DA70EBAE00B4FEA86C54D6B1434D8B13FB52"}} 3΢С -{"req":"Plugin_Update","rid":1,"para":{"Name":"΢С","PID":"AE023C55-E408-45DB-BF58-8B11C4E8D945","Date":"2020-12-18","Desc":"PluginOKм֮Ͽ΢С򣬿ChromeEdgeFirefoxIEOpera360QQѹȵ°ʵʶָֹ","DownAddr":"http://local.zorrosoft.com/Files/Plugin/WrlSpVoice_Update.pid","MD5":"B1465FD907A366E036956D9A796F1D87","Version":"2.0.3.11","Size":458752,"HideIns":0,"Type":1,"Cookie":"","Auth":"","TK":"850DF6D8CFD0DAA5DCFCE9CD8813B724EF7301BB32B4598BD677B32D2A7BDAD0A435C3E883A47CE68DED21A9E24CD0270A355C604EC54871E37ACC51B2ED1B57E1F69BA07AE0720F89B09BB9885B03E31DCD253B4604D7539B72C031426DC72B5A73B2CA7791D6F3A351DA688E365CD2FB6344F51E48B56748E0403C0E62B5790779BF8247C3984F54C32FF31297BA7AB21E1311B9B5E6273E44465BB1826A0F04D05EE297473E39EC71231691DDBE0039490DD6CDF69BAD24DE78263025F0F7993976D5EB6DFA53A6230D5EB025E4FA48428D5E2D84A0D15D6CD57FB2C6A881E5FAAB28E38ED7DDEE027DC7425D116F8FA6D602F0C540B933C33C4F1E9EC225"}} +{"req":"Plugin_Update","rid":1,"para":{"Name":"΢С","PID":"AE023C55-E408-45DB-BF58-8B11C4E8D945","Date":"2021-01-20","Desc":"PluginOKм֮Ͽ΢С򣬿ChromeEdgeFirefoxIEOpera360QQѹȵ°ʵʶָֹ","DownAddr":"http://local.zorrosoft.com/Files/Plugin/WrlSpVoice_Update.pid","MD5":"6F1E4C770FFB8A77822942659DB07C42","Version":"2.1.1.1","Size":458752,"HideIns":0,"Type":1,"Cookie":"","Auth":"","TK":"80858429335683EE08E68D66F5A5B1DF1D836A8674CBD67F55E37236C1447F876380A7B258A933295EF0A5A449B1E6CEAEF31DEA0E0EB349A83EC2787F290C479C8D10C24E4FB1E3AB22BDCA43AB68F934D288DCD06901CD86E96A56F045D33CE06E67F07F2DD399C3D25404139465C954894B150C7F5E81810EEEF2E5045AF1449161F0D078EBC25BE7E0FBFB73E54AD37E14BF897CA6144B15D97F69A0DD26B1748B4ACCB62000D1D4627EA857F7A0D8D29BD08CFD8409C02535EC5F0C1CF496DDC4FB3953FD90E67C7B9954FB0E8CD80BF09BCD944C68DD2C6AF8ED5BEBCB22B47F0447EBA4E2EE4C6C291D31D8D35FF1CADB45346B75B4649059255B9408"}} ϰװJSON汾ݲͬװʱϵͷȡµ diff --git a/Bin/SerialPortApplet.txt b/Bin/SerialPortApplet.txt index 223ba842af5f8bea9052d44a5f4cf74be7881fe1..42553c2cf8fb33f01d4c6981256da608aa3e1dff 100644 --- a/Bin/SerialPortApplet.txt +++ b/Bin/SerialPortApplet.txt @@ -8,11 +8,11 @@ 2װͨСڲҳ ws://localhost?sid=123&flag=1 мȻһݵͣ -{"req":"Plugin_Install","rid":1,"para":{"Name":"ͨС","PID":"C0B01CD6-7DD9-4D3C-B668-04168D5236FC","Date":"2020-12-12","Desc":"PluginOKм֮ϿĴͨС򣬿ChromeEdgeFirefoxIEOpera360QQȵ°е","DownAddr":"http://local.zorrosoft.com/Files/Plugin/WrlComm.pid","MD5":"628817FE6A190CBCC538974CA5EC6B00","Version":"2.0.3.11","Size":753664,"HideIns":0,"Type":1,"Cookie":"","Auth":"","TK":"55E06F607D655FE105E9D99AD2ABD9CBACEDBAD3EF6A1454A6F81F70A539AF46846132E917D6E96B552D63DE6D677169848384532BB375AB15F15E3D6941A94291CEA2038951304CAB2FC6FC00E686E4E63E2685B3D568907FDBBFA36F3B33BB5F31D01F1708053A1958E22CDBCAB432EBA4A086F1CA7C46765FF789992FAA9AB00BD1F1BF1D60CB230AD8893D21D355E91E7364A76CEEC47FD9F78D8F9813563090855291544DD5CC413C9045B66C9AE34D92974DF3A8763365CDC64DDC3A5C6002EB288D745C28093F638617BC3C5048750B329CAB292BEA3445D485D4898A75E18EE6BAC14946F6172915922AEC93CE638BBA114CBA15CEE0ABD8661A5738"}} +{"req":"Plugin_Install","rid":1,"para":{"Name":"ͨС","PID":"C0B01CD6-7DD9-4D3C-B668-04168D5236FC","Date":"2021-01-20","Desc":"PluginOKм֮ϿĴͨС򣬿ChromeEdgeFirefoxIEOpera360QQȵ°е","DownAddr":"http://local.zorrosoft.com/Files/Plugin/WrlComm.pid","MD5":"3C364F6E68B55F5A2B9987C78B5B87DB","Version":"2.1.1.1","Size":622592,"HideIns":0,"Type":1,"Cookie":"","Auth":"","TK":"683801970A8FCF76A67918F8D28C028C85A8F68C26D17B743CD07D5982A2C6C5D9606D86FD0D72E6F7B471D0B35EE19377AA18604176237CD99AF7481F7980A4CA6958DE64F7AC4AA835B0CB1957123582373B8DFBBC58D91B05984BA87E85D11BF37F89395C8899A8E6818F7C1C29073B4FD8D985DE3014E640380742F38D0BF6F928A71FC42A0CD5CCA3F55E059382E15EFCC11CBEC554CBC88B04A8CD0F297012C2EF6D9DE2E6C9CC759C55E7BE01F811F767C89C4CDD6D7C7EDAD4EE6935AC7ED031AD2AE9E2AE3C1B6CB0C1BBDDC3EEB1BC483EF8652322D16E01DFF285E65A08D7CAD6F654F62502189DF58A1EF0C083FFE7A1532160E09BBF7348DC83"}} 3󴮿ͨС£ -{"req":"Plugin_Update","rid":1,"para":{"Name":"ͨС","PID":"C0B01CD6-7DD9-4D3C-B668-04168D5236FC","Date":"2020-12-12","Desc":"PluginOKм֮ϿĴͨС򣬿ChromeEdgeFirefoxIEOpera360QQȵ°е","DownAddr":"http://local.zorrosoft.com/Files/Plugin/WrlComm_Update.pid","MD5":"6F24CD5141249F50A5A5E98414901BD5","Version":"2.0.3.11","Size":753664,"HideIns":0,"Type":1,"Cookie":"","Auth":"","TK":"72606452D9D9E4B5B8DE3162A7634F88DF63E615EC1B6DD2709913215B73A7900B672EC2DE44E4F65757B2A6B86C121AC0D0A8E3B2EC1ADE4C4DE09EDAAAF59CD3B66BEA1ED4EAEADC1BBA54ACDA538E363770AF1E39538CABBFCBD76D27517DBA15C78BB73B6F415E308DE5410B8A94C948B4AC23573DE51AF2C7CF0AE73135E5DE8F200DA8947049569048C89E9AE79AEDCF4A4270E024837581B0DDCAEDEC6CD849621DEA55A4989E587F14A7248E2495F307A15A525A2527C2BFD9C9FBCA9F15102CB72B54561DEBEED251A863D6FE2082CFCD5F29F8755D2ABEF2A4A1045A66703A106A1E5A631B54AADEEF6BDE8BF12A2BF686468025EFD531BF7C2F4F"}} +{"req":"Plugin_Update","rid":1,"para":{"Name":"ͨС","PID":"C0B01CD6-7DD9-4D3C-B668-04168D5236FC","Date":"2021-01-20","Desc":"PluginOKм֮ϿĴͨС򣬿ChromeEdgeFirefoxIEOpera360QQȵ°е","DownAddr":"http://local.zorrosoft.com/Files/Plugin/WrlComm_Update.pid","MD5":"770A619B880A0A37C6329FC5BC7FDA4A","Version":"2.1.1.1","Size":622592,"HideIns":0,"Type":1,"Cookie":"","Auth":"","TK":"6614FE635346B95337280BC92B0EA97081ADC5029E1BD244F321B2B2060A9890BE4F34596700500001C2F91E1583F8CDEFE2875C9F551280DA3CC28176651A07F2EC8BE4D086360D8D157320D0CD1C15AB9F11BDF7B75C812212AC56447FD39ADE5C2B528FBBD3A952ABBC689C015FC631B6DBD355DE583033E81176B3A93DF596B7F0D6F7F014572C7DDDD0A31234F550C231DECBC3284A13866E6976BEE5EEB4BD25EE87C1A71DE2BC2DED07A9BBD184089DE51C1A973A997B36506960F2B96F440C53EA511B3AF9E334AD9381A308302078A4B88560FBEDCAFA4751D0F284843E3100AA85144AE5B61D6477EF202272E89149F1415337904A0EB58160D483"}} ϰװJSON汾ݲͬװʱϵͷȡµ diff --git a/Bin/TXWebApplet.txt b/Bin/TXWebApplet.txt new file mode 100644 index 0000000000000000000000000000000000000000..46cc2e91796ca4c4ca906d66c3da0cc8d0228070 --- /dev/null +++ b/Bin/TXWebApplet.txt @@ -0,0 +1,137 @@ +腾讯软件内嵌网页版:基于跨浏览器的小程序系统-PluginOK(牛插)中间件( https://github.com/wangzuohuai/WebRunLocal )开发,可实现将腾讯微信、企业微信、腾讯会议、QQ等客户端软件内嵌到网页中运行。最低可用在Chrome 41、Firefox 52、Edge 80(Chromium内核)、360极速/安全、IE 8、Oprea 36、QQ、搜狗等浏览器,也兼容运行于这些浏览器的最新版本。 + +1、PluginOK(牛插)中间件的安装: +1)、如果是exe的安装程序,请直接运行安装; +2)、如果是绿色版的程序包,请解压到磁盘某个目录后,双击“InstallWrl.bat”进行安装; +3)、安装完成时会启动PluginOK中间件服务,在安装目录下的Data子目录有WrlService.txt日志文件输出运行情况。 + +2、腾讯软件内嵌网页版控制相关接口: +说明:以下功能请通过Web Socket连接PluginOK主服务(ws://localhost?sid=12345&flag=1)后可执行,如默认侦听端口不是80(关于如何配置侦听端口,请参考SDK包中的文档“PluginOK开发者手册.doc”),请在连接地址中指定端口号进行连接。 +HTTP网页在线测试:http://zorrosoft.com/txfull.html HTTPS网页在线测试:https://zorrosoft.com/txframe.html +前端集成可参考以上测试网页进行,HTML网页中需要嵌入以下类似代码; +A、标记程序的显示位置和大小 +.TXWebApplet { + margin: 20px 0 0 20px; + width: 480px; + height: 320px; + border: 1px solid blue; + } +或者 +.TXWebApplet { + width: 480px; + height: 320px; + top: 20px; + left: 20px; + border: 1px solid blue; + } +B、嵌入 +支持IFrame的: + +
+ +
+
+
+ + + + + +
+
+
+ + +
+
+
+
+
通讯记录
+
+
+
+
+
+ + diff --git a/Test/TXFull.html b/Test/TXFull.html new file mode 100644 index 0000000000000000000000000000000000000000..3fc0bb2b09d23b5bdbe1152a9418a641255c7803 --- /dev/null +++ b/Test/TXFull.html @@ -0,0 +1,94 @@ + + + + + + 当前页内嵌腾讯微信体验 + + + + + + + + + + + + + + + + + +
+ +
+ +
+
+
+ + +   + +   + +
+
+
+ + +
+
+
+
+
通讯记录
+
+
+
+
+ +
+ + + diff --git a/WrlSDK/Package/WrlEngine.dll b/WrlSDK/Package/WrlEngine.dll index 3fdd70e2e8f44a0ff58a8167c60b834d372df652..ed965cb3eec932bfeb76f3bc01a7bd781f39b7d2 100644 Binary files a/WrlSDK/Package/WrlEngine.dll and b/WrlSDK/Package/WrlEngine.dll differ diff --git a/WrlSDK/Package/WrlPackage.exe b/WrlSDK/Package/WrlPackage.exe index c585ea0c590646cb59bc26c54b55d4e5d65c87c5..f8004ed128107d3e24953a941a51e6c0b25767bd 100644 Binary files a/WrlSDK/Package/WrlPackage.exe and b/WrlSDK/Package/WrlPackage.exe differ diff --git "a/WrlSDK/PluginOK\344\270\255\351\227\264\344\273\266\345\256\211\345\205\250\350\247\243\345\206\263\346\226\271\346\241\210.doc" "b/WrlSDK/PluginOK\344\270\255\351\227\264\344\273\266\345\256\211\345\205\250\350\247\243\345\206\263\346\226\271\346\241\210.doc" index 78a77352af96adef37a5a0d7e6ce838b61055df4..5655b95988e740909cfcb4c6cff5b011bce09a5f 100644 Binary files "a/WrlSDK/PluginOK\344\270\255\351\227\264\344\273\266\345\256\211\345\205\250\350\247\243\345\206\263\346\226\271\346\241\210.doc" and "b/WrlSDK/PluginOK\344\270\255\351\227\264\344\273\266\345\256\211\345\205\250\350\247\243\345\206\263\346\226\271\346\241\210.doc" differ diff --git a/WrlSDK/SampleCode/Bin/WrlApplet.dll b/WrlSDK/SampleCode/Bin/WrlApplet.dll index c9c38dc3faab7d14657e45fbbdeb0cb3da999ba2..5b99a6c229c6fdc9ee322df24c461e7f679ece87 100644 Binary files a/WrlSDK/SampleCode/Bin/WrlApplet.dll and b/WrlSDK/SampleCode/Bin/WrlApplet.dll differ diff --git a/WrlSDK/SampleCode/Bin/WrlBase.dll b/WrlSDK/SampleCode/Bin/WrlBase.dll index 580bb34db9e09f3d5fa6411a382eb721a3555ac9..2439b92670a756de46e86986732294f36b6599ef 100644 Binary files a/WrlSDK/SampleCode/Bin/WrlBase.dll and b/WrlSDK/SampleCode/Bin/WrlBase.dll differ diff --git a/WrlSDK/SampleCode/Bin/WrlEngine.dll b/WrlSDK/SampleCode/Bin/WrlEngine.dll index 3fdd70e2e8f44a0ff58a8167c60b834d372df652..ed965cb3eec932bfeb76f3bc01a7bd781f39b7d2 100644 Binary files a/WrlSDK/SampleCode/Bin/WrlEngine.dll and b/WrlSDK/SampleCode/Bin/WrlEngine.dll differ diff --git a/WrlSDK/SampleCode/PluginComDll/PluginComDll.rc b/WrlSDK/SampleCode/PluginComDll/PluginComDll.rc index 24a37d1d104fb282c3fa86dfeb7c542933ae228e..0580d69b76f6b0123eaa89afc539b512bad22948 100644 Binary files a/WrlSDK/SampleCode/PluginComDll/PluginComDll.rc and b/WrlSDK/SampleCode/PluginComDll/PluginComDll.rc differ diff --git a/WrlSDK/SampleCode/PluginComDll/PluginConfig.json b/WrlSDK/SampleCode/PluginComDll/PluginConfig.json index a154d3ea10127716d8d5f15b39f283fe91d62772..ad3c8865351df831d74b9de0af9e3170f68338ef 100644 --- a/WrlSDK/SampleCode/PluginComDll/PluginConfig.json +++ b/WrlSDK/SampleCode/PluginComDll/PluginConfig.json @@ -2,13 +2,14 @@ "Type": 1, "OS": 1, "Control": 0, + "Http": 1, "OSMinVer": "5.0", - "Version": "2.0.2.1", - "Name": "无窗口小程序范例(C++语言)", + "Version": "2.1.1.1", + "Name": "DLL小程序范例(C++语言)", "Corp": "ZorroSoft", "Icon": "", - "Date": "2020.08.25", - "Desc": "无窗口小程序(C++语言)-读写TXT记事本及获取当前系统信息", + "Date": "2021.01.12", + "Desc": "无窗小程序(C++语言)-读写TXT记事本及获取当前系统信息", "Home": "http://zorrosoft.com/WRL", "Down": "http://zorrosoft.com/WRL", "Module": "PluginComDll.dll", diff --git a/WrlSDK/SampleCode/PluginComDll/TextFile.h b/WrlSDK/SampleCode/PluginComDll/TextFile.h index 98453c3b7f34d77ced644404590f88e2aa46861e..c6c918ee41d97589370b3e5c656b60fb3ab23a39 100644 --- a/WrlSDK/SampleCode/PluginComDll/TextFile.h +++ b/WrlSDK/SampleCode/PluginComDll/TextFile.h @@ -27,7 +27,11 @@ class ATL_NO_VTABLE CTextFile : #else public IDispatchImpl, #endif +#ifdef WRL_VRSION_STANDALONE public IDispatchImpl +#else + public IDispatchImpl +#endif { protected: @@ -44,9 +48,9 @@ public: BEGIN_COM_MAP(CTextFile) COM_INTERFACE_ENTRY(ITextFile) - COM_INTERFACE_ENTRY2(IDispatch, IWrlConn) - COM_INTERFACE_ENTRY(IConnectionPointContainer) COM_INTERFACE_ENTRY(IWrlConn) + COM_INTERFACE_ENTRY(IConnectionPointContainer) + COM_INTERFACE_ENTRY2(IDispatch, IWrlConn) END_COM_MAP() BEGIN_CONNECTION_POINT_MAP(CTextFile) @@ -112,10 +116,16 @@ public: return S_FALSE; } - STDMETHOD(HttpRequst)(BSTR bstrUrl,BSTR bstrPara, BSTR* pVal) + STDMETHOD(HttpRequst)(BSTR bstrUrl,BSTR bstrPara,BSTR* pVal) { - /// HTTPӦ - return E_NOTIMPL; + /// յHTTPЭҪǰͬ󣬱ǰҪȴܼ + /// ɸݴݵIJֱִвͬĹܣDLLСУҪִУ޸мļNoServiceΪ1°װмЧ + ::MessageBox(NULL,L"ִв",L"ʾ",MB_OK); + /// ÷ݣ鶼JSONʽڽ + CComBSTR bstrVal(L"{\"ret\":0,\"data\":{\"Ret\":0,\"Code\":1}}"); + bstrVal.CopyTo(pVal); + bstrVal.Empty(); + return S_OK; } }; diff --git a/WrlSDK/SampleCode/PluginExeDemo/Config.json b/WrlSDK/SampleCode/PluginExeDemo/Config.json index df74b525d165ee7b8baad558dea3de7cfdcab49c..7753acb85d59d9832d235bbd6a15ba63518255f7 100644 --- a/WrlSDK/SampleCode/PluginExeDemo/Config.json +++ b/WrlSDK/SampleCode/PluginExeDemo/Config.json @@ -1,3 +1,4 @@ { - "PORT": 12900 + "PORT": 12900, + "HTTP": 12903 } \ No newline at end of file diff --git a/WrlSDK/SampleCode/PluginExeDemo/Form1.cs b/WrlSDK/SampleCode/PluginExeDemo/Form1.cs index 97a80d31e36023bc8f64aba7fde65f0e807039fc..e30ca56fdb605eaa8b2e53c02ea69ce505df91f5 100644 --- a/WrlSDK/SampleCode/PluginExeDemo/Form1.cs +++ b/WrlSDK/SampleCode/PluginExeDemo/Form1.cs @@ -103,7 +103,7 @@ namespace PluginExeDemo MessageBox.Show("还未有来自网页的连接!"); return; } - Send(strLastSID, this.textBox1.Text); + Send(strLastSID,this.textBox1.Text); this.textBox1.Text = ""; } @@ -144,7 +144,7 @@ namespace PluginExeDemo } /// - /// 通知新连接 + /// 通知收到新连接 /// /// public void NewConnEvent(string bstrSID) @@ -164,7 +164,7 @@ namespace PluginExeDemo /// public void RecMsgEvent(string bstrSID, uint nReqID, string bstrPushName, string bstrMsg) { - m_Form.textBox2.AppendText("收到新数据包,请求序号:"); + m_Form.textBox2.AppendText("收到新数据包,请求序号:"); m_Form.textBox2.AppendText(nReqID.ToString()); m_Form.textBox2.AppendText("协议名:"); m_Form.textBox2.AppendText(bstrPushName); @@ -201,31 +201,64 @@ namespace PluginExeDemo } /// - /// + /// 通知连接收到字节流内容 /// /// /// /// public void RecByteEvent(string bstrSID, Object Content, uint nLen) { + m_Form.textBox2.AppendText("收到二进制流:"); + m_Form.textBox2.AppendText(Content.ToString()); + m_Form.textBox2.AppendText("\r\n"); + } + + /// + /// 通知HTTP同步请求处理 + /// + /// + /// + /// + public void HttpReqEvent(string bstrSID, string bstrProtocol, string bstrUrl, string bstrPara, out string pVal) + { + /// 收到HTTP协议请求,主要用于前端同步请求,比如前端需要等待请求完成浏览器才能继续操作 + /// 这里执行阻塞操作,比如弹出模态对话框 + pVal = "{\"ret\":0,\"data\":{\"Ret\":0,\"Code\":1}}"; } /// - /// + /// 通知HTTP侦听端口 + /// + /// + public void HttpPortEvent(ushort nPort) + { + m_Form.textBox2.AppendText("HTTP侦听端口:"); + m_Form.textBox2.AppendText(nPort.ToString()); + m_Form.textBox2.AppendText("\r\n"); + } + + /// + /// WS连接请求中出现错误 /// - /// /// /// - public void HttpReqEvent(uint nSessionID, string strUrl, string strPara) + /// + public void RecErrEvent(string bstrSID, uint nReqID, string bstrErrInfo) { + m_Form.textBox2.AppendText("连接出现错误:"); + m_Form.textBox2.AppendText(bstrErrInfo); + m_Form.textBox2.AppendText("\r\n"); } /// /// 通知关闭连接 /// /// - public void ConnCloseEvent(string bstrSID) + public void ConnCloseEvent(string bstrSID, string bstrReason) { + m_Form.textBox2.AppendText("关闭连接:"); + m_Form.textBox2.AppendText(bstrReason); + m_Form.textBox2.AppendText("\r\n"); } } } diff --git a/WrlSDK/SampleCode/PluginExeDemo/PluginConfig.json b/WrlSDK/SampleCode/PluginExeDemo/PluginConfig.json index f8939f678ce21e94eb30944924aec64e82db79e6..2360c2d892e4a43252d66f1520153e3b792ace68 100644 --- a/WrlSDK/SampleCode/PluginExeDemo/PluginConfig.json +++ b/WrlSDK/SampleCode/PluginExeDemo/PluginConfig.json @@ -2,12 +2,13 @@ "Type": 2, "OS": 1, "Control": 0, + "Http": 1, "OSMinVer": "5.0", - "Version": "2.0.2.1", + "Version": "2.1.1.1", "Name": "弹窗小程序范例(C#语言)", "Corp": "ZorroSoft", "Icon": "", - "Date": "2020.08.25", + "Date": "2021.01.20", "Desc": "弹窗小程序范例(C#语言)-演示脚本请求打开指定网站", "Home": "http://zorrosoft.com/WRL", "Down": "http://zorrosoft.com/WRL", diff --git a/WrlSDK/SampleCode/PluginNetDll/PluginConfig.json b/WrlSDK/SampleCode/PluginNetDll/PluginConfig.json index dccd312ea63d3c7688abf6b8878aa1e8312f44ff..8121cf33101bb6db502fec7c03b3d9716db35880 100644 --- a/WrlSDK/SampleCode/PluginNetDll/PluginConfig.json +++ b/WrlSDK/SampleCode/PluginNetDll/PluginConfig.json @@ -2,13 +2,14 @@ "Type": 1, "OS": 1, "Control": 0, + "Http": 1, "Asm": 1, "OSMinVer": "5.0", - "Version": "2.0.2.1", - "Name": "无窗口小程序范例(C#语言)", + "Version": "2.1.1.1", + "Name": "DLL小程序范例(C#语言)", "Corp": "ZorroSoft", "Icon": "", - "Date": "2020.08.25", + "Date": "2021.01.03", "Desc": "无窗口小程序范例(C#语言)", "Home": "http://zorrosoft.com/WRL", "Down": "http://zorrosoft.com/WRL", diff --git a/WrlSDK/SampleCode/PluginNetDll/TestWrl.cs b/WrlSDK/SampleCode/PluginNetDll/TestWrl.cs index 1d444f9eb6480a6523ca2cf6e2f2400cc1963f7d..a70422358fd84725d098c5dfc03628428cbe58ad 100644 --- a/WrlSDK/SampleCode/PluginNetDll/TestWrl.cs +++ b/WrlSDK/SampleCode/PluginNetDll/TestWrl.cs @@ -48,8 +48,10 @@ namespace PluginNetDll string IWrlConn.HttpRequst(string bstrUrl, string bstrPara) { - /// 收到HTTP类型请求,暂未实现 - return ""; + WriteLog(bstrUrl, bstrPara); + /// 收到HTTP协议请求,主要用于前端同步请求,比如前端需要等待请求完成浏览器才能继续操作 + /// 可根据传递的参数分别执行不同的功能,在DLL小程序中,如需要弹窗执行,请先修改中间件配置文件参数NoService为1后再重新安装中间件生效! + return "{\"ret\":0,\"data\":{\"Ret\":0,\"Code\":1}}"; } void IWrlConn.RecByte(ref byte pContent, uint nLen) @@ -85,19 +87,18 @@ namespace PluginNetDll string strName = JsonService.GetStringValue("Name"); string strContent = JsonService.GetStringValue("Content"); - string strAppPath = this.GetType().Assembly.Location; - strAppPath.Replace(".exe",""); - strAppPath += "\\Data\\"; - StreamWriter swFile = new StreamWriter(strAppPath + strName, true, Encoding.Unicode); + string strAppPath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Data"); + if (!System.IO.Directory.Exists(strAppPath)) + System.IO.Directory.CreateDirectory(strAppPath); + StreamWriter swFile = new StreamWriter(strAppPath + "\\" + strName, true, Encoding.Unicode); swFile.WriteLine(strContent); swFile.Close(); swFile.Dispose(); - strReturn = strAppPath + strName + "写入内容" ; + strReturn = strAppPath + "\\" + strName + " 文件中写入内容"; } else strReturn = "收到未知请求:" + bstrPushName; - WriteLog(bstrPushName, strReturn); /// 给前端回复请求 m_WebSocketConnect.AsynSendText(strReturn); } diff --git a/WrlSDK/SampleCode/PluginWinExe/Config.json b/WrlSDK/SampleCode/PluginWinExe/Config.json index e2f2dd527d5554394a59853a7365a2da79276429..f6b1b05e329c52a2d0e4c36ba0c9be4e06aadcb8 100644 --- a/WrlSDK/SampleCode/PluginWinExe/Config.json +++ b/WrlSDK/SampleCode/PluginWinExe/Config.json @@ -1,3 +1,4 @@ { - "PORT": 12800 + "PORT": 12800, + "HTTP": 12803 } \ No newline at end of file diff --git a/WrlSDK/SampleCode/PluginWinExe/MainDlg.cpp b/WrlSDK/SampleCode/PluginWinExe/MainDlg.cpp index 55b61132797ab595b674704c416cffb93e981802..1e8240dd37182664f7d3edca98d2d5ba53d6a05e 100644 --- a/WrlSDK/SampleCode/PluginWinExe/MainDlg.cpp +++ b/WrlSDK/SampleCode/PluginWinExe/MainDlg.cpp @@ -48,9 +48,98 @@ LRESULT CMainDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam m_spiSocketProxyEvent = NULL; this->PostMessage(WM_APP,0,0); /// 첽ʼ + SetCheckTimer(500); return TRUE; } +BOOL FindProName(DWORD dwPID,ATL::CString& strFileName) +{ + BOOL bFindFlag = FALSE; + HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0); + ATLASSERT(hSnapshot); + + PROCESSENTRY32 pe = {0}; + pe.dwSize = sizeof(pe); + BOOL fok = Process32First(hSnapshot, &pe); + DWORD dwGetProcessID = dwPID; + if(!dwGetProcessID) + dwGetProcessID = ::GetCurrentProcessId(); + for(;fok ;fok = Process32Next(hSnapshot , &pe)) + { + if(pe.th32ProcessID == dwGetProcessID) + { + strFileName = _wcsupr(pe.szExeFile); + strFileName.MakeLower(); + bFindFlag = TRUE; + break; + } + } + + CloseHandle(hSnapshot); + hSnapshot = NULL; + return bFindFlag; +} + +LRESULT CMainDlg::OnTimer ( UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/ ) +{ + if(wParam == WRL_BROWSER_CHECKTIMER) + { + DWORD dwPID = 0; + /// 㴰ǷΪȸ + HWND hWnd = ::GetForegroundWindow(); + ::GetWindowThreadProcessId(hWnd,&dwPID); + if(dwPID != ::GetCurrentProcessId()) + { + /// ݽIDִгļжǷΪӦĹȸ + CString strExeFile; + FindProName(dwPID,strExeFile); + CString strExeName; + switch(m_eBrowserType) + { + case BROWSERTYPE_IE: + strExeName = L"iexplore.exe"; + break; + case BROWSERTYPE_EDGE: + strExeName = L"msedge.exe"; + break; + case BROWSERTYPE_FIREFOX: + strExeName = L"firefox.exe"; + break; + case BROWSERTYPE_OPERA: + strExeName = L"opera.exe"; + break; + case BROWSERTYPE_360: + strExeName = L"360chrome.exe"; + break; + case BROWSERTYPE_360SE: + strExeName = L"360se.exe"; + break; + case BROWSERTYPE_360ENTSE: + strExeName = L"360ent.exe"; + break; + case BROWSERTYPE_QQ: + strExeName = L"qqbrowser.exe"; + break; + case BROWSERTYPE_SOGOU: + strExeName = L"sogouexplorer.exe"; + break; + default: + strExeName = L"chrome.exe"; + break; + } + if(-1 != strExeFile.CompareNoCase(strExeName)) + { + SetWindowPos(HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE); + } + else + { + SetWindowPos(HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE); + } + } + } + return 0; +} + void CMainDlg::InitWebCtrl() { CRect rcClient; @@ -102,6 +191,21 @@ void CMainDlg::InitWebCtrl() } } +void CMainDlg::SetCheckTimer(UINT nElapse) +{ + if(m_nTimerID) + return; + m_nTimerID = ::SetTimer(this->m_hWnd,WRL_BROWSER_CHECKTIMER,nElapse,NULL); +} + +void CMainDlg::KillCheckTimer() +{ + if(!m_nTimerID) + return; + ::KillTimer(this->m_hWnd,m_nTimerID); + m_nTimerID = 0; +} + LRESULT CMainDlg::OnOpenUrl(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/) { if(NULL == m_spiWebBrowser) @@ -215,12 +319,12 @@ LRESULT CMainDlg::OnInitConn(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/ { if(NULL != m_spiSocketProxy) return 0;/// Ѿʼ - HRESULT hRet = m_spiSocketProxy.CreateInstance(__uuidof(SocketProxy)); - ATLASSERT(SUCCEEDED(hRet)); - if(FAILED(hRet)) + HRESULT hRet(E_FAIL); + hRet = m_spiSocketProxy.CreateInstance(__uuidof(SocketProxy)); + if(NULL == m_spiSocketProxy) { - this->MessageBox(L"Web Socketδעɹ"); InitWebCtrl(); + this->MessageBox(L"Web Socketδעɹ"); return 0; } #ifdef NEED_FINAL_CONSTRUCT @@ -256,34 +360,71 @@ LRESULT CMainDlg::OnNewConnect(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, { BSTR bstrSID = (BSTR)lParam; /// ¼ӱʶȻԵ֪ͨϢ - m_mapConnID[bstrSID] = bstrSID; + m_mapConnID[bstrSID] = NULL; this->GetDlgItem(IDC_EDIT_LOG).SetWindowText(CString(L"յ֪ͨ") + bstrSID); return 0; } +LRESULT CMainDlg::OnHttpReq(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) +{ + /// յHTTPЭҪǰͬ󣬱ǰҪȴܼ + HttpReqData* phd = (HttpReqData*)lParam; + if(NULL != phd) + { + /// ִ絯ģ̬Ի + this->MessageBox(L"ִ",L"ʾ",MB_OK); + /// ÷ֵ + phd->strRet = L"{\"ret\":0,\"data\":{\"Ret\":0,\"Code\":1}}"; + } + return 0; +} + +LRESULT CMainDlg::OnHttpPort(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) +{ + m_nHttpPort = (USHORT)lParam; + return 0; +} + +LRESULT CMainDlg::OnRecError(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) +{ + return 0; +} + LRESULT CMainDlg::OnRecMessage(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) { - CString strReqName = (BSTR)wParam; - BSTR bstrContent = (BSTR)lParam; + if(NULL == m_spiSocketProxyEvent) + return 0; + IJsonServicePtr spiJsonService = NULL; + HRESULT hRet = spiJsonService.CreateInstance(__uuidof(JsonService)); + if(NULL == spiJsonService) + return 0; + BSTR bstrSID = (BSTR)wParam; + ULONG nReqID = (ULONG)lParam; + CRecData* pRecData = m_spiSocketProxyEvent->GetCatchData(bstrSID,nReqID,TRUE); + if(NULL == pRecData) + { + spiJsonService = NULL; + return 0; + } + CString strReqName = pRecData->strReqName; CString strMsg; - strMsg.Format(L"յΪ %s JSONݰ:%s",strReqName,(CString)bstrContent); + strMsg.Format(L"յΪ %s JSONݰ:%s",strReqName,pRecData->strRecText); this->GetDlgItem(IDC_EDIT_LOG).SetWindowText(strMsg); strMsg.Empty(); - ULONG nReqID = 0; - m_spiSocketProxy->AsynSendText(CComBSTR(m_mapConnID.begin()->first),\ - CComBSTR(CString(L"APPյ:")+bstrContent),&nReqID); + + ULONG nSendID = 0; + m_spiSocketProxy->AsynSendText(bstrSID,\ + CComBSTR(CString(L"APPյ:")+pRecData->strRecText),&nSendID); /// յ - IJsonServicePtr spiJsonService = NULL; - HRESULT hRet = spiJsonService.CreateInstance(__uuidof(JsonService)); - if(NULL == spiJsonService) - return 0; VARIANT_BOOL bLoadFlag = VARIANT_FALSE; spiJsonService->put_CodingType(CODINGTYPE_US2); - spiJsonService->ParseString(bstrContent,&bLoadFlag); + spiJsonService->ParseString(CComBSTR(pRecData->strRecText),&bLoadFlag); if(VARIANT_FALSE == bLoadFlag) { spiJsonService = NULL; + delete pRecData; + pRecData = NULL; return 0; } if(0 == strReqName.CompareNoCase(L"Demo_OpenUrl")) @@ -296,7 +437,19 @@ LRESULT CMainDlg::OnRecMessage(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL /// ֪ͨվ this->PostMessage(WM_APP_OPENURL,0,0); } + else if(0 == strReqName.CompareNoCase(L"Demo_HttpPort")) + { + /// 󷵻HTTP˿ + nSendID = 0; + CString strRetInfo; + strRetInfo.Format(L"{\"ret\":0,\"data\":{\"Port\":%ld}}",m_nHttpPort); + m_spiSocketProxy->AsynSendText(bstrSID,\ + CComBSTR(strRetInfo),&nSendID); + strRetInfo.Empty(); + } spiJsonService = NULL; + delete pRecData; + pRecData = NULL; return 0; } diff --git a/WrlSDK/SampleCode/PluginWinExe/MainDlg.h b/WrlSDK/SampleCode/PluginWinExe/MainDlg.h index f7b332705f79aa2f65e9b5bf0eddb9038c512e5f..218a0be9a0dcbce5287d0e56e28f891c427e11f4 100644 --- a/WrlSDK/SampleCode/PluginWinExe/MainDlg.h +++ b/WrlSDK/SampleCode/PluginWinExe/MainDlg.h @@ -8,8 +8,10 @@ #include "BrowserHost.h" #define WM_APP_OPENURL WM_USER + 500 +#define WRL_BROWSER_CHECKTIMER 9 -typedef std::map CSTRING_MAP; +typedef std::map CSTRING_MAP; +typedef std::map STRINGULONG_MAP; int Us2ToChar(const ATL::CString& strSrc, char** pDst,int nCodePage = CP_ACP); @@ -27,20 +29,29 @@ protected: /// Ϊ CDocHostUIHandler m_DocHostUIHandler; - /// ˿ - USHORT m_nPort; + /// ʱʶ + UINT_PTR m_nTimerID; + + /// + EWrlBrowserType m_eBrowserType; + + /// WS˿ + USHORT m_nPort; + /// HTTP˿ + USHORT m_nHttpPort; + /// ỰID - CString m_strSID; + CString m_strSID; /// ȨϢ - CString m_strAuthInfo; + CString m_strAuthInfo; - CSTRING_MAP m_mapPara; + CSTRING_MAP m_mapPara; /// ׼򿪵URLַ - CString m_strOpenUrl; + CString m_strOpenUrl; /// ¼еӱʶ - CSTRING_MAP m_mapConnID; + STRINGULONG_MAP m_mapConnID; /// ͨѶ ISocketProxyPtr m_spiSocketProxy; @@ -49,6 +60,10 @@ protected: /// ¼ CComObject* m_spiSocketProxyEvent; + void KillCheckTimer(); + + void SetCheckTimer(UINT nElapse); + void UnAdviseSocket(); void InitWebCtrl(); @@ -67,7 +82,10 @@ protected: public: CMainDlg() - :m_nPort(12900) + :m_nTimerID(0) + ,m_nPort(12900) + ,m_nHttpPort(0) + ,m_eBrowserType(BROWSERTYPE_UNKNOWN) ,m_spiWebBrowser(NULL) ,m_spiHtmlDoc(NULL) ,m_spiSocketProxy(NULL) @@ -102,7 +120,6 @@ public: if(it != m_mapPara.end()) m_strSID = it->second; it = m_mapPara.find(L"AI"); - ATLASSERT(it != m_mapPara.end()); if(it != m_mapPara.end()) m_strAuthInfo = it->second; } @@ -117,12 +134,16 @@ public: BEGIN_MSG_MAP(CMainDlg) MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) MESSAGE_HANDLER(WM_APP, OnInitConn) + MESSAGE_HANDLER(WM_TIMER, OnTimer) MESSAGE_HANDLER(WM_APP_OPENURL, OnOpenUrl) MESSAGE_HANDLER(WM_PROXYSEREREVENT_NEWCONNECT, OnNewConnect) MESSAGE_HANDLER(WM_PROXYSEREREVENT_RECMESSAGE, OnRecMessage) MESSAGE_HANDLER(WM_PROXYSEREREVENT_RECTEXT, OnRecText) MESSAGE_HANDLER(WM_PROXYSEREREVENT_CLOSECONN, OnCloseConnect) MESSAGE_HANDLER(WM_PROXYSEREREVENT_BYTE, OnRecByte) + MESSAGE_HANDLER(WM_PROXYSEREREVENT_HTTPREQ, OnHttpReq) + MESSAGE_HANDLER(WM_PROXYSEREREVENT_HTTPPORT, OnHttpPort) + MESSAGE_HANDLER(WM_PROXYSEREREVENT_RECERR, OnRecError) COMMAND_ID_HANDLER(ID_APP_ABOUT, OnAppAbout) COMMAND_ID_HANDLER(IDOK, OnOK) @@ -137,12 +158,16 @@ public: LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); LRESULT OnInitConn(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/ ); LRESULT OnOpenUrl(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/ ); + LRESULT OnTimer(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); LRESULT OnNewConnect(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); LRESULT OnRecMessage(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); LRESULT OnRecText(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); LRESULT OnRecByte(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); LRESULT OnCloseConnect(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); + LRESULT OnHttpReq(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); + LRESULT OnHttpPort(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); + LRESULT OnRecError(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); LRESULT OnAppAbout(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); LRESULT OnOK(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/); diff --git a/WrlSDK/SampleCode/PluginWinExe/PluginConfig.json b/WrlSDK/SampleCode/PluginWinExe/PluginConfig.json index 0cbec4e2f6513269e3b8d0edcde308f8d334a500..0f3b7cbc09d3ccd3b8dde3a6edfd753937bf6532 100644 --- a/WrlSDK/SampleCode/PluginWinExe/PluginConfig.json +++ b/WrlSDK/SampleCode/PluginWinExe/PluginConfig.json @@ -2,12 +2,13 @@ "Type": 2, "OS": 1, "Control": 0, + "Http": 1, "OSMinVer": "5.0", - "Version": "2.0.2.1", + "Version": "2.1.1.1", "Name": "弹窗小程序范例(C++语言)", "Corp": "ZorroSoft", "Icon": "", - "Date": "2020.08.25", + "Date": "2021.01.20", "Desc": "弹窗小程序(C++语言)-演示脚本请求打开指定网站", "Home": "http://zorrosoft.com/WRL", "Down": "http://zorrosoft.com/WRL", diff --git a/WrlSDK/SampleCode/PluginWinExe/PluginWinExe.rc b/WrlSDK/SampleCode/PluginWinExe/PluginWinExe.rc index 33999264abfc83b31e6dd87bd8746a55b1ac79ac..6f6aa9f1aa1f760c907fcae804e017800acfdf86 100644 --- a/WrlSDK/SampleCode/PluginWinExe/PluginWinExe.rc +++ b/WrlSDK/SampleCode/PluginWinExe/PluginWinExe.rc @@ -46,7 +46,7 @@ END IDD_MAINDLG DIALOGEX 0, 0, 400, 362 STYLE DS_SETFONT | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_CAPTION | WS_SYSMENU -CAPTION "C++Сʾ" +CAPTION "Сʾ(C++)" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN EDITTEXT IDC_EDIT_CONTENT,17,279,171,52,ES_MULTILINE | ES_AUTOVSCROLL @@ -89,8 +89,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,0,1,1 - PRODUCTVERSION 2,0,1,1 + FILEVERSION 2,1,1,1 + PRODUCTVERSION 2,1,1,1 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -105,13 +105,13 @@ BEGIN BEGIN BLOCK "040904b0" BEGIN - VALUE "FileDescription", "Сʾ(C++)" - VALUE "FileVersion", "2,0,1,1" + VALUE "FileDescription", "Сʾ(C++)" + VALUE "FileVersion", "2,1,1,1" VALUE "InternalName", "PluginWinExe" VALUE "LegalCopyright", "Copyright(C) 2013-? ZorroSoft. All Rights Reserved." VALUE "OriginalFilename", "PluginWinExe.exe" VALUE "ProductName", "PluginOK" - VALUE "ProductVersion", "2,0,1,1" + VALUE "ProductVersion", "2,1,1,1" END END BLOCK "VarFileInfo" diff --git a/WrlSDK/SampleCode/PluginWinExe/PluginWinExe.vcxproj b/WrlSDK/SampleCode/PluginWinExe/PluginWinExe.vcxproj index 762e169bd543205282dc3a36f6c030de3f573f3b..ac5a1245b721eab5c64e583a5c777fc988c16f00 100644 --- a/WrlSDK/SampleCode/PluginWinExe/PluginWinExe.vcxproj +++ b/WrlSDK/SampleCode/PluginWinExe/PluginWinExe.vcxproj @@ -230,6 +230,7 @@ + @@ -242,11 +243,14 @@ + + + diff --git a/WrlSDK/SampleCode/PluginWinExe/PluginWinExe.vcxproj.filters b/WrlSDK/SampleCode/PluginWinExe/PluginWinExe.vcxproj.filters index 4edf20a93428ae1ba713954c0cdb3fa8c054cb3e..f239b04cfa4bf54141676c2522067d99b5738a23 100644 --- a/WrlSDK/SampleCode/PluginWinExe/PluginWinExe.vcxproj.filters +++ b/WrlSDK/SampleCode/PluginWinExe/PluginWinExe.vcxproj.filters @@ -30,6 +30,9 @@ Source Files + + Source Files + @@ -50,6 +53,15 @@ Header Files + + Header Files + + + Header Files + + + Header Files + diff --git a/WrlSDK/SampleCode/PluginWinExe/ProxyServerEvent.cpp b/WrlSDK/SampleCode/PluginWinExe/ProxyServerEvent.cpp index 65f75d80b69e3356d78af3d0b4cd6ee832c68c90..99fbd9485471d9023ec8f7fbaf0ed6c2c6dadb4e 100644 --- a/WrlSDK/SampleCode/PluginWinExe/ProxyServerEvent.cpp +++ b/WrlSDK/SampleCode/PluginWinExe/ProxyServerEvent.cpp @@ -28,14 +28,13 @@ STDMETHODIMP CProxyServerEvent::Invoke( DISPID dispIdMember,REFIID riid,LCID lci CComVariant varSID; VariantInit(&varSID); - hRet = VariantChangeTypeEx( &varSID,&(pDispParams->rgvarg[0]),lcid,0,VT_BSTR); + hRet = VariantChangeTypeEx(&varSID,&(pDispParams->rgvarg[0]),lcid,0,VT_BSTR); if FAILED(hRet) return DISP_E_BADVARTYPE; hRet = NewConn(varSID.bstrVal); VariantClear(&varSID); break; } - case 0x00000002: { if ( pDispParams->cArgs != 4 ) @@ -48,16 +47,16 @@ STDMETHODIMP CProxyServerEvent::Invoke( DISPID dispIdMember,REFIID riid,LCID lci VariantInit(&varReqID); VariantInit(&varReqName); VariantInit(&varMsgInfo); - hRet = VariantChangeTypeEx( &varSID,&(pDispParams->rgvarg[3]),lcid,0,VT_BSTR); + hRet = VariantChangeTypeEx(&varSID,&(pDispParams->rgvarg[3]),lcid,0,VT_BSTR); if FAILED(hRet) return DISP_E_BADVARTYPE; - hRet = VariantChangeTypeEx( &varReqID,&(pDispParams->rgvarg[2]),lcid,0,VT_I4); + hRet = VariantChangeTypeEx(&varReqID,&(pDispParams->rgvarg[2]),lcid,0,VT_I4); if FAILED(hRet) return DISP_E_BADVARTYPE; - hRet = VariantChangeTypeEx( &varReqName,&(pDispParams->rgvarg[1]),lcid,0,VT_BSTR); + hRet = VariantChangeTypeEx(&varReqName,&(pDispParams->rgvarg[1]),lcid,0,VT_BSTR); if FAILED(hRet) return DISP_E_BADVARTYPE; - hRet = VariantChangeTypeEx( &varMsgInfo,&(pDispParams->rgvarg[0]),lcid,0,VT_BSTR); + hRet = VariantChangeTypeEx(&varMsgInfo,&(pDispParams->rgvarg[0]),lcid,0,VT_BSTR); if FAILED(hRet) return DISP_E_BADVARTYPE; hRet = RecMsgEvent(varSID.bstrVal,varReqID.ulVal,varReqName.bstrVal,varMsgInfo.bstrVal); @@ -77,10 +76,10 @@ STDMETHODIMP CProxyServerEvent::Invoke( DISPID dispIdMember,REFIID riid,LCID lci CComVariant varText,varSID; VariantInit(&varText); VariantInit(&varSID); - hRet = VariantChangeTypeEx( &varSID,&(pDispParams->rgvarg[1]),lcid,0,VT_BSTR); + hRet = VariantChangeTypeEx(&varSID,&(pDispParams->rgvarg[1]),lcid,0,VT_BSTR); if FAILED(hRet) return DISP_E_BADVARTYPE; - hRet = VariantChangeTypeEx( &varText,&(pDispParams->rgvarg[0]),lcid,0,VT_BSTR); + hRet = VariantChangeTypeEx(&varText,&(pDispParams->rgvarg[0]),lcid,0,VT_BSTR); if FAILED(hRet) return DISP_E_BADVARTYPE; hRet = RecTextEvent(varSID.bstrVal,varText.bstrVal); @@ -99,13 +98,13 @@ STDMETHODIMP CProxyServerEvent::Invoke( DISPID dispIdMember,REFIID riid,LCID lci VariantInit(&varSID); VariantInit(&varByte); VariantInit(&varLen); - hRet = VariantChangeTypeEx( &varSID,&(pDispParams->rgvarg[2]),lcid,0,VT_BSTR); + hRet = VariantChangeTypeEx(&varSID,&(pDispParams->rgvarg[2]),lcid,0,VT_BSTR); if FAILED(hRet) return DISP_E_BADVARTYPE; - hRet = VariantChangeTypeEx( &varByte,&(pDispParams->rgvarg[1]),lcid,0,VT_PTR); + hRet = VariantChangeTypeEx(&varByte,&(pDispParams->rgvarg[1]),lcid,0,VT_PTR); if FAILED(hRet) return DISP_E_BADVARTYPE; - hRet = VariantChangeTypeEx( &varLen,&(pDispParams->rgvarg[0]),lcid,0,VT_UI4); + hRet = VariantChangeTypeEx(&varLen,&(pDispParams->rgvarg[0]),lcid,0,VT_UI4); if FAILED(hRet) return DISP_E_BADVARTYPE; hRet = RecByte(varSID.bstrVal,varByte.pbVal,varLen.uiVal); @@ -114,7 +113,6 @@ STDMETHODIMP CProxyServerEvent::Invoke( DISPID dispIdMember,REFIID riid,LCID lci VariantClear(&varLen); break; } - case 0x00000005: { if ( pDispParams->cArgs != 2 ) @@ -125,10 +123,10 @@ STDMETHODIMP CProxyServerEvent::Invoke( DISPID dispIdMember,REFIID riid,LCID lci CComVariant varReason,varSID; VariantInit(&varReason); VariantInit(&varSID); - hRet = VariantChangeTypeEx( &varSID,&(pDispParams->rgvarg[1]),lcid,0,VT_BSTR); + hRet = VariantChangeTypeEx(&varSID,&(pDispParams->rgvarg[1]),lcid,0,VT_BSTR); if FAILED(hRet) return DISP_E_BADVARTYPE; - hRet = VariantChangeTypeEx( &varReason,&(pDispParams->rgvarg[0]),lcid,0,VT_BSTR); + hRet = VariantChangeTypeEx(&varReason,&(pDispParams->rgvarg[0]),lcid,0,VT_BSTR); if FAILED(hRet) return DISP_E_BADVARTYPE; hRet = CloseEvent(varSID.bstrVal,varReason.bstrVal); @@ -136,12 +134,110 @@ STDMETHODIMP CProxyServerEvent::Invoke( DISPID dispIdMember,REFIID riid,LCID lci VariantClear(&varSID); break; } + case 0x00000006: + { + if ( pDispParams->cArgs != 5 ) + return DISP_E_BADPARAMCOUNT; + if ( pDispParams->cNamedArgs ) + return DISP_E_NONAMEDARGS; + + CComVariant varSID,varProtocol,varUrl,varPara; + VariantInit(&varSID); + VariantInit(&varProtocol); + VariantInit(&varUrl); + VariantInit(&varPara); + hRet = VariantChangeTypeEx(&varSID,&(pDispParams->rgvarg[4]),lcid,0,VT_BSTR); + hRet = VariantChangeTypeEx(&varProtocol,&(pDispParams->rgvarg[3]),lcid,0,VT_BSTR); + hRet = VariantChangeTypeEx(&varUrl,&(pDispParams->rgvarg[2]),lcid,0,VT_BSTR); + if FAILED(hRet) + return DISP_E_BADVARTYPE; + hRet = VariantChangeTypeEx(&varPara,&(pDispParams->rgvarg[1]),lcid,0,VT_BSTR); + if FAILED(hRet) + return DISP_E_BADVARTYPE; + pDispParams->rgvarg[0].bstrVal = NULL; + pDispParams->rgvarg[0].vt = VT_BSTR; + if(NULL != m_hMsgWnd && ::IsWindow(m_hMsgWnd)) + { + /// ͬ󣬱SendMessage + HttpReqData hd; + hd.strProtocol = varProtocol.bstrVal; + hd.strUri = varUrl.bstrVal; + hd.strPara = varPara.bstrVal; + ::SendMessage(m_hMsgWnd,WM_PROXYSEREREVENT_HTTPREQ,0,(LPARAM)&hd); + CComBSTR bstrRet(hd.strRet); + bstrRet.CopyTo(&(pDispParams->rgvarg[0].bstrVal)); + bstrRet.Empty(); + } + VariantClear(&varSID); + VariantClear(&varProtocol); + VariantClear(&varUrl); + VariantClear(&varPara); + break; + } + case 0x00000007: + { + if ( pDispParams->cArgs != 3 ) + return DISP_E_BADPARAMCOUNT; + if ( pDispParams->cNamedArgs ) + return DISP_E_NONAMEDARGS; + + CComVariant varReason,varReqID,varSessionID; + VariantInit(&varReason); + VariantInit(&varReqID); + VariantInit(&varSessionID); + hRet = VariantChangeTypeEx( &varSessionID,&(pDispParams->rgvarg[2]),lcid,0,VT_UI4); + if FAILED(hRet) + return DISP_E_BADVARTYPE; + hRet = VariantChangeTypeEx( &varReqID,&(pDispParams->rgvarg[1]),lcid,0,VT_UI4); + if FAILED(hRet) + return DISP_E_BADVARTYPE; + hRet = VariantChangeTypeEx( &varReason,&(pDispParams->rgvarg[0]),lcid,0,VT_BSTR); + if FAILED(hRet) + return DISP_E_BADVARTYPE; + hRet = RecErrEvent(varSessionID.ulVal,varReqID.ulVal,varReason.bstrVal); + VariantClear(&varReason); + VariantClear(&varReqID); + VariantClear(&varSessionID); + break; + } + case 0x00000008: + { + if ( pDispParams->cArgs != 1 ) + return DISP_E_BADPARAMCOUNT; + if ( pDispParams->cNamedArgs ) + return DISP_E_NONAMEDARGS; + + CComVariant varPort; + VariantInit(&varPort); + hRet = VariantChangeTypeEx(&varPort,&(pDispParams->rgvarg[0]),lcid,0,VT_UI2); + if FAILED(hRet) + return DISP_E_BADVARTYPE; + if(NULL != m_hMsgWnd && ::IsWindow(m_hMsgWnd)) + { + /// ֪ͨHTTP˿ + ::PostMessage(m_hMsgWnd,WM_PROXYSEREREVENT_HTTPPORT,0,(LPARAM)varPort.uiVal); + } + VariantClear(&varPort); + break; + } default: break; } return hRet; } +STDMETHODIMP CProxyServerEvent::RecErrEvent(ULONG nSocketID,ULONG nReqID,BSTR bstrText) +{ + HRESULT hRet(E_FAIL); + if(NULL == bstrText) + return hRet; + if(NULL != m_hMsgWnd && ::IsWindow(m_hMsgWnd)) + { + ::SendMessage(m_hMsgWnd,WM_PROXYSEREREVENT_RECERR,nSocketID,(LPARAM)bstrText); + } + return hRet; +} + STDMETHODIMP CProxyServerEvent::NewConn(BSTR bstrSID) { HRESULT hRet(E_FAIL); @@ -155,19 +251,27 @@ STDMETHODIMP CProxyServerEvent::NewConn(BSTR bstrSID) return hRet; } -STDMETHODIMP CProxyServerEvent::RecMsgEvent(BSTR bstrSID,ULONG nReqID,BSTR bstrReqName,BSTR bstrRecInfo) +STDMETHODIMP CProxyServerEvent::RecMsgEvent(BSTR bstrSID,ULONG nReqID,\ + BSTR bstrReqName,BSTR bstrRecInfo) { HRESULT hRet(E_FAIL); if(!nReqID || NULL == bstrSID) - { return hRet; - } if(NULL != m_hMsgWnd && ::IsWindow(m_hMsgWnd)) { - m_nReqID = nReqID; - if(0 != m_strSID.CompareNoCase(bstrSID)) - m_strSID = bstrSID; - ::SendMessage(m_hMsgWnd,WM_PROXYSEREREVENT_RECMESSAGE,(WPARAM)bstrReqName,(LPARAM)bstrRecInfo); + CString strKey; + strKey.Format(L"%ld_%s",nReqID,(CString)bstrSID); + CRecData* pRecData = new CRecData(); + if(NULL != pRecData) + { + pRecData->pbContent = NULL; + pRecData->strReqName = bstrReqName; + pRecData->strRecText = bstrRecInfo; + } + m_DataLock.Lock(L"RecMsgEvent"); + m_CatchData[strKey] = pRecData; + m_DataLock.Unlock(L"RecMsgEvent"); + ::SendMessage(m_hMsgWnd,WM_PROXYSEREREVENT_RECMESSAGE,(WPARAM)bstrSID,(LPARAM)nReqID); } return hRet; } @@ -191,9 +295,15 @@ STDMETHODIMP CProxyServerEvent::RecByte(BSTR bstrSID,BYTE* pContent,ULONG nLen) return hRet; if(NULL != m_hMsgWnd && ::IsWindow(m_hMsgWnd)) { - if(0 != m_strSID.CompareNoCase(bstrSID)) - m_strSID = bstrSID; - ::SendMessage(m_hMsgWnd,WM_PROXYSEREREVENT_BYTE,(WPARAM)pContent,(LPARAM)nLen); + CString strKey; + strKey.Format(L"%ld_%s",nLen,(CString)bstrSID); + CRecData* pRecData = new CRecData(); + if(NULL != pRecData) + pRecData->pbContent = pContent; + m_DataLock.Lock(L"RecByte"); + m_CatchData[strKey] = pRecData; + m_DataLock.Unlock(L"RecByte"); + ::SendMessage(m_hMsgWnd,WM_PROXYSEREREVENT_BYTE,(WPARAM)bstrSID,(LPARAM)nLen); } return hRet; } diff --git a/WrlSDK/SampleCode/PluginWinExe/ProxyServerEvent.h b/WrlSDK/SampleCode/PluginWinExe/ProxyServerEvent.h index af15221f753c658979c0c2a1d0ddf3b1734379ad..9caaad4cddabdb164dc99cb8f0eaff0908079a35 100644 --- a/WrlSDK/SampleCode/PluginWinExe/ProxyServerEvent.h +++ b/WrlSDK/SampleCode/PluginWinExe/ProxyServerEvent.h @@ -1,15 +1,40 @@ #pragma once - -#define WM_PROXYSEREREVENT_NEWCONNECT WM_USER + 2000 -#define WM_PROXYSEREREVENT_RECMESSAGE WM_USER + 2001 -#define WM_PROXYSEREREVENT_RECTEXT WM_USER + 2002 -#define WM_PROXYSEREREVENT_BYTE WM_USER + 2003 -#define WM_PROXYSEREREVENT_CLOSECONN WM_USER + 2005 +#include +#include "BaseFuncLib.h" + +#define WM_PROXYSEREREVENT_NEWCONNECT WM_USER + 2000 +#define WM_PROXYSEREREVENT_RECMESSAGE WM_USER + 2001 +#define WM_PROXYSEREREVENT_RECTEXT WM_USER + 2002 +#define WM_PROXYSEREREVENT_BYTE WM_USER + 2003 +#define WM_PROXYSEREREVENT_CLOSECONN WM_USER + 2005 +#define WM_PROXYSEREREVENT_HTTPREQ WM_USER + 2006 +#define WM_PROXYSEREREVENT_HTTPPORT WM_USER + 2007 +#define WM_PROXYSEREREVENT_RECERR WM_USER + 2008 #ifndef NEED_FINAL_CONSTRUCT #define NEED_FINAL_CONSTRUCT #endif +struct HttpReqData +{ + CString strUri; + CString strPara; + CString strRet; + + CString strProtocol; +}; + +struct CRecData +{ + CString strReqName; + CString strRecText; + + // յĶ + BYTE* pbContent; +}; + +typedef std::map RECDATA_MAP; + // CProxyServerEvent class CProxyServerEvent : public CComObjectRoot, @@ -19,13 +44,25 @@ class CProxyServerEvent : protected: /// Ϣ - HWND m_hMsgWnd; + HWND m_hMsgWnd; + + CThreadDataLock m_DataLock; - /// ǰỰID - CString m_strSID; + RECDATA_MAP m_CatchData; - /// ǰ - ULONG m_nReqID; + void FreeAll() + { + m_DataLock.Lock(L"FreeAll"); + RECDATA_MAP::iterator it = m_CatchData.begin(); + while(it != m_CatchData.end()) + { + if(NULL != it->second) + delete it->second; + it++; + } + m_CatchData.clear(); + m_DataLock.Unlock(L"FreeAll"); + } public: CProxyServerEvent() @@ -35,16 +72,7 @@ public: ~CProxyServerEvent() { - } - - CString GetCurSID() - { - return m_strSID; - } - - ULONG GetCurReqID() - { - return m_nReqID; + FreeAll(); } void SetCallPara(HWND hMsgWnd) @@ -57,6 +85,23 @@ public: m_hMsgWnd = hMsgWnd; } + CRecData* GetCatchData(const CString& strSID,ULONG nReqID,BOOL bRemove = TRUE) + { + CRecData* pRecData = NULL; + CString strKey; + strKey.Format(L"%ld_%s",nReqID,strSID); + m_DataLock.Lock(L"GetCatchData"); + RECDATA_MAP::iterator it = m_CatchData.find(strKey); + if(it != m_CatchData.end()) + { + pRecData = it->second; + if(bRemove) + m_CatchData.erase(it); + } + m_DataLock.Unlock(L"GetCatchData"); + return pRecData; + } + BEGIN_COM_MAP(CProxyServerEvent) COM_INTERFACE_ENTRY(_ISocketProxyEvents) END_COM_MAP() @@ -85,9 +130,10 @@ public: // _ISocketProxyEvents STDMETHOD(NewConn)(BSTR bstrSID); - STDMETHOD(RecMsgEvent)(BSTR bstrSID,ULONG nReqID,BSTR nReqName,BSTR bstrRecText); + STDMETHOD(RecMsgEvent)(BSTR bstrSID,ULONG nReqID,BSTR bstrReqName,BSTR bstrRecText); STDMETHOD(RecTextEvent)(BSTR bstrSID,BSTR bstrText); STDMETHOD(RecByte)(BSTR bstrSID,BYTE* pContent,ULONG nLen); + STDMETHOD(RecErrEvent)(ULONG nSocketID,ULONG nReqID,BSTR bstrErrInfo); STDMETHOD(CloseEvent)(BSTR bstrSID,BSTR bstrReason); }; \ No newline at end of file diff --git a/WrlSDK/SampleCode/PluginWinExe/WRLRegKey.cpp b/WrlSDK/SampleCode/PluginWinExe/WRLRegKey.cpp index 527eecdcf984352fb839be8becbfd4420b5044e1..9f2241dcfcf277b720342bb43a94986005503cd5 100644 --- a/WrlSDK/SampleCode/PluginWinExe/WRLRegKey.cpp +++ b/WrlSDK/SampleCode/PluginWinExe/WRLRegKey.cpp @@ -1,15 +1,37 @@ -// WrlRegKey.cpp : עװʵ +/** + * @file ZMRegKey.cpp + * + * Copyright (c) 2013-?,ɶ + * All rights reserved. + * + * @ingroup + * + * @brief עװʵ + * + * + * + * @version + * + * @date 2018-09-01 + * + * @author WZH + * + * @history + * + */ +// ZMRegKey.cpp : עװʵ #include "stdafx.h" -#include "WrlRegKey.h" +#include "WRLRegKey.h" +#include "BaseFuncLib.h" CWrlRegKey::CWrlRegKey(const ATL::CString& strMainRegPath,\ const ATL::CString& strChildName, HKEY hKey,REGSAM samDesired) { m_bOpenFlag = FALSE; m_dwLastErr = 0; - if(!strMainRegPath.IsEmpty()) - NewRegPath(strMainRegPath,strChildName,hKey,samDesired); + ATLASSERT(strMainRegPath.GetLength()); + NewRegPath(strMainRegPath,strChildName,hKey,samDesired); } void CWrlRegKey::Close() @@ -24,25 +46,21 @@ void CWrlRegKey::Close() BOOL CWrlRegKey::NewRegPath(const ATL::CString& strMainRegPath,\ const ATL::CString& strChildName, HKEY hKey,REGSAM samDesired) { - Close(); + if(m_bOpenFlag) + Close(); ATL::CString strRegPath; if(!strChildName.IsEmpty()) - { - if(strMainRegPath.GetLength()) - strRegPath.Format(_T("%s\\%s"),strMainRegPath,strChildName); - else - strRegPath = strChildName; - } + strRegPath.Format(_T("%s\\%s"),strMainRegPath,strChildName); else strRegPath = strMainRegPath; m_dwLastErr = Open(hKey,strRegPath,samDesired); if(ERROR_SUCCESS != m_dwLastErr) { - if(ERROR_ACCESS_DENIED != m_dwLastErr) + if(ERROR_ACCESS_DENIED != m_dwLastErr && ERROR_WRITE_PROTECT != m_dwLastErr) { - /// ڣԶ + /// ָעĿԶ m_dwLastErr = Create(hKey,strRegPath,NULL,0,samDesired); } } @@ -53,20 +71,32 @@ BOOL CWrlRegKey::NewRegPath(const ATL::CString& strMainRegPath,\ return m_bOpenFlag; } -BOOL CWrlRegKey::GetRegStringVal(const ATL::CString& strKeyName, - ATL::CString& strKeyValue) +BOOL CWrlRegKey::GetRegStringVal( + const ATL::CString& strKeyName,ATL::CString& strKeyValue) { BOOL bGetFlag = FALSE; if(!m_bOpenFlag) + { return bGetFlag; + } DWORD dwSize = 0; - m_dwLastErr = CRegKey::QueryStringValue(strKeyName,NULL,&dwSize); - + if(strKeyName.IsEmpty()) + m_dwLastErr = CRegKey::QueryStringValue(NULL,NULL,&dwSize); + else + m_dwLastErr = CRegKey::QueryStringValue(strKeyName,NULL,&dwSize); + if(!dwSize) + { + /// ûֵ + return bGetFlag; + } TCHAR *szBuf = new TCHAR[dwSize+1]; if(NULL == szBuf) return bGetFlag; memset(szBuf,0,(dwSize+1)*sizeof(TCHAR)); - m_dwLastErr = CRegKey::QueryStringValue(strKeyName,szBuf,&dwSize); + if(strKeyName.IsEmpty()) + m_dwLastErr = CRegKey::QueryStringValue(NULL,szBuf,&dwSize); + else + m_dwLastErr = CRegKey::QueryStringValue(strKeyName,szBuf,&dwSize); if(m_dwLastErr != ERROR_SUCCESS) { if(NULL != szBuf) @@ -120,56 +150,6 @@ BOOL CWrlRegKey::SetRegDwordVal(const ATL::CString& strKeyName, return TRUE; } -BOOL CWrlRegKey::GetRegBinaryValue(const ATL::CString &strKeyName,BYTE **ppValue,ULONG* pnBytes) -{ - if(!m_bOpenFlag) - return FALSE; - ATLASSERT(ppValue && pnBytes); - m_dwLastErr = CRegKey::QueryBinaryValue(strKeyName,NULL,pnBytes); - if(0 == *pnBytes || m_dwLastErr != ERROR_SUCCESS) - { - *ppValue = NULL; - return FALSE; - } - ULONG nLen = (*pnBytes)+1; - *ppValue = new BYTE[nLen]; - memset(*ppValue,0,nLen*sizeof(BYTE)); - m_dwLastErr = CRegKey::QueryBinaryValue(strKeyName,*ppValue,pnBytes); - if(m_dwLastErr != ERROR_SUCCESS) - return FALSE; - return TRUE; -} - -BOOL CWrlRegKey::SetRegBinaryValue(const ATL::CString &strKeyName,const BYTE* Value,ULONG nBytes) -{ - if(!m_bOpenFlag) - return FALSE; - m_dwLastErr = CRegKey::SetBinaryValue(strKeyName,Value,nBytes); - if(m_dwLastErr != ERROR_SUCCESS) - return FALSE; - return TRUE; -} - -BOOL CWrlRegKey::GetRegGuidValue(const ATL::CString &strKeyName,GUID &Value) -{ - if(!m_bOpenFlag) - return FALSE; - m_dwLastErr = CRegKey::QueryGUIDValue(strKeyName,Value)==ERROR_SUCCESS; - if(m_dwLastErr != ERROR_SUCCESS) - return FALSE; - return TRUE; -} - -BOOL CWrlRegKey::SetRegGuidValue(const ATL::CString &strKeyName,GUID Value) -{ - if(!m_bOpenFlag) - return FALSE; - m_dwLastErr = CRegKey::SetGUIDValue(strKeyName,Value); - if(m_dwLastErr != ERROR_SUCCESS) - return FALSE; - return TRUE; -} - BOOL CWrlRegKey::DelKeyName(const ATL::CString& strKeyName) { if(!m_bOpenFlag) @@ -178,4 +158,4 @@ BOOL CWrlRegKey::DelKeyName(const ATL::CString& strKeyName) if(m_dwLastErr != ERROR_SUCCESS) return FALSE; return TRUE; -} +} \ No newline at end of file diff --git a/WrlSDK/SampleCode/PluginWinExe/WRLRegKey.h b/WrlSDK/SampleCode/PluginWinExe/WRLRegKey.h index e016079df457abb61be7f49f641f2029b7dd7a95..a0e0702bb3a211bc60404eff6eab95d7228293d8 100644 --- a/WrlSDK/SampleCode/PluginWinExe/WRLRegKey.h +++ b/WrlSDK/SampleCode/PluginWinExe/WRLRegKey.h @@ -1,130 +1,71 @@ +/** + * @file WRLRegKey.h + * + * Copyright (c) 2013-?,ɶ޹˾ + * All rights reserved. + * + * @ingroup + * + * @brief עװ + * + * + * + * @version + * + * @date 2020-07-13 + * + * @author WZH + * + * @history + * + */ // WRLRegKey.h : עͷļ // -////////////////////////////////////////////////////////////////////// #pragma once +#include "WRLBaseDef.h" + +/// Ʒעеİװ· +#define PRODUCT_COMMAN_INSPATH L"InsPath" +/// Ʒעе汾 +#define PRODUCT_COMMAN_MAINVERNAME L"MainVer" +/// ƷעеĴΰ汾 +#define PRODUCT_COMMAN_MINIVERNAME L"MiniVer" +/// ƷעеС汾 +#define PRODUCT_COMMAN_SMALLVERNAME L"SmallVer" +/// Ʒעеı汾 +#define PRODUCT_COMMAN_BUILDVERNAME L"BuildVer" + class CWrlRegKey : public CRegKey { public: - CWrlRegKey(const ATL::CString& strMainRegPath,\ - const ATL::CString& strChildName, \ - HKEY hKey,REGSAM samDesired); + CWrlRegKey(const ATL::CString& strMainRegPath = COMPANY_REGPATH,\ + const ATL::CString& strChildName = PRODUCT_REGNODENAME, \ + HKEY hKey = HKEY_CURRENT_USER,REGSAM samDesired = KEY_ALL_ACCESS); virtual ~CWrlRegKey(void) { - /// ʱԶرգй¶ Close(); } - /// жǷע BOOL IsOpen() { return m_bOpenFlag; } - /** - * @brief ·ʵ - * - * - * @param strMainRegPath עλ - * @param strChildName עĿ¼ - * @param bCurrentUser ǷΪûעΪϵͳע - * @return - */ - BOOL NewRegPath(const ATL::CString& strMainRegPath,\ - const ATL::CString& strChildName,\ - HKEY hKey,REGSAM samDesired); - - /** - * @brief ݼƻַͼֵ - * - * - * @param strKeyName - * @param strKeyValue ֵ - * @return Ƿɹȡ - */ + BOOL NewRegPath(const ATL::CString& strMainRegPath = COMPANY_REGPATH,\ + const ATL::CString& strChildName = PRODUCT_REGNODENAME,\ + HKEY hKey = HKEY_CURRENT_USER,REGSAM samDesired = KEY_ALL_ACCESS); + BOOL GetRegStringVal(const ATL::CString& strKeyName,ATL::CString& strKeyValue); - - /** - * @brief עֵַ - * - * - * @param strKeyName - * @param strKeyValue ֵ - * @return Ƿɹ - */ + BOOL SetRegStringVal(const ATL::CString& strKeyName,const ATL::CString& strKeyValue); - /** - * @brief עDWORDֵ - * - * - * @param strKeyName - * @param dwKeyValue ֵ - * @return Ƿȡɹ - */ BOOL GetRegDwordVal(const ATL::CString& strKeyName,DWORD& dwKeyValue); - /** - * @brief עDWORDֵ - * - * - * @param strKeyName - * @param dwKeyValue ֵ - * @return Ƿɹ - */ BOOL SetRegDwordVal(const ATL::CString& strKeyName,DWORD dwKeyValue); - /** - * @brief עֵ - * - * - * @param strKeyName - * @param ppValue ֵ - * @param pnBytes س - * @return Ƿȡɹ - */ - BOOL GetRegBinaryValue(const ATL::CString &strKeyName,BYTE **ppValue,ULONG* pnBytes); - - /** - * @brief öֵ - * - * - * @param strKeyName - * @param Value ֵ - * @param pnBytes س - * @return Ƿóɹ - */ - BOOL SetRegBinaryValue(const ATL::CString &strKeyName,const BYTE* Value,ULONG nBytes); - - /** - * @brief GUIDעֵ - * - * - * @param strKeyName - * @param Value ֵ - * @return Ƿȡɹ - */ - BOOL GetRegGuidValue(const ATL::CString &strKeyName,GUID &Value); - - /** - * @brief GUIDעֵ - * - * - * @param strKeyName - * @param Value ֵ - * @return Ƿóɹ - */ - BOOL SetRegGuidValue(const ATL::CString &strKeyName,GUID Value); - - /** - * @brief ɾָļֵ - * - * - * @param strKeyName - * @return - */ BOOL DelKeyName(const ATL::CString& strKeyName); DWORD GetLastErr() @@ -132,18 +73,11 @@ public: return m_dwLastErr; } - /** - * @brief رע - * - * - */ virtual void Close(); protected: - /// DWORD m_dwLastErr; - /// Ƿע BOOL m_bOpenFlag; }; diff --git a/WrlSDK/SampleCode/PluginWinExe/WTL/atlapp.h b/WrlSDK/SampleCode/PluginWinExe/WTL/atlapp.h index 4b3fe38d846da65e2f04257dec2bd4c0bb63cf8e..8be6edc59a794cd87e90c679005f323b5d183a3c 100644 --- a/WrlSDK/SampleCode/PluginWinExe/WTL/atlapp.h +++ b/WrlSDK/SampleCode/PluginWinExe/WTL/atlapp.h @@ -1,4 +1,4 @@ -// Windows Template Library - WTL version 9.10 +// Windows Template Library - WTL version 10.0 // Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. // // This file is a part of the Windows Template Library. @@ -19,64 +19,76 @@ #error atlapp.h requires atlbase.h to be included first #endif -#ifndef _WIN32_WCE - #if (WINVER < 0x0400) - #error WTL requires Windows version 4.0 or higher - #endif - - #if (_WIN32_IE < 0x0300) - #error WTL requires IE version 3.0 or higher - #endif +#ifdef _WIN32_WCE + #error WTL10 doesn't support Windows CE #endif #ifdef _ATL_NO_COMMODULE - #error WTL requires that _ATL_NO_COMMODULE is not defined + #error WTL doesn't support _ATL_NO_COMMODULE #endif -#if (_ATL_VER >= 0x0900) && defined(_ATL_MIN_CRT) - #error _ATL_MIN_CRT is not supported with ATL 9.0 and higher +#ifdef _ATL_NO_WIN_SUPPORT + #error WTL doesn't support _ATL_NO_WIN_SUPPORT #endif -#if defined(_WIN32_WCE) && defined(_ATL_MIN_CRT) - #pragma message("Warning: WTL for Windows CE doesn't use _ATL_MIN_CRT") +#if (_MSC_VER < 1400) + #error WTL10 requires C++ compiler version 14 (Visual C++ 2005) or higher #endif -#include -#if !defined(_ATL_MIN_CRT) && defined(_MT) && !defined(_WIN32_WCE) - #include // for _beginthreadex +#if (WINVER < 0x0501) + #error WTL requires WINVER >= 0x0501 #endif -#if (_ATL_VER < 0x0800) && !defined(_DEBUG) - #include +#if (_WIN32_WINNT < 0x0501) + #error WTL requires _WIN32_WINNT >= 0x0501 #endif -#include -#ifndef _WIN32_WCE - #pragma comment(lib, "comctl32.lib") +#if (_WIN32_IE < 0x0600) + #error WTL requires _WIN32_IE >= 0x0600 #endif -#if defined(_SYSINFOAPI_H_) && defined(NOT_BUILD_WINDOWS_DEPRECATE) && (_WIN32_WINNT >= 0x0501) - #include +#if (_ATL_VER < 0x0800) + #error WTL10 requires ATL version 8 or higher #endif -#ifndef _WIN32_WCE - #include "atlres.h" -#else // CE specific - #include "atlresce.h" -#endif // _WIN32_WCE +#ifdef _ATL_MIN_CRT + #error WTL10 doesn't support _ATL_MIN_CRT +#endif -// We need to disable this warning because of template class arguments -#pragma warning(disable: 4127) +#ifdef _ATL_NO_MSIMG + #error WTL10 doesn't support _ATL_NO_MSIMG +#endif -#if (_ATL_VER >= 0x0900) && !defined(_SECURE_ATL) - #define _SECURE_ATL 1 +#include +#ifdef _MT + #include // for _beginthreadex #endif +#include +#pragma comment(lib, "comctl32.lib") + +#include +#include + +// Check for VS2005 without newer WinSDK +#if (_MSC_VER == 1400) && !defined(RB_GETEXTENDEDSTYLE) + #error WTL10 requires WinSDK 6.0 ot higher +#endif + +#include +#pragma comment(lib, "uxtheme.lib") + +#if defined(_SYSINFOAPI_H_) && defined(NOT_BUILD_WINDOWS_DEPRECATE) + #include +#endif + +#include "atlres.h" + /////////////////////////////////////////////////////////////////////////////// // WTL version number -#define _WTL_VER 0x0910 +#define _WTL_VER 0x1000 // version 10.0 /////////////////////////////////////////////////////////////////////////////// @@ -89,416 +101,12 @@ // CAppModule // CServerAppModule // -// CRegKeyEx -// // Global functions: +// AtlInitCommonControls() // AtlGetDefaultGuiFont() // AtlCreateControlFont() // AtlCreateBoldFont() -// AtlInitCommonControls() - - -/////////////////////////////////////////////////////////////////////////////// -// Global support for Windows CE - -#ifdef _WIN32_WCE - -#ifndef SW_SHOWDEFAULT - #define SW_SHOWDEFAULT SW_SHOWNORMAL -#endif // !SW_SHOWDEFAULT - -// These get's OR-ed in a constant and will have no effect. -// Defining them reduces the number of #ifdefs required for CE. -#define LR_DEFAULTSIZE 0 -#define LR_LOADFROMFILE 0 - -#ifndef SM_CXCURSOR - #define SM_CXCURSOR 13 -#endif -#ifndef SM_CYCURSOR - #define SM_CYCURSOR 14 -#endif - -inline BOOL IsMenu(HMENU hMenu) -{ - MENUITEMINFO mii = { sizeof(MENUITEMINFO) }; - ::SetLastError(0); - BOOL bRet = ::GetMenuItemInfo(hMenu, 0, TRUE, &mii); - if(!bRet) - bRet = (::GetLastError() != ERROR_INVALID_MENU_HANDLE) ? TRUE : FALSE; - return bRet; -} - -#if (_WIN32_WCE >= 410) -extern "C" void WINAPI ListView_SetItemSpacing(HWND hwndLV, int iHeight); -#endif // (_WIN32_WCE >= 410) - -inline int MulDiv(IN int nNumber, IN int nNumerator, IN int nDenominator) -{ - __int64 multiple = nNumber * nNumerator; - return static_cast(multiple / nDenominator); -} - -#if (_ATL_VER >= 0x0800) - -#ifndef _WTL_KEEP_WS_OVERLAPPEDWINDOW - #ifdef WS_OVERLAPPEDWINDOW - #undef WS_OVERLAPPEDWINDOW - #define WS_OVERLAPPEDWINDOW 0 - #endif // WS_OVERLAPPEDWINDOW -#endif // !_WTL_KEEP_WS_OVERLAPPEDWINDOW - -#ifndef RDW_FRAME - #define RDW_FRAME 0 -#endif // !RDW_FRAME - -#ifndef WM_WINDOWPOSCHANGING - #define WM_WINDOWPOSCHANGING 0 -#endif // !WM_WINDOWPOSCHANGING - -#define FreeResource(x) -#define UnlockResource(x) - -namespace ATL -{ - inline HRESULT CComModule::RegisterClassObjects(DWORD /*dwClsContext*/, DWORD /*dwFlags*/) throw() - { return E_NOTIMPL; } - inline HRESULT CComModule::RevokeClassObjects() throw() - { return E_NOTIMPL; } -}; // namespace ATL - -#ifndef lstrlenW - #define lstrlenW (int)ATL::lstrlenW -#endif // lstrlenW - -inline int WINAPI lstrlenA(LPCSTR lpszString) -{ return ATL::lstrlenA(lpszString); } - -#ifdef lstrcpyn - #undef lstrcpyn - #define lstrcpyn ATL::lstrcpynW -#endif // lstrcpyn - -#ifndef SetWindowLongPtrW - inline LONG_PTR tmp_SetWindowLongPtrW( HWND hWnd, int nIndex, LONG_PTR dwNewLong ) - { - return( ::SetWindowLongW( hWnd, nIndex, LONG( dwNewLong ) ) ); - } - #define SetWindowLongPtrW tmp_SetWindowLongPtrW -#endif - -#ifndef GetWindowLongPtrW - inline LONG_PTR tmp_GetWindowLongPtrW( HWND hWnd, int nIndex ) - { - return( ::GetWindowLongW( hWnd, nIndex ) ); - } - #define GetWindowLongPtrW tmp_GetWindowLongPtrW -#endif - -#ifndef LongToPtr - #define LongToPtr(x) ((void*)x) -#endif - -#ifndef PtrToInt - #define PtrToInt( p ) ((INT)(INT_PTR) (p) ) -#endif - -#else // !(_ATL_VER >= 0x0800) - -#ifdef lstrlenW - #undef lstrlenW - #define lstrlenW (int)::wcslen -#endif // lstrlenW - -#define lstrlenA (int)strlen - -#ifndef lstrcpyn - inline LPTSTR lstrcpyn(LPTSTR lpstrDest, LPCTSTR lpstrSrc, int nLength) - { - if(lpstrDest == NULL || lpstrSrc == NULL || nLength <= 0) - return NULL; - int nLen = __min(lstrlen(lpstrSrc), nLength - 1); - LPTSTR lpstrRet = (LPTSTR)memcpy(lpstrDest, lpstrSrc, nLen * sizeof(TCHAR)); - lpstrDest[nLen] = 0; - return lpstrRet; - } -#endif // !lstrcpyn - -#ifndef lstrcpynW - inline LPWSTR lstrcpynW(LPWSTR lpstrDest, LPCWSTR lpstrSrc, int nLength) - { - return lstrcpyn(lpstrDest, lpstrSrc, nLength); // WinCE is Unicode only - } -#endif // !lstrcpynW - -#ifndef lstrcpynA - inline LPSTR lstrcpynA(LPSTR lpstrDest, LPCSTR lpstrSrc, int nLength) - { - if(lpstrDest == NULL || lpstrSrc == NULL || nLength <= 0) - return NULL; - int nLen = __min(lstrlenA(lpstrSrc), nLength - 1); - LPSTR lpstrRet = (LPSTR)memcpy(lpstrDest, lpstrSrc, nLen * sizeof(char)); - lpstrDest[nLen] = 0; - return lpstrRet; - } -#endif // !lstrcpyn - -#ifdef TrackPopupMenu - #undef TrackPopupMenu -#endif // TrackPopupMenu - -#define DECLARE_WND_CLASS_EX(WndClassName, style, bkgnd) \ -static CWndClassInfo& GetWndClassInfo() \ -{ \ - static CWndClassInfo wc = \ - { \ - { style, StartWindowProc, \ - 0, 0, NULL, NULL, NULL, (HBRUSH)(bkgnd + 1), NULL, WndClassName }, \ - NULL, NULL, IDC_ARROW, TRUE, 0, _T("") \ - }; \ - return wc; \ -} - -#ifndef _MAX_FNAME - #define _MAX_FNAME _MAX_PATH -#endif // _MAX_FNAME - -#if (_WIN32_WCE < 400) - #define MAKEINTATOM(i) (LPTSTR)((ULONG_PTR)((WORD)(i))) -#endif // (_WIN32_WCE < 400) - -#if (_WIN32_WCE < 410) - #define WHEEL_PAGESCROLL (UINT_MAX) - #define WHEEL_DELTA 120 -#endif // (_WIN32_WCE < 410) - -#ifdef DrawIcon - #undef DrawIcon -#endif - -#ifndef VARCMP_LT - #define VARCMP_LT 0 -#endif -#ifndef VARCMP_EQ - #define VARCMP_EQ 1 -#endif -#ifndef VARCMP_GT - #define VARCMP_GT 2 -#endif -#ifndef VARCMP_NULL - #define VARCMP_NULL 3 -#endif - -#ifndef RDW_ALLCHILDREN - #define RDW_ALLCHILDREN 0 -#endif - -#endif // !(_ATL_VER >= 0x0800) - -#endif // _WIN32_WCE - - -/////////////////////////////////////////////////////////////////////////////// -// Global support for using original VC++ 6.0 headers with WTL - -#if (_MSC_VER < 1300) && !defined(_WIN32_WCE) - #ifndef REG_QWORD - #define REG_QWORD 11 - #endif - - #ifndef BS_PUSHBOX - #define BS_PUSHBOX 0x0000000AL - #endif - - struct __declspec(uuid("000214e6-0000-0000-c000-000000000046")) IShellFolder; - struct __declspec(uuid("000214f9-0000-0000-c000-000000000046")) IShellLinkW; - struct __declspec(uuid("000214ee-0000-0000-c000-000000000046")) IShellLinkA; -#endif // (_MSC_VER < 1300) && !defined(_WIN32_WCE) - -#ifndef _ATL_NO_OLD_HEADERS_WIN64 -#if !defined(_WIN64) && (_ATL_VER < 0x0700) - - #ifndef PSM_INSERTPAGE - #define PSM_INSERTPAGE (WM_USER + 119) - #endif // !PSM_INSERTPAGE - - #ifndef GetClassLongPtr - #define GetClassLongPtrA GetClassLongA - #define GetClassLongPtrW GetClassLongW - #ifdef UNICODE - #define GetClassLongPtr GetClassLongPtrW - #else - #define GetClassLongPtr GetClassLongPtrA - #endif // !UNICODE - #endif // !GetClassLongPtr - - #ifndef GCLP_HICONSM - #define GCLP_HICONSM (-34) - #endif // !GCLP_HICONSM - - #ifndef GetWindowLongPtr - #define GetWindowLongPtrA GetWindowLongA - #define GetWindowLongPtrW GetWindowLongW - #ifdef UNICODE - #define GetWindowLongPtr GetWindowLongPtrW - #else - #define GetWindowLongPtr GetWindowLongPtrA - #endif // !UNICODE - #endif // !GetWindowLongPtr - - #ifndef SetWindowLongPtr - #define SetWindowLongPtrA SetWindowLongA - #define SetWindowLongPtrW SetWindowLongW - #ifdef UNICODE - #define SetWindowLongPtr SetWindowLongPtrW - #else - #define SetWindowLongPtr SetWindowLongPtrA - #endif // !UNICODE - #endif // !SetWindowLongPtr - - #ifndef GWLP_WNDPROC - #define GWLP_WNDPROC (-4) - #endif - #ifndef GWLP_HINSTANCE - #define GWLP_HINSTANCE (-6) - #endif - #ifndef GWLP_HWNDPARENT - #define GWLP_HWNDPARENT (-8) - #endif - #ifndef GWLP_USERDATA - #define GWLP_USERDATA (-21) - #endif - #ifndef GWLP_ID - #define GWLP_ID (-12) - #endif - - #ifndef DWLP_MSGRESULT - #define DWLP_MSGRESULT 0 - #endif - - typedef long LONG_PTR; - typedef unsigned long ULONG_PTR; - typedef ULONG_PTR DWORD_PTR; - - #ifndef HandleToUlong - #define HandleToUlong( h ) ((ULONG)(ULONG_PTR)(h) ) - #endif - #ifndef HandleToLong - #define HandleToLong( h ) ((LONG)(LONG_PTR) (h) ) - #endif - #ifndef LongToHandle - #define LongToHandle( h) ((HANDLE)(LONG_PTR) (h)) - #endif - #ifndef PtrToUlong - #define PtrToUlong( p ) ((ULONG)(ULONG_PTR) (p) ) - #endif - #ifndef PtrToLong - #define PtrToLong( p ) ((LONG)(LONG_PTR) (p) ) - #endif - #ifndef PtrToUint - #define PtrToUint( p ) ((UINT)(UINT_PTR) (p) ) - #endif - #ifndef PtrToInt - #define PtrToInt( p ) ((INT)(INT_PTR) (p) ) - #endif - #ifndef PtrToUshort - #define PtrToUshort( p ) ((unsigned short)(ULONG_PTR)(p) ) - #endif - #ifndef PtrToShort - #define PtrToShort( p ) ((short)(LONG_PTR)(p) ) - #endif - #ifndef IntToPtr - #define IntToPtr( i ) ((VOID *)(INT_PTR)((int)i)) - #endif - #ifndef UIntToPtr - #define UIntToPtr( ui ) ((VOID *)(UINT_PTR)((unsigned int)ui)) - #endif - #ifndef LongToPtr - #define LongToPtr( l ) ((VOID *)(LONG_PTR)((long)l)) - #endif - #ifndef ULongToPtr - #define ULongToPtr( ul ) ((VOID *)(ULONG_PTR)((unsigned long)ul)) - #endif - -#endif // !defined(_WIN64) && (_ATL_VER < 0x0700) -#endif // !_ATL_NO_OLD_HEADERS_WIN64 - - -/////////////////////////////////////////////////////////////////////////////// -// Global support for using original VC++ 7.x headers with WTL - -#if (_MSC_VER >= 1300) && (_MSC_VER < 1400) - - #ifndef BS_PUSHBOX - #define BS_PUSHBOX 0x0000000AL - #endif - - #pragma warning(disable: 4244) // conversion from 'type1' to 'type2', possible loss of data - -#endif // (_MSC_VER >= 1300) && (_MSC_VER < 1400) - - -/////////////////////////////////////////////////////////////////////////////// -// Global support for old SDK headers - -#ifndef BTNS_BUTTON - #define BTNS_BUTTON TBSTYLE_BUTTON -#endif - -#ifndef BTNS_SEP - #define BTNS_SEP TBSTYLE_SEP -#endif - -#ifndef BTNS_CHECK - #define BTNS_CHECK TBSTYLE_CHECK -#endif - -#ifndef BTNS_GROUP - #define BTNS_GROUP TBSTYLE_GROUP -#endif - -#ifndef BTNS_CHECKGROUP - #define BTNS_CHECKGROUP TBSTYLE_CHECKGROUP -#endif - -#if (_WIN32_IE >= 0x0300) - #ifndef BTNS_DROPDOWN - #define BTNS_DROPDOWN TBSTYLE_DROPDOWN - #endif -#endif - -#if (_WIN32_IE >= 0x0400) - #ifndef BTNS_AUTOSIZE - #define BTNS_AUTOSIZE TBSTYLE_AUTOSIZE - #endif - - #ifndef BTNS_NOPREFIX - #define BTNS_NOPREFIX TBSTYLE_NOPREFIX - #endif -#endif - - -/////////////////////////////////////////////////////////////////////////////// -// Global support for SecureHelper functions - -#ifndef _TRUNCATE - #define _TRUNCATE ((size_t)-1) -#endif - -#ifndef _ERRCODE_DEFINED - #define _ERRCODE_DEFINED - typedef int errno_t; -#endif - -#ifndef _SECURECRT_ERRCODE_VALUES_DEFINED - #define _SECURECRT_ERRCODE_VALUES_DEFINED - #define EINVAL 22 - #define STRUNCATE 80 -#endif - -#ifndef _countof - #define _countof(_Array) (sizeof(_Array) / sizeof(_Array[0])) -#endif +// AtlGetStringPtr() /////////////////////////////////////////////////////////////////////////////// @@ -523,124 +131,90 @@ static CWndClassInfo& GetWndClassInfo() \ #endif // Dummy structs for compiling with /CLR -#if (_MSC_VER >= 1300) && defined(_MANAGED) +#ifdef _MANAGED __if_not_exists(_IMAGELIST::_IMAGELIST) { struct _IMAGELIST { }; } __if_not_exists(_TREEITEM::_TREEITEM) { struct _TREEITEM { }; } __if_not_exists(_PSP::_PSP) { struct _PSP { }; } #endif -// Define ATLVERIFY macro for ATL3 -#if (_ATL_VER < 0x0700) - #ifndef ATLVERIFY - #ifdef _DEBUG - #define ATLVERIFY(expr) ATLASSERT(expr) - #else - #define ATLVERIFY(expr) (expr) - #endif // DEBUG - #endif // ATLVERIFY -#endif // (_ATL_VER < 0x0700) - -// Forward declaration for ATL3 and ATL11 fix -#if (((_ATL_VER < 0x0700) && defined(_ATL_DLL)) || (_ATL_VER >= 0x0B00)) && !defined(_WIN32_WCE) - namespace ATL { HRESULT AtlGetCommCtrlVersion(LPDWORD pdwMajor, LPDWORD pdwMinor); }; +// Forward declaration for ATL11 fix +#if (_ATL_VER >= 0x0B00) + namespace ATL { HRESULT AtlGetCommCtrlVersion(LPDWORD pdwMajor, LPDWORD pdwMinor); } #endif #ifndef WM_MOUSEHWHEEL #define WM_MOUSEHWHEEL 0x020E #endif +// Used for stack allocations with ATL::CTempBuffer +#ifndef _WTL_STACK_ALLOC_THRESHOLD + #define _WTL_STACK_ALLOC_THRESHOLD 512 +#endif + namespace WTL { -#if (_ATL_VER >= 0x0700) - DECLARE_TRACE_CATEGORY(atlTraceUI); - #ifdef _DEBUG - __declspec(selectany) ATL::CTraceCategory atlTraceUI(_T("atlTraceUI")); - #endif // _DEBUG -#else // !(_ATL_VER >= 0x0700) - enum wtlTraceFlags - { - atlTraceUI = 0x10000000 - }; -#endif // !(_ATL_VER >= 0x0700) - -// Windows version helper -inline bool AtlIsOldWindows() +DECLARE_TRACE_CATEGORY(atlTraceUI) +#ifdef _DEBUG + __declspec(selectany) ATL::CTraceCategory atlTraceUI(_T("atlTraceUI")); +#endif // _DEBUG + +// Common Controls initialization helper +inline BOOL AtlInitCommonControls(DWORD dwFlags) { -#ifdef _versionhelpers_H_INCLUDED_ - return !::IsWindowsVersionOrGreater(4, 90, 0); -#else // !_versionhelpers_H_INCLUDED_ -OSVERSIONINFO ovi = { sizeof(OSVERSIONINFO) }; - BOOL bRet = ::GetVersionEx(&ovi); - return (!bRet || !((ovi.dwMajorVersion >= 5) || (ovi.dwMajorVersion == 4 && ovi.dwMinorVersion >= 90))); -#endif // _versionhelpers_H_INCLUDED_ + INITCOMMONCONTROLSEX iccx = { sizeof(INITCOMMONCONTROLSEX), dwFlags }; + BOOL bRet = ::InitCommonControlsEx(&iccx); + ATLASSERT(bRet); + return bRet; } // Default GUI font helper - "MS Shell Dlg" stock font inline HFONT AtlGetDefaultGuiFont() { -#ifndef _WIN32_WCE return (HFONT)::GetStockObject(DEFAULT_GUI_FONT); -#else // CE specific - return (HFONT)::GetStockObject(SYSTEM_FONT); -#endif // _WIN32_WCE } // Control font helper - default font for controls not in a dialog // (NOTE: Caller owns the font, and should destroy it when it's no longer needed) inline HFONT AtlCreateControlFont() { -#ifndef _WIN32_WCE - LOGFONT lf = { 0 }; + LOGFONT lf = {}; ATLVERIFY(::SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(LOGFONT), &lf, 0) != FALSE); HFONT hFont = ::CreateFontIndirect(&lf); ATLASSERT(hFont != NULL); return hFont; -#else // CE specific - return (HFONT)::GetStockObject(SYSTEM_FONT); -#endif // _WIN32_WCE } // Bold font helper // (NOTE: Caller owns the font, and should destroy it when it's no longer needed) inline HFONT AtlCreateBoldFont(HFONT hFont = NULL) { - LOGFONT lf = { 0 }; -#ifndef _WIN32_WCE + LOGFONT lf = {}; if(hFont == NULL) ATLVERIFY(::SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(LOGFONT), &lf, 0) != FALSE); else ATLVERIFY(::GetObject(hFont, sizeof(LOGFONT), &lf) == sizeof(LOGFONT)); -#else // CE specific - if(hFont == NULL) - hFont = (HFONT)::GetStockObject(SYSTEM_FONT); - ATLVERIFY(::GetObject(hFont, sizeof(LOGFONT), &lf) == sizeof(LOGFONT)); -#endif // _WIN32_WCE lf.lfWeight = FW_BOLD; HFONT hFontBold = ::CreateFontIndirect(&lf); ATLASSERT(hFontBold != NULL); return hFontBold; } -// Common Controls initialization helper -inline BOOL AtlInitCommonControls(DWORD dwFlags) +// Resource string pointer +inline LPCWSTR AtlGetStringPtr(UINT uID, int* pch = NULL) { - INITCOMMONCONTROLSEX iccx = { sizeof(INITCOMMONCONTROLSEX), dwFlags }; - BOOL bRet = ::InitCommonControlsEx(&iccx); - ATLASSERT(bRet); - return bRet; + LPCWSTR lpstr = NULL; + int nRet = ::LoadStringW(ATL::_AtlBaseModule.GetResourceInstance(), uID, (LPWSTR)&lpstr, 0); + if(pch != NULL) + *pch = nRet; + return lpstr; } /////////////////////////////////////////////////////////////////////////////// // RunTimeHelper - helper functions for Windows version and structure sizes -// Not for Windows CE -#if defined(_WIN32_WCE) && !defined(_WTL_NO_RUNTIME_STRUCT_SIZE) - #define _WTL_NO_RUNTIME_STRUCT_SIZE -#endif - #ifndef _WTL_NO_RUNTIME_STRUCT_SIZE #ifndef _SIZEOF_STRUCT @@ -663,19 +237,18 @@ inline BOOL AtlInitCommonControls(DWORD dwFlags) #define MCHITTESTINFO_V1_SIZE _SIZEOF_STRUCT(MCHITTESTINFO, st) #endif // defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_LONGHORN) && !defined(MCHITTESTINFO_V1_SIZE) -#if !defined(_WIN32_WCE) && (WINVER >= 0x0600) && !defined(NONCLIENTMETRICS_V1_SIZE) +#if (WINVER >= 0x0600) && !defined(NONCLIENTMETRICS_V1_SIZE) #define NONCLIENTMETRICS_V1_SIZE _SIZEOF_STRUCT(NONCLIENTMETRICS, lfMessageFont) -#endif // !defined(_WIN32_WCE) && (WINVER >= 0x0600) && !defined(NONCLIENTMETRICS_V1_SIZE) +#endif // (WINVER >= 0x0600) && !defined(NONCLIENTMETRICS_V1_SIZE) -#if !defined(_WIN32_WCE) && (_WIN32_WINNT >= 0x0501) && !defined(TTTOOLINFO_V2_SIZE) +#ifndef TTTOOLINFO_V2_SIZE #define TTTOOLINFO_V2_SIZE _SIZEOF_STRUCT(TTTOOLINFO, lParam) -#endif // !defined(_WIN32_WCE) && (_WIN32_WINNT >= 0x0501) && !defined(TTTOOLINFO_V2_SIZE) +#endif #endif // !_WTL_NO_RUNTIME_STRUCT_SIZE namespace RunTimeHelper { -#ifndef _WIN32_WCE inline bool IsCommCtrl6() { DWORD dwMajor = 0, dwMinor = 0; @@ -696,30 +269,7 @@ namespace RunTimeHelper inline bool IsThemeAvailable() { - bool bRet = false; - - if(IsCommCtrl6()) - { - HMODULE hThemeDLL = ::LoadLibrary(_T("uxtheme.dll")); - if(hThemeDLL != NULL) - { - typedef BOOL (STDAPICALLTYPE *PFN_IsThemeActive)(); - PFN_IsThemeActive pfnIsThemeActive = (PFN_IsThemeActive)::GetProcAddress(hThemeDLL, "IsThemeActive"); - ATLASSERT(pfnIsThemeActive != NULL); - bRet = (pfnIsThemeActive != NULL) && (pfnIsThemeActive() != FALSE); - if(bRet) - { - typedef BOOL (STDAPICALLTYPE *PFN_IsAppThemed)(); - PFN_IsAppThemed pfnIsAppThemed = (PFN_IsAppThemed)::GetProcAddress(hThemeDLL, "IsAppThemed"); - ATLASSERT(pfnIsAppThemed != NULL); - bRet = (pfnIsAppThemed != NULL) && (pfnIsAppThemed() != FALSE); - } - - ::FreeLibrary(hThemeDLL); - } - } - - return bRet; + return IsCommCtrl6() && (::IsThemeActive() != FALSE) && (::IsAppThemed() != FALSE); } inline bool IsWin7() @@ -729,7 +279,7 @@ namespace RunTimeHelper #else // !_versionhelpers_H_INCLUDED_ OSVERSIONINFO ovi = { sizeof(OSVERSIONINFO) }; BOOL bRet = ::GetVersionEx(&ovi); - return ((bRet != FALSE) && (ovi.dwMajorVersion == 6) && (ovi.dwMinorVersion >= 1)); + return ((bRet != FALSE) && ((ovi.dwMajorVersion > 6) || ((ovi.dwMajorVersion == 6) && (ovi.dwMinorVersion >= 1)))); #endif // _versionhelpers_H_INCLUDED_ } @@ -761,8 +311,6 @@ namespace RunTimeHelper return (iRibbonUI == 1); } -#endif // !_WIN32_WCE - inline UINT SizeOf_REBARBANDINFO() { UINT uSize = sizeof(REBARBANDINFO); @@ -773,7 +321,6 @@ namespace RunTimeHelper return uSize; } -#if (_WIN32_WINNT >= 0x501) inline UINT SizeOf_LVGROUP() { UINT uSize = sizeof(LVGROUP); @@ -793,7 +340,6 @@ namespace RunTimeHelper #endif // !defined(_WTL_NO_RUNTIME_STRUCT_SIZE) && (_WIN32_WINNT >= 0x0600) return uSize; } -#endif // (_WIN32_WINNT >= 0x501) inline UINT SizeOf_MCHITTESTINFO() { @@ -805,7 +351,6 @@ namespace RunTimeHelper return uSize; } -#ifndef _WIN32_WCE inline UINT SizeOf_NONCLIENTMETRICS() { UINT uSize = sizeof(NONCLIENTMETRICS); @@ -819,86 +364,56 @@ namespace RunTimeHelper inline UINT SizeOf_TOOLINFO() { UINT uSize = sizeof(TOOLINFO); -#if !defined(_WTL_NO_RUNTIME_STRUCT_SIZE) && (_WIN32_WINNT >= 0x0501) +#ifndef _WTL_NO_RUNTIME_STRUCT_SIZE if(!IsVista()) uSize = TTTOOLINFO_V2_SIZE; -#endif // !defined(_WTL_NO_RUNTIME_STRUCT_SIZE) && (_WIN32_WINNT >= 0x0501) +#endif return uSize; } -#endif // !_WIN32_WCE -}; +} // namespace RunTimeHelper /////////////////////////////////////////////////////////////////////////////// -// ModuleHelper - helper functions for ATL3 and ATL7 module classes +// ModuleHelper - helper functions for ATL (deprecated) namespace ModuleHelper { inline HINSTANCE GetModuleInstance() { -#if (_ATL_VER >= 0x0700) return ATL::_AtlBaseModule.GetModuleInstance(); -#else // !(_ATL_VER >= 0x0700) - return ATL::_pModule->GetModuleInstance(); -#endif // !(_ATL_VER >= 0x0700) } inline HINSTANCE GetResourceInstance() { -#if (_ATL_VER >= 0x0700) return ATL::_AtlBaseModule.GetResourceInstance(); -#else // !(_ATL_VER >= 0x0700) - return ATL::_pModule->GetResourceInstance(); -#endif // !(_ATL_VER >= 0x0700) } inline void AddCreateWndData(ATL::_AtlCreateWndData* pData, void* pObject) { -#if (_ATL_VER >= 0x0700) ATL::_AtlWinModule.AddCreateWndData(pData, pObject); -#else // !(_ATL_VER >= 0x0700) - ATL::_pModule->AddCreateWndData(pData, pObject); -#endif // !(_ATL_VER >= 0x0700) } inline void* ExtractCreateWndData() { -#if (_ATL_VER >= 0x0700) return ATL::_AtlWinModule.ExtractCreateWndData(); -#else // !(_ATL_VER >= 0x0700) - return ATL::_pModule->ExtractCreateWndData(); -#endif // !(_ATL_VER >= 0x0700) } -}; +} // namespace ModuleHelper /////////////////////////////////////////////////////////////////////////////// -// SecureHelper - helper functions for VS2005 secure CRT +// SecureHelper - WTL10 requires use of secure functions +// these are here only for compatibility with existing projects namespace SecureHelper { inline void strcpyA_x(char* lpstrDest, size_t cchDest, const char* lpstrSrc) { -#if _SECURE_ATL ATL::Checked::strcpy_s(lpstrDest, cchDest, lpstrSrc); -#else - if(cchDest > (size_t)lstrlenA(lpstrSrc)) - ATLVERIFY(lstrcpyA(lpstrDest, lpstrSrc) != NULL); - else - ATLASSERT(FALSE); -#endif } inline void strcpyW_x(wchar_t* lpstrDest, size_t cchDest, const wchar_t* lpstrSrc) { -#if _SECURE_ATL ATL::Checked::wcscpy_s(lpstrDest, cchDest, lpstrSrc); -#else - if(cchDest > (size_t)lstrlenW(lpstrSrc)) - ATLVERIFY(lstrcpyW(lpstrDest, lpstrSrc) != NULL); - else - ATLASSERT(FALSE); -#endif } inline void strcpy_x(LPTSTR lpstrDest, size_t cchDest, LPCTSTR lpstrSrc) @@ -912,56 +427,12 @@ namespace SecureHelper inline errno_t strncpyA_x(char* lpstrDest, size_t cchDest, const char* lpstrSrc, size_t cchCount) { -#if _SECURE_ATL return ATL::Checked::strncpy_s(lpstrDest, cchDest, lpstrSrc, cchCount); -#else - errno_t nRet = 0; - if(lpstrDest == NULL || cchDest == 0 || lpstrSrc == NULL) - { - nRet = EINVAL; - } - else if(cchCount == _TRUNCATE) - { - cchCount = __min(cchDest - 1, size_t(lstrlenA(lpstrSrc))); - nRet = STRUNCATE; - } - else if(cchDest <= cchCount) - { - lpstrDest[0] = 0; - nRet = EINVAL; - } - if(nRet == 0 || nRet == STRUNCATE) - nRet = (lstrcpynA(lpstrDest, lpstrSrc, (int)cchCount + 1) != NULL) ? nRet : EINVAL; - ATLASSERT(nRet == 0 || nRet == STRUNCATE); - return nRet; -#endif } inline errno_t strncpyW_x(wchar_t* lpstrDest, size_t cchDest, const wchar_t* lpstrSrc, size_t cchCount) { -#if _SECURE_ATL return ATL::Checked::wcsncpy_s(lpstrDest, cchDest, lpstrSrc, cchCount); -#else - errno_t nRet = 0; - if(lpstrDest == NULL || cchDest == 0 || lpstrSrc == NULL) - { - nRet = EINVAL; - } - else if(cchCount == _TRUNCATE) - { - cchCount = __min(cchDest - 1, size_t(lstrlenW(lpstrSrc))); - nRet = STRUNCATE; - } - else if(cchDest <= cchCount) - { - lpstrDest[0] = 0; - nRet = EINVAL; - } - if(nRet == 0 || nRet == STRUNCATE) - nRet = (lstrcpynW(lpstrDest, lpstrSrc, (int)cchCount + 1) != NULL) ? nRet : EINVAL; - ATLASSERT(nRet == 0 || nRet == STRUNCATE); - return nRet; -#endif } inline errno_t strncpy_x(LPTSTR lpstrDest, size_t cchDest, LPCTSTR lpstrSrc, size_t cchCount) @@ -975,26 +446,12 @@ namespace SecureHelper inline void strcatA_x(char* lpstrDest, size_t cchDest, const char* lpstrSrc) { -#if _SECURE_ATL ATL::Checked::strcat_s(lpstrDest, cchDest, lpstrSrc); -#else - if(cchDest > (size_t)lstrlenA(lpstrSrc)) - ATLVERIFY(lstrcatA(lpstrDest, lpstrSrc) != NULL); - else - ATLASSERT(FALSE); -#endif } inline void strcatW_x(wchar_t* lpstrDest, size_t cchDest, const wchar_t* lpstrSrc) { -#if _SECURE_ATL ATL::Checked::wcscat_s(lpstrDest, cchDest, lpstrSrc); -#else - if(cchDest > (size_t)lstrlenW(lpstrSrc)) - ATLVERIFY(lstrcatW(lpstrDest, lpstrSrc) != NULL); - else - ATLASSERT(FALSE); -#endif } inline void strcat_x(LPTSTR lpstrDest, size_t cchDest, LPCTSTR lpstrSrc) @@ -1008,49 +465,22 @@ namespace SecureHelper inline void memcpy_x(void* pDest, size_t cbDest, const void* pSrc, size_t cbSrc) { -#if _SECURE_ATL ATL::Checked::memcpy_s(pDest, cbDest, pSrc, cbSrc); -#else - if(cbDest >= cbSrc) - memcpy(pDest, pSrc, cbSrc); - else - ATLASSERT(FALSE); -#endif } inline void memmove_x(void* pDest, size_t cbDest, const void* pSrc, size_t cbSrc) { -#if _SECURE_ATL ATL::Checked::memmove_s(pDest, cbDest, pSrc, cbSrc); -#else - if(cbDest >= cbSrc) - memmove(pDest, pSrc, cbSrc); - else - ATLASSERT(FALSE); -#endif } inline int vsprintf_x(LPTSTR lpstrBuff, size_t cchBuff, LPCTSTR lpstrFormat, va_list args) { -#if _SECURE_ATL && !defined(_ATL_MIN_CRT) && !defined(_WIN32_WCE) return _vstprintf_s(lpstrBuff, cchBuff, lpstrFormat, args); -#else - cchBuff; // Avoid unused argument warning - #pragma warning(push) - #pragma warning(disable: 4996) - return _vstprintf(lpstrBuff, lpstrFormat, args); - #pragma warning(pop) -#endif } inline int wvsprintf_x(LPTSTR lpstrBuff, size_t cchBuff, LPCTSTR lpstrFormat, va_list args) { -#if _SECURE_ATL && !defined(_ATL_MIN_CRT) && !defined(_WIN32_WCE) return _vstprintf_s(lpstrBuff, cchBuff, lpstrFormat, args); -#else - cchBuff; // Avoid unused argument warning - return ::wvsprintf(lpstrBuff, lpstrFormat, args); -#endif } inline int sprintf_x(LPTSTR lpstrBuff, size_t cchBuff, LPCTSTR lpstrFormat, ...) @@ -1070,92 +500,40 @@ namespace SecureHelper va_end(args); return nRes; } -}; // namespace SecureHelper +} // namespace SecureHelper /////////////////////////////////////////////////////////////////////////////// -// MinCrtHelper - helper functions for using _ATL_MIN_CRT +// MinCrtHelper - WTL10 doesn't support _ATL_MIN_CRT, +// these are here only for compatibility with existing projects namespace MinCrtHelper { inline int _isspace(TCHAR ch) { -#ifndef _ATL_MIN_CRT return _istspace(ch); -#else // _ATL_MIN_CRT - WORD type = 0; - ::GetStringTypeEx(::GetThreadLocale(), CT_CTYPE1, &ch, 1, &type); - return (type & C1_SPACE) == C1_SPACE; -#endif // _ATL_MIN_CRT } inline int _isdigit(TCHAR ch) { -#ifndef _ATL_MIN_CRT return _istdigit(ch); -#else // _ATL_MIN_CRT - WORD type = 0; - ::GetStringTypeEx(::GetThreadLocale(), CT_CTYPE1, &ch, 1, &type); - return (type & C1_DIGIT) == C1_DIGIT; -#endif // _ATL_MIN_CRT } inline int _atoi(LPCTSTR str) { -#ifndef _ATL_MIN_CRT return _ttoi(str); -#else // _ATL_MIN_CRT - while(_isspace(*str) != 0) - ++str; - - TCHAR ch = *str++; - TCHAR sign = ch; // save sign indication - if(ch == _T('-') || ch == _T('+')) - ch = *str++; // skip sign - - int total = 0; - while(_isdigit(ch) != 0) - { - total = 10 * total + (ch - '0'); // accumulate digit - ch = *str++; // get next char - } - - return (sign == '-') ? -total : total; // return result, negated if necessary -#endif // _ATL_MIN_CRT } inline LPCTSTR _strrchr(LPCTSTR str, TCHAR ch) { -#ifndef _ATL_MIN_CRT return _tcsrchr(str, ch); -#else // _ATL_MIN_CRT - LPCTSTR lpsz = NULL; - while(*str != 0) - { - if(*str == ch) - lpsz = str; - str = ::CharNext(str); - } - return lpsz; -#endif // _ATL_MIN_CRT } inline LPTSTR _strrchr(LPTSTR str, TCHAR ch) { -#ifndef _ATL_MIN_CRT return _tcsrchr(str, ch); -#else // _ATL_MIN_CRT - LPTSTR lpsz = NULL; - while(*str != 0) - { - if(*str == ch) - lpsz = str; - str = ::CharNext(str); - } - return lpsz; -#endif // _ATL_MIN_CRT } -}; // namespace MinCrtHelper +} // namespace MinCrtHelper /////////////////////////////////////////////////////////////////////////////// @@ -1173,21 +551,13 @@ namespace GenericWndClass inline ATOM Register() { -#ifndef _WIN32_WCE WNDCLASSEX wc = { sizeof(WNDCLASSEX) }; -#else - WNDCLASS wc = { 0 }; -#endif wc.lpfnWndProc = ::DefWindowProc; wc.hInstance = ModuleHelper::GetModuleInstance(); wc.hCursor = ::LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); wc.lpszClassName = GetName(); -#ifndef _WIN32_WCE ATOM atom = ::RegisterClassEx(&wc); -#else - ATOM atom = ::RegisterClass(&wc); -#endif ATLASSERT(atom != 0); return atom; } @@ -1196,13 +566,13 @@ namespace GenericWndClass { return ::UnregisterClass(GetName(), ModuleHelper::GetModuleInstance()); } -}; // namespace GenericWndClass +} // namespace GenericWndClass /////////////////////////////////////////////////////////////////////////////// // CMessageFilter - Interface for message filter support -class CMessageFilter +class ATL_NO_VTABLE CMessageFilter { public: virtual BOOL PreTranslateMessage(MSG* pMsg) = 0; @@ -1212,18 +582,12 @@ public: /////////////////////////////////////////////////////////////////////////////// // CIdleHandler - Interface for idle processing -class CIdleHandler +class ATL_NO_VTABLE CIdleHandler { public: virtual BOOL OnIdle() = 0; }; -#ifndef _ATL_NO_OLD_NAMES - // for compatilibility with old names only - typedef CIdleHandler CUpdateUIObject; - #define DoUpdate OnIdle -#endif // !_ATL_NO_OLD_NAMES - /////////////////////////////////////////////////////////////////////////////// // CMessageLoop - message loop implementation @@ -1235,6 +599,14 @@ public: ATL::CSimpleArray m_aIdleHandler; MSG m_msg; + CMessageLoop() + { + memset(&m_msg, 0, sizeof(m_msg)); + } + + virtual ~CMessageLoop() + { } + // Message filter operations BOOL AddMessageFilter(CMessageFilter* pMessageFilter) { @@ -1257,27 +629,12 @@ public: return m_aIdleHandler.Remove(pIdleHandler); } -#ifndef _ATL_NO_OLD_NAMES - // for compatilibility with old names only - BOOL AddUpdateUI(CIdleHandler* pIdleHandler) - { - ATLTRACE2(atlTraceUI, 0, _T("CUpdateUIObject and AddUpdateUI are deprecated. Please change your code to use CIdleHandler and OnIdle\n")); - return AddIdleHandler(pIdleHandler); - } - - BOOL RemoveUpdateUI(CIdleHandler* pIdleHandler) - { - ATLTRACE2(atlTraceUI, 0, _T("CUpdateUIObject and RemoveUpdateUI are deprecated. Please change your code to use CIdleHandler and OnIdle\n")); - return RemoveIdleHandler(pIdleHandler); - } -#endif // !_ATL_NO_OLD_NAMES - // message loop int Run() { BOOL bDoIdle = TRUE; int nIdleCount = 0; - BOOL bRet; + BOOL bRet = FALSE; for(;;) { @@ -1316,23 +673,6 @@ public: return (int)m_msg.wParam; } - static BOOL IsIdleMessage(MSG* pMsg) - { - // These messages should NOT cause idle processing - switch(pMsg->message) - { - case WM_MOUSEMOVE: -#ifndef _WIN32_WCE - case WM_NCMOUSEMOVE: -#endif // !_WIN32_WCE - case WM_PAINT: - case 0x0118: // WM_SYSTIMER (caret blink) - return FALSE; - } - - return TRUE; - } - // Overrideables // Override to change message filtering virtual BOOL PreTranslateMessage(MSG* pMsg) @@ -1341,7 +681,7 @@ public: for(int i = m_aMsgFilter.GetSize() - 1; i >= 0; i--) { CMessageFilter* pMessageFilter = m_aMsgFilter[i]; - if(pMessageFilter != NULL && pMessageFilter->PreTranslateMessage(pMsg)) + if((pMessageFilter != NULL) && pMessageFilter->PreTranslateMessage(pMsg)) return TRUE; } return FALSE; // not translated @@ -1358,40 +698,45 @@ public: } return FALSE; // don't continue } + + // override to change non-idle messages + virtual BOOL IsIdleMessage(MSG* pMsg) const + { + // These messages should NOT cause idle processing + switch(pMsg->message) + { + case WM_MOUSEMOVE: + case WM_NCMOUSEMOVE: + case WM_PAINT: + case 0x0118: // WM_SYSTIMER (caret blink) + return FALSE; + } + + return TRUE; + } }; /////////////////////////////////////////////////////////////////////////////// // CStaticDataInitCriticalSectionLock and CWindowCreateCriticalSectionLock -// internal classes to manage critical sections for both ATL3 and ATL7 +// internal classes to manage critical sections for ATL (deprecated) class CStaticDataInitCriticalSectionLock { public: -#if (_ATL_VER >= 0x0700) ATL::CComCritSecLock m_cslock; CStaticDataInitCriticalSectionLock() : m_cslock(ATL::_pAtlModule->m_csStaticDataInitAndTypeInfo, false) { } -#endif // (_ATL_VER >= 0x0700) HRESULT Lock() { -#if (_ATL_VER >= 0x0700) return m_cslock.Lock(); -#else // !(_ATL_VER >= 0x0700) - ::EnterCriticalSection(&ATL::_pModule->m_csStaticDataInit); - return S_OK; -#endif // !(_ATL_VER >= 0x0700) } void Unlock() { -#if (_ATL_VER >= 0x0700) m_cslock.Unlock(); -#else // !(_ATL_VER >= 0x0700) - ::LeaveCriticalSection(&ATL::_pModule->m_csStaticDataInit); -#endif // !(_ATL_VER >= 0x0700) } }; @@ -1399,118 +744,32 @@ public: class CWindowCreateCriticalSectionLock { public: -#if (_ATL_VER >= 0x0700) ATL::CComCritSecLock m_cslock; CWindowCreateCriticalSectionLock() : m_cslock(ATL::_AtlWinModule.m_csWindowCreate, false) { } -#endif // (_ATL_VER >= 0x0700) HRESULT Lock() { -#if (_ATL_VER >= 0x0700) return m_cslock.Lock(); -#else // !(_ATL_VER >= 0x0700) - ::EnterCriticalSection(&ATL::_pModule->m_csWindowCreate); - return S_OK; -#endif // !(_ATL_VER >= 0x0700) } void Unlock() { -#if (_ATL_VER >= 0x0700) m_cslock.Unlock(); -#else // !(_ATL_VER >= 0x0700) - ::LeaveCriticalSection(&ATL::_pModule->m_csWindowCreate); -#endif // !(_ATL_VER >= 0x0700) } }; /////////////////////////////////////////////////////////////////////////////// -// CTempBuffer - helper class for stack allocations for ATL3 - -#ifndef _WTL_STACK_ALLOC_THRESHOLD - #define _WTL_STACK_ALLOC_THRESHOLD 512 -#endif - -#if (_ATL_VER >= 0x0700) - -using ATL::CTempBuffer; - -#else // !(_ATL_VER >= 0x0700) +// CAppModule - module class for an application -#ifndef SIZE_MAX - #ifdef _WIN64 - #define SIZE_MAX _UI64_MAX - #else - #define SIZE_MAX UINT_MAX - #endif +#if (_MSC_VER == 1400) // VS2005 + #pragma warning(push) + #pragma warning(disable : 4244) + #pragma warning(disable : 4312) #endif -#pragma warning(push) -#pragma warning(disable: 4284) // warning for operator -> - -template -class CTempBuffer -{ -public: - CTempBuffer() : m_p(NULL) - { - } - - CTempBuffer(size_t nElements) : m_p(NULL) - { - Allocate(nElements); - } - - ~CTempBuffer() - { - if(m_p != reinterpret_cast(m_abFixedBuffer)) - free(m_p); - } - - operator T*() const - { - return m_p; - } - - T* operator ->() const - { - ATLASSERT(m_p != NULL); - return m_p; - } - - T* Allocate(size_t nElements) - { - ATLASSERT(nElements <= (SIZE_MAX / sizeof(T))); - return AllocateBytes(nElements * sizeof(T)); - } - - T* AllocateBytes(size_t nBytes) - { - ATLASSERT(m_p == NULL); - if(nBytes > t_nFixedBytes) - m_p = static_cast(malloc(nBytes)); - else - m_p = reinterpret_cast(m_abFixedBuffer); - - return m_p; - } - -private: - T* m_p; - BYTE m_abFixedBuffer[t_nFixedBytes]; -}; - -#pragma warning(pop) - -#endif // !(_ATL_VER >= 0x0700) - - -/////////////////////////////////////////////////////////////////////////////// -// CAppModule - module class for an application - class CAppModule : public ATL::CComModule { public: @@ -1518,6 +777,9 @@ public: ATL::CSimpleMap* m_pMsgLoopMap; ATL::CSimpleArray* m_pSettingChangeNotify; + CAppModule() : m_dwMainThreadID(0), m_pMsgLoopMap(NULL), m_pSettingChangeNotify(NULL) + { } + // Overrides of CComModule::Init and Term HRESULT Init(ATL::_ATL_OBJMAP_ENTRY* pObjMap, HINSTANCE hInstance, const GUID* pLibID = NULL) { @@ -1618,7 +880,7 @@ public: } BOOL bRet = (m_pSettingChangeNotify != NULL); - if(bRet && m_pSettingChangeNotify->GetSize() == 0) + if(bRet && (m_pSettingChangeNotify->GetSize() == 0)) { // init everything _ATL_EMPTY_DLGTEMPLATE templ; @@ -1626,12 +888,7 @@ public: ATLASSERT(::IsWindow(hNtfWnd)); if(::IsWindow(hNtfWnd)) { -// need conditional code because types don't match in winuser.h -#ifdef _WIN64 ::SetWindowLongPtr(hNtfWnd, GWLP_USERDATA, (LONG_PTR)this); -#else - ::SetWindowLongPtr(hNtfWnd, GWLP_USERDATA, PtrToLong(this)); -#endif bRet = m_pSettingChangeNotify->Add(hNtfWnd); } else @@ -1655,7 +912,7 @@ public: return; } - if(m_pSettingChangeNotify != NULL && m_pSettingChangeNotify->GetSize() > 0) + if((m_pSettingChangeNotify != NULL) && (m_pSettingChangeNotify->GetSize() > 0)) ::DestroyWindow((*m_pSettingChangeNotify)[0]); delete m_pSettingChangeNotify; m_pSettingChangeNotify = NULL; @@ -1713,40 +970,28 @@ public: WORD wMenu, wClass, wTitle; }; -#ifdef _WIN64 static INT_PTR CALLBACK _SettingChangeDlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -#else - static BOOL CALLBACK _SettingChangeDlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -#endif { if(uMsg == WM_SETTINGCHANGE) { -// need conditional code because types don't match in winuser.h -#ifdef _WIN64 CAppModule* pModule = (CAppModule*)::GetWindowLongPtr(hWnd, GWLP_USERDATA); -#else - CAppModule* pModule = (CAppModule*)LongToPtr(::GetWindowLongPtr(hWnd, GWLP_USERDATA)); -#endif ATLASSERT(pModule != NULL); ATLASSERT(pModule->m_pSettingChangeNotify != NULL); const UINT uTimeout = 1500; // ms for(int i = 1; i < pModule->m_pSettingChangeNotify->GetSize(); i++) - { -#if !defined(_WIN32_WCE) ::SendMessageTimeout((*pModule->m_pSettingChangeNotify)[i], uMsg, wParam, lParam, SMTO_ABORTIFHUNG, uTimeout, NULL); -#elif(_WIN32_WCE >= 400) // CE specific - ::SendMessageTimeout((*pModule->m_pSettingChangeNotify)[i], uMsg, wParam, lParam, SMTO_NORMAL, uTimeout, NULL); -#else // _WIN32_WCE < 400 specific - uTimeout; - ::SendMessage((*pModule->m_pSettingChangeNotify)[i], uMsg, wParam, lParam); -#endif - } + return TRUE; } + return FALSE; } }; +#if (_MSC_VER == 1400) // VS2005 + #pragma warning(pop) +#endif + /////////////////////////////////////////////////////////////////////////////// // CServerAppModule - module class for a COM server application @@ -1759,6 +1004,9 @@ public: DWORD m_dwTimeOut; DWORD m_dwPause; + CServerAppModule() : m_hEventShutdown(NULL), m_bActivity(false), m_dwTimeOut(5000), m_dwPause(1000) + { } + // Override of CAppModule::Init HRESULT Init(ATL::_ATL_OBJMAP_ENTRY* pObjMap, HINSTANCE hInstance, const GUID* pLibID = NULL) { @@ -1769,17 +1017,13 @@ public: void Term() { - if(m_hEventShutdown != NULL && ::CloseHandle(m_hEventShutdown)) + if((m_hEventShutdown != NULL) && ::CloseHandle(m_hEventShutdown)) m_hEventShutdown = NULL; CAppModule::Term(); } // COM Server methods -#if (_MSC_VER >= 1300) LONG Unlock() throw() -#else - LONG Unlock() -#endif { LONG lRet = CComModule::Unlock(); if(lRet == 0) @@ -1803,11 +1047,11 @@ public: } while(dwWait == WAIT_OBJECT_0); // timed out - if(!m_bActivity && m_nLockCnt == 0) // if no activity let's really bail + if(!m_bActivity && (m_nLockCnt == 0)) // if no activity let's really bail { -#if ((_WIN32_WINNT >= 0x0400 ) || defined(_WIN32_DCOM)) && defined(_ATL_FREE_THREADED) && !defined(_WIN32_WCE) +#if defined(_WIN32_DCOM) && defined(_ATL_FREE_THREADED) ::CoSuspendClassObjects(); - if(!m_bActivity && m_nLockCnt == 0) + if(!m_bActivity && (m_nLockCnt == 0)) #endif break; } @@ -1825,7 +1069,7 @@ public: if(m_hEventShutdown == NULL) return false; DWORD dwThreadID = 0; -#if !defined(_ATL_MIN_CRT) && defined(_MT) && !defined(_WIN32_WCE) +#ifdef _MT HANDLE hThread = (HANDLE)_beginthreadex(NULL, 0, (UINT (WINAPI*)(void*))MonitorProc, this, 0, (UINT*)&dwThreadID); #else HANDLE hThread = ::CreateThread(NULL, 0, MonitorProc, this, 0, &dwThreadID); @@ -1842,322 +1086,35 @@ public: p->MonitorShutdown(); return 0; } - -#if (_ATL_VER < 0x0700) - // search for an occurence of string p2 in string p1 - static LPCTSTR FindOneOf(LPCTSTR p1, LPCTSTR p2) - { - while(p1 != NULL && *p1 != NULL) - { - LPCTSTR p = p2; - while(p != NULL && *p != NULL) - { - if(*p1 == *p) - return ::CharNext(p1); - p = ::CharNext(p); - } - p1 = ::CharNext(p1); - } - return NULL; - } -#endif // (_ATL_VER < 0x0700) }; /////////////////////////////////////////////////////////////////////////////// -// CRegKeyEx - adds type-specific methods to ATL3 CRegKey - -#if (_ATL_VER < 0x0700) - -class CRegKeyEx : public ATL::CRegKey -{ -public: -// Constructors and operators - CRegKeyEx(HKEY hKey = NULL) - { - m_hKey = hKey; - } - - CRegKeyEx(CRegKeyEx& key) - { - Attach(key.Detach()); - } - - CRegKeyEx& operator =(CRegKeyEx& key) - { - Close(); - Attach(key.Detach()); - return *this; - } - -// Methods - LONG SetValue(LPCTSTR pszValueName, DWORD dwType, const void* pValue, ULONG nBytes) - { - ATLASSERT(m_hKey != NULL); - return ::RegSetValueEx(m_hKey, pszValueName, NULL, dwType, static_cast(pValue), nBytes); - } - - LONG SetGUIDValue(LPCTSTR pszValueName, REFGUID guidValue) - { - ATLASSERT(m_hKey != NULL); - - OLECHAR szGUID[64] = { 0 }; - ::StringFromGUID2(guidValue, szGUID, 64); - - USES_CONVERSION; - LPCTSTR lpstr = OLE2CT(szGUID); -#ifndef _UNICODE - if(lpstr == NULL) - return E_OUTOFMEMORY; -#endif - return SetStringValue(pszValueName, lpstr); - } - - LONG SetBinaryValue(LPCTSTR pszValueName, const void* pValue, ULONG nBytes) - { - ATLASSERT(m_hKey != NULL); - return ::RegSetValueEx(m_hKey, pszValueName, NULL, REG_BINARY, reinterpret_cast(pValue), nBytes); - } - - LONG SetDWORDValue(LPCTSTR pszValueName, DWORD dwValue) - { - ATLASSERT(m_hKey != NULL); - return ::RegSetValueEx(m_hKey, pszValueName, NULL, REG_DWORD, reinterpret_cast(&dwValue), sizeof(DWORD)); - } - -#ifndef _WIN32_WCE - LONG SetQWORDValue(LPCTSTR pszValueName, ULONGLONG qwValue) - { - ATLASSERT(m_hKey != NULL); - return ::RegSetValueEx(m_hKey, pszValueName, NULL, REG_QWORD, reinterpret_cast(&qwValue), sizeof(ULONGLONG)); - } -#endif - - LONG SetStringValue(LPCTSTR pszValueName, LPCTSTR pszValue, DWORD dwType = REG_SZ) - { - ATLASSERT(m_hKey != NULL); - if(pszValue == NULL) - { - ATLASSERT(FALSE); - return ERROR_INVALID_DATA; - } - ATLASSERT((dwType == REG_SZ) || (dwType == REG_EXPAND_SZ)); - - return ::RegSetValueEx(m_hKey, pszValueName, NULL, dwType, reinterpret_cast(pszValue), (lstrlen(pszValue) + 1) * sizeof(TCHAR)); - } - - LONG SetMultiStringValue(LPCTSTR pszValueName, LPCTSTR pszValue) - { - ATLASSERT(m_hKey != NULL); - if(pszValue == NULL) - { - ATLASSERT(FALSE); - return ERROR_INVALID_DATA; - } - - ULONG nBytes = 0; - ULONG nLength = 0; - LPCTSTR pszTemp = pszValue; - do - { - nLength = lstrlen(pszTemp) + 1; - pszTemp += nLength; - nBytes += nLength * sizeof(TCHAR); - } while (nLength != 1); - - return ::RegSetValueEx(m_hKey, pszValueName, NULL, REG_MULTI_SZ, reinterpret_cast(pszValue), nBytes); - } - - LONG QueryValue(LPCTSTR pszValueName, DWORD* pdwType, void* pData, ULONG* pnBytes) - { - ATLASSERT(m_hKey != NULL); - return ::RegQueryValueEx(m_hKey, pszValueName, NULL, pdwType, static_cast(pData), pnBytes); - } - - LONG QueryGUIDValue(LPCTSTR pszValueName, GUID& guidValue) - { - ATLASSERT(m_hKey != NULL); - - guidValue = GUID_NULL; - - TCHAR szGUID[64] = { 0 }; - ULONG nCount = 64; - LONG lRes = QueryStringValue(pszValueName, szGUID, &nCount); - - if (lRes != ERROR_SUCCESS) - return lRes; - - if(szGUID[0] != _T('{')) - return ERROR_INVALID_DATA; - - USES_CONVERSION; - LPOLESTR lpstr = T2OLE(szGUID); -#ifndef _UNICODE - if(lpstr == NULL) - return E_OUTOFMEMORY; -#endif - - HRESULT hr = ::CLSIDFromString(lpstr, &guidValue); - if (FAILED(hr)) - return ERROR_INVALID_DATA; - - return ERROR_SUCCESS; - } - - LONG QueryBinaryValue(LPCTSTR pszValueName, void* pValue, ULONG* pnBytes) - { - ATLASSERT(pnBytes != NULL); - ATLASSERT(m_hKey != NULL); - - DWORD dwType = 0; - LONG lRes = ::RegQueryValueEx(m_hKey, pszValueName, NULL, &dwType, reinterpret_cast(pValue), pnBytes); - if (lRes != ERROR_SUCCESS) - return lRes; - if (dwType != REG_BINARY) - return ERROR_INVALID_DATA; - - return ERROR_SUCCESS; - } - - LONG QueryDWORDValue(LPCTSTR pszValueName, DWORD& dwValue) - { - ATLASSERT(m_hKey != NULL); - - ULONG nBytes = sizeof(DWORD); - DWORD dwType = 0; - LONG lRes = ::RegQueryValueEx(m_hKey, pszValueName, NULL, &dwType, reinterpret_cast(&dwValue), &nBytes); - if (lRes != ERROR_SUCCESS) - return lRes; - if (dwType != REG_DWORD) - return ERROR_INVALID_DATA; - - return ERROR_SUCCESS; - } - -#ifndef _WIN32_WCE - LONG QueryQWORDValue(LPCTSTR pszValueName, ULONGLONG& qwValue) - { - ATLASSERT(m_hKey != NULL); - - ULONG nBytes = sizeof(ULONGLONG); - DWORD dwType = 0; - LONG lRes = ::RegQueryValueEx(m_hKey, pszValueName, NULL, &dwType, reinterpret_cast(&qwValue), &nBytes); - if (lRes != ERROR_SUCCESS) - return lRes; - if (dwType != REG_QWORD) - return ERROR_INVALID_DATA; - - return ERROR_SUCCESS; - } -#endif - - LONG QueryStringValue(LPCTSTR pszValueName, LPTSTR pszValue, ULONG* pnChars) - { - ATLASSERT(m_hKey != NULL); - ATLASSERT(pnChars != NULL); - - ULONG nBytes = (*pnChars) * sizeof(TCHAR); - DWORD dwType = 0; - *pnChars = 0; - LONG lRes = ::RegQueryValueEx(m_hKey, pszValueName, NULL, &dwType, reinterpret_cast(pszValue), &nBytes); - - if (lRes != ERROR_SUCCESS) - { - return lRes; - } - - if(dwType != REG_SZ && dwType != REG_EXPAND_SZ) - { - return ERROR_INVALID_DATA; - } - - if (pszValue != NULL) - { - if(nBytes != 0) - { - if ((nBytes % sizeof(TCHAR) != 0) || (pszValue[nBytes / sizeof(TCHAR) -1] != 0)) - return ERROR_INVALID_DATA; - } - else - { - pszValue[0] = _T('\0'); - } - } - - *pnChars = nBytes / sizeof(TCHAR); - - return ERROR_SUCCESS; - } - - LONG QueryMultiStringValue(LPCTSTR pszValueName, LPTSTR pszValue, ULONG* pnChars) - { - ATLASSERT(m_hKey != NULL); - ATLASSERT(pnChars != NULL); - - if (pszValue != NULL && *pnChars < 2) - return ERROR_INSUFFICIENT_BUFFER; - - ULONG nBytes = (*pnChars) * sizeof(TCHAR); - DWORD dwType = 0; - *pnChars = 0; - LONG lRes = ::RegQueryValueEx(m_hKey, pszValueName, NULL, &dwType, reinterpret_cast(pszValue), &nBytes); - if (lRes != ERROR_SUCCESS) - return lRes; - if (dwType != REG_MULTI_SZ) - return ERROR_INVALID_DATA; - if (pszValue != NULL && (nBytes % sizeof(TCHAR) != 0 || nBytes / sizeof(TCHAR) < 1 || pszValue[nBytes / sizeof(TCHAR) - 1] != 0 || ((nBytes / sizeof(TCHAR)) > 1 && pszValue[nBytes / sizeof(TCHAR) - 2] != 0))) - return ERROR_INVALID_DATA; - - *pnChars = nBytes / sizeof(TCHAR); - - return ERROR_SUCCESS; - } -}; - -#else // !(_ATL_VER < 0x0700) +// CRegKeyEx - not used any more, here only for compatibility with old projects typedef ATL::CRegKey CRegKeyEx; -#endif // !(_ATL_VER < 0x0700) +} // namespace WTL /////////////////////////////////////////////////////////////////////////////// // CString forward reference (enables CString use in atluser.h and atlgdi.h) -#if defined(_WTL_FORWARD_DECLARE_CSTRING) && !defined(_WTL_USE_CSTRING) - #define _WTL_USE_CSTRING -#endif // defined(_WTL_FORWARD_DECLARE_CSTRING) && !defined(_WTL_USE_CSTRING) - -#ifdef _WTL_USE_CSTRING - class CString; // forward declaration (include atlmisc.h for the whole class) -#endif // _WTL_USE_CSTRING +#if (defined(_WTL_USE_CSTRING) || defined(_WTL_FORWARD_DECLARE_CSTRING)) && !defined(__ATLSTR_H__) + #include +#endif // CString namespace -#ifndef _CSTRING_NS - #ifdef __ATLSTR_H__ - #define _CSTRING_NS ATL - #else - #define _CSTRING_NS WTL - #endif -#endif // _CSTRING_NS +#define _CSTRING_NS ATL // Type classes namespace -#ifndef _WTYPES_NS - #ifdef __ATLTYPES_H__ - #define _WTYPES_NS - #else - #define _WTYPES_NS WTL - #endif -#endif // _WTYPES_NS - -}; // namespace WTL +#define _WTYPES_NS /////////////////////////////////////////////////////////////////////////////// -// General DLL version helpers -// (ATL3: excluded from atlbase.h if _ATL_DLL is defined; ATL11: removed) +// General DLL version helpers (removed in ATL11) -#if (((_ATL_VER < 0x0700) && defined(_ATL_DLL)) || (_ATL_VER >= 0x0B00)) && !defined(_WIN32_WCE) +#if (_ATL_VER >= 0x0B00) namespace ATL { @@ -2192,8 +1149,8 @@ inline HRESULT AtlGetDllVersion(LPCTSTR lpstrDllName, DLLVERSIONINFO* pDllVersio // IE 4.0 maj=4 min=71 inline HRESULT AtlGetCommCtrlVersion(LPDWORD pdwMajor, LPDWORD pdwMinor) { - ATLASSERT(pdwMajor != NULL && pdwMinor != NULL); - if(pdwMajor == NULL || pdwMinor == NULL) + ATLASSERT((pdwMajor != NULL) && (pdwMinor != NULL)); + if((pdwMajor == NULL) || (pdwMinor == NULL)) return E_INVALIDARG; DLLVERSIONINFO dvi; @@ -2225,8 +1182,8 @@ inline HRESULT AtlGetCommCtrlVersion(LPDWORD pdwMajor, LPDWORD pdwMinor) // IE 4.01 with Web Integrated Desktop maj=4 min=72 inline HRESULT AtlGetShellVersion(LPDWORD pdwMajor, LPDWORD pdwMinor) { - ATLASSERT(pdwMajor != NULL && pdwMinor != NULL); - if(pdwMajor == NULL || pdwMinor == NULL) + ATLASSERT((pdwMajor != NULL) && (pdwMinor != NULL)); + if((pdwMajor == NULL) || (pdwMinor == NULL)) return E_INVALIDARG; DLLVERSIONINFO dvi; @@ -2251,9 +1208,9 @@ inline HRESULT AtlGetShellVersion(LPDWORD pdwMajor, LPDWORD pdwMinor) return hRet; } -}; // namespace ATL +} // namespace ATL -#endif // (_ATL_VER < 0x0700) && defined(_ATL_DLL) && !defined(_WIN32_WCE) +#endif // (_ATL_VER >= 0x0B00) // These are always included diff --git a/WrlSDK/SampleCode/PluginWinExe/WTL/atlcrack.h b/WrlSDK/SampleCode/PluginWinExe/WTL/atlcrack.h index e824966f8bbe81babd1407ec17697b758a0013ea..da6a8963c80434f99476c6e2c0bb685b70f69e32 100644 --- a/WrlSDK/SampleCode/PluginWinExe/WTL/atlcrack.h +++ b/WrlSDK/SampleCode/PluginWinExe/WTL/atlcrack.h @@ -1,4 +1,4 @@ -// Windows Template Library - WTL version 9.10 +// Windows Template Library - WTL version 10.0 // Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. // // This file is a part of the Windows Template Library. @@ -20,9 +20,8 @@ // Message map macro for cracked handlers // Note about message maps with cracked handlers: -// For ATL 3.0, a message map using cracked handlers MUST use BEGIN_MSG_MAP_EX. -// For ATL 7.0 or higher, you can use BEGIN_MSG_MAP for CWindowImpl/CDialogImpl derived classes, -// but must use BEGIN_MSG_MAP_EX for classes that don't derive from CWindowImpl/CDialogImpl. +// You can use BEGIN_MSG_MAP for classes that derive from CWindowImpl/CDialogImpl, +// but must use BEGIN_MSG_MAP_EX for classes that don't. #define BEGIN_MSG_MAP_EX(theClass) \ public: \ @@ -64,9 +63,9 @@ public: \ #define MSG_WM_CREATE(func) \ if (uMsg == WM_CREATE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((LPCREATESTRUCT)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -74,9 +73,9 @@ public: \ #define MSG_WM_INITDIALOG(func) \ if (uMsg == WM_INITDIALOG) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((HWND)wParam, lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -84,9 +83,9 @@ public: \ #define MSG_WM_COPYDATA(func) \ if (uMsg == WM_COPYDATA) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((HWND)wParam, (PCOPYDATASTRUCT)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -94,10 +93,10 @@ public: \ #define MSG_WM_DESTROY(func) \ if (uMsg == WM_DESTROY) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func(); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -105,10 +104,10 @@ public: \ #define MSG_WM_MOVE(func) \ if (uMsg == WM_MOVE) \ { \ - SetMsgHandled(TRUE); \ - func(_WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + this->SetMsgHandled(TRUE); \ + func(::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -116,10 +115,10 @@ public: \ #define MSG_WM_SIZE(func) \ if (uMsg == WM_SIZE) \ { \ - SetMsgHandled(TRUE); \ - func((UINT)wParam, _WTYPES_NS::CSize(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CSize(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -127,10 +126,10 @@ public: \ #define MSG_WM_ACTIVATE(func) \ if (uMsg == WM_ACTIVATE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)LOWORD(wParam), (BOOL)HIWORD(wParam), (HWND)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -138,10 +137,10 @@ public: \ #define MSG_WM_SETFOCUS(func) \ if (uMsg == WM_SETFOCUS) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((HWND)wParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -149,10 +148,10 @@ public: \ #define MSG_WM_KILLFOCUS(func) \ if (uMsg == WM_KILLFOCUS) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((HWND)wParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -160,10 +159,10 @@ public: \ #define MSG_WM_ENABLE(func) \ if (uMsg == WM_ENABLE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((BOOL)wParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -171,10 +170,10 @@ public: \ #define MSG_WM_PAINT(func) \ if (uMsg == WM_PAINT) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((HDC)wParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -182,10 +181,10 @@ public: \ #define MSG_WM_CLOSE(func) \ if (uMsg == WM_CLOSE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func(); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -193,9 +192,9 @@ public: \ #define MSG_WM_QUERYENDSESSION(func) \ if (uMsg == WM_QUERYENDSESSION) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((UINT)wParam, (UINT)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -203,9 +202,9 @@ public: \ #define MSG_WM_QUERYOPEN(func) \ if (uMsg == WM_QUERYOPEN) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func(); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -213,9 +212,9 @@ public: \ #define MSG_WM_ERASEBKGND(func) \ if (uMsg == WM_ERASEBKGND) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((HDC)wParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -223,10 +222,10 @@ public: \ #define MSG_WM_SYSCOLORCHANGE(func) \ if (uMsg == WM_SYSCOLORCHANGE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func(); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -234,10 +233,10 @@ public: \ #define MSG_WM_ENDSESSION(func) \ if (uMsg == WM_ENDSESSION) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((BOOL)wParam, (UINT)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -245,10 +244,10 @@ public: \ #define MSG_WM_SHOWWINDOW(func) \ if (uMsg == WM_SHOWWINDOW) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((BOOL)wParam, (int)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -256,9 +255,9 @@ public: \ #define MSG_WM_CTLCOLOREDIT(func) \ if (uMsg == WM_CTLCOLOREDIT) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -266,9 +265,9 @@ public: \ #define MSG_WM_CTLCOLORLISTBOX(func) \ if (uMsg == WM_CTLCOLORLISTBOX) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -276,9 +275,9 @@ public: \ #define MSG_WM_CTLCOLORBTN(func) \ if (uMsg == WM_CTLCOLORBTN) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -286,9 +285,9 @@ public: \ #define MSG_WM_CTLCOLORDLG(func) \ if (uMsg == WM_CTLCOLORDLG) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -296,9 +295,9 @@ public: \ #define MSG_WM_CTLCOLORSCROLLBAR(func) \ if (uMsg == WM_CTLCOLORSCROLLBAR) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -306,9 +305,9 @@ public: \ #define MSG_WM_CTLCOLORSTATIC(func) \ if (uMsg == WM_CTLCOLORSTATIC) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -316,10 +315,10 @@ public: \ #define MSG_WM_SETTINGCHANGE(func) \ if (uMsg == WM_SETTINGCHANGE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)wParam, (LPCTSTR)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -327,10 +326,10 @@ public: \ #define MSG_WM_DEVMODECHANGE(func) \ if (uMsg == WM_DEVMODECHANGE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((LPCTSTR)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -338,10 +337,10 @@ public: \ #define MSG_WM_ACTIVATEAPP(func) \ if (uMsg == WM_ACTIVATEAPP) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((BOOL)wParam, (DWORD)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -349,10 +348,10 @@ public: \ #define MSG_WM_FONTCHANGE(func) \ if (uMsg == WM_FONTCHANGE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func(); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -360,10 +359,10 @@ public: \ #define MSG_WM_TIMECHANGE(func) \ if (uMsg == WM_TIMECHANGE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func(); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -371,10 +370,10 @@ public: \ #define MSG_WM_CANCELMODE(func) \ if (uMsg == WM_CANCELMODE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func(); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -382,9 +381,9 @@ public: \ #define MSG_WM_SETCURSOR(func) \ if (uMsg == WM_SETCURSOR) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((HWND)wParam, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam)); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -392,9 +391,9 @@ public: \ #define MSG_WM_MOUSEACTIVATE(func) \ if (uMsg == WM_MOUSEACTIVATE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((HWND)wParam, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam)); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -402,10 +401,10 @@ public: \ #define MSG_WM_CHILDACTIVATE(func) \ if (uMsg == WM_CHILDACTIVATE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func(); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -413,10 +412,10 @@ public: \ #define MSG_WM_GETMINMAXINFO(func) \ if (uMsg == WM_GETMINMAXINFO) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((LPMINMAXINFO)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -424,10 +423,10 @@ public: \ #define MSG_WM_ICONERASEBKGND(func) \ if (uMsg == WM_ICONERASEBKGND) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((HDC)wParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -435,10 +434,10 @@ public: \ #define MSG_WM_SPOOLERSTATUS(func) \ if (uMsg == WM_SPOOLERSTATUS) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)wParam, (UINT)LOWORD(lParam)); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -446,10 +445,10 @@ public: \ #define MSG_WM_DRAWITEM(func) \ if (uMsg == WM_DRAWITEM) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)wParam, (LPDRAWITEMSTRUCT)lParam); \ lResult = TRUE; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -457,10 +456,10 @@ public: \ #define MSG_WM_MEASUREITEM(func) \ if (uMsg == WM_MEASUREITEM) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)wParam, (LPMEASUREITEMSTRUCT)lParam); \ lResult = TRUE; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -468,10 +467,10 @@ public: \ #define MSG_WM_DELETEITEM(func) \ if (uMsg == WM_DELETEITEM) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)wParam, (LPDELETEITEMSTRUCT)lParam); \ lResult = TRUE; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -479,9 +478,9 @@ public: \ #define MSG_WM_CHARTOITEM(func) \ if (uMsg == WM_CHARTOITEM) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), (HWND)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -489,9 +488,9 @@ public: \ #define MSG_WM_VKEYTOITEM(func) \ if (uMsg == WM_VKEYTOITEM) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), (HWND)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -499,9 +498,9 @@ public: \ #define MSG_WM_QUERYDRAGICON(func) \ if (uMsg == WM_QUERYDRAGICON) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func(); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -509,9 +508,9 @@ public: \ #define MSG_WM_COMPAREITEM(func) \ if (uMsg == WM_COMPAREITEM) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((UINT)wParam, (LPCOMPAREITEMSTRUCT)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -519,10 +518,10 @@ public: \ #define MSG_WM_COMPACTING(func) \ if (uMsg == WM_COMPACTING) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)wParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -530,9 +529,9 @@ public: \ #define MSG_WM_NCCREATE(func) \ if (uMsg == WM_NCCREATE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((LPCREATESTRUCT)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -540,10 +539,10 @@ public: \ #define MSG_WM_NCDESTROY(func) \ if (uMsg == WM_NCDESTROY) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func(); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -551,9 +550,9 @@ public: \ #define MSG_WM_NCCALCSIZE(func) \ if (uMsg == WM_NCCALCSIZE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = func((BOOL)wParam, lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -561,9 +560,9 @@ public: \ #define MSG_WM_NCHITTEST(func) \ if (uMsg == WM_NCHITTEST) \ { \ - SetMsgHandled(TRUE); \ - lResult = (LRESULT)func(_WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ - if(IsMsgHandled()) \ + this->SetMsgHandled(TRUE); \ + lResult = (LRESULT)func(::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -571,10 +570,10 @@ public: \ #define MSG_WM_NCPAINT(func) \ if (uMsg == WM_NCPAINT) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((HRGN)wParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -582,9 +581,9 @@ public: \ #define MSG_WM_NCACTIVATE(func) \ if (uMsg == WM_NCACTIVATE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((BOOL)wParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -592,9 +591,9 @@ public: \ #define MSG_WM_GETDLGCODE(func) \ if (uMsg == WM_GETDLGCODE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((LPMSG)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -602,10 +601,10 @@ public: \ #define MSG_WM_NCMOUSEMOVE(func) \ if (uMsg == WM_NCMOUSEMOVE) \ { \ - SetMsgHandled(TRUE); \ - func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -613,10 +612,10 @@ public: \ #define MSG_WM_NCLBUTTONDOWN(func) \ if (uMsg == WM_NCLBUTTONDOWN) \ { \ - SetMsgHandled(TRUE); \ - func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -624,10 +623,10 @@ public: \ #define MSG_WM_NCLBUTTONUP(func) \ if (uMsg == WM_NCLBUTTONUP) \ { \ - SetMsgHandled(TRUE); \ - func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -635,10 +634,10 @@ public: \ #define MSG_WM_NCLBUTTONDBLCLK(func) \ if (uMsg == WM_NCLBUTTONDBLCLK) \ { \ - SetMsgHandled(TRUE); \ - func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -646,10 +645,10 @@ public: \ #define MSG_WM_NCRBUTTONDOWN(func) \ if (uMsg == WM_NCRBUTTONDOWN) \ { \ - SetMsgHandled(TRUE); \ - func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -657,10 +656,10 @@ public: \ #define MSG_WM_NCRBUTTONUP(func) \ if (uMsg == WM_NCRBUTTONUP) \ { \ - SetMsgHandled(TRUE); \ - func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -668,10 +667,10 @@ public: \ #define MSG_WM_NCRBUTTONDBLCLK(func) \ if (uMsg == WM_NCRBUTTONDBLCLK) \ { \ - SetMsgHandled(TRUE); \ - func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -679,10 +678,10 @@ public: \ #define MSG_WM_NCMBUTTONDOWN(func) \ if (uMsg == WM_NCMBUTTONDOWN) \ { \ - SetMsgHandled(TRUE); \ - func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -690,10 +689,10 @@ public: \ #define MSG_WM_NCMBUTTONUP(func) \ if (uMsg == WM_NCMBUTTONUP) \ { \ - SetMsgHandled(TRUE); \ - func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -701,10 +700,10 @@ public: \ #define MSG_WM_NCMBUTTONDBLCLK(func) \ if (uMsg == WM_NCMBUTTONDBLCLK) \ { \ - SetMsgHandled(TRUE); \ - func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -712,10 +711,10 @@ public: \ #define MSG_WM_KEYDOWN(func) \ if (uMsg == WM_KEYDOWN) \ { \ - SetMsgHandled(TRUE); \ - func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -723,32 +722,32 @@ public: \ #define MSG_WM_KEYUP(func) \ if (uMsg == WM_KEYUP) \ { \ - SetMsgHandled(TRUE); \ - func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } -// void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) +// void OnChar(TCHAR chChar, UINT nRepCnt, UINT nFlags) #define MSG_WM_CHAR(func) \ if (uMsg == WM_CHAR) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } -// void OnDeadChar(UINT nChar, UINT nRepCnt, UINT nFlags) +// void OnDeadChar(TCHAR chChar, UINT nRepCnt, UINT nFlags) #define MSG_WM_DEADCHAR(func) \ if (uMsg == WM_DEADCHAR) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -756,10 +755,10 @@ public: \ #define MSG_WM_SYSKEYDOWN(func) \ if (uMsg == WM_SYSKEYDOWN) \ { \ - SetMsgHandled(TRUE); \ - func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -767,32 +766,32 @@ public: \ #define MSG_WM_SYSKEYUP(func) \ if (uMsg == WM_SYSKEYUP) \ { \ - SetMsgHandled(TRUE); \ - func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } -// void OnSysChar(UINT nChar, UINT nRepCnt, UINT nFlags) +// void OnSysChar(TCHAR chChar, UINT nRepCnt, UINT nFlags) #define MSG_WM_SYSCHAR(func) \ if (uMsg == WM_SYSCHAR) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } -// void OnSysDeadChar(UINT nChar, UINT nRepCnt, UINT nFlags) +// void OnSysDeadChar(TCHAR chChar, UINT nRepCnt, UINT nFlags) #define MSG_WM_SYSDEADCHAR(func) \ if (uMsg == WM_SYSDEADCHAR) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -800,10 +799,10 @@ public: \ #define MSG_WM_SYSCOMMAND(func) \ if (uMsg == WM_SYSCOMMAND) \ { \ - SetMsgHandled(TRUE); \ - func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -811,10 +810,10 @@ public: \ #define MSG_WM_TCARD(func) \ if (uMsg == WM_TCARD) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)wParam, (DWORD)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -822,10 +821,10 @@ public: \ #define MSG_WM_TIMER(func) \ if (uMsg == WM_TIMER) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT_PTR)wParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -833,10 +832,10 @@ public: \ #define MSG_WM_HSCROLL(func) \ if (uMsg == WM_HSCROLL) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((int)LOWORD(wParam), (short)HIWORD(wParam), (HWND)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -844,10 +843,10 @@ public: \ #define MSG_WM_VSCROLL(func) \ if (uMsg == WM_VSCROLL) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((int)LOWORD(wParam), (short)HIWORD(wParam), (HWND)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -855,10 +854,10 @@ public: \ #define MSG_WM_INITMENU(func) \ if (uMsg == WM_INITMENU) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((HMENU)wParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -866,10 +865,10 @@ public: \ #define MSG_WM_INITMENUPOPUP(func) \ if (uMsg == WM_INITMENUPOPUP) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((HMENU)wParam, (UINT)LOWORD(lParam), (BOOL)HIWORD(lParam)); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -877,10 +876,10 @@ public: \ #define MSG_WM_MENUSELECT(func) \ if (uMsg == WM_MENUSELECT) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), (HMENU)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -888,9 +887,9 @@ public: \ #define MSG_WM_MENUCHAR(func) \ if (uMsg == WM_MENUCHAR) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = func((TCHAR)LOWORD(wParam), (UINT)HIWORD(wParam), (HMENU)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -898,9 +897,9 @@ public: \ #define MSG_WM_NOTIFY(func) \ if (uMsg == WM_NOTIFY) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = func((int)wParam, (LPNMHDR)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -908,10 +907,10 @@ public: \ #define MSG_WM_ENTERIDLE(func) \ if (uMsg == WM_ENTERIDLE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)wParam, (HWND)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -919,10 +918,10 @@ public: \ #define MSG_WM_MOUSEMOVE(func) \ if (uMsg == WM_MOUSEMOVE) \ { \ - SetMsgHandled(TRUE); \ - func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -930,9 +929,9 @@ public: \ #define MSG_WM_MOUSEWHEEL(func) \ if (uMsg == WM_MOUSEWHEEL) \ { \ - SetMsgHandled(TRUE); \ - lResult = (LRESULT)func((UINT)LOWORD(wParam), (short)HIWORD(wParam), _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ - if(IsMsgHandled()) \ + this->SetMsgHandled(TRUE); \ + lResult = (LRESULT)func((UINT)LOWORD(wParam), (short)HIWORD(wParam), ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -940,10 +939,10 @@ public: \ #define MSG_WM_LBUTTONDOWN(func) \ if (uMsg == WM_LBUTTONDOWN) \ { \ - SetMsgHandled(TRUE); \ - func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -951,10 +950,10 @@ public: \ #define MSG_WM_LBUTTONUP(func) \ if (uMsg == WM_LBUTTONUP) \ { \ - SetMsgHandled(TRUE); \ - func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -962,10 +961,10 @@ public: \ #define MSG_WM_LBUTTONDBLCLK(func) \ if (uMsg == WM_LBUTTONDBLCLK) \ { \ - SetMsgHandled(TRUE); \ - func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -973,10 +972,10 @@ public: \ #define MSG_WM_RBUTTONDOWN(func) \ if (uMsg == WM_RBUTTONDOWN) \ { \ - SetMsgHandled(TRUE); \ - func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -984,10 +983,10 @@ public: \ #define MSG_WM_RBUTTONUP(func) \ if (uMsg == WM_RBUTTONUP) \ { \ - SetMsgHandled(TRUE); \ - func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -995,10 +994,10 @@ public: \ #define MSG_WM_RBUTTONDBLCLK(func) \ if (uMsg == WM_RBUTTONDBLCLK) \ { \ - SetMsgHandled(TRUE); \ - func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1006,10 +1005,10 @@ public: \ #define MSG_WM_MBUTTONDOWN(func) \ if (uMsg == WM_MBUTTONDOWN) \ { \ - SetMsgHandled(TRUE); \ - func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1017,10 +1016,10 @@ public: \ #define MSG_WM_MBUTTONUP(func) \ if (uMsg == WM_MBUTTONUP) \ { \ - SetMsgHandled(TRUE); \ - func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1028,10 +1027,10 @@ public: \ #define MSG_WM_MBUTTONDBLCLK(func) \ if (uMsg == WM_MBUTTONDBLCLK) \ { \ - SetMsgHandled(TRUE); \ - func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1039,21 +1038,21 @@ public: \ #define MSG_WM_PARENTNOTIFY(func) \ if (uMsg == WM_PARENTNOTIFY) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } -// void OnMDIActivate(CWindow wndActivate, CWindow wndDeactivate) +// void OnMDIActivate(CWindow wndDeactivate, CWindow wndActivate) #define MSG_WM_MDIACTIVATE(func) \ if (uMsg == WM_MDIACTIVATE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((HWND)wParam, (HWND)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1061,10 +1060,10 @@ public: \ #define MSG_WM_RENDERFORMAT(func) \ if (uMsg == WM_RENDERFORMAT) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)wParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1072,10 +1071,10 @@ public: \ #define MSG_WM_RENDERALLFORMATS(func) \ if (uMsg == WM_RENDERALLFORMATS) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func(); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1083,10 +1082,10 @@ public: \ #define MSG_WM_DESTROYCLIPBOARD(func) \ if (uMsg == WM_DESTROYCLIPBOARD) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func(); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1094,10 +1093,10 @@ public: \ #define MSG_WM_DRAWCLIPBOARD(func) \ if (uMsg == WM_DRAWCLIPBOARD) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func(); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1105,11 +1104,11 @@ public: \ #define MSG_WM_PAINTCLIPBOARD(func) \ if (uMsg == WM_PAINTCLIPBOARD) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((HWND)wParam, (const LPPAINTSTRUCT)::GlobalLock((HGLOBAL)lParam)); \ ::GlobalUnlock((HGLOBAL)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1117,10 +1116,10 @@ public: \ #define MSG_WM_VSCROLLCLIPBOARD(func) \ if (uMsg == WM_VSCROLLCLIPBOARD) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((HWND)wParam, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam)); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1128,10 +1127,10 @@ public: \ #define MSG_WM_CONTEXTMENU(func) \ if (uMsg == WM_CONTEXTMENU) \ { \ - SetMsgHandled(TRUE); \ - func((HWND)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + this->SetMsgHandled(TRUE); \ + func((HWND)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1139,11 +1138,11 @@ public: \ #define MSG_WM_SIZECLIPBOARD(func) \ if (uMsg == WM_SIZECLIPBOARD) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((HWND)wParam, (const LPRECT)::GlobalLock((HGLOBAL)lParam)); \ ::GlobalUnlock((HGLOBAL)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1151,10 +1150,10 @@ public: \ #define MSG_WM_ASKCBFORMATNAME(func) \ if (uMsg == WM_ASKCBFORMATNAME) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)wParam, (LPTSTR)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1162,10 +1161,10 @@ public: \ #define MSG_WM_CHANGECBCHAIN(func) \ if (uMsg == WM_CHANGECBCHAIN) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((HWND)wParam, (HWND)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1173,10 +1172,10 @@ public: \ #define MSG_WM_HSCROLLCLIPBOARD(func) \ if (uMsg == WM_HSCROLLCLIPBOARD) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((HWND)wParam, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam)); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1184,9 +1183,9 @@ public: \ #define MSG_WM_QUERYNEWPALETTE(func) \ if (uMsg == WM_QUERYNEWPALETTE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func(); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1194,10 +1193,10 @@ public: \ #define MSG_WM_PALETTECHANGED(func) \ if (uMsg == WM_PALETTECHANGED) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((HWND)wParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1205,10 +1204,10 @@ public: \ #define MSG_WM_PALETTEISCHANGING(func) \ if (uMsg == WM_PALETTEISCHANGING) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((HWND)wParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1216,10 +1215,10 @@ public: \ #define MSG_WM_DROPFILES(func) \ if (uMsg == WM_DROPFILES) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((HDROP)wParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1227,10 +1226,10 @@ public: \ #define MSG_WM_WINDOWPOSCHANGING(func) \ if (uMsg == WM_WINDOWPOSCHANGING) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((LPWINDOWPOS)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1238,10 +1237,10 @@ public: \ #define MSG_WM_WINDOWPOSCHANGED(func) \ if (uMsg == WM_WINDOWPOSCHANGED) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((LPWINDOWPOS)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1249,10 +1248,10 @@ public: \ #define MSG_WM_EXITMENULOOP(func) \ if (uMsg == WM_EXITMENULOOP) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((BOOL)wParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1260,10 +1259,10 @@ public: \ #define MSG_WM_ENTERMENULOOP(func) \ if (uMsg == WM_ENTERMENULOOP) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((BOOL)wParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1271,10 +1270,10 @@ public: \ #define MSG_WM_STYLECHANGED(func) \ if (uMsg == WM_STYLECHANGED) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)wParam, (LPSTYLESTRUCT)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1282,10 +1281,10 @@ public: \ #define MSG_WM_STYLECHANGING(func) \ if (uMsg == WM_STYLECHANGING) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)wParam, (LPSTYLESTRUCT)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1293,10 +1292,10 @@ public: \ #define MSG_WM_SIZING(func) \ if (uMsg == WM_SIZING) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)wParam, (LPRECT)lParam); \ lResult = TRUE; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1304,10 +1303,10 @@ public: \ #define MSG_WM_MOVING(func) \ if (uMsg == WM_MOVING) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)wParam, (LPRECT)lParam); \ lResult = TRUE; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1315,10 +1314,10 @@ public: \ #define MSG_WM_CAPTURECHANGED(func) \ if (uMsg == WM_CAPTURECHANGED) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((HWND)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1326,9 +1325,9 @@ public: \ #define MSG_WM_DEVICECHANGE(func) \ if (uMsg == WM_DEVICECHANGE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((UINT)wParam, (DWORD_PTR)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1336,10 +1335,10 @@ public: \ #define MSG_WM_COMMAND(func) \ if (uMsg == WM_COMMAND) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1347,10 +1346,10 @@ public: \ #define MSG_WM_DISPLAYCHANGE(func) \ if (uMsg == WM_DISPLAYCHANGE) \ { \ - SetMsgHandled(TRUE); \ - func((UINT)wParam, _WTYPES_NS::CSize(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CSize(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1358,10 +1357,10 @@ public: \ #define MSG_WM_ENTERSIZEMOVE(func) \ if (uMsg == WM_ENTERSIZEMOVE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func(); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1369,10 +1368,10 @@ public: \ #define MSG_WM_EXITSIZEMOVE(func) \ if (uMsg == WM_EXITSIZEMOVE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func(); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1380,9 +1379,9 @@ public: \ #define MSG_WM_GETFONT(func) \ if (uMsg == WM_GETFONT) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func(); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1390,9 +1389,9 @@ public: \ #define MSG_WM_GETHOTKEY(func) \ if (uMsg == WM_GETHOTKEY) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = func(); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1400,9 +1399,9 @@ public: \ #define MSG_WM_GETICON(func) \ if (uMsg == WM_GETICON) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((UINT)wParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1410,9 +1409,9 @@ public: \ #define MSG_WM_GETTEXT(func) \ if (uMsg == WM_GETTEXT) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((int)wParam, (LPTSTR)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1420,9 +1419,9 @@ public: \ #define MSG_WM_GETTEXTLENGTH(func) \ if (uMsg == WM_GETTEXTLENGTH) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func(); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1430,10 +1429,10 @@ public: \ #define MSG_WM_HELP(func) \ if (uMsg == WM_HELP) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((LPHELPINFO)lParam); \ lResult = TRUE; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1441,10 +1440,10 @@ public: \ #define MSG_WM_HOTKEY(func) \ if (uMsg == WM_HOTKEY) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((int)wParam, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam)); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1452,10 +1451,10 @@ public: \ #define MSG_WM_INPUTLANGCHANGE(func) \ if (uMsg == WM_INPUTLANGCHANGE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((DWORD)wParam, (HKL)lParam); \ lResult = TRUE; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1463,10 +1462,10 @@ public: \ #define MSG_WM_INPUTLANGCHANGEREQUEST(func) \ if (uMsg == WM_INPUTLANGCHANGEREQUEST) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((BOOL)wParam, (HKL)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1474,10 +1473,10 @@ public: \ #define MSG_WM_NEXTDLGCTL(func) \ if (uMsg == WM_NEXTDLGCTL) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((BOOL)LOWORD(lParam), wParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1485,10 +1484,10 @@ public: \ #define MSG_WM_NEXTMENU(func) \ if (uMsg == WM_NEXTMENU) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((int)wParam, (LPMDINEXTMENU)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1496,9 +1495,9 @@ public: \ #define MSG_WM_NOTIFYFORMAT(func) \ if (uMsg == WM_NOTIFYFORMAT) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((HWND)wParam, (int)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1506,9 +1505,9 @@ public: \ #define MSG_WM_POWERBROADCAST(func) \ if (uMsg == WM_POWERBROADCAST) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((DWORD)wParam, (DWORD_PTR)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1516,10 +1515,10 @@ public: \ #define MSG_WM_PRINT(func) \ if (uMsg == WM_PRINT) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((HDC)wParam, (UINT)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1527,10 +1526,10 @@ public: \ #define MSG_WM_PRINTCLIENT(func) \ if (uMsg == WM_PRINTCLIENT) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((HDC)wParam, (UINT)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1538,10 +1537,10 @@ public: \ #define MSG_WM_RASDIALEVENT(func) \ if (uMsg == WM_RASDIALEVENT) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((RASCONNSTATE)wParam, (DWORD)lParam); \ lResult = TRUE; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1549,10 +1548,10 @@ public: \ #define MSG_WM_SETFONT(func) \ if (uMsg == WM_SETFONT) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((HFONT)wParam, (BOOL)LOWORD(lParam)); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1560,9 +1559,9 @@ public: \ #define MSG_WM_SETHOTKEY(func) \ if (uMsg == WM_SETHOTKEY) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((int)LOBYTE(LOWORD(wParam)), (UINT)HIBYTE(LOWORD(wParam))); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1570,9 +1569,9 @@ public: \ #define MSG_WM_SETICON(func) \ if (uMsg == WM_SETICON) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((UINT)wParam, (HICON)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1580,10 +1579,10 @@ public: \ #define MSG_WM_SETREDRAW(func) \ if (uMsg == WM_SETREDRAW) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((BOOL)wParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1591,9 +1590,9 @@ public: \ #define MSG_WM_SETTEXT(func) \ if (uMsg == WM_SETTEXT) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((LPCTSTR)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1601,26 +1600,24 @@ public: \ #define MSG_WM_USERCHANGED(func) \ if (uMsg == WM_USERCHANGED) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func(); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } /////////////////////////////////////////////////////////////////////////////// -// New NT4 & NT5 messages - -#if (_WIN32_WINNT >= 0x0400) +// Newer Windows messages // void OnMouseHover(WPARAM wParam, CPoint ptPos) #define MSG_WM_MOUSEHOVER(func) \ if (uMsg == WM_MOUSEHOVER) \ { \ - SetMsgHandled(TRUE); \ - func(wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + this->SetMsgHandled(TRUE); \ + func(wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1628,25 +1625,43 @@ public: \ #define MSG_WM_MOUSELEAVE(func) \ if (uMsg == WM_MOUSELEAVE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func(); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } -#endif // _WIN32_WINNT >= 0x0400 +// void OnNcMouseHover(UINT nHitTest, CPoint ptPos) +#define MSG_WM_NCMOUSEHOVER(func) \ + if (uMsg == WM_NCMOUSEHOVER) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(MAKEPOINTS(lParam).x, MAKEPOINTS(lParam).y)); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } -#if (WINVER >= 0x0500) +// void OnNcMouseLeave() +#define MSG_WM_NCMOUSELEAVE(func) \ + if (uMsg == WM_NCMOUSELEAVE) \ + { \ + this->SetMsgHandled(TRUE); \ + func(); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } // void OnMenuRButtonUp(WPARAM wParam, CMenuHandle menu) #define MSG_WM_MENURBUTTONUP(func) \ if (uMsg == WM_MENURBUTTONUP) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func(wParam, (HMENU)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1654,9 +1669,9 @@ public: \ #define MSG_WM_MENUDRAG(func) \ if (uMsg == WM_MENUDRAG) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = func(wParam, (HMENU)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1664,9 +1679,9 @@ public: \ #define MSG_WM_MENUGETOBJECT(func) \ if (uMsg == WM_MENUGETOBJECT) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = func((PMENUGETOBJECTINFO)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1674,10 +1689,10 @@ public: \ #define MSG_WM_UNINITMENUPOPUP(func) \ if (uMsg == WM_UNINITMENUPOPUP) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)HIWORD(lParam), (HMENU)wParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1685,24 +1700,20 @@ public: \ #define MSG_WM_MENUCOMMAND(func) \ if (uMsg == WM_MENUCOMMAND) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func(wParam, (HMENU)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } -#endif // WINVER >= 0x0500 - -#if (_WIN32_WINNT >= 0x0500) - // BOOL OnAppCommand(CWindow wndFocus, short cmd, WORD uDevice, int dwKeys) #define MSG_WM_APPCOMMAND(func) \ if (uMsg == WM_APPCOMMAND) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((HWND)wParam, GET_APPCOMMAND_LPARAM(lParam), GET_DEVICE_LPARAM(lParam), GET_KEYSTATE_LPARAM(lParam)); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1710,10 +1721,10 @@ public: \ #define MSG_WM_NCXBUTTONDOWN(func) \ if (uMsg == WM_NCXBUTTONDOWN) \ { \ - SetMsgHandled(TRUE); \ - func(GET_XBUTTON_WPARAM(wParam), GET_NCHITTEST_WPARAM(wParam), _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ - lResult = 0; \ - if(IsMsgHandled()) \ + this->SetMsgHandled(TRUE); \ + func(GET_XBUTTON_WPARAM(wParam), GET_NCHITTEST_WPARAM(wParam), ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + lResult = (LRESULT)TRUE; \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1721,10 +1732,10 @@ public: \ #define MSG_WM_NCXBUTTONUP(func) \ if (uMsg == WM_NCXBUTTONUP) \ { \ - SetMsgHandled(TRUE); \ - func(GET_XBUTTON_WPARAM(wParam), GET_NCHITTEST_WPARAM(wParam), _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ - lResult = 0; \ - if(IsMsgHandled()) \ + this->SetMsgHandled(TRUE); \ + func(GET_XBUTTON_WPARAM(wParam), GET_NCHITTEST_WPARAM(wParam), ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + lResult = (LRESULT)TRUE; \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1732,10 +1743,10 @@ public: \ #define MSG_WM_NCXBUTTONDBLCLK(func) \ if (uMsg == WM_NCXBUTTONDBLCLK) \ { \ - SetMsgHandled(TRUE); \ - func(GET_XBUTTON_WPARAM(wParam), GET_NCHITTEST_WPARAM(wParam), _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ - lResult = 0; \ - if(IsMsgHandled()) \ + this->SetMsgHandled(TRUE); \ + func(GET_XBUTTON_WPARAM(wParam), GET_NCHITTEST_WPARAM(wParam), ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + lResult = (LRESULT)TRUE; \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1743,10 +1754,10 @@ public: \ #define MSG_WM_XBUTTONDOWN(func) \ if (uMsg == WM_XBUTTONDOWN) \ { \ - SetMsgHandled(TRUE); \ - func(GET_XBUTTON_WPARAM(wParam), GET_KEYSTATE_WPARAM(wParam), _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ - lResult = 0; \ - if(IsMsgHandled()) \ + this->SetMsgHandled(TRUE); \ + func(GET_XBUTTON_WPARAM(wParam), GET_KEYSTATE_WPARAM(wParam), ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + lResult = (LRESULT)TRUE; \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1754,10 +1765,10 @@ public: \ #define MSG_WM_XBUTTONUP(func) \ if (uMsg == WM_XBUTTONUP) \ { \ - SetMsgHandled(TRUE); \ - func(GET_XBUTTON_WPARAM(wParam), GET_KEYSTATE_WPARAM(wParam), _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ - lResult = 0; \ - if(IsMsgHandled()) \ + this->SetMsgHandled(TRUE); \ + func(GET_XBUTTON_WPARAM(wParam), GET_KEYSTATE_WPARAM(wParam), ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + lResult = (LRESULT)TRUE; \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1765,10 +1776,10 @@ public: \ #define MSG_WM_XBUTTONDBLCLK(func) \ if (uMsg == WM_XBUTTONDBLCLK) \ { \ - SetMsgHandled(TRUE); \ - func(GET_XBUTTON_WPARAM(wParam), GET_KEYSTATE_WPARAM(wParam), _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ - lResult = 0; \ - if(IsMsgHandled()) \ + this->SetMsgHandled(TRUE); \ + func(GET_XBUTTON_WPARAM(wParam), GET_KEYSTATE_WPARAM(wParam), ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + lResult = (LRESULT)TRUE; \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1776,10 +1787,10 @@ public: \ #define MSG_WM_CHANGEUISTATE(func) \ if (uMsg == WM_CHANGEUISTATE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func(LOWORD(wParam), HIWORD(wParam)); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1787,10 +1798,10 @@ public: \ #define MSG_WM_UPDATEUISTATE(func) \ if (uMsg == WM_UPDATEUISTATE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func(LOWORD(wParam), HIWORD(wParam)); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1798,24 +1809,20 @@ public: \ #define MSG_WM_QUERYUISTATE(func) \ if (uMsg == WM_QUERYUISTATE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = func(); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } -#endif // (_WIN32_WINNT >= 0x0500) - -#if(_WIN32_WINNT >= 0x0501) - // void OnInput(WPARAM RawInputCode, HRAWINPUT hRawInput) #define MSG_WM_INPUT(func) \ if (uMsg == WM_INPUT) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func(GET_RAWINPUT_CODE_WPARAM(wParam), (HRAWINPUT)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1823,23 +1830,23 @@ public: \ #define MSG_WM_UNICHAR(func) \ if (uMsg == WM_UNICHAR) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ { \ lResult = (wParam == UNICODE_NOCHAR) ? TRUE : FALSE; \ return TRUE; \ } \ } -// void OnWTSSessionChange(WPARAM nStatusCode, PWTSSESSION_NOTIFICATION nSessionID) +// void OnWTSSessionChange(WPARAM nStatusCode, DWORD dwSessionID) #define MSG_WM_WTSSESSION_CHANGE(func) \ if (uMsg == WM_WTSSESSION_CHANGE) \ { \ - SetMsgHandled(TRUE); \ - func(wParam, (PWTSSESSION_NOTIFICATION)lParam); \ + this->SetMsgHandled(TRUE); \ + func(wParam, (DWORD)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1847,29 +1854,96 @@ public: \ #define MSG_WM_THEMECHANGED(func) \ if (uMsg == WM_THEMECHANGED) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func(); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } -#endif // _WIN32_WINNT >= 0x0501 - #if (_WIN32_WINNT >= 0x0600) // BOOL OnMouseHWheel(UINT nFlags, short zDelta, CPoint pt) #define MSG_WM_MOUSEHWHEEL(func) \ if (uMsg == WM_MOUSEHWHEEL) \ { \ - SetMsgHandled(TRUE); \ - lResult = (LRESULT)func((UINT)LOWORD(wParam), (short)HIWORD(wParam), _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ - if(IsMsgHandled()) \ + this->SetMsgHandled(TRUE); \ + lResult = (LRESULT)func((UINT)LOWORD(wParam), (short)HIWORD(wParam), ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + if(this->IsMsgHandled()) \ return TRUE; \ } #endif // (_WIN32_WINNT >= 0x0600) +#if (WINVER >= 0x0601) + +// void OnGesture(ULONGLONG ullArguments, HGESTUREINFO hGestureInfo) +#define MSG_WM_GESTURE(func) \ + if (uMsg == WM_GESTURE) \ + { \ + this->SetMsgHandled(TRUE); \ + func((ULONGLONG)wParam, (HGESTUREINFO)lParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnGestureNotify(PGESTURENOTIFYSTRUCT pGestureNotifyStruct) +#define MSG_WM_GESTURENOTIFY(func) \ + if (uMsg == WM_GESTURENOTIFY) \ + { \ + func((PGESTURENOTIFYSTRUCT)lParam); \ + } + +// void OnDpiChanged(UINT nDpiX, UINT nDpiY, PRECT pRect) +#define MSG_WM_DPICHANGED(func) \ + if (uMsg == WM_DPICHANGED) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), (PRECT)lParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +#endif // (WINVER >= 0x0601) + +#if (WINVER >= 0x0605) + +// void OnDpiChangedBeforeParent() +#define MSG_WM_DPICHANGED_BEFOREPARENT(func) \ + if (uMsg == WM_DPICHANGED_BEFOREPARENT) \ + { \ + this->SetMsgHandled(TRUE); \ + func(); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnDpiChangedAfterParent() +#define MSG_WM_DPICHANGED_AFTERPARENT(func) \ + if (uMsg == WM_DPICHANGED_AFTERPARENT) \ + { \ + this->SetMsgHandled(TRUE); \ + func(); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// BOOL OnGetDpiScaledSize(UINT uDpi, PSIZE pSize) +#define MSG_WM_GETDPISCALEDSIZE(func) \ +if (uMsg == WM_GETDPISCALEDSIZE) \ +{ \ + this->SetMsgHandled(TRUE); \ + lResult = (LRESULT)func((UINT)wParam, (PSIZE)lParam); \ + if(this->IsMsgHandled()) \ + return TRUE; \ +} + +#endif // (WINVER >= 0x0605) + /////////////////////////////////////////////////////////////////////////////// // ATL defined messages @@ -1877,9 +1951,9 @@ public: \ #define MSG_WM_FORWARDMSG(func) \ if (uMsg == WM_FORWARDMSG) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((LPMSG)lParam, (DWORD)wParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1890,9 +1964,9 @@ public: \ #define MSG_DM_GETDEFID(func) \ if (uMsg == DM_GETDEFID) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = func(); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1900,10 +1974,10 @@ public: \ #define MSG_DM_SETDEFID(func) \ if (uMsg == DM_SETDEFID) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)wParam); \ lResult = TRUE; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1911,10 +1985,10 @@ public: \ #define MSG_DM_REPOSITION(func) \ if (uMsg == DM_REPOSITION) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func(); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1925,10 +1999,10 @@ public: \ #define MSG_OCM_COMMAND(func) \ if (uMsg == OCM_COMMAND) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1936,9 +2010,9 @@ public: \ #define MSG_OCM_NOTIFY(func) \ if (uMsg == OCM_NOTIFY) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = func((int)wParam, (LPNMHDR)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1946,10 +2020,10 @@ public: \ #define MSG_OCM_PARENTNOTIFY(func) \ if (uMsg == OCM_PARENTNOTIFY) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1957,10 +2031,10 @@ public: \ #define MSG_OCM_DRAWITEM(func) \ if (uMsg == OCM_DRAWITEM) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)wParam, (LPDRAWITEMSTRUCT)lParam); \ lResult = TRUE; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1968,10 +2042,10 @@ public: \ #define MSG_OCM_MEASUREITEM(func) \ if (uMsg == OCM_MEASUREITEM) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)wParam, (LPMEASUREITEMSTRUCT)lParam); \ lResult = TRUE; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1979,9 +2053,9 @@ public: \ #define MSG_OCM_COMPAREITEM(func) \ if (uMsg == OCM_COMPAREITEM) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((UINT)wParam, (LPCOMPAREITEMSTRUCT)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1989,10 +2063,10 @@ public: \ #define MSG_OCM_DELETEITEM(func) \ if (uMsg == OCM_DELETEITEM) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)wParam, (LPDELETEITEMSTRUCT)lParam); \ lResult = TRUE; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -2000,9 +2074,9 @@ public: \ #define MSG_OCM_VKEYTOITEM(func) \ if (uMsg == OCM_VKEYTOITEM) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), (HWND)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -2010,9 +2084,9 @@ public: \ #define MSG_OCM_CHARTOITEM(func) \ if (uMsg == OCM_CHARTOITEM) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), (HWND)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -2020,10 +2094,10 @@ public: \ #define MSG_OCM_HSCROLL(func) \ if (uMsg == OCM_HSCROLL) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((int)LOWORD(wParam), (short)HIWORD(wParam), (HWND)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -2031,10 +2105,10 @@ public: \ #define MSG_OCM_VSCROLL(func) \ if (uMsg == OCM_VSCROLL) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((int)LOWORD(wParam), (short)HIWORD(wParam), (HWND)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -2042,9 +2116,9 @@ public: \ #define MSG_OCM_CTLCOLOREDIT(func) \ if (uMsg == OCM_CTLCOLOREDIT) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -2052,9 +2126,9 @@ public: \ #define MSG_OCM_CTLCOLORLISTBOX(func) \ if (uMsg == OCM_CTLCOLORLISTBOX) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -2062,9 +2136,9 @@ public: \ #define MSG_OCM_CTLCOLORBTN(func) \ if (uMsg == OCM_CTLCOLORBTN) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -2072,9 +2146,9 @@ public: \ #define MSG_OCM_CTLCOLORDLG(func) \ if (uMsg == OCM_CTLCOLORDLG) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -2082,9 +2156,9 @@ public: \ #define MSG_OCM_CTLCOLORSCROLLBAR(func) \ if (uMsg == OCM_CTLCOLORSCROLLBAR) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -2092,9 +2166,9 @@ public: \ #define MSG_OCM_CTLCOLORSTATIC(func) \ if (uMsg == OCM_CTLCOLORSTATIC) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -2105,10 +2179,10 @@ public: \ #define MSG_WM_CLEAR(func) \ if (uMsg == WM_CLEAR) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func(); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -2116,10 +2190,10 @@ public: \ #define MSG_WM_COPY(func) \ if (uMsg == WM_COPY) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func(); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -2127,10 +2201,10 @@ public: \ #define MSG_WM_CUT(func) \ if (uMsg == WM_CUT) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func(); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -2138,10 +2212,10 @@ public: \ #define MSG_WM_PASTE(func) \ if (uMsg == WM_PASTE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func(); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -2149,10 +2223,10 @@ public: \ #define MSG_WM_UNDO(func) \ if (uMsg == WM_UNDO) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func(); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -2163,19 +2237,19 @@ public: \ #define MESSAGE_HANDLER_EX(msg, func) \ if(uMsg == msg) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = func(uMsg, wParam, lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } // LRESULT OnMessageRangeHandlerEX(UINT uMsg, WPARAM wParam, LPARAM lParam) #define MESSAGE_RANGE_HANDLER_EX(msgFirst, msgLast, func) \ - if(uMsg >= msgFirst && uMsg <= msgLast) \ + if((uMsg >= msgFirst) && (uMsg <= msgLast)) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = func(uMsg, wParam, lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -2184,211 +2258,222 @@ public: \ // void OnCommandHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl) #define COMMAND_HANDLER_EX(id, code, func) \ - if (uMsg == WM_COMMAND && code == HIWORD(wParam) && id == LOWORD(wParam)) \ + if ((uMsg == WM_COMMAND) && (code == HIWORD(wParam)) && (id == LOWORD(wParam))) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } // void OnCommandIDHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl) #define COMMAND_ID_HANDLER_EX(id, func) \ - if (uMsg == WM_COMMAND && id == LOWORD(wParam)) \ + if ((uMsg == WM_COMMAND) && (id == LOWORD(wParam))) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } // void OnCommandCodeHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl) #define COMMAND_CODE_HANDLER_EX(code, func) \ - if (uMsg == WM_COMMAND && code == HIWORD(wParam)) \ + if ((uMsg == WM_COMMAND) && (code == HIWORD(wParam))) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } // LRESULT OnNotifyHandlerEX(LPNMHDR pnmh) #define NOTIFY_HANDLER_EX(id, cd, func) \ - if (uMsg == WM_NOTIFY && cd == ((LPNMHDR)lParam)->code && id == ((LPNMHDR)lParam)->idFrom) \ + if ((uMsg == WM_NOTIFY) && (cd == ((LPNMHDR)lParam)->code) && (id == ((LPNMHDR)lParam)->idFrom)) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = func((LPNMHDR)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } // LRESULT OnNotifyIDHandlerEX(LPNMHDR pnmh) #define NOTIFY_ID_HANDLER_EX(id, func) \ - if (uMsg == WM_NOTIFY && id == ((LPNMHDR)lParam)->idFrom) \ + if ((uMsg == WM_NOTIFY) && (id == ((LPNMHDR)lParam)->idFrom)) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = func((LPNMHDR)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } // LRESULT OnNotifyCodeHandlerEX(LPNMHDR pnmh) #define NOTIFY_CODE_HANDLER_EX(cd, func) \ - if (uMsg == WM_NOTIFY && cd == ((LPNMHDR)lParam)->code) \ + if ((uMsg == WM_NOTIFY) && (cd == ((LPNMHDR)lParam)->code)) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = func((LPNMHDR)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } // void OnCommandRangeHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl) #define COMMAND_RANGE_HANDLER_EX(idFirst, idLast, func) \ - if(uMsg == WM_COMMAND && LOWORD(wParam) >= idFirst && LOWORD(wParam) <= idLast) \ + if((uMsg == WM_COMMAND) && (LOWORD(wParam) >= idFirst) && (LOWORD(wParam) <= idLast)) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } // void OnCommandRangeCodeHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl) #define COMMAND_RANGE_CODE_HANDLER_EX(idFirst, idLast, code, func) \ - if(uMsg == WM_COMMAND && code == HIWORD(wParam) && LOWORD(wParam) >= idFirst && LOWORD(wParam) <= idLast) \ + if((uMsg == WM_COMMAND) && (code == HIWORD(wParam)) && (LOWORD(wParam) >= idFirst) && (LOWORD(wParam) <= idLast)) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } // LRESULT OnNotifyRangeHandlerEX(LPNMHDR pnmh) #define NOTIFY_RANGE_HANDLER_EX(idFirst, idLast, func) \ - if(uMsg == WM_NOTIFY && ((LPNMHDR)lParam)->idFrom >= idFirst && ((LPNMHDR)lParam)->idFrom <= idLast) \ + if((uMsg == WM_NOTIFY) && (((LPNMHDR)lParam)->idFrom >= idFirst) && (((LPNMHDR)lParam)->idFrom <= idLast)) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = func((LPNMHDR)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } // LRESULT OnNotifyRangeCodeHandlerEX(LPNMHDR pnmh) #define NOTIFY_RANGE_CODE_HANDLER_EX(idFirst, idLast, cd, func) \ - if(uMsg == WM_NOTIFY && cd == ((LPNMHDR)lParam)->code && ((LPNMHDR)lParam)->idFrom >= idFirst && ((LPNMHDR)lParam)->idFrom <= idLast) \ + if((uMsg == WM_NOTIFY) && (cd == ((LPNMHDR)lParam)->code) && (((LPNMHDR)lParam)->idFrom >= idFirst) && (((LPNMHDR)lParam)->idFrom <= idLast)) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = func((LPNMHDR)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } // LRESULT OnReflectedCommandHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl) #define REFLECTED_COMMAND_HANDLER_EX(id, code, func) \ - if (uMsg == OCM_COMMAND && code == HIWORD(wParam) && id == LOWORD(wParam)) \ + if ((uMsg == OCM_COMMAND) && (code == HIWORD(wParam)) && (id == LOWORD(wParam))) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } // LRESULT OnReflectedCommandIDHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl) #define REFLECTED_COMMAND_ID_HANDLER_EX(id, func) \ - if (uMsg == OCM_COMMAND && id == LOWORD(wParam)) \ + if ((uMsg == OCM_COMMAND) && (id == LOWORD(wParam))) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } // LRESULT OnReflectedCommandCodeHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl) #define REFLECTED_COMMAND_CODE_HANDLER_EX(code, func) \ - if (uMsg == OCM_COMMAND && code == HIWORD(wParam)) \ + if ((uMsg == OCM_COMMAND) && (code == HIWORD(wParam))) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } // LRESULT OnReflectedNotifyHandlerEX(LPNMHDR pnmh) #define REFLECTED_NOTIFY_HANDLER_EX(id, cd, func) \ - if (uMsg == OCM_NOTIFY && cd == ((LPNMHDR)lParam)->code && id == ((LPNMHDR)lParam)->idFrom) \ + if ((uMsg == OCM_NOTIFY) && (cd == ((LPNMHDR)lParam)->code) && (id == ((LPNMHDR)lParam)->idFrom)) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = func((LPNMHDR)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } // LRESULT OnReflectedNotifyIDHandlerEX(LPNMHDR pnmh) #define REFLECTED_NOTIFY_ID_HANDLER_EX(id, func) \ - if (uMsg == OCM_NOTIFY && id == ((LPNMHDR)lParam)->idFrom) \ + if ((uMsg == OCM_NOTIFY) && (id == ((LPNMHDR)lParam)->idFrom)) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = func((LPNMHDR)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } // LRESULT OnReflectedNotifyCodeHandlerEX(LPNMHDR pnmh) #define REFLECTED_NOTIFY_CODE_HANDLER_EX(cd, func) \ - if (uMsg == OCM_NOTIFY && cd == ((LPNMHDR)lParam)->code) \ + if ((uMsg == OCM_NOTIFY) && (cd == ((LPNMHDR)lParam)->code)) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = func((LPNMHDR)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } // void OnReflectedCommandRangeHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl) #define REFLECTED_COMMAND_RANGE_HANDLER_EX(idFirst, idLast, func) \ - if(uMsg == OCM_COMMAND && LOWORD(wParam) >= idFirst && LOWORD(wParam) <= idLast) \ + if((uMsg == OCM_COMMAND) && (LOWORD(wParam) >= idFirst) && (LOWORD(wParam) <= idLast)) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } // void OnReflectedCommandRangeCodeHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl) #define REFLECTED_COMMAND_RANGE_CODE_HANDLER_EX(idFirst, idLast, code, func) \ - if(uMsg == OCM_COMMAND && code == HIWORD(wParam) && LOWORD(wParam) >= idFirst && LOWORD(wParam) <= idLast) \ + if((uMsg == OCM_COMMAND) && (code == HIWORD(wParam)) && (LOWORD(wParam) >= idFirst) && (LOWORD(wParam) <= idLast)) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } // LRESULT OnReflectedNotifyRangeHandlerEX(LPNMHDR pnmh) #define REFLECTED_NOTIFY_RANGE_HANDLER_EX(idFirst, idLast, func) \ - if(uMsg == OCM_NOTIFY && ((LPNMHDR)lParam)->idFrom >= idFirst && ((LPNMHDR)lParam)->idFrom <= idLast) \ + if((uMsg == OCM_NOTIFY) && (((LPNMHDR)lParam)->idFrom >= idFirst) && (((LPNMHDR)lParam)->idFrom <= idLast)) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = func((LPNMHDR)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } // LRESULT OnReflectedNotifyRangeCodeHandlerEX(LPNMHDR pnmh) #define REFLECTED_NOTIFY_RANGE_CODE_HANDLER_EX(idFirst, idLast, cd, func) \ - if(uMsg == OCM_NOTIFY && cd == ((LPNMHDR)lParam)->code && ((LPNMHDR)lParam)->idFrom >= idFirst && ((LPNMHDR)lParam)->idFrom <= idLast) \ + if((uMsg == OCM_NOTIFY) && (cd == ((LPNMHDR)lParam)->code) && (((LPNMHDR)lParam)->idFrom >= idFirst) && (((LPNMHDR)lParam)->idFrom <= idLast)) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = func((LPNMHDR)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnAppCommandHandler(UINT uDevice, DWORD dwKeys, CWindow wndFocus) +#define APPCOMMAND_HANDLER_EX(cmd, func) \ + if((uMsg == WM_APPCOMMAND) && (cmd == GET_APPCOMMAND_LPARAM(lParam))) \ + { \ + this->SetMsgHandled(TRUE); \ + func(GET_DEVICE_LPARAM(lParam), GET_KEYSTATE_LPARAM(lParam), (HWND)wParam); \ + lResult = TRUE; \ + if(this->IsMsgHandled()) \ return TRUE; \ } diff --git a/WrlSDK/SampleCode/PluginWinExe/WTL/atlctrls.h b/WrlSDK/SampleCode/PluginWinExe/WTL/atlctrls.h index cd015102877313057277bb7a746aacd16509d743..61df4279d6df02f770c3f895754292b3ca6dd3a6 100644 --- a/WrlSDK/SampleCode/PluginWinExe/WTL/atlctrls.h +++ b/WrlSDK/SampleCode/PluginWinExe/WTL/atlctrls.h @@ -1,4 +1,4 @@ -// Windows Template Library - WTL version 9.10 +// Windows Template Library - WTL version 10.0 // Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. // // This file is a part of the Windows Template Library. @@ -19,12 +19,12 @@ #error atlctrls.h requires atlwin.h to be included first #endif -#ifndef _WIN32_WCE - #include - #include -#elif defined(WIN32_PLATFORM_WFSP) && !defined(_WINUSERM_H_) - #include -#endif // !_WIN32_WCE +#include +#include + +#if (_RICHEDIT_VER < 0x0300) + #error WTL10 requires _RICHEDIT_VER >= 0x0300 +#endif // protect template members from windowsx.h macros #ifdef _INC_WINDOWSX @@ -75,9 +75,6 @@ // CLinkCtrlT - CLinkCtrl // // CCustomDraw -// -// CCECommandBarCtrlT - CCECommandBarCtrl -// CCECommandBandsCtrlT - CCECommandBandsCtrl namespace WTL @@ -112,7 +109,7 @@ public: CStaticT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -129,66 +126,52 @@ public: return _T("STATIC"); } -#ifndef _WIN32_WCE HICON GetIcon() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (HICON)::SendMessage(m_hWnd, STM_GETICON, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HICON)::SendMessage(this->m_hWnd, STM_GETICON, 0, 0L); } HICON SetIcon(HICON hIcon) { - ATLASSERT(::IsWindow(m_hWnd)); - return (HICON)::SendMessage(m_hWnd, STM_SETICON, (WPARAM)hIcon, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HICON)::SendMessage(this->m_hWnd, STM_SETICON, (WPARAM)hIcon, 0L); } HENHMETAFILE GetEnhMetaFile() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (HENHMETAFILE)::SendMessage(m_hWnd, STM_GETIMAGE, IMAGE_ENHMETAFILE, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HENHMETAFILE)::SendMessage(this->m_hWnd, STM_GETIMAGE, IMAGE_ENHMETAFILE, 0L); } HENHMETAFILE SetEnhMetaFile(HENHMETAFILE hMetaFile) { - ATLASSERT(::IsWindow(m_hWnd)); - return (HENHMETAFILE)::SendMessage(m_hWnd, STM_SETIMAGE, IMAGE_ENHMETAFILE, (LPARAM)hMetaFile); - } -#else // CE specific - HICON GetIcon() const - { - ATLASSERT(::IsWindow(m_hWnd)); - return (HICON)::SendMessage(m_hWnd, STM_GETIMAGE, IMAGE_ICON, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HENHMETAFILE)::SendMessage(this->m_hWnd, STM_SETIMAGE, IMAGE_ENHMETAFILE, (LPARAM)hMetaFile); } - HICON SetIcon(HICON hIcon) - { - ATLASSERT(::IsWindow(m_hWnd)); - return (HICON)::SendMessage(m_hWnd, STM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); - } -#endif // _WIN32_WCE - CBitmapHandle GetBitmap() const { - ATLASSERT(::IsWindow(m_hWnd)); - return CBitmapHandle((HBITMAP)::SendMessage(m_hWnd, STM_GETIMAGE, IMAGE_BITMAP, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CBitmapHandle((HBITMAP)::SendMessage(this->m_hWnd, STM_GETIMAGE, IMAGE_BITMAP, 0L)); } CBitmapHandle SetBitmap(HBITMAP hBitmap) { - ATLASSERT(::IsWindow(m_hWnd)); - return CBitmapHandle((HBITMAP)::SendMessage(m_hWnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBitmap)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CBitmapHandle((HBITMAP)::SendMessage(this->m_hWnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBitmap)); } HCURSOR GetCursor() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (HCURSOR)::SendMessage(m_hWnd, STM_GETIMAGE, IMAGE_CURSOR, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HCURSOR)::SendMessage(this->m_hWnd, STM_GETIMAGE, IMAGE_CURSOR, 0L); } HCURSOR SetCursor(HCURSOR hCursor) { - ATLASSERT(::IsWindow(m_hWnd)); - return (HCURSOR)::SendMessage(m_hWnd, STM_SETIMAGE, IMAGE_CURSOR, (LPARAM)hCursor); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HCURSOR)::SendMessage(this->m_hWnd, STM_SETIMAGE, IMAGE_CURSOR, (LPARAM)hCursor); } }; @@ -208,7 +191,7 @@ public: CButtonT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -227,161 +210,157 @@ public: UINT GetState() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (UINT)::SendMessage(m_hWnd, BM_GETSTATE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, BM_GETSTATE, 0, 0L); } void SetState(BOOL bHighlight) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, BM_SETSTATE, bHighlight, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, BM_SETSTATE, bHighlight, 0L); } int GetCheck() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, BM_GETCHECK, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, BM_GETCHECK, 0, 0L); } void SetCheck(int nCheck) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, BM_SETCHECK, nCheck, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, BM_SETCHECK, nCheck, 0L); } UINT GetButtonStyle() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (UINT)::GetWindowLong(m_hWnd, GWL_STYLE) & 0xFFFF; + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::GetWindowLong(this->m_hWnd, GWL_STYLE) & 0xFFFF; } void SetButtonStyle(UINT nStyle, BOOL bRedraw = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, BM_SETSTYLE, nStyle, (LPARAM)bRedraw); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, BM_SETSTYLE, nStyle, (LPARAM)bRedraw); } -#ifndef _WIN32_WCE HICON GetIcon() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (HICON)::SendMessage(m_hWnd, BM_GETIMAGE, IMAGE_ICON, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HICON)::SendMessage(this->m_hWnd, BM_GETIMAGE, IMAGE_ICON, 0L); } HICON SetIcon(HICON hIcon) { - ATLASSERT(::IsWindow(m_hWnd)); - return (HICON)::SendMessage(m_hWnd, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HICON)::SendMessage(this->m_hWnd, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); } CBitmapHandle GetBitmap() const { - ATLASSERT(::IsWindow(m_hWnd)); - return CBitmapHandle((HBITMAP)::SendMessage(m_hWnd, BM_GETIMAGE, IMAGE_BITMAP, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CBitmapHandle((HBITMAP)::SendMessage(this->m_hWnd, BM_GETIMAGE, IMAGE_BITMAP, 0L)); } CBitmapHandle SetBitmap(HBITMAP hBitmap) { - ATLASSERT(::IsWindow(m_hWnd)); - return CBitmapHandle((HBITMAP)::SendMessage(m_hWnd, BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBitmap)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CBitmapHandle((HBITMAP)::SendMessage(this->m_hWnd, BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBitmap)); } -#endif // !_WIN32_WCE -#if (_WIN32_WINNT >= 0x0501) BOOL GetIdealSize(LPSIZE lpSize) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, BCM_GETIDEALSIZE, 0, (LPARAM)lpSize); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, BCM_GETIDEALSIZE, 0, (LPARAM)lpSize); } BOOL GetImageList(PBUTTON_IMAGELIST pButtonImagelist) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, BCM_GETIMAGELIST, 0, (LPARAM)pButtonImagelist); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, BCM_GETIMAGELIST, 0, (LPARAM)pButtonImagelist); } BOOL SetImageList(PBUTTON_IMAGELIST pButtonImagelist) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, BCM_SETIMAGELIST, 0, (LPARAM)pButtonImagelist); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, BCM_SETIMAGELIST, 0, (LPARAM)pButtonImagelist); } BOOL GetTextMargin(LPRECT lpRect) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, BCM_GETTEXTMARGIN, 0, (LPARAM)lpRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, BCM_GETTEXTMARGIN, 0, (LPARAM)lpRect); } BOOL SetTextMargin(LPRECT lpRect) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, BCM_SETTEXTMARGIN, 0, (LPARAM)lpRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, BCM_SETTEXTMARGIN, 0, (LPARAM)lpRect); } -#endif // (_WIN32_WINNT >= 0x0501) #if (WINVER >= 0x0600) void SetDontClick(BOOL bDontClick) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, BM_SETDONTCLICK, (WPARAM)bDontClick, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, BM_SETDONTCLICK, (WPARAM)bDontClick, 0L); } #endif // (WINVER >= 0x0600) #if (_WIN32_WINNT >= 0x0600) BOOL SetDropDownState(BOOL bDropDown) { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT((GetStyle() & (BS_SPLITBUTTON | BS_DEFSPLITBUTTON)) != 0); - return (BOOL)::SendMessage(m_hWnd, BCM_SETDROPDOWNSTATE, (WPARAM)bDropDown, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & (BS_SPLITBUTTON | BS_DEFSPLITBUTTON)) != 0); + return (BOOL)::SendMessage(this->m_hWnd, BCM_SETDROPDOWNSTATE, (WPARAM)bDropDown, 0L); } BOOL GetSplitInfo(PBUTTON_SPLITINFO pSplitInfo) const { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT((GetStyle() & (BS_SPLITBUTTON | BS_DEFSPLITBUTTON)) != 0); - return (BOOL)::SendMessage(m_hWnd, BCM_GETSPLITINFO, 0, (LPARAM)pSplitInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & (BS_SPLITBUTTON | BS_DEFSPLITBUTTON)) != 0); + return (BOOL)::SendMessage(this->m_hWnd, BCM_GETSPLITINFO, 0, (LPARAM)pSplitInfo); } BOOL SetSplitInfo(PBUTTON_SPLITINFO pSplitInfo) { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT((GetStyle() & (BS_SPLITBUTTON | BS_DEFSPLITBUTTON)) != 0); - return (BOOL)::SendMessage(m_hWnd, BCM_SETSPLITINFO, 0, (LPARAM)pSplitInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & (BS_SPLITBUTTON | BS_DEFSPLITBUTTON)) != 0); + return (BOOL)::SendMessage(this->m_hWnd, BCM_SETSPLITINFO, 0, (LPARAM)pSplitInfo); } int GetNoteLength() const { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT((GetStyle() & (BS_COMMANDLINK | BS_DEFCOMMANDLINK)) != 0); - return (int)::SendMessage(m_hWnd, BCM_GETNOTELENGTH, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & (BS_COMMANDLINK | BS_DEFCOMMANDLINK)) != 0); + return (int)::SendMessage(this->m_hWnd, BCM_GETNOTELENGTH, 0, 0L); } BOOL GetNote(LPWSTR lpstrNoteText, int cchNoteText) const { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT((GetStyle() & (BS_COMMANDLINK | BS_DEFCOMMANDLINK)) != 0); - return (BOOL)::SendMessage(m_hWnd, BCM_GETNOTE, cchNoteText, (LPARAM)lpstrNoteText); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & (BS_COMMANDLINK | BS_DEFCOMMANDLINK)) != 0); + return (BOOL)::SendMessage(this->m_hWnd, BCM_GETNOTE, cchNoteText, (LPARAM)lpstrNoteText); } BOOL SetNote(LPCWSTR lpstrNoteText) { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT((GetStyle() & (BS_COMMANDLINK | BS_DEFCOMMANDLINK)) != 0); - return (BOOL)::SendMessage(m_hWnd, BCM_SETNOTE, 0, (LPARAM)lpstrNoteText); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & (BS_COMMANDLINK | BS_DEFCOMMANDLINK)) != 0); + return (BOOL)::SendMessage(this->m_hWnd, BCM_SETNOTE, 0, (LPARAM)lpstrNoteText); } LRESULT SetElevationRequiredState(BOOL bSet) { - ATLASSERT(::IsWindow(m_hWnd)); - return ::SendMessage(m_hWnd, BCM_SETSHIELD, 0, (LPARAM)bSet); + ATLASSERT(::IsWindow(this->m_hWnd)); + return ::SendMessage(this->m_hWnd, BCM_SETSHIELD, 0, (LPARAM)bSet); } #endif // (_WIN32_WINNT >= 0x0600) // Operations void Click() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, BM_CLICK, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, BM_CLICK, 0, 0L); } }; @@ -401,7 +380,7 @@ public: CListBoxT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -421,186 +400,177 @@ public: // for entire listbox int GetCount() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LB_GETCOUNT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_GETCOUNT, 0, 0L); } -#ifndef _WIN32_WCE int SetCount(int cItems) { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT(((GetStyle() & LBS_NODATA) != 0) && ((GetStyle() & LBS_HASSTRINGS) == 0)); - return (int)::SendMessage(m_hWnd, LB_SETCOUNT, cItems, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(((this->GetStyle() & LBS_NODATA) != 0) && ((this->GetStyle() & LBS_HASSTRINGS) == 0)); + return (int)::SendMessage(this->m_hWnd, LB_SETCOUNT, cItems, 0L); } -#endif // !_WIN32_WCE int GetHorizontalExtent() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LB_GETHORIZONTALEXTENT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_GETHORIZONTALEXTENT, 0, 0L); } void SetHorizontalExtent(int cxExtent) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, LB_SETHORIZONTALEXTENT, cxExtent, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, LB_SETHORIZONTALEXTENT, cxExtent, 0L); } int GetTopIndex() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LB_GETTOPINDEX, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_GETTOPINDEX, 0, 0L); } int SetTopIndex(int nIndex) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LB_SETTOPINDEX, nIndex, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_SETTOPINDEX, nIndex, 0L); } LCID GetLocale() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (LCID)::SendMessage(m_hWnd, LB_GETLOCALE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (LCID)::SendMessage(this->m_hWnd, LB_GETLOCALE, 0, 0L); } LCID SetLocale(LCID nNewLocale) { - ATLASSERT(::IsWindow(m_hWnd)); - return (LCID)::SendMessage(m_hWnd, LB_SETLOCALE, (WPARAM)nNewLocale, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (LCID)::SendMessage(this->m_hWnd, LB_SETLOCALE, (WPARAM)nNewLocale, 0L); } -#if (WINVER >= 0x0500) && !defined(_WIN32_WCE) DWORD GetListBoxInfo() const { - ATLASSERT(::IsWindow(m_hWnd)); -#if (_WIN32_WINNT >= 0x0501) - return (DWORD)::SendMessage(m_hWnd, LB_GETLISTBOXINFO, 0, 0L); -#else // !(_WIN32_WINNT >= 0x0501) - return ::GetListBoxInfo(m_hWnd); -#endif // !(_WIN32_WINNT >= 0x0501) + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, LB_GETLISTBOXINFO, 0, 0L); } -#endif // (WINVER >= 0x0500) && !defined(_WIN32_WCE) // for single-selection listboxes int GetCurSel() const { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT((GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) == 0); - return (int)::SendMessage(m_hWnd, LB_GETCURSEL, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) == 0); + return (int)::SendMessage(this->m_hWnd, LB_GETCURSEL, 0, 0L); } int SetCurSel(int nSelect) { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT((GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) == 0); - return (int)::SendMessage(m_hWnd, LB_SETCURSEL, nSelect, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) == 0); + return (int)::SendMessage(this->m_hWnd, LB_SETCURSEL, nSelect, 0L); } // for multiple-selection listboxes int GetSel(int nIndex) const // also works for single-selection { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LB_GETSEL, nIndex, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_GETSEL, nIndex, 0L); } int SetSel(int nIndex, BOOL bSelect = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT((GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != 0); - return (int)::SendMessage(m_hWnd, LB_SETSEL, bSelect, nIndex); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != 0); + return (int)::SendMessage(this->m_hWnd, LB_SETSEL, bSelect, nIndex); } int GetSelCount() const { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT((GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != 0); - return (int)::SendMessage(m_hWnd, LB_GETSELCOUNT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != 0); + return (int)::SendMessage(this->m_hWnd, LB_GETSELCOUNT, 0, 0L); } int GetSelItems(int nMaxItems, LPINT rgIndex) const { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT((GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != 0); - return (int)::SendMessage(m_hWnd, LB_GETSELITEMS, nMaxItems, (LPARAM)rgIndex); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != 0); + return (int)::SendMessage(this->m_hWnd, LB_GETSELITEMS, nMaxItems, (LPARAM)rgIndex); } int GetAnchorIndex() const { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT((GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != 0); - return (int)::SendMessage(m_hWnd, LB_GETANCHORINDEX, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != 0); + return (int)::SendMessage(this->m_hWnd, LB_GETANCHORINDEX, 0, 0L); } void SetAnchorIndex(int nIndex) { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT((GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != 0); - ::SendMessage(m_hWnd, LB_SETANCHORINDEX, nIndex, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != 0); + ::SendMessage(this->m_hWnd, LB_SETANCHORINDEX, nIndex, 0L); } int GetCaretIndex() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LB_GETCARETINDEX, 0, 0); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_GETCARETINDEX, 0, 0); } int SetCaretIndex(int nIndex, BOOL bScroll = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LB_SETCARETINDEX, nIndex, MAKELONG(bScroll, 0)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_SETCARETINDEX, nIndex, MAKELONG(bScroll, 0)); } // for listbox items DWORD_PTR GetItemData(int nIndex) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD_PTR)::SendMessage(m_hWnd, LB_GETITEMDATA, nIndex, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD_PTR)::SendMessage(this->m_hWnd, LB_GETITEMDATA, nIndex, 0L); } int SetItemData(int nIndex, DWORD_PTR dwItemData) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LB_SETITEMDATA, nIndex, (LPARAM)dwItemData); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_SETITEMDATA, nIndex, (LPARAM)dwItemData); } void* GetItemDataPtr(int nIndex) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (void*)::SendMessage(m_hWnd, LB_GETITEMDATA, nIndex, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (void*)::SendMessage(this->m_hWnd, LB_GETITEMDATA, nIndex, 0L); } int SetItemDataPtr(int nIndex, void* pData) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); return SetItemData(nIndex, (DWORD_PTR)pData); } int GetItemRect(int nIndex, LPRECT lpRect) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LB_GETITEMRECT, nIndex, (LPARAM)lpRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_GETITEMRECT, nIndex, (LPARAM)lpRect); } int GetText(int nIndex, LPTSTR lpszBuffer) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LB_GETTEXT, nIndex, (LPARAM)lpszBuffer); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_GETTEXT, nIndex, (LPARAM)lpszBuffer); } -#ifndef _ATL_NO_COM #ifdef _OLEAUTO_H_ BOOL GetTextBSTR(int nIndex, BSTR& bstrText) const { USES_CONVERSION; - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(bstrText == NULL); int nLen = GetTextLen(nIndex); if(nLen == LB_ERR) return FALSE; - CTempBuffer buff; + ATL::CTempBuffer buff; LPTSTR lpstrText = buff.Allocate(nLen + 1); if(lpstrText == NULL) return FALSE; @@ -612,12 +582,11 @@ public: return (bstrText != NULL) ? TRUE : FALSE; } #endif // _OLEAUTO_H_ -#endif // !_ATL_NO_COM -#if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) - int GetText(int nIndex, _CSTRING_NS::CString& strText) const +#ifdef __ATLSTR_H__ + int GetText(int nIndex, ATL::CString& strText) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); int cchLen = GetTextLen(nIndex); if(cchLen == LB_ERR) return LB_ERR; @@ -630,71 +599,71 @@ public: } return nRet; } -#endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) +#endif // __ATLSTR_H__ int GetTextLen(int nIndex) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LB_GETTEXTLEN, nIndex, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_GETTEXTLEN, nIndex, 0L); } int GetItemHeight(int nIndex) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LB_GETITEMHEIGHT, nIndex, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_GETITEMHEIGHT, nIndex, 0L); } int SetItemHeight(int nIndex, UINT cyItemHeight) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LB_SETITEMHEIGHT, nIndex, MAKELONG(cyItemHeight, 0)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_SETITEMHEIGHT, nIndex, MAKELONG(cyItemHeight, 0)); } // Settable only attributes void SetColumnWidth(int cxWidth) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, LB_SETCOLUMNWIDTH, cxWidth, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, LB_SETCOLUMNWIDTH, cxWidth, 0L); } BOOL SetTabStops(int nTabStops, LPINT rgTabStops) { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT((GetStyle() & LBS_USETABSTOPS) != 0); - return (BOOL)::SendMessage(m_hWnd, LB_SETTABSTOPS, nTabStops, (LPARAM)rgTabStops); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & LBS_USETABSTOPS) != 0); + return (BOOL)::SendMessage(this->m_hWnd, LB_SETTABSTOPS, nTabStops, (LPARAM)rgTabStops); } BOOL SetTabStops() { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT((GetStyle() & LBS_USETABSTOPS) != 0); - return (BOOL)::SendMessage(m_hWnd, LB_SETTABSTOPS, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & LBS_USETABSTOPS) != 0); + return (BOOL)::SendMessage(this->m_hWnd, LB_SETTABSTOPS, 0, 0L); } BOOL SetTabStops(const int& cxEachStop) // takes an 'int' { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT((GetStyle() & LBS_USETABSTOPS) != 0); - return (BOOL)::SendMessage(m_hWnd, LB_SETTABSTOPS, 1, (LPARAM)(LPINT)&cxEachStop); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & LBS_USETABSTOPS) != 0); + return (BOOL)::SendMessage(this->m_hWnd, LB_SETTABSTOPS, 1, (LPARAM)(LPINT)&cxEachStop); } // Operations int InitStorage(int nItems, UINT nBytes) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LB_INITSTORAGE, (WPARAM)nItems, nBytes); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_INITSTORAGE, (WPARAM)nItems, nBytes); } void ResetContent() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, LB_RESETCONTENT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, LB_RESETCONTENT, 0, 0L); } UINT ItemFromPoint(POINT pt, BOOL& bOutside) const { - ATLASSERT(::IsWindow(m_hWnd)); - DWORD dw = (DWORD)::SendMessage(m_hWnd, LB_ITEMFROMPOINT, 0, MAKELPARAM(pt.x, pt.y)); + ATLASSERT(::IsWindow(this->m_hWnd)); + DWORD dw = (DWORD)::SendMessage(this->m_hWnd, LB_ITEMFROMPOINT, 0, MAKELPARAM(pt.x, pt.y)); bOutside = (BOOL)HIWORD(dw); return (UINT)LOWORD(dw); } @@ -702,74 +671,60 @@ public: // manipulating listbox items int AddString(LPCTSTR lpszItem) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LB_ADDSTRING, 0, (LPARAM)lpszItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_ADDSTRING, 0, (LPARAM)lpszItem); } int DeleteString(UINT nIndex) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LB_DELETESTRING, nIndex, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_DELETESTRING, nIndex, 0L); } int InsertString(int nIndex, LPCTSTR lpszItem) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LB_INSERTSTRING, nIndex, (LPARAM)lpszItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_INSERTSTRING, nIndex, (LPARAM)lpszItem); } -#ifndef _WIN32_WCE int Dir(UINT attr, LPCTSTR lpszWildCard) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LB_DIR, attr, (LPARAM)lpszWildCard); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_DIR, attr, (LPARAM)lpszWildCard); } int AddFile(LPCTSTR lpstrFileName) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LB_ADDFILE, 0, (LPARAM)lpstrFileName); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_ADDFILE, 0, (LPARAM)lpstrFileName); } -#endif // !_WIN32_WCE // selection helpers int FindString(int nStartAfter, LPCTSTR lpszItem) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LB_FINDSTRING, nStartAfter, (LPARAM)lpszItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_FINDSTRING, nStartAfter, (LPARAM)lpszItem); } int FindStringExact(int nIndexStart, LPCTSTR lpszFind) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LB_FINDSTRINGEXACT, nIndexStart, (LPARAM)lpszFind); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_FINDSTRINGEXACT, nIndexStart, (LPARAM)lpszFind); } int SelectString(int nStartAfter, LPCTSTR lpszItem) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LB_SELECTSTRING, nStartAfter, (LPARAM)lpszItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_SELECTSTRING, nStartAfter, (LPARAM)lpszItem); } int SelItemRange(BOOL bSelect, int nFirstItem, int nLastItem) { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT((GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != 0); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != 0); ATLASSERT(nFirstItem <= nLastItem); - return bSelect ? (int)::SendMessage(m_hWnd, LB_SELITEMRANGEEX, nFirstItem, nLastItem) : (int)::SendMessage(m_hWnd, LB_SELITEMRANGEEX, nLastItem, nFirstItem); - } - -#ifdef WIN32_PLATFORM_WFSP // SmartPhone only messages - DWORD GetInputMode(BOOL bCurrentMode = TRUE) - { - return SendMessage(LB_GETINPUTMODE, 0, (LPARAM)bCurrentMode); + return bSelect ? (int)::SendMessage(this->m_hWnd, LB_SELITEMRANGEEX, nFirstItem, nLastItem) : (int)::SendMessage(this->m_hWnd, LB_SELITEMRANGEEX, nLastItem, nFirstItem); } - - BOOL SetInputMode(DWORD dwMode) - { - return SendMessage(LB_SETINPUTMODE, 0, (LPARAM)dwMode); - } -#endif // WIN32_PLATFORM_WFSP }; typedef CListBoxT CListBox; @@ -778,8 +733,6 @@ typedef CListBoxT CListBox; /////////////////////////////////////////////////////////////////////////////// // CComboBox - client side for a Windows COMBOBOX control -#ifndef WIN32_PLATFORM_WFSP // No COMBOBOX on SmartPhones - template class CComboBoxT : public TBase { @@ -790,7 +743,7 @@ public: CComboBoxT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -810,138 +763,131 @@ public: // for entire combo box int GetCount() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, CB_GETCOUNT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_GETCOUNT, 0, 0L); } int GetCurSel() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, CB_GETCURSEL, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_GETCURSEL, 0, 0L); } int SetCurSel(int nSelect) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, CB_SETCURSEL, nSelect, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_SETCURSEL, nSelect, 0L); } LCID GetLocale() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (LCID)::SendMessage(m_hWnd, CB_GETLOCALE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (LCID)::SendMessage(this->m_hWnd, CB_GETLOCALE, 0, 0L); } LCID SetLocale(LCID nNewLocale) { - ATLASSERT(::IsWindow(m_hWnd)); - return (LCID)::SendMessage(m_hWnd, CB_SETLOCALE, (WPARAM)nNewLocale, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (LCID)::SendMessage(this->m_hWnd, CB_SETLOCALE, (WPARAM)nNewLocale, 0L); } int GetTopIndex() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, CB_GETTOPINDEX, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_GETTOPINDEX, 0, 0L); } int SetTopIndex(int nIndex) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, CB_SETTOPINDEX, nIndex, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_SETTOPINDEX, nIndex, 0L); } UINT GetHorizontalExtent() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (UINT)::SendMessage(m_hWnd, CB_GETHORIZONTALEXTENT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, CB_GETHORIZONTALEXTENT, 0, 0L); } void SetHorizontalExtent(UINT nExtent) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, CB_SETHORIZONTALEXTENT, nExtent, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, CB_SETHORIZONTALEXTENT, nExtent, 0L); } int GetDroppedWidth() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, CB_GETDROPPEDWIDTH, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_GETDROPPEDWIDTH, 0, 0L); } int SetDroppedWidth(UINT nWidth) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, CB_SETDROPPEDWIDTH, nWidth, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_SETDROPPEDWIDTH, nWidth, 0L); } -#if ((WINVER >= 0x0500) && !defined(_WIN32_WCE)) || (defined(_WIN32_WCE) && (_WIN32_WCE >= 420)) BOOL GetComboBoxInfo(PCOMBOBOXINFO pComboBoxInfo) const { - ATLASSERT(::IsWindow(m_hWnd)); -#if ((_WIN32_WINNT >= 0x0501) && !defined(_WIN32_WCE)) || (defined(_WIN32_WCE) && (_WIN32_WCE >= 420)) - return (BOOL)::SendMessage(m_hWnd, CB_GETCOMBOBOXINFO, 0, (LPARAM)pComboBoxInfo); -#else // !((_WIN32_WINNT >= 0x0501) && !defined(_WIN32_WCE)) || (defined(_WIN32_WCE) && (_WIN32_WCE >= 420)) - return ::GetComboBoxInfo(m_hWnd, pComboBoxInfo); -#endif // !((_WIN32_WINNT >= 0x0501) && !defined(_WIN32_WCE)) || (defined(_WIN32_WCE) && (_WIN32_WCE >= 420)) + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, CB_GETCOMBOBOXINFO, 0, (LPARAM)pComboBoxInfo); } -#endif // ((WINVER >= 0x0500) && !defined(_WIN32_WCE)) || (defined(_WIN32_WCE) && (_WIN32_WCE >= 420)) // for edit control DWORD GetEditSel() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, CB_GETEDITSEL, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, CB_GETEDITSEL, 0, 0L); } BOOL SetEditSel(int nStartChar, int nEndChar) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, CB_SETEDITSEL, 0, MAKELONG(nStartChar, nEndChar)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, CB_SETEDITSEL, 0, MAKELONG(nStartChar, nEndChar)); } // for combobox item DWORD_PTR GetItemData(int nIndex) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD_PTR)::SendMessage(m_hWnd, CB_GETITEMDATA, nIndex, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD_PTR)::SendMessage(this->m_hWnd, CB_GETITEMDATA, nIndex, 0L); } int SetItemData(int nIndex, DWORD_PTR dwItemData) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, CB_SETITEMDATA, nIndex, (LPARAM)dwItemData); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_SETITEMDATA, nIndex, (LPARAM)dwItemData); } void* GetItemDataPtr(int nIndex) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); return (void*)GetItemData(nIndex); } int SetItemDataPtr(int nIndex, void* pData) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); return SetItemData(nIndex, (DWORD_PTR)pData); } int GetLBText(int nIndex, LPTSTR lpszText) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, CB_GETLBTEXT, nIndex, (LPARAM)lpszText); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_GETLBTEXT, nIndex, (LPARAM)lpszText); } -#ifndef _ATL_NO_COM BOOL GetLBTextBSTR(int nIndex, BSTR& bstrText) const { USES_CONVERSION; - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(bstrText == NULL); int nLen = GetLBTextLen(nIndex); if(nLen == CB_ERR) return FALSE; - CTempBuffer buff; + ATL::CTempBuffer buff; LPTSTR lpstrText = buff.Allocate(nLen + 1); if(lpstrText == NULL) return FALSE; @@ -952,12 +898,11 @@ public: bstrText = ::SysAllocString(T2OLE(lpstrText)); return (bstrText != NULL) ? TRUE : FALSE; } -#endif // !_ATL_NO_COM -#if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) - int GetLBText(int nIndex, _CSTRING_NS::CString& strText) const +#ifdef __ATLSTR_H__ + int GetLBText(int nIndex, ATL::CString& strText) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); int cchLen = GetLBTextLen(nIndex); if(cchLen == CB_ERR) return CB_ERR; @@ -970,186 +915,175 @@ public: } return nRet; } -#endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) +#endif // __ATLSTR_H__ int GetLBTextLen(int nIndex) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, CB_GETLBTEXTLEN, nIndex, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_GETLBTEXTLEN, nIndex, 0L); } int GetItemHeight(int nIndex) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, CB_GETITEMHEIGHT, nIndex, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_GETITEMHEIGHT, nIndex, 0L); } int SetItemHeight(int nIndex, UINT cyItemHeight) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, CB_SETITEMHEIGHT, nIndex, MAKELONG(cyItemHeight, 0)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_SETITEMHEIGHT, nIndex, MAKELONG(cyItemHeight, 0)); } BOOL GetExtendedUI() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, CB_GETEXTENDEDUI, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, CB_GETEXTENDEDUI, 0, 0L); } int SetExtendedUI(BOOL bExtended = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, CB_SETEXTENDEDUI, bExtended, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_SETEXTENDEDUI, bExtended, 0L); } void GetDroppedControlRect(LPRECT lprect) const { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, CB_GETDROPPEDCONTROLRECT, 0, (LPARAM)lprect); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, CB_GETDROPPEDCONTROLRECT, 0, (LPARAM)lprect); } BOOL GetDroppedState() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, CB_GETDROPPEDSTATE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, CB_GETDROPPEDSTATE, 0, 0L); } -#if (_WIN32_WINNT >= 0x0501) int GetMinVisible() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, CB_GETMINVISIBLE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_GETMINVISIBLE, 0, 0L); } BOOL SetMinVisible(int nMinVisible) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, CB_SETMINVISIBLE, nMinVisible, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, CB_SETMINVISIBLE, nMinVisible, 0L); } // Vista only BOOL GetCueBannerText(LPWSTR lpwText, int cchText) const { -#ifndef CB_GETCUEBANNER - const UINT CB_GETCUEBANNER = (CBM_FIRST + 4); -#endif - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, CB_GETCUEBANNER, (WPARAM)lpwText, cchText); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, CB_GETCUEBANNER, (WPARAM)lpwText, cchText); } // Vista only BOOL SetCueBannerText(LPCWSTR lpcwText) { -#ifndef CB_SETCUEBANNER - const UINT CB_SETCUEBANNER = (CBM_FIRST + 3); -#endif - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, CB_SETCUEBANNER, 0, (LPARAM)lpcwText); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, CB_SETCUEBANNER, 0, (LPARAM)lpcwText); } -#endif // (_WIN32_WINNT >= 0x0501) // Operations int InitStorage(int nItems, UINT nBytes) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, CB_INITSTORAGE, (WPARAM)nItems, nBytes); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_INITSTORAGE, (WPARAM)nItems, nBytes); } void ResetContent() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, CB_RESETCONTENT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, CB_RESETCONTENT, 0, 0L); } // for edit control BOOL LimitText(int nMaxChars) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, CB_LIMITTEXT, nMaxChars, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, CB_LIMITTEXT, nMaxChars, 0L); } // for drop-down combo boxes void ShowDropDown(BOOL bShowIt = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, CB_SHOWDROPDOWN, bShowIt, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, CB_SHOWDROPDOWN, bShowIt, 0L); } // manipulating listbox items int AddString(LPCTSTR lpszString) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, CB_ADDSTRING, 0, (LPARAM)lpszString); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_ADDSTRING, 0, (LPARAM)lpszString); } int DeleteString(UINT nIndex) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, CB_DELETESTRING, nIndex, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_DELETESTRING, nIndex, 0L); } int InsertString(int nIndex, LPCTSTR lpszString) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, CB_INSERTSTRING, nIndex, (LPARAM)lpszString); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_INSERTSTRING, nIndex, (LPARAM)lpszString); } -#ifndef _WIN32_WCE int Dir(UINT attr, LPCTSTR lpszWildCard) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, CB_DIR, attr, (LPARAM)lpszWildCard); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_DIR, attr, (LPARAM)lpszWildCard); } -#endif // !_WIN32_WCE // selection helpers int FindString(int nStartAfter, LPCTSTR lpszString) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, CB_FINDSTRING, nStartAfter, (LPARAM)lpszString); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_FINDSTRING, nStartAfter, (LPARAM)lpszString); } int FindStringExact(int nIndexStart, LPCTSTR lpszFind) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, CB_FINDSTRINGEXACT, nIndexStart, (LPARAM)lpszFind); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_FINDSTRINGEXACT, nIndexStart, (LPARAM)lpszFind); } int SelectString(int nStartAfter, LPCTSTR lpszString) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, CB_SELECTSTRING, nStartAfter, (LPARAM)lpszString); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_SELECTSTRING, nStartAfter, (LPARAM)lpszString); } // Clipboard operations void Clear() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, WM_CLEAR, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, WM_CLEAR, 0, 0L); } void Copy() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, WM_COPY, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, WM_COPY, 0, 0L); } void Cut() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, WM_CUT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, WM_CUT, 0, 0L); } void Paste() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, WM_PASTE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, WM_PASTE, 0, 0L); } }; typedef CComboBoxT CComboBox; -#endif // !WIN32_PLATFORM_WFSP /////////////////////////////////////////////////////////////////////////////// // CEdit - client side for a Windows EDIT control @@ -1164,7 +1098,7 @@ public: CEditT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -1183,104 +1117,102 @@ public: BOOL CanUndo() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_CANUNDO, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_CANUNDO, 0, 0L); } int GetLineCount() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, EM_GETLINECOUNT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, EM_GETLINECOUNT, 0, 0L); } BOOL GetModify() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_GETMODIFY, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_GETMODIFY, 0, 0L); } void SetModify(BOOL bModified = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_SETMODIFY, bModified, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SETMODIFY, bModified, 0L); } void GetRect(LPRECT lpRect) const { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_GETRECT, 0, (LPARAM)lpRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_GETRECT, 0, (LPARAM)lpRect); } DWORD GetSel() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, EM_GETSEL, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, EM_GETSEL, 0, 0L); } void GetSel(int& nStartChar, int& nEndChar) const { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_GETSEL, (WPARAM)&nStartChar, (LPARAM)&nEndChar); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_GETSEL, (WPARAM)&nStartChar, (LPARAM)&nEndChar); } -#ifndef _WIN32_WCE HLOCAL GetHandle() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (HLOCAL)::SendMessage(m_hWnd, EM_GETHANDLE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HLOCAL)::SendMessage(this->m_hWnd, EM_GETHANDLE, 0, 0L); } void SetHandle(HLOCAL hBuffer) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_SETHANDLE, (WPARAM)hBuffer, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SETHANDLE, (WPARAM)hBuffer, 0L); } -#endif // !_WIN32_WCE DWORD GetMargins() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, EM_GETMARGINS, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, EM_GETMARGINS, 0, 0L); } void GetMargins(UINT& nLeft, UINT& nRight) const { - ATLASSERT(::IsWindow(m_hWnd)); - DWORD dwRet = (DWORD)::SendMessage(m_hWnd, EM_GETMARGINS, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, EM_GETMARGINS, 0, 0L); nLeft = LOWORD(dwRet); nRight = HIWORD(dwRet); } void SetMargins(UINT nLeft, UINT nRight, WORD wFlags = EC_LEFTMARGIN | EC_RIGHTMARGIN) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_SETMARGINS, wFlags, MAKELONG(nLeft, nRight)); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SETMARGINS, wFlags, MAKELONG(nLeft, nRight)); } UINT GetLimitText() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (UINT)::SendMessage(m_hWnd, EM_GETLIMITTEXT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, EM_GETLIMITTEXT, 0, 0L); } void SetLimitText(UINT nMax) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_SETLIMITTEXT, nMax, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SETLIMITTEXT, nMax, 0L); } POINT PosFromChar(UINT nChar) const { - ATLASSERT(::IsWindow(m_hWnd)); - DWORD dwRet = (DWORD)::SendMessage(m_hWnd, EM_POSFROMCHAR, nChar, 0); + ATLASSERT(::IsWindow(this->m_hWnd)); + DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, EM_POSFROMCHAR, nChar, 0); POINT point = { GET_X_LPARAM(dwRet), GET_Y_LPARAM(dwRet) }; return point; } int CharFromPos(POINT pt, int* pLine = NULL) const { - ATLASSERT(::IsWindow(m_hWnd)); - DWORD dwRet = (DWORD)::SendMessage(m_hWnd, EM_CHARFROMPOS, 0, MAKELPARAM(pt.x, pt.y)); + ATLASSERT(::IsWindow(this->m_hWnd)); + DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, EM_CHARFROMPOS, 0, MAKELPARAM(pt.x, pt.y)); if(pLine != NULL) *pLine = (int)(short)HIWORD(dwRet); return (int)(short)LOWORD(dwRet); @@ -1289,168 +1221,160 @@ public: // NOTE: first word in lpszBuffer must contain the size of the buffer! int GetLine(int nIndex, LPTSTR lpszBuffer) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, EM_GETLINE, nIndex, (LPARAM)lpszBuffer); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, EM_GETLINE, nIndex, (LPARAM)lpszBuffer); } int GetLine(int nIndex, LPTSTR lpszBuffer, int nMaxLength) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); *(LPWORD)lpszBuffer = (WORD)nMaxLength; - return (int)::SendMessage(m_hWnd, EM_GETLINE, nIndex, (LPARAM)lpszBuffer); + return (int)::SendMessage(this->m_hWnd, EM_GETLINE, nIndex, (LPARAM)lpszBuffer); } TCHAR GetPasswordChar() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (TCHAR)::SendMessage(m_hWnd, EM_GETPASSWORDCHAR, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (TCHAR)::SendMessage(this->m_hWnd, EM_GETPASSWORDCHAR, 0, 0L); } void SetPasswordChar(TCHAR ch) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_SETPASSWORDCHAR, ch, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SETPASSWORDCHAR, ch, 0L); } -#ifndef _WIN32_WCE EDITWORDBREAKPROC GetWordBreakProc() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (EDITWORDBREAKPROC)::SendMessage(m_hWnd, EM_GETWORDBREAKPROC, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (EDITWORDBREAKPROC)::SendMessage(this->m_hWnd, EM_GETWORDBREAKPROC, 0, 0L); } void SetWordBreakProc(EDITWORDBREAKPROC ewbprc) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_SETWORDBREAKPROC, 0, (LPARAM)ewbprc); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SETWORDBREAKPROC, 0, (LPARAM)ewbprc); } -#endif // !_WIN32_WCE int GetFirstVisibleLine() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, EM_GETFIRSTVISIBLELINE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, EM_GETFIRSTVISIBLELINE, 0, 0L); } -#ifndef _WIN32_WCE int GetThumb() const { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT((GetStyle() & ES_MULTILINE) != 0); - return (int)::SendMessage(m_hWnd, EM_GETTHUMB, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & ES_MULTILINE) != 0); + return (int)::SendMessage(this->m_hWnd, EM_GETTHUMB, 0, 0L); } -#endif // !_WIN32_WCE BOOL SetReadOnly(BOOL bReadOnly = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_SETREADONLY, bReadOnly, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETREADONLY, bReadOnly, 0L); } -#if (WINVER >= 0x0500) && !defined(_WIN32_WCE) UINT GetImeStatus(UINT uStatus) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (UINT)::SendMessage(m_hWnd, EM_GETIMESTATUS, uStatus, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, EM_GETIMESTATUS, uStatus, 0L); } UINT SetImeStatus(UINT uStatus, UINT uData) { - ATLASSERT(::IsWindow(m_hWnd)); - return (UINT)::SendMessage(m_hWnd, EM_SETIMESTATUS, uStatus, uData); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, EM_SETIMESTATUS, uStatus, uData); } -#endif // (WINVER >= 0x0500) && !defined(_WIN32_WCE) -#if (_WIN32_WINNT >= 0x0501) BOOL GetCueBannerText(LPCWSTR lpstrText, int cchText) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_GETCUEBANNER, (WPARAM)lpstrText, cchText); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_GETCUEBANNER, (WPARAM)lpstrText, cchText); } // bKeepWithFocus - Vista only BOOL SetCueBannerText(LPCWSTR lpstrText, BOOL bKeepWithFocus = FALSE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_SETCUEBANNER, (WPARAM)bKeepWithFocus, (LPARAM)(lpstrText)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETCUEBANNER, (WPARAM)bKeepWithFocus, (LPARAM)(lpstrText)); } -#endif // (_WIN32_WINNT >= 0x0501) // Operations void EmptyUndoBuffer() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_EMPTYUNDOBUFFER, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_EMPTYUNDOBUFFER, 0, 0L); } BOOL FmtLines(BOOL bAddEOL) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_FMTLINES, bAddEOL, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_FMTLINES, bAddEOL, 0L); } void LimitText(int nChars = 0) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_LIMITTEXT, nChars, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_LIMITTEXT, nChars, 0L); } int LineFromChar(int nIndex = -1) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, EM_LINEFROMCHAR, nIndex, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, EM_LINEFROMCHAR, nIndex, 0L); } int LineIndex(int nLine = -1) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, EM_LINEINDEX, nLine, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, EM_LINEINDEX, nLine, 0L); } int LineLength(int nLine = -1) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, EM_LINELENGTH, nLine, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, EM_LINELENGTH, nLine, 0L); } void LineScroll(int nLines, int nChars = 0) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_LINESCROLL, nChars, nLines); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_LINESCROLL, nChars, nLines); } void ReplaceSel(LPCTSTR lpszNewText, BOOL bCanUndo = FALSE) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_REPLACESEL, (WPARAM) bCanUndo, (LPARAM)lpszNewText); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_REPLACESEL, (WPARAM) bCanUndo, (LPARAM)lpszNewText); } void SetRect(LPCRECT lpRect) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_SETRECT, 0, (LPARAM)lpRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SETRECT, 0, (LPARAM)lpRect); } void SetRectNP(LPCRECT lpRect) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_SETRECTNP, 0, (LPARAM)lpRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SETRECTNP, 0, (LPARAM)lpRect); } void SetSel(DWORD dwSelection, BOOL bNoScroll = FALSE) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_SETSEL, LOWORD(dwSelection), HIWORD(dwSelection)); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SETSEL, LOWORD(dwSelection), HIWORD(dwSelection)); if(!bNoScroll) - ::SendMessage(m_hWnd, EM_SCROLLCARET, 0, 0L); + ::SendMessage(this->m_hWnd, EM_SCROLLCARET, 0, 0L); } void SetSel(int nStartChar, int nEndChar, BOOL bNoScroll = FALSE) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_SETSEL, nStartChar, nEndChar); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SETSEL, nStartChar, nEndChar); if(!bNoScroll) - ::SendMessage(m_hWnd, EM_SCROLLCARET, 0, 0L); + ::SendMessage(this->m_hWnd, EM_SCROLLCARET, 0, 0L); } void SetSelAll(BOOL bNoScroll = FALSE) @@ -1465,33 +1389,33 @@ public: BOOL SetTabStops(int nTabStops, LPINT rgTabStops) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_SETTABSTOPS, nTabStops, (LPARAM)rgTabStops); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETTABSTOPS, nTabStops, (LPARAM)rgTabStops); } BOOL SetTabStops() { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_SETTABSTOPS, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETTABSTOPS, 0, 0L); } BOOL SetTabStops(const int& cxEachStop) // takes an 'int' { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_SETTABSTOPS, 1, (LPARAM)(LPINT)&cxEachStop); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETTABSTOPS, 1, (LPARAM)(LPINT)&cxEachStop); } void ScrollCaret() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_SCROLLCARET, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SCROLLCARET, 0, 0L); } int Scroll(int nScrollAction) { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT((GetStyle() & ES_MULTILINE) != 0); - LRESULT lRet = ::SendMessage(m_hWnd, EM_SCROLL, nScrollAction, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & ES_MULTILINE) != 0); + LRESULT lRet = ::SendMessage(this->m_hWnd, EM_SCROLL, nScrollAction, 0L); if(!(BOOL)HIWORD(lRet)) return -1; // failed return (int)(short)LOWORD(lRet); @@ -1506,107 +1430,190 @@ public: void AppendText(LPCTSTR lpstrText, BOOL bNoScroll = FALSE, BOOL bCanUndo = FALSE) { - InsertText(GetWindowTextLength(), lpstrText, bNoScroll, bCanUndo); + InsertText(this->GetWindowTextLength(), lpstrText, bNoScroll, bCanUndo); } -#if (_WIN32_WINNT >= 0x0501) BOOL ShowBalloonTip(PEDITBALLOONTIP pEditBaloonTip) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_SHOWBALLOONTIP, 0, (LPARAM)pEditBaloonTip); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SHOWBALLOONTIP, 0, (LPARAM)pEditBaloonTip); } BOOL HideBalloonTip() { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_HIDEBALLOONTIP, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_HIDEBALLOONTIP, 0, 0L); } -#endif // (_WIN32_WINNT >= 0x0501) #if (_WIN32_WINNT >= 0x0600) DWORD GetHilite() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, EM_GETHILITE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, EM_GETHILITE, 0, 0L); } void GetHilite(int& nStartChar, int& nEndChar) const { - ATLASSERT(::IsWindow(m_hWnd)); - DWORD dwRet = (DWORD)::SendMessage(m_hWnd, EM_GETHILITE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, EM_GETHILITE, 0, 0L); nStartChar = (int)(short)LOWORD(dwRet); nEndChar = (int)(short)HIWORD(dwRet); } void SetHilite(int nStartChar, int nEndChar) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_SETHILITE, nStartChar, nEndChar); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SETHILITE, nStartChar, nEndChar); } #endif // (_WIN32_WINNT >= 0x0600) // Clipboard operations BOOL Undo() { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_UNDO, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_UNDO, 0, 0L); } void Clear() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, WM_CLEAR, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, WM_CLEAR, 0, 0L); } void Copy() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, WM_COPY, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, WM_COPY, 0, 0L); } void Cut() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, WM_CUT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, WM_CUT, 0, 0L); } void Paste() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, WM_PASTE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, WM_PASTE, 0, 0L); + } + + // New messages added in Windows 10.0.17763 +#if defined(NTDDI_VERSION) && defined(NTDDI_WIN10_RS5) && (NTDDI_VERSION >= NTDDI_WIN10_RS5) + DWORD SetExtendedStyle(DWORD dwStyle, DWORD dwMask) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return ::SendMessage(this->m_hWnd, EM_SETEXTENDEDSTYLE, dwMask, dwStyle); + } + + DWORD GetExtendedStyle() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return ::SendMessage(this->m_hWnd, EM_GETEXTENDEDSTYLE, 0, 0L); + } + + BOOL SetEndOfLine(EC_ENDOFLINE eolType) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETENDOFLINE, eolType, 0L); + } + + EC_ENDOFLINE GetEndOfLine() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (EC_ENDOFLINE)::SendMessage(this->m_hWnd, EM_GETENDOFLINE, 0, 0L); + } + + BOOL EnableSearchWeb(BOOL bEnable) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_ENABLESEARCHWEB, (WPARAM)bEnable, 0L); + } + + void SearchWeb() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SEARCHWEB, 0, 0L); + } + + BOOL SetCaretIndex(DWORD dwCaretIndex) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETCARETINDEX, dwCaretIndex, 0L); + } + + DWORD GetCaretIndex() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return ::SendMessage(this->m_hWnd, EM_GETCARETINDEX, 0, 0L); + } + + BOOL GetZoom(int& nNum, int& nDen) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_GETZOOM, (WPARAM)&nNum, (LPARAM)&nDen); + } + + BOOL SetZoom(int nNum, int nDen) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((nNum >= 0) && (nNum <= 64)); + ATLASSERT((nDen >= 0) && (nDen <= 64)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETZOOM, nNum, nDen); } -#ifdef WIN32_PLATFORM_WFSP // SmartPhone only messages - DWORD GetExtendedStyle() + DWORD GetFileLineFromChar(DWORD dwCharIndex) const { - return SendMessage(EM_GETEXTENDEDSTYLE); + ATLASSERT(::IsWindow(this->m_hWnd)); + return ::SendMessage(this->m_hWnd, EM_FILELINEFROMCHAR, dwCharIndex, 0L); } - DWORD SetExtendedStyle(DWORD dwMask, DWORD dwExStyle) + DWORD GetFileLineIndex(DWORD dwLineNum) const { - return SendMessage(EM_SETEXTENDEDSTYLE, (WPARAM)dwMask, (LPARAM)dwExStyle); + ATLASSERT(::IsWindow(this->m_hWnd)); + return ::SendMessage(this->m_hWnd, EM_FILELINEINDEX, dwLineNum, 0L); } - DWORD GetInputMode(BOOL bCurrentMode = TRUE) + DWORD GetFileLineLength(DWORD dwCharIndex) const { - return SendMessage(EM_GETINPUTMODE, 0, (LPARAM)bCurrentMode); + ATLASSERT(::IsWindow(this->m_hWnd)); + return ::SendMessage(this->m_hWnd, EM_FILELINELENGTH, dwCharIndex, 0L); } - BOOL SetInputMode(DWORD dwMode) + DWORD GetFileLine(DWORD dwLineNum, LPTSTR lpstrLine, WORD wLen) const { - return SendMessage(EM_SETINPUTMODE, 0, (LPARAM)dwMode); + ATLASSERT(::IsWindow(this->m_hWnd)); + WORD* pw = (WORD*)lpstrLine; + *pw = wLen; + return ::SendMessage(this->m_hWnd, EM_GETFILELINE, dwLineNum, (LPARAM)lpstrLine); } - BOOL SetSymbols(LPCTSTR szSymbols) +#ifdef __ATLSTR_H__ + ATL::CString GetFileLine(DWORD dwLineNum) const { - return SendMessage(EM_SETSYMBOLS, 0, (LPARAM)szSymbols); + ATL::CString strLine; + DWORD dwCharIndex = GetFileLineIndex(dwLineNum); + if(dwCharIndex != (DWORD)-1) + { + DWORD dwLen = GetFileLineLength(dwCharIndex); + if(dwLen > 0) + { + LPTSTR lpstrLine = strLine.GetBufferSetLength(dwLen); + ATLVERIFY(GetFileLine(dwLineNum, lpstrLine, (WORD)dwLen) == dwLen); + strLine.ReleaseBuffer(); + } + } + + return strLine; } +#endif // __ATLSTR_H__ - BOOL ResetSymbols() + DWORD GetFileLineCount() const { - return SendMessage(EM_SETSYMBOLS); + ATLASSERT(::IsWindow(this->m_hWnd)); + return ::SendMessage(this->m_hWnd, EM_GETFILELINECOUNT, 0, 0L); } -#endif // WIN32_PLATFORM_WFSP +#endif // defined(NTDDI_VERSION) && defined(NTDDI_WIN10_RS5) && (NTDDI_VERSION >= NTDDI_WIN10_RS5) }; typedef CEditT CEdit; @@ -1748,7 +1755,7 @@ public: CScrollBarT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -1765,82 +1772,70 @@ public: return _T("SCROLLBAR"); } -#ifndef _WIN32_WCE int GetScrollPos() const { - ATLASSERT(::IsWindow(m_hWnd)); - return ::GetScrollPos(m_hWnd, SB_CTL); + ATLASSERT(::IsWindow(this->m_hWnd)); + return ::GetScrollPos(this->m_hWnd, SB_CTL); } -#endif // !_WIN32_WCE int SetScrollPos(int nPos, BOOL bRedraw = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return ::SetScrollPos(m_hWnd, SB_CTL, nPos, bRedraw); + ATLASSERT(::IsWindow(this->m_hWnd)); + return ::SetScrollPos(this->m_hWnd, SB_CTL, nPos, bRedraw); } -#ifndef _WIN32_WCE void GetScrollRange(LPINT lpMinPos, LPINT lpMaxPos) const { - ATLASSERT(::IsWindow(m_hWnd)); - ::GetScrollRange(m_hWnd, SB_CTL, lpMinPos, lpMaxPos); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::GetScrollRange(this->m_hWnd, SB_CTL, lpMinPos, lpMaxPos); } -#endif // !_WIN32_WCE void SetScrollRange(int nMinPos, int nMaxPos, BOOL bRedraw = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SetScrollRange(m_hWnd, SB_CTL, nMinPos, nMaxPos, bRedraw); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SetScrollRange(this->m_hWnd, SB_CTL, nMinPos, nMaxPos, bRedraw); } BOOL GetScrollInfo(LPSCROLLINFO lpScrollInfo) const { - ATLASSERT(::IsWindow(m_hWnd)); - return ::GetScrollInfo(m_hWnd, SB_CTL, lpScrollInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + return ::GetScrollInfo(this->m_hWnd, SB_CTL, lpScrollInfo); } int SetScrollInfo(LPSCROLLINFO lpScrollInfo, BOOL bRedraw = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return ::SetScrollInfo(m_hWnd, SB_CTL, lpScrollInfo, bRedraw); + ATLASSERT(::IsWindow(this->m_hWnd)); + return ::SetScrollInfo(this->m_hWnd, SB_CTL, lpScrollInfo, bRedraw); } -#ifndef _WIN32_WCE int GetScrollLimit() const { SCROLLINFO info = { sizeof(SCROLLINFO), SIF_RANGE | SIF_PAGE }; - ::GetScrollInfo(m_hWnd, SB_CTL, &info); + ::GetScrollInfo(this->m_hWnd, SB_CTL, &info); if(info.nPage > 1) info.nMax -= info.nPage - 1; return info.nMax; } -#if (WINVER >= 0x0500) BOOL GetScrollBarInfo(PSCROLLBARINFO pScrollBarInfo) const { - ATLASSERT(::IsWindow(m_hWnd)); -#if (_WIN32_WINNT >= 0x0501) - return (BOOL)::SendMessage(m_hWnd, SBM_GETSCROLLBARINFO, 0, (LPARAM)pScrollBarInfo); -#else // !(_WIN32_WINNT >= 0x0501) - return ::GetScrollBarInfo(m_hWnd, OBJID_CLIENT, pScrollBarInfo); -#endif // !(_WIN32_WINNT >= 0x0501) + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, SBM_GETSCROLLBARINFO, 0, (LPARAM)pScrollBarInfo); } -#endif // (WINVER >= 0x0500) // Operations void ShowScrollBar(BOOL bShow = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - ::ShowScrollBar(m_hWnd, SB_CTL, bShow); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::ShowScrollBar(this->m_hWnd, SB_CTL, bShow); } BOOL EnableScrollBar(UINT nArrowFlags = ESB_ENABLE_BOTH) { - ATLASSERT(::IsWindow(m_hWnd)); - return ::EnableScrollBar(m_hWnd, SB_CTL, nArrowFlags); + ATLASSERT(::IsWindow(this->m_hWnd)); + return ::EnableScrollBar(this->m_hWnd, SB_CTL, nArrowFlags); } -#endif // !_WIN32_WCE }; typedef CScrollBarT CScrollBar; @@ -1994,7 +1989,6 @@ public: return (m_hImageList != NULL) ? TRUE : FALSE; } -#ifndef _WIN32_WCE #ifdef __IStream_INTERFACE_DEFINED__ BOOL CreateFromStream(LPSTREAM lpStream) { @@ -2003,7 +1997,6 @@ public: return (m_hImageList != NULL) ? TRUE : FALSE; } #endif // __IStream_INTERFACE_DEFINED__ -#endif // !_WIN32_WCE BOOL Destroy() { @@ -2103,7 +2096,6 @@ public: } #ifdef __IStream_INTERFACE_DEFINED__ -#ifndef _WIN32_WCE static HIMAGELIST Read(LPSTREAM lpStream) { return ImageList_Read(lpStream); @@ -2114,9 +2106,7 @@ public: ATLASSERT(m_hImageList != NULL); return ImageList_Write(m_hImageList, lpStream); } -#endif // !_WIN32_WCE -#if (_WIN32_WINNT >= 0x0501) static HRESULT ReadEx(DWORD dwFlags, LPSTREAM lpStream, REFIID riid, PVOID* ppv) { return ImageList_ReadEx(dwFlags, lpStream, riid, ppv); @@ -2127,7 +2117,6 @@ public: ATLASSERT(m_hImageList != NULL); return ImageList_WriteEx(m_hImageList, dwFlags, lpStream); } -#endif // (_WIN32_WINNT >= 0x0501) #endif // __IStream_INTERFACE_DEFINED__ // Drag operations @@ -2195,7 +2184,6 @@ public: return ImageList_DragLeave(hWnd); } -#if (_WIN32_IE >= 0x0400) CImageList Duplicate() const { ATLASSERT(m_hImageList != NULL); @@ -2207,15 +2195,12 @@ public: ATLASSERT(hImageList != NULL); return CImageList(ImageList_Duplicate(hImageList)); } -#endif // (_WIN32_IE >= 0x0400) }; /////////////////////////////////////////////////////////////////////////////// // CToolTipCtrl -#ifndef _WIN32_WCE - class CToolInfo : public TOOLINFO { public: @@ -2263,7 +2248,7 @@ public: CToolTipCtrlT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -2282,32 +2267,32 @@ public: void GetText(LPTOOLINFO lpToolInfo) const { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TTM_GETTEXT, 0, (LPARAM)&lpToolInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_GETTEXT, 0, (LPARAM)&lpToolInfo); } void GetText(LPTSTR lpstrText, HWND hWnd, UINT_PTR nIDTool = 0) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(hWnd != NULL); CToolInfo ti(0, hWnd, nIDTool, NULL, lpstrText); - ::SendMessage(m_hWnd, TTM_GETTEXT, 0, ti); + ::SendMessage(this->m_hWnd, TTM_GETTEXT, 0, ti); } BOOL GetToolInfo(LPTOOLINFO lpToolInfo) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TTM_GETTOOLINFO, 0, (LPARAM)lpToolInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TTM_GETTOOLINFO, 0, (LPARAM)lpToolInfo); } BOOL GetToolInfo(HWND hWnd, UINT_PTR nIDTool, UINT* puFlags, LPRECT lpRect, LPTSTR lpstrText) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(hWnd != NULL); ATLASSERT(puFlags != NULL); ATLASSERT(lpRect != NULL); CToolInfo ti(0, hWnd, nIDTool, NULL, lpstrText); - BOOL bRet = (BOOL)::SendMessage(m_hWnd, TTM_GETTOOLINFO, 0, ti); + BOOL bRet = (BOOL)::SendMessage(this->m_hWnd, TTM_GETTOOLINFO, 0, ti); if(bRet != FALSE) { *puFlags = ti.uFlags; @@ -2318,191 +2303,188 @@ public: void SetToolInfo(LPTOOLINFO lpToolInfo) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TTM_SETTOOLINFO, 0, (LPARAM)lpToolInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_SETTOOLINFO, 0, (LPARAM)lpToolInfo); } void SetToolRect(LPTOOLINFO lpToolInfo) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TTM_NEWTOOLRECT, 0, (LPARAM)lpToolInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_NEWTOOLRECT, 0, (LPARAM)lpToolInfo); } void SetToolRect(HWND hWnd, UINT_PTR nIDTool, LPCRECT lpRect) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(hWnd != NULL); ATLASSERT(nIDTool != 0); CToolInfo ti(0, hWnd, nIDTool, (LPRECT)lpRect, NULL); - ::SendMessage(m_hWnd, TTM_NEWTOOLRECT, 0, ti); + ::SendMessage(this->m_hWnd, TTM_NEWTOOLRECT, 0, ti); } int GetToolCount() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TTM_GETTOOLCOUNT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TTM_GETTOOLCOUNT, 0, 0L); } int GetDelayTime(DWORD dwType) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TTM_GETDELAYTIME, dwType, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TTM_GETDELAYTIME, dwType, 0L); } void SetDelayTime(DWORD dwType, int nTime) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TTM_SETDELAYTIME, dwType, MAKELPARAM(nTime, 0)); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_SETDELAYTIME, dwType, MAKELPARAM(nTime, 0)); } void GetMargin(LPRECT lpRect) const { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TTM_GETMARGIN, 0, (LPARAM)lpRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_GETMARGIN, 0, (LPARAM)lpRect); } void SetMargin(LPRECT lpRect) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TTM_SETMARGIN, 0, (LPARAM)lpRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_SETMARGIN, 0, (LPARAM)lpRect); } int GetMaxTipWidth() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TTM_GETMAXTIPWIDTH, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TTM_GETMAXTIPWIDTH, 0, 0L); } int SetMaxTipWidth(int nWidth) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TTM_SETMAXTIPWIDTH, 0, nWidth); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TTM_SETMAXTIPWIDTH, 0, nWidth); } COLORREF GetTipBkColor() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, TTM_GETTIPBKCOLOR, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, TTM_GETTIPBKCOLOR, 0, 0L); } void SetTipBkColor(COLORREF clr) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TTM_SETTIPBKCOLOR, (WPARAM)clr, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_SETTIPBKCOLOR, (WPARAM)clr, 0L); } COLORREF GetTipTextColor() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, TTM_GETTIPTEXTCOLOR, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, TTM_GETTIPTEXTCOLOR, 0, 0L); } void SetTipTextColor(COLORREF clr) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TTM_SETTIPTEXTCOLOR, (WPARAM)clr, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_SETTIPTEXTCOLOR, (WPARAM)clr, 0L); } BOOL GetCurrentTool(LPTOOLINFO lpToolInfo) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TTM_GETCURRENTTOOL, 0, (LPARAM)lpToolInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TTM_GETCURRENTTOOL, 0, (LPARAM)lpToolInfo); } -#if (_WIN32_IE >= 0x0500) SIZE GetBubbleSize(LPTOOLINFO lpToolInfo) const { - ATLASSERT(::IsWindow(m_hWnd)); - DWORD dwRet = (DWORD)::SendMessage(m_hWnd, TTM_GETBUBBLESIZE, 0, (LPARAM)lpToolInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, TTM_GETBUBBLESIZE, 0, (LPARAM)lpToolInfo); SIZE size = { GET_X_LPARAM(dwRet), GET_Y_LPARAM(dwRet) }; return size; } BOOL SetTitle(UINT_PTR uIcon, LPCTSTR lpstrTitle) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TTM_SETTITLE, uIcon, (LPARAM)lpstrTitle); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TTM_SETTITLE, uIcon, (LPARAM)lpstrTitle); } + BOOL SetTitle(HICON hIcon, LPCTSTR lpstrTitle) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TTM_SETTITLE, (WPARAM)hIcon, (LPARAM)lpstrTitle); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TTM_SETTITLE, (WPARAM)hIcon, (LPARAM)lpstrTitle); } -#endif // (_WIN32_IE >= 0x0500) -#if (_WIN32_WINNT >= 0x0501) void GetTitle(PTTGETTITLE pTTGetTitle) const { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TTM_GETTITLE, 0, (LPARAM)pTTGetTitle); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_GETTITLE, 0, (LPARAM)pTTGetTitle); } void SetWindowTheme(LPCWSTR lpstrTheme) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TTM_SETWINDOWTHEME, 0, (LPARAM)lpstrTheme); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_SETWINDOWTHEME, 0, (LPARAM)lpstrTheme); } -#endif // (_WIN32_WINNT >= 0x0501) // Operations void Activate(BOOL bActivate) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TTM_ACTIVATE, bActivate, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_ACTIVATE, bActivate, 0L); } BOOL AddTool(LPTOOLINFO lpToolInfo) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TTM_ADDTOOL, 0, (LPARAM)lpToolInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TTM_ADDTOOL, 0, (LPARAM)lpToolInfo); } BOOL AddTool(HWND hWnd, ATL::_U_STRINGorID text = LPSTR_TEXTCALLBACK, LPCRECT lpRectTool = NULL, UINT_PTR nIDTool = 0) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(hWnd != NULL); // the toolrect and toolid must both be zero or both valid - ATLASSERT((lpRectTool != NULL && nIDTool != 0) || (lpRectTool == NULL && nIDTool == 0)); + ATLASSERT(((lpRectTool != NULL) && (nIDTool != 0)) || ((lpRectTool == NULL) && (nIDTool == 0))); CToolInfo ti(0, hWnd, nIDTool, (LPRECT)lpRectTool, (LPTSTR)text.m_lpstr); - return (BOOL)::SendMessage(m_hWnd, TTM_ADDTOOL, 0, ti); + return (BOOL)::SendMessage(this->m_hWnd, TTM_ADDTOOL, 0, ti); } void DelTool(LPTOOLINFO lpToolInfo) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TTM_DELTOOL, 0, (LPARAM)lpToolInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_DELTOOL, 0, (LPARAM)lpToolInfo); } void DelTool(HWND hWnd, UINT_PTR nIDTool = 0) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(hWnd != NULL); CToolInfo ti(0, hWnd, nIDTool, NULL, NULL); - ::SendMessage(m_hWnd, TTM_DELTOOL, 0, ti); + ::SendMessage(this->m_hWnd, TTM_DELTOOL, 0, ti); } BOOL HitTest(LPTTHITTESTINFO lpHitTestInfo) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TTM_HITTEST, 0, (LPARAM)lpHitTestInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TTM_HITTEST, 0, (LPARAM)lpHitTestInfo); } BOOL HitTest(HWND hWnd, POINT pt, LPTOOLINFO lpToolInfo) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(hWnd != NULL); ATLASSERT(lpToolInfo != NULL); - TTHITTESTINFO hti = { 0 }; + TTHITTESTINFO hti = {}; hti.ti.cbSize = RunTimeHelper::SizeOf_TOOLINFO(); hti.hwnd = hWnd; hti.pt.x = pt.x; hti.pt.y = pt.y; - if((BOOL)::SendMessage(m_hWnd, TTM_HITTEST, 0, (LPARAM)&hti) != FALSE) + if((BOOL)::SendMessage(this->m_hWnd, TTM_HITTEST, 0, (LPARAM)&hti) != FALSE) { *lpToolInfo = hti.ti; return TRUE; @@ -2512,87 +2494,79 @@ public: void RelayEvent(LPMSG lpMsg) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TTM_RELAYEVENT, 0, (LPARAM)lpMsg); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_RELAYEVENT, 0, (LPARAM)lpMsg); } void UpdateTipText(LPTOOLINFO lpToolInfo) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TTM_UPDATETIPTEXT, 0, (LPARAM)lpToolInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_UPDATETIPTEXT, 0, (LPARAM)lpToolInfo); } void UpdateTipText(ATL::_U_STRINGorID text, HWND hWnd, UINT_PTR nIDTool = 0) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(hWnd != NULL); CToolInfo ti(0, hWnd, nIDTool, NULL, (LPTSTR)text.m_lpstr); - ::SendMessage(m_hWnd, TTM_UPDATETIPTEXT, 0, ti); + ::SendMessage(this->m_hWnd, TTM_UPDATETIPTEXT, 0, ti); } BOOL EnumTools(UINT_PTR nTool, LPTOOLINFO lpToolInfo) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TTM_ENUMTOOLS, nTool, (LPARAM)lpToolInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TTM_ENUMTOOLS, nTool, (LPARAM)lpToolInfo); } void Pop() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TTM_POP, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_POP, 0, 0L); } void TrackActivate(LPTOOLINFO lpToolInfo, BOOL bActivate) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TTM_TRACKACTIVATE, bActivate, (LPARAM)lpToolInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_TRACKACTIVATE, bActivate, (LPARAM)lpToolInfo); } void TrackActivate(HWND hWnd, UINT_PTR nIDTool, BOOL bActivate) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(hWnd != NULL); CToolInfo ti(0, hWnd, nIDTool); - ::SendMessage(m_hWnd, TTM_TRACKACTIVATE, bActivate, ti); + ::SendMessage(this->m_hWnd, TTM_TRACKACTIVATE, bActivate, ti); } void TrackPosition(int xPos, int yPos) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TTM_TRACKPOSITION, 0, MAKELPARAM(xPos, yPos)); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_TRACKPOSITION, 0, MAKELPARAM(xPos, yPos)); } -#if (_WIN32_IE >= 0x0400) void Update() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TTM_UPDATE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_UPDATE, 0, 0L); } -#endif // (_WIN32_IE >= 0x0400) -#if (_WIN32_IE >= 0x0500) BOOL AdjustRect(LPRECT lpRect, BOOL bLarger /*= TRUE*/) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TTM_ADJUSTRECT, bLarger, (LPARAM)lpRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TTM_ADJUSTRECT, bLarger, (LPARAM)lpRect); } -#endif // (_WIN32_IE >= 0x0500) -#if (_WIN32_WINNT >= 0x0501) void Popup() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TTM_POPUP, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_POPUP, 0, 0L); } -#endif // (_WIN32_WINNT >= 0x0501) }; typedef CToolTipCtrlT CToolTipCtrl; -#endif // !_WIN32_WCE - /////////////////////////////////////////////////////////////////////////////// // CHeaderCtrl @@ -2607,7 +2581,7 @@ public: CHeaderCtrlT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -2626,123 +2600,119 @@ public: int GetItemCount() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, HDM_GETITEMCOUNT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, HDM_GETITEMCOUNT, 0, 0L); } BOOL GetItem(int nIndex, LPHDITEM pHeaderItem) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, HDM_GETITEM, nIndex, (LPARAM)pHeaderItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, HDM_GETITEM, nIndex, (LPARAM)pHeaderItem); } BOOL SetItem(int nIndex, LPHDITEM pHeaderItem) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, HDM_SETITEM, nIndex, (LPARAM)pHeaderItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, HDM_SETITEM, nIndex, (LPARAM)pHeaderItem); } CImageList GetImageList() const { - ATLASSERT(::IsWindow(m_hWnd)); - return CImageList((HIMAGELIST)::SendMessage(m_hWnd, HDM_GETIMAGELIST, 0, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, HDM_GETIMAGELIST, 0, 0L)); } CImageList SetImageList(HIMAGELIST hImageList) { - ATLASSERT(::IsWindow(m_hWnd)); - return CImageList((HIMAGELIST)::SendMessage(m_hWnd, HDM_SETIMAGELIST, 0, (LPARAM)hImageList)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, HDM_SETIMAGELIST, 0, (LPARAM)hImageList)); } BOOL GetOrderArray(int nSize, int* lpnArray) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, HDM_GETORDERARRAY, nSize, (LPARAM)lpnArray); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, HDM_GETORDERARRAY, nSize, (LPARAM)lpnArray); } BOOL SetOrderArray(int nSize, int* lpnArray) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, HDM_SETORDERARRAY, nSize, (LPARAM)lpnArray); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, HDM_SETORDERARRAY, nSize, (LPARAM)lpnArray); } BOOL GetItemRect(int nIndex, LPRECT lpItemRect) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, HDM_GETITEMRECT, nIndex, (LPARAM)lpItemRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, HDM_GETITEMRECT, nIndex, (LPARAM)lpItemRect); } int SetHotDivider(BOOL bPos, DWORD dwInputValue) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, HDM_SETHOTDIVIDER, bPos, dwInputValue); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, HDM_SETHOTDIVIDER, bPos, dwInputValue); } -#if (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) BOOL GetUnicodeFormat() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, HDM_GETUNICODEFORMAT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, HDM_GETUNICODEFORMAT, 0, 0L); } BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, HDM_SETUNICODEFORMAT, bUnicode, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, HDM_SETUNICODEFORMAT, bUnicode, 0L); } -#endif // (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) -#if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) int GetBitmapMargin() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, HDM_GETBITMAPMARGIN, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, HDM_GETBITMAPMARGIN, 0, 0L); } int SetBitmapMargin(int nWidth) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, HDM_SETBITMAPMARGIN, nWidth, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, HDM_SETBITMAPMARGIN, nWidth, 0L); } int SetFilterChangeTimeout(DWORD dwTimeOut) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, HDM_SETFILTERCHANGETIMEOUT, 0, dwTimeOut); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, HDM_SETFILTERCHANGETIMEOUT, 0, dwTimeOut); } -#endif // (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) #if (_WIN32_WINNT >= 0x0600) BOOL GetItemDropDownRect(int nIndex, LPRECT lpRect) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, HDM_GETITEMDROPDOWNRECT, nIndex, (LPARAM)lpRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, HDM_GETITEMDROPDOWNRECT, nIndex, (LPARAM)lpRect); } BOOL GetOverflowRect(LPRECT lpRect) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, HDM_GETOVERFLOWRECT, 0, (LPARAM)lpRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, HDM_GETOVERFLOWRECT, 0, (LPARAM)lpRect); } int GetFocusedItem() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, HDM_GETFOCUSEDITEM, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, HDM_GETFOCUSEDITEM, 0, 0L); } BOOL SetFocusedItem(int nIndex) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, HDM_SETFOCUSEDITEM, 0, nIndex); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, HDM_SETFOCUSEDITEM, 0, nIndex); } #endif // (_WIN32_WINNT >= 0x0600) // Operations int InsertItem(int nIndex, LPHDITEM phdi) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, HDM_INSERTITEM, nIndex, (LPARAM)phdi); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, HDM_INSERTITEM, nIndex, (LPARAM)phdi); } int AddItem(LPHDITEM phdi) @@ -2752,53 +2722,51 @@ public: BOOL DeleteItem(int nIndex) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, HDM_DELETEITEM, nIndex, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, HDM_DELETEITEM, nIndex, 0L); } BOOL Layout(HD_LAYOUT* pHeaderLayout) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, HDM_LAYOUT, 0, (LPARAM)pHeaderLayout); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, HDM_LAYOUT, 0, (LPARAM)pHeaderLayout); } int HitTest(LPHDHITTESTINFO lpHitTestInfo) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, HDM_HITTEST, 0, (LPARAM)lpHitTestInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, HDM_HITTEST, 0, (LPARAM)lpHitTestInfo); } int OrderToIndex(int nOrder) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, HDM_ORDERTOINDEX, nOrder, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, HDM_ORDERTOINDEX, nOrder, 0L); } CImageList CreateDragImage(int nIndex) { - ATLASSERT(::IsWindow(m_hWnd)); - return CImageList((HIMAGELIST)::SendMessage(m_hWnd, HDM_CREATEDRAGIMAGE, nIndex, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, HDM_CREATEDRAGIMAGE, nIndex, 0L)); } -#if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) int EditFilter(int nColumn, BOOL bDiscardChanges) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, HDM_EDITFILTER, nColumn, MAKELPARAM(bDiscardChanges, 0)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, HDM_EDITFILTER, nColumn, MAKELPARAM(bDiscardChanges, 0)); } int ClearFilter(int nColumn) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, HDM_CLEARFILTER, nColumn, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, HDM_CLEARFILTER, nColumn, 0L); } int ClearAllFilters() { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, HDM_CLEARFILTER, (WPARAM)-1, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, HDM_CLEARFILTER, (WPARAM)-1, 0L); } -#endif // (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) }; typedef CHeaderCtrlT CHeaderCtrl; @@ -2817,7 +2785,7 @@ public: CListViewCtrlT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -2836,57 +2804,57 @@ public: COLORREF GetBkColor() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, LVM_GETBKCOLOR, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, LVM_GETBKCOLOR, 0, 0L); } BOOL SetBkColor(COLORREF cr) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_SETBKCOLOR, 0, cr); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETBKCOLOR, 0, cr); } CImageList GetImageList(int nImageListType) const { - ATLASSERT(::IsWindow(m_hWnd)); - return CImageList((HIMAGELIST)::SendMessage(m_hWnd, LVM_GETIMAGELIST, nImageListType, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, LVM_GETIMAGELIST, nImageListType, 0L)); } CImageList SetImageList(HIMAGELIST hImageList, int nImageList) { - ATLASSERT(::IsWindow(m_hWnd)); - return CImageList((HIMAGELIST)::SendMessage(m_hWnd, LVM_SETIMAGELIST, nImageList, (LPARAM)hImageList)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, LVM_SETIMAGELIST, nImageList, (LPARAM)hImageList)); } int GetItemCount() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_GETITEMCOUNT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_GETITEMCOUNT, 0, 0L); } BOOL SetItemCount(int nItems) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_SETITEMCOUNT, nItems, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETITEMCOUNT, nItems, 0L); } BOOL GetItem(LPLVITEM pItem) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_GETITEM, 0, (LPARAM)pItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETITEM, 0, (LPARAM)pItem); } BOOL SetItem(const LVITEM* pItem) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_SETITEM, 0, (LPARAM)pItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETITEM, 0, (LPARAM)pItem); } BOOL SetItem(int nItem, int nSubItem, UINT nMask, LPCTSTR lpszItem, int nImage, UINT nState, UINT nStateMask, LPARAM lParam) { - ATLASSERT(::IsWindow(m_hWnd)); - LVITEM lvi = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + LVITEM lvi = {}; lvi.mask = nMask; lvi.iItem = nItem; lvi.iSubItem = nSubItem; @@ -2895,37 +2863,36 @@ public: lvi.pszText = (LPTSTR) lpszItem; lvi.iImage = nImage; lvi.lParam = lParam; - return (BOOL)::SendMessage(m_hWnd, LVM_SETITEM, 0, (LPARAM)&lvi); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETITEM, 0, (LPARAM)&lvi); } UINT GetItemState(int nItem, UINT nMask) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (UINT)::SendMessage(m_hWnd, LVM_GETITEMSTATE, nItem, nMask); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, LVM_GETITEMSTATE, nItem, nMask); } BOOL SetItemState(int nItem, UINT nState, UINT nStateMask) { - ATLASSERT(::IsWindow(m_hWnd)); - LVITEM lvi = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + LVITEM lvi = {}; lvi.state = nState; lvi.stateMask = nStateMask; - return (BOOL)::SendMessage(m_hWnd, LVM_SETITEMSTATE, nItem, (LPARAM)&lvi); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETITEMSTATE, nItem, (LPARAM)&lvi); } BOOL SetItemState(int nItem, LPLVITEM pItem) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_SETITEMSTATE, nItem, (LPARAM)pItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETITEMSTATE, nItem, (LPARAM)pItem); } -#ifndef _ATL_NO_COM BOOL GetItemText(int nItem, int nSubItem, BSTR& bstrText) const { USES_CONVERSION; - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(bstrText == NULL); - LVITEM lvi = { 0 }; + LVITEM lvi = {}; lvi.iSubItem = nSubItem; LPTSTR lpstrText = NULL; @@ -2938,7 +2905,7 @@ public: lpstrText[0] = NULL; lvi.cchTextMax = nLen; lvi.pszText = lpstrText; - nRes = (int)::SendMessage(m_hWnd, LVM_GETITEMTEXT, (WPARAM)nItem, (LPARAM)&lvi); + nRes = (int)::SendMessage(this->m_hWnd, LVM_GETITEMTEXT, (WPARAM)nItem, (LPARAM)&lvi); if(nRes < nLen - 1) break; delete [] lpstrText; @@ -2954,13 +2921,12 @@ public: return (bstrText != NULL) ? TRUE : FALSE; } -#endif // !_ATL_NO_COM -#if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) - int GetItemText(int nItem, int nSubItem, _CSTRING_NS::CString& strText) const +#ifdef __ATLSTR_H__ + int GetItemText(int nItem, int nSubItem, ATL::CString& strText) const { - ATLASSERT(::IsWindow(m_hWnd)); - LVITEM lvi = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + LVITEM lvi = {}; lvi.iSubItem = nSubItem; strText.Empty(); @@ -2974,297 +2940,287 @@ public: nRes = 0; break; } - nRes = (int)::SendMessage(m_hWnd, LVM_GETITEMTEXT, (WPARAM)nItem, (LPARAM)&lvi); + nRes = (int)::SendMessage(this->m_hWnd, LVM_GETITEMTEXT, (WPARAM)nItem, (LPARAM)&lvi); if(nRes < nLen - 1) break; } strText.ReleaseBuffer(); return nRes; } -#endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) +#endif // __ATLSTR_H__ int GetItemText(int nItem, int nSubItem, LPTSTR lpszText, int nLen) const { - ATLASSERT(::IsWindow(m_hWnd)); - LVITEM lvi = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + LVITEM lvi = {}; lvi.iSubItem = nSubItem; lvi.cchTextMax = nLen; lvi.pszText = lpszText; - return (int)::SendMessage(m_hWnd, LVM_GETITEMTEXT, (WPARAM)nItem, (LPARAM)&lvi); + return (int)::SendMessage(this->m_hWnd, LVM_GETITEMTEXT, (WPARAM)nItem, (LPARAM)&lvi); } BOOL SetItemText(int nItem, int nSubItem, LPCTSTR lpszText) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); return SetItem(nItem, nSubItem, LVIF_TEXT, lpszText, 0, 0, 0, 0); } DWORD_PTR GetItemData(int nItem) const { - ATLASSERT(::IsWindow(m_hWnd)); - LVITEM lvi = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + LVITEM lvi = {}; lvi.iItem = nItem; lvi.mask = LVIF_PARAM; - BOOL bRet = (BOOL)::SendMessage(m_hWnd, LVM_GETITEM, 0, (LPARAM)&lvi); + BOOL bRet = (BOOL)::SendMessage(this->m_hWnd, LVM_GETITEM, 0, (LPARAM)&lvi); return (DWORD_PTR)(bRet ? lvi.lParam : NULL); } BOOL SetItemData(int nItem, DWORD_PTR dwData) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); return SetItem(nItem, 0, LVIF_PARAM, NULL, 0, 0, 0, (LPARAM)dwData); } UINT GetCallbackMask() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (UINT)::SendMessage(m_hWnd, LVM_GETCALLBACKMASK, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, LVM_GETCALLBACKMASK, 0, 0L); } BOOL SetCallbackMask(UINT nMask) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_SETCALLBACKMASK, nMask, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETCALLBACKMASK, nMask, 0L); } BOOL GetItemPosition(int nItem, LPPOINT lpPoint) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_GETITEMPOSITION, nItem, (LPARAM)lpPoint); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETITEMPOSITION, nItem, (LPARAM)lpPoint); } BOOL SetItemPosition(int nItem, POINT pt) { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT(((GetStyle() & LVS_TYPEMASK) == LVS_ICON) || ((GetStyle() & LVS_TYPEMASK) == LVS_SMALLICON)); - return (BOOL)::SendMessage(m_hWnd, LVM_SETITEMPOSITION32, nItem, (LPARAM)&pt); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(((this->GetStyle() & LVS_TYPEMASK) == LVS_ICON) || ((this->GetStyle() & LVS_TYPEMASK) == LVS_SMALLICON)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETITEMPOSITION32, nItem, (LPARAM)&pt); } BOOL SetItemPosition(int nItem, int x, int y) { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT(((GetStyle() & LVS_TYPEMASK) == LVS_ICON) || ((GetStyle() & LVS_TYPEMASK) == LVS_SMALLICON)); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(((this->GetStyle() & LVS_TYPEMASK) == LVS_ICON) || ((this->GetStyle() & LVS_TYPEMASK) == LVS_SMALLICON)); POINT pt = { x, y }; - return (BOOL)::SendMessage(m_hWnd, LVM_SETITEMPOSITION32, nItem, (LPARAM)&pt); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETITEMPOSITION32, nItem, (LPARAM)&pt); } int GetStringWidth(LPCTSTR lpsz) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_GETSTRINGWIDTH, 0, (LPARAM)lpsz); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_GETSTRINGWIDTH, 0, (LPARAM)lpsz); } CEdit GetEditControl() const { - ATLASSERT(::IsWindow(m_hWnd)); - return CEdit((HWND)::SendMessage(m_hWnd, LVM_GETEDITCONTROL, 0, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CEdit((HWND)::SendMessage(this->m_hWnd, LVM_GETEDITCONTROL, 0, 0L)); } BOOL GetColumn(int nCol, LVCOLUMN* pColumn) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_GETCOLUMN, nCol, (LPARAM)pColumn); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETCOLUMN, nCol, (LPARAM)pColumn); } BOOL SetColumn(int nCol, const LVCOLUMN* pColumn) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_SETCOLUMN, nCol, (LPARAM)pColumn); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETCOLUMN, nCol, (LPARAM)pColumn); } int GetColumnWidth(int nCol) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_GETCOLUMNWIDTH, nCol, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_GETCOLUMNWIDTH, nCol, 0L); } BOOL SetColumnWidth(int nCol, int cx) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_SETCOLUMNWIDTH, nCol, MAKELPARAM(cx, 0)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETCOLUMNWIDTH, nCol, MAKELPARAM(cx, 0)); } BOOL GetViewRect(LPRECT lpRect) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_GETVIEWRECT, 0, (LPARAM)lpRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETVIEWRECT, 0, (LPARAM)lpRect); } COLORREF GetTextColor() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, LVM_GETTEXTCOLOR, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, LVM_GETTEXTCOLOR, 0, 0L); } BOOL SetTextColor(COLORREF cr) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_SETTEXTCOLOR, 0, cr); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETTEXTCOLOR, 0, cr); } COLORREF GetTextBkColor() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, LVM_GETTEXTBKCOLOR, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, LVM_GETTEXTBKCOLOR, 0, 0L); } BOOL SetTextBkColor(COLORREF cr) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_SETTEXTBKCOLOR, 0, cr); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETTEXTBKCOLOR, 0, cr); } int GetTopIndex() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_GETTOPINDEX, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_GETTOPINDEX, 0, 0L); } int GetCountPerPage() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_GETCOUNTPERPAGE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_GETCOUNTPERPAGE, 0, 0L); } BOOL GetOrigin(LPPOINT lpPoint) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_GETORIGIN, 0, (LPARAM)lpPoint); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETORIGIN, 0, (LPARAM)lpPoint); } UINT GetSelectedCount() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (UINT)::SendMessage(m_hWnd, LVM_GETSELECTEDCOUNT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, LVM_GETSELECTEDCOUNT, 0, 0L); } BOOL GetItemRect(int nItem, LPRECT lpRect, UINT nCode) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); lpRect->left = nCode; - return (BOOL)::SendMessage(m_hWnd, LVM_GETITEMRECT, (WPARAM)nItem, (LPARAM)lpRect); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETITEMRECT, (WPARAM)nItem, (LPARAM)lpRect); } -#ifndef _WIN32_WCE HCURSOR GetHotCursor() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (HCURSOR)::SendMessage(m_hWnd, LVM_GETHOTCURSOR, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HCURSOR)::SendMessage(this->m_hWnd, LVM_GETHOTCURSOR, 0, 0L); } HCURSOR SetHotCursor(HCURSOR hHotCursor) { - ATLASSERT(::IsWindow(m_hWnd)); - return (HCURSOR)::SendMessage(m_hWnd, LVM_SETHOTCURSOR, 0, (LPARAM)hHotCursor); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HCURSOR)::SendMessage(this->m_hWnd, LVM_SETHOTCURSOR, 0, (LPARAM)hHotCursor); } int GetHotItem() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_GETHOTITEM, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_GETHOTITEM, 0, 0L); } int SetHotItem(int nIndex) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_SETHOTITEM, nIndex, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_SETHOTITEM, nIndex, 0L); } -#endif // !_WIN32_WCE BOOL GetColumnOrderArray(int nCount, int* lpnArray) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_GETCOLUMNORDERARRAY, nCount, (LPARAM)lpnArray); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETCOLUMNORDERARRAY, nCount, (LPARAM)lpnArray); } BOOL SetColumnOrderArray(int nCount, int* lpnArray) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_SETCOLUMNORDERARRAY, nCount, (LPARAM)lpnArray); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETCOLUMNORDERARRAY, nCount, (LPARAM)lpnArray); } CHeaderCtrl GetHeader() const { - ATLASSERT(::IsWindow(m_hWnd)); - return CHeaderCtrl((HWND)::SendMessage(m_hWnd, LVM_GETHEADER, 0, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CHeaderCtrl((HWND)::SendMessage(this->m_hWnd, LVM_GETHEADER, 0, 0L)); } BOOL GetSubItemRect(int nItem, int nSubItem, int nFlag, LPRECT lpRect) const { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT((GetStyle() & LVS_TYPEMASK) == LVS_REPORT); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & LVS_TYPEMASK) == LVS_REPORT); ATLASSERT(lpRect != NULL); lpRect->top = nSubItem; lpRect->left = nFlag; - return (BOOL)::SendMessage(m_hWnd, LVM_GETSUBITEMRECT, nItem, (LPARAM)lpRect); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETSUBITEMRECT, nItem, (LPARAM)lpRect); } DWORD SetIconSpacing(int cx, int cy) { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT((GetStyle() & LVS_TYPEMASK) == LVS_ICON); - return (DWORD)::SendMessage(m_hWnd, LVM_SETICONSPACING, 0, MAKELPARAM(cx, cy)); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & LVS_TYPEMASK) == LVS_ICON); + return (DWORD)::SendMessage(this->m_hWnd, LVM_SETICONSPACING, 0, MAKELPARAM(cx, cy)); } int GetISearchString(LPTSTR lpstr) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_GETISEARCHSTRING, 0, (LPARAM)lpstr); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_GETISEARCHSTRING, 0, (LPARAM)lpstr); } void GetItemSpacing(SIZE& sizeSpacing, BOOL bSmallIconView = FALSE) const { - ATLASSERT(::IsWindow(m_hWnd)); - DWORD dwRet = (DWORD)::SendMessage(m_hWnd, LVM_GETITEMSPACING, bSmallIconView, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, LVM_GETITEMSPACING, bSmallIconView, 0L); sizeSpacing.cx = GET_X_LPARAM(dwRet); sizeSpacing.cy = GET_Y_LPARAM(dwRet); } -#if (_WIN32_WCE >= 410) - void SetItemSpacing(INT cySpacing) - { - ATLASSERT(::IsWindow(m_hWnd)); - ListView_SetItemSpacing(m_hWnd, cySpacing); - } -#endif // (_WIN32_WCE >= 410) - // single-selection only int GetSelectedIndex() const { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT((GetStyle() & LVS_SINGLESEL) != 0); - return (int)::SendMessage(m_hWnd, LVM_GETNEXTITEM, (WPARAM)-1, MAKELPARAM(LVNI_ALL | LVNI_SELECTED, 0)); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & LVS_SINGLESEL) != 0); + return (int)::SendMessage(this->m_hWnd, LVM_GETNEXTITEM, (WPARAM)-1, MAKELPARAM(LVNI_ALL | LVNI_SELECTED, 0)); } BOOL GetSelectedItem(LPLVITEM pItem) const { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT((GetStyle() & LVS_SINGLESEL) != 0); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & LVS_SINGLESEL) != 0); ATLASSERT(pItem != NULL); - pItem->iItem = (int)::SendMessage(m_hWnd, LVM_GETNEXTITEM, (WPARAM)-1, MAKELPARAM(LVNI_ALL | LVNI_SELECTED, 0)); + pItem->iItem = (int)::SendMessage(this->m_hWnd, LVM_GETNEXTITEM, (WPARAM)-1, MAKELPARAM(LVNI_ALL | LVNI_SELECTED, 0)); if(pItem->iItem == -1) return FALSE; - return (BOOL)::SendMessage(m_hWnd, LVM_GETITEM, 0, (LPARAM)pItem); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETITEM, 0, (LPARAM)pItem); } // extended list view styles DWORD GetExtendedListViewStyle() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0L); } // dwExMask = 0 means all styles DWORD SetExtendedListViewStyle(DWORD dwExStyle, DWORD dwExMask = 0) { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, LVM_SETEXTENDEDLISTVIEWSTYLE, dwExMask, dwExStyle); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, LVM_SETEXTENDEDLISTVIEWSTYLE, dwExMask, dwExStyle); } // checkboxes only BOOL GetCheckState(int nIndex) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT((GetExtendedListViewStyle() & LVS_EX_CHECKBOXES) != 0); UINT uRet = GetItemState(nIndex, LVIS_STATEIMAGEMASK); return (uRet >> 12) - 1; @@ -3279,304 +3235,294 @@ public: // view type DWORD GetViewType() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (GetStyle() & LVS_TYPEMASK); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (this->GetStyle() & LVS_TYPEMASK); } DWORD SetViewType(DWORD dwType) { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT(dwType == LVS_ICON || dwType == LVS_SMALLICON || dwType == LVS_LIST || dwType == LVS_REPORT); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((dwType == LVS_ICON) || (dwType == LVS_SMALLICON) || (dwType == LVS_LIST) || (dwType == LVS_REPORT)); DWORD dwOldType = GetViewType(); if(dwType != dwOldType) - ModifyStyle(LVS_TYPEMASK, (dwType & LVS_TYPEMASK)); + this->ModifyStyle(LVS_TYPEMASK, (dwType & LVS_TYPEMASK)); return dwOldType; } -#if (_WIN32_IE >= 0x0400) -#ifndef _WIN32_WCE BOOL GetBkImage(LPLVBKIMAGE plvbki) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_GETBKIMAGE, 0, (LPARAM)plvbki); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETBKIMAGE, 0, (LPARAM)plvbki); } BOOL SetBkImage(LPLVBKIMAGE plvbki) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_SETBKIMAGE, 0, (LPARAM)plvbki); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETBKIMAGE, 0, (LPARAM)plvbki); } -#endif // !_WIN32_WCE int GetSelectionMark() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_GETSELECTIONMARK, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_GETSELECTIONMARK, 0, 0L); } int SetSelectionMark(int nIndex) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_SETSELECTIONMARK, 0, nIndex); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_SETSELECTIONMARK, 0, nIndex); } -#ifndef _WIN32_WCE BOOL GetWorkAreas(int nWorkAreas, LPRECT lpRect) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_GETWORKAREAS, nWorkAreas, (LPARAM)lpRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETWORKAREAS, nWorkAreas, (LPARAM)lpRect); } BOOL SetWorkAreas(int nWorkAreas, LPRECT lpRect) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_SETWORKAREAS, nWorkAreas, (LPARAM)lpRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETWORKAREAS, nWorkAreas, (LPARAM)lpRect); } DWORD GetHoverTime() const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT((GetExtendedListViewStyle() & (LVS_EX_TRACKSELECT | LVS_EX_ONECLICKACTIVATE | LVS_EX_TWOCLICKACTIVATE)) != 0); - return (DWORD)::SendMessage(m_hWnd, LVM_GETHOVERTIME, 0, 0L); + return (DWORD)::SendMessage(this->m_hWnd, LVM_GETHOVERTIME, 0, 0L); } DWORD SetHoverTime(DWORD dwHoverTime) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT((GetExtendedListViewStyle() & (LVS_EX_TRACKSELECT | LVS_EX_ONECLICKACTIVATE | LVS_EX_TWOCLICKACTIVATE)) != 0); - return (DWORD)::SendMessage(m_hWnd, LVM_SETHOVERTIME, 0, dwHoverTime); + return (DWORD)::SendMessage(this->m_hWnd, LVM_SETHOVERTIME, 0, dwHoverTime); } BOOL GetNumberOfWorkAreas(int* pnWorkAreas) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_GETNUMBEROFWORKAREAS, 0, (LPARAM)pnWorkAreas); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETNUMBEROFWORKAREAS, 0, (LPARAM)pnWorkAreas); } -#endif // !_WIN32_WCE BOOL SetItemCountEx(int nItems, DWORD dwFlags) { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT(((GetStyle() & LVS_OWNERDATA) != 0) && (((GetStyle() & LVS_TYPEMASK) == LVS_REPORT) || ((GetStyle() & LVS_TYPEMASK) == LVS_LIST))); - return (BOOL)::SendMessage(m_hWnd, LVM_SETITEMCOUNT, nItems, dwFlags); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(((this->GetStyle() & LVS_OWNERDATA) != 0) && (((this->GetStyle() & LVS_TYPEMASK) == LVS_REPORT) || ((this->GetStyle() & LVS_TYPEMASK) == LVS_LIST))); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETITEMCOUNT, nItems, dwFlags); } -#ifndef _WIN32_WCE CToolTipCtrl GetToolTips() const { - ATLASSERT(::IsWindow(m_hWnd)); - return CToolTipCtrl((HWND)::SendMessage(m_hWnd, LVM_GETTOOLTIPS, 0, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CToolTipCtrl((HWND)::SendMessage(this->m_hWnd, LVM_GETTOOLTIPS, 0, 0L)); } CToolTipCtrl SetToolTips(HWND hWndTT) { - ATLASSERT(::IsWindow(m_hWnd)); - return CToolTipCtrl((HWND)::SendMessage(m_hWnd, LVM_SETTOOLTIPS, (WPARAM)hWndTT, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CToolTipCtrl((HWND)::SendMessage(this->m_hWnd, LVM_SETTOOLTIPS, (WPARAM)hWndTT, 0L)); } BOOL GetUnicodeFormat() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_GETUNICODEFORMAT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETUNICODEFORMAT, 0, 0L); } BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_SETUNICODEFORMAT, bUnicode, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETUNICODEFORMAT, bUnicode, 0L); } -#endif // !_WIN32_WCE -#endif // (_WIN32_IE >= 0x0400) -#if (_WIN32_WINNT >= 0x0501) int GetSelectedColumn() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_GETSELECTEDCOLUMN, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_GETSELECTEDCOLUMN, 0, 0L); } void SetSelectedColumn(int nColumn) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, LVM_SETSELECTEDCOLUMN, nColumn, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, LVM_SETSELECTEDCOLUMN, nColumn, 0L); } DWORD GetView() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, LVM_GETVIEW, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, LVM_GETVIEW, 0, 0L); } int SetView(DWORD dwView) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_SETVIEW, dwView, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_SETVIEW, dwView, 0L); } BOOL IsGroupViewEnabled() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_ISGROUPVIEWENABLED, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_ISGROUPVIEWENABLED, 0, 0L); } int GetGroupInfo(int nGroupID, PLVGROUP pGroup) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_GETGROUPINFO, nGroupID, (LPARAM)pGroup); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_GETGROUPINFO, nGroupID, (LPARAM)pGroup); } int SetGroupInfo(int nGroupID, PLVGROUP pGroup) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_SETGROUPINFO, nGroupID, (LPARAM)pGroup); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_SETGROUPINFO, nGroupID, (LPARAM)pGroup); } void GetGroupMetrics(PLVGROUPMETRICS pGroupMetrics) const { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, LVM_GETGROUPMETRICS, 0, (LPARAM)pGroupMetrics); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, LVM_GETGROUPMETRICS, 0, (LPARAM)pGroupMetrics); } void SetGroupMetrics(PLVGROUPMETRICS pGroupMetrics) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, LVM_SETGROUPMETRICS, 0, (LPARAM)pGroupMetrics); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, LVM_SETGROUPMETRICS, 0, (LPARAM)pGroupMetrics); } void GetTileViewInfo(PLVTILEVIEWINFO pTileViewInfo) const { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, LVM_GETTILEVIEWINFO, 0, (LPARAM)pTileViewInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, LVM_GETTILEVIEWINFO, 0, (LPARAM)pTileViewInfo); } BOOL SetTileViewInfo(PLVTILEVIEWINFO pTileViewInfo) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_SETTILEVIEWINFO, 0, (LPARAM)pTileViewInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETTILEVIEWINFO, 0, (LPARAM)pTileViewInfo); } void GetTileInfo(PLVTILEINFO pTileInfo) const { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, LVM_GETTILEINFO, 0, (LPARAM)pTileInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, LVM_GETTILEINFO, 0, (LPARAM)pTileInfo); } BOOL SetTileInfo(PLVTILEINFO pTileInfo) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_SETTILEINFO, 0, (LPARAM)pTileInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETTILEINFO, 0, (LPARAM)pTileInfo); } BOOL GetInsertMark(LPLVINSERTMARK pInsertMark) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_GETINSERTMARK, 0, (LPARAM)pInsertMark); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETINSERTMARK, 0, (LPARAM)pInsertMark); } BOOL SetInsertMark(LPLVINSERTMARK pInsertMark) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_SETINSERTMARK, 0, (LPARAM)pInsertMark); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETINSERTMARK, 0, (LPARAM)pInsertMark); } int GetInsertMarkRect(LPRECT lpRect) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_GETINSERTMARKRECT, 0, (LPARAM)lpRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_GETINSERTMARKRECT, 0, (LPARAM)lpRect); } COLORREF GetInsertMarkColor() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, LVM_GETINSERTMARKCOLOR, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, LVM_GETINSERTMARKCOLOR, 0, 0L); } COLORREF SetInsertMarkColor(COLORREF clr) { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, LVM_SETINSERTMARKCOLOR, 0, clr); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, LVM_SETINSERTMARKCOLOR, 0, clr); } COLORREF GetOutlineColor() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, LVM_GETOUTLINECOLOR, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, LVM_GETOUTLINECOLOR, 0, 0L); } COLORREF SetOutlineColor(COLORREF clr) { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, LVM_SETOUTLINECOLOR, 0, clr); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, LVM_SETOUTLINECOLOR, 0, clr); } -#endif // (_WIN32_WINNT >= 0x0501) #if (_WIN32_WINNT >= 0x0600) int GetGroupCount() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_GETGROUPCOUNT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_GETGROUPCOUNT, 0, 0L); } BOOL GetGroupInfoByIndex(int nIndex, PLVGROUP pGroup) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_GETGROUPINFOBYINDEX, nIndex, (LPARAM)pGroup); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETGROUPINFOBYINDEX, nIndex, (LPARAM)pGroup); } BOOL GetGroupRect(int nGroupID, int nType, LPRECT lpRect) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(lpRect != NULL); if(lpRect != NULL) lpRect->top = nType; - return (BOOL)::SendMessage(m_hWnd, LVM_GETGROUPRECT, nGroupID, (LPARAM)lpRect); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETGROUPRECT, nGroupID, (LPARAM)lpRect); } UINT GetGroupState(int nGroupID, UINT uMask) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (UINT)::SendMessage(m_hWnd, LVM_GETGROUPSTATE, nGroupID, (LPARAM)uMask); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, LVM_GETGROUPSTATE, nGroupID, (LPARAM)uMask); } int GetFocusedGroup() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_GETFOCUSEDGROUP, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_GETFOCUSEDGROUP, 0, 0L); } BOOL GetEmptyText(LPWSTR lpstrText, int cchText) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_GETEMPTYTEXT, cchText, (LPARAM)lpstrText); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETEMPTYTEXT, cchText, (LPARAM)lpstrText); } BOOL GetFooterRect(LPRECT lpRect) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_GETFOOTERRECT, 0, (LPARAM)lpRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETFOOTERRECT, 0, (LPARAM)lpRect); } BOOL GetFooterInfo(LPLVFOOTERINFO lpFooterInfo) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_GETFOOTERINFO, 0, (LPARAM)lpFooterInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETFOOTERINFO, 0, (LPARAM)lpFooterInfo); } BOOL GetFooterItemRect(int nItem, LPRECT lpRect) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_GETFOOTERITEMRECT, nItem, (LPARAM)lpRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETFOOTERITEMRECT, nItem, (LPARAM)lpRect); } BOOL GetFooterItem(int nItem, LPLVFOOTERITEM lpFooterItem) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_GETFOOTERITEM, nItem, (LPARAM)lpFooterItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETFOOTERITEM, nItem, (LPARAM)lpFooterItem); } BOOL GetItemIndexRect(PLVITEMINDEX pItemIndex, int nSubItem, int nType, LPRECT lpRect) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(pItemIndex != NULL); ATLASSERT(lpRect != NULL); if(lpRect != NULL) @@ -3584,37 +3530,37 @@ public: lpRect->top = nSubItem; lpRect->left = nType; } - return (BOOL)::SendMessage(m_hWnd, LVM_GETITEMINDEXRECT, (WPARAM)pItemIndex, (LPARAM)lpRect); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETITEMINDEXRECT, (WPARAM)pItemIndex, (LPARAM)lpRect); } BOOL SetItemIndexState(PLVITEMINDEX pItemIndex, UINT uState, UINT dwMask) { - ATLASSERT(::IsWindow(m_hWnd)); - LVITEM lvi = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + LVITEM lvi = {}; lvi.state = uState; lvi.stateMask = dwMask; - return (BOOL)::SendMessage(m_hWnd, LVM_SETITEMINDEXSTATE, (WPARAM)pItemIndex, (LPARAM)&lvi); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETITEMINDEXSTATE, (WPARAM)pItemIndex, (LPARAM)&lvi); } BOOL GetNextItemIndex(PLVITEMINDEX pItemIndex, WORD wFlags) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_GETNEXTITEMINDEX, (WPARAM)pItemIndex, MAKELPARAM(wFlags, 0)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETNEXTITEMINDEX, (WPARAM)pItemIndex, MAKELPARAM(wFlags, 0)); } #endif // (_WIN32_WINNT >= 0x0600) // Operations int InsertColumn(int nCol, const LVCOLUMN* pColumn) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_INSERTCOLUMN, nCol, (LPARAM)pColumn); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_INSERTCOLUMN, nCol, (LPARAM)pColumn); } int InsertColumn(int nCol, LPCTSTR lpszColumnHeading, int nFormat = LVCFMT_LEFT, int nWidth = -1, int nSubItem = -1, int iImage = -1, int iOrder = -1) { - LVCOLUMN column = { 0 }; - column.mask = LVCF_TEXT|LVCF_FMT; + LVCOLUMN column = {}; + column.mask = LVCF_TEXT | LVCF_FMT; column.pszText = (LPTSTR)lpszColumnHeading; column.fmt = nFormat; if (nWidth != -1) @@ -3642,14 +3588,14 @@ public: BOOL DeleteColumn(int nCol) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_DELETECOLUMN, nCol, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_DELETECOLUMN, nCol, 0L); } int InsertItem(UINT nMask, int nItem, LPCTSTR lpszItem, UINT nState, UINT nStateMask, int nImage, LPARAM lParam) { - ATLASSERT(::IsWindow(m_hWnd)); - LVITEM item = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + LVITEM item = {}; item.mask = nMask; item.iItem = nItem; item.iSubItem = 0; @@ -3663,67 +3609,67 @@ public: int InsertItem(const LVITEM* pItem) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_INSERTITEM, 0, (LPARAM)pItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_INSERTITEM, 0, (LPARAM)pItem); } int InsertItem(int nItem, LPCTSTR lpszItem) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); return InsertItem(LVIF_TEXT, nItem, lpszItem, 0, 0, 0, 0); } int InsertItem(int nItem, LPCTSTR lpszItem, int nImage) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); return InsertItem(LVIF_TEXT|LVIF_IMAGE, nItem, lpszItem, 0, 0, nImage, 0); } int GetNextItem(int nItem, int nFlags) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_GETNEXTITEM, nItem, MAKELPARAM(nFlags, 0)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_GETNEXTITEM, nItem, MAKELPARAM(nFlags, 0)); } BOOL DeleteItem(int nItem) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_DELETEITEM, nItem, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_DELETEITEM, nItem, 0L); } BOOL DeleteAllItems() { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_DELETEALLITEMS, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_DELETEALLITEMS, 0, 0L); } int FindItem(LVFINDINFO* pFindInfo, int nStart = -1) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_FINDITEM, nStart, (LPARAM)pFindInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_FINDITEM, nStart, (LPARAM)pFindInfo); } int FindItem(LPCTSTR lpstrFind, bool bPartial = true, bool bWrap = false, int nStart = -1) const { - ATLASSERT(::IsWindow(m_hWnd)); - LVFINDINFO lvfi = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + LVFINDINFO lvfi = {}; lvfi.flags = LVFI_STRING | (bWrap ? LVFI_WRAP : 0) | (bPartial ? LVFI_PARTIAL : 0); lvfi.psz = lpstrFind; - return (int)::SendMessage(m_hWnd, LVM_FINDITEM, nStart, (LPARAM)&lvfi); + return (int)::SendMessage(this->m_hWnd, LVM_FINDITEM, nStart, (LPARAM)&lvfi); } int HitTest(LVHITTESTINFO* pHitTestInfo) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_HITTEST, 0, (LPARAM)pHitTestInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_HITTEST, 0, (LPARAM)pHitTestInfo); } int HitTest(POINT pt, UINT* pFlags) const { - ATLASSERT(::IsWindow(m_hWnd)); - LVHITTESTINFO hti = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + LVHITTESTINFO hti = {}; hti.pt = pt; - int nRes = (int)::SendMessage(m_hWnd, LVM_HITTEST, 0, (LPARAM)&hti); + int nRes = (int)::SendMessage(this->m_hWnd, LVM_HITTEST, 0, (LPARAM)&hti); if (pFlags != NULL) *pFlags = hti.flags; return nRes; @@ -3731,80 +3677,86 @@ public: BOOL EnsureVisible(int nItem, BOOL bPartialOK) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_ENSUREVISIBLE, nItem, MAKELPARAM(bPartialOK, 0)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_ENSUREVISIBLE, nItem, MAKELPARAM(bPartialOK, 0)); + } + + BOOL Scroll(int cx, int cy) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SCROLL, cx, cy); } BOOL Scroll(SIZE size) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_SCROLL, size.cx, size.cy); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SCROLL, size.cx, size.cy); } BOOL RedrawItems(int nFirst, int nLast) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_REDRAWITEMS, nFirst, nLast); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_REDRAWITEMS, nFirst, nLast); } BOOL Arrange(UINT nCode) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_ARRANGE, nCode, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_ARRANGE, nCode, 0L); } CEdit EditLabel(int nItem) { - ATLASSERT(::IsWindow(m_hWnd)); - return CEdit((HWND)::SendMessage(m_hWnd, LVM_EDITLABEL, nItem, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CEdit((HWND)::SendMessage(this->m_hWnd, LVM_EDITLABEL, nItem, 0L)); } BOOL Update(int nItem) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_UPDATE, nItem, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_UPDATE, nItem, 0L); } BOOL SortItems(PFNLVCOMPARE pfnCompare, LPARAM lParamSort) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_SORTITEMS, (WPARAM)lParamSort, (LPARAM)pfnCompare); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SORTITEMS, (WPARAM)lParamSort, (LPARAM)pfnCompare); } CImageList RemoveImageList(int nImageList) { - ATLASSERT(::IsWindow(m_hWnd)); - return CImageList((HIMAGELIST)::SendMessage(m_hWnd, LVM_SETIMAGELIST, (WPARAM)nImageList, NULL)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, LVM_SETIMAGELIST, (WPARAM)nImageList, NULL)); } CImageList CreateDragImage(int nItem, LPPOINT lpPoint) { - ATLASSERT(::IsWindow(m_hWnd)); - return CImageList((HIMAGELIST)::SendMessage(m_hWnd, LVM_CREATEDRAGIMAGE, nItem, (LPARAM)lpPoint)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, LVM_CREATEDRAGIMAGE, nItem, (LPARAM)lpPoint)); } DWORD ApproximateViewRect(int cx = -1, int cy = -1, int nCount = -1) { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, LVM_APPROXIMATEVIEWRECT, nCount, MAKELPARAM(cx, cy)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, LVM_APPROXIMATEVIEWRECT, nCount, MAKELPARAM(cx, cy)); } int SubItemHitTest(LPLVHITTESTINFO lpInfo) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_SUBITEMHITTEST, 0, (LPARAM)lpInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_SUBITEMHITTEST, 0, (LPARAM)lpInfo); } - int AddColumn(LPCTSTR strItem, int nItem, int nSubItem = -1, + int AddColumn(LPCTSTR strColumn, int nItem, int nSubItem = -1, int nMask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM, int nFmt = LVCFMT_LEFT) { const int cxOffset = 15; - ATLASSERT(::IsWindow(m_hWnd)); - LVCOLUMN lvc = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + LVCOLUMN lvc = {}; lvc.mask = nMask; lvc.fmt = nFmt; - lvc.pszText = (LPTSTR)strItem; + lvc.pszText = (LPTSTR)strColumn; lvc.cx = GetStringWidth(lvc.pszText) + cxOffset; if(nMask & LVCF_SUBITEM) lvc.iSubItem = (nSubItem != -1) ? nSubItem : nItem; @@ -3813,8 +3765,8 @@ public: int AddItem(int nItem, int nSubItem, LPCTSTR strItem, int nImageIndex = -3) { - ATLASSERT(::IsWindow(m_hWnd)); - LVITEM lvItem = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + LVITEM lvItem = {}; lvItem.mask = LVIF_TEXT; lvItem.iItem = nItem; lvItem.iSubItem = nSubItem; @@ -3829,19 +3781,16 @@ public: return SetItem(&lvItem) ? nItem : -1; } -#if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) BOOL SortItemsEx(PFNLVCOMPARE pfnCompare, LPARAM lParamSort) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_SORTITEMSEX, (WPARAM)lParamSort, (LPARAM)pfnCompare); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SORTITEMSEX, (WPARAM)lParamSort, (LPARAM)pfnCompare); } -#endif // (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) -#if (_WIN32_WINNT >= 0x0501) int InsertGroup(int nItem, PLVGROUP pGroup) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_INSERTGROUP, nItem, (LPARAM)pGroup); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_INSERTGROUP, nItem, (LPARAM)pGroup); } int AddGroup(PLVGROUP pGroup) @@ -3851,96 +3800,101 @@ public: int RemoveGroup(int nGroupID) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_REMOVEGROUP, nGroupID, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_REMOVEGROUP, nGroupID, 0L); } void MoveGroup(int nGroupID, int nItem) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, LVM_MOVEGROUP, nGroupID, nItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, LVM_MOVEGROUP, nGroupID, nItem); } void MoveItemToGroup(int nItem, int nGroupID) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, LVM_MOVEITEMTOGROUP, nItem, nGroupID); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, LVM_MOVEITEMTOGROUP, nItem, nGroupID); } int EnableGroupView(BOOL bEnable) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_ENABLEGROUPVIEW, bEnable, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_ENABLEGROUPVIEW, bEnable, 0L); } int SortGroups(PFNLVGROUPCOMPARE pCompareFunc, LPVOID lpVoid = NULL) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_SORTGROUPS, (WPARAM)pCompareFunc, (LPARAM)lpVoid); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_SORTGROUPS, (WPARAM)pCompareFunc, (LPARAM)lpVoid); } void InsertGroupSorted(PLVINSERTGROUPSORTED pInsertGroupSorted) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, LVM_INSERTGROUPSORTED, (WPARAM)pInsertGroupSorted, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, LVM_INSERTGROUPSORTED, (WPARAM)pInsertGroupSorted, 0L); } void RemoveAllGroups() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, LVM_REMOVEALLGROUPS, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, LVM_REMOVEALLGROUPS, 0, 0L); } BOOL HasGroup(int nGroupID) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_HASGROUP, nGroupID, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_HASGROUP, nGroupID, 0L); } BOOL InsertMarkHitTest(LPPOINT lpPoint, LPLVINSERTMARK pInsertMark) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_INSERTMARKHITTEST, (WPARAM)lpPoint, (LPARAM)pInsertMark); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_INSERTMARKHITTEST, (WPARAM)lpPoint, (LPARAM)pInsertMark); } BOOL SetInfoTip(PLVSETINFOTIP pSetInfoTip) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_SETINFOTIP, 0, (LPARAM)pSetInfoTip); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETINFOTIP, 0, (LPARAM)pSetInfoTip); } void CancelEditLabel() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, LVM_CANCELEDITLABEL, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, LVM_CANCELEDITLABEL, 0, 0L); } UINT MapIndexToID(int nIndex) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (UINT)::SendMessage(m_hWnd, LVM_MAPINDEXTOID, nIndex, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, LVM_MAPINDEXTOID, nIndex, 0L); } int MapIDToIndex(UINT uID) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_MAPIDTOINDEX, uID, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_MAPIDTOINDEX, uID, 0L); + } + + BOOL IsItemVisible(int nItem) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_ISITEMVISIBLE, nItem, 0L); } -#endif // (_WIN32_WINNT >= 0x0501) #if (_WIN32_WINNT >= 0x0600) int HitTestEx(LPLVHITTESTINFO lpHitTestInfo) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_HITTEST, (WPARAM)-1, (LPARAM)lpHitTestInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_HITTEST, (WPARAM)-1, (LPARAM)lpHitTestInfo); } int HitTestEx(POINT pt, UINT* pFlags) const { - ATLASSERT(::IsWindow(m_hWnd)); - LVHITTESTINFO hti = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + LVHITTESTINFO hti = {}; hti.pt = pt; - int nRes = (int)::SendMessage(m_hWnd, LVM_HITTEST, (WPARAM)-1, (LPARAM)&hti); + int nRes = (int)::SendMessage(this->m_hWnd, LVM_HITTEST, (WPARAM)-1, (LPARAM)&hti); if (pFlags != NULL) *pFlags = hti.flags; return nRes; @@ -3948,26 +3902,46 @@ public: int SubItemHitTestEx(LPLVHITTESTINFO lpHitTestInfo) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_SUBITEMHITTEST, (WPARAM)-1, (LPARAM)lpHitTestInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_SUBITEMHITTEST, (WPARAM)-1, (LPARAM)lpHitTestInfo); } #endif // (_WIN32_WINNT >= 0x0600) // Note: selects only one item - BOOL SelectItem(int nIndex) + BOOL SelectItem(int nIndex) // -1 to select none { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); - // multi-selection only: de-select all items - if((GetStyle() & LVS_SINGLESEL) == 0) - SetItemState(-1, 0, LVIS_SELECTED); + BOOL bRet = FALSE; + if(nIndex != -1) + { + // multi-selection only: de-select all items + if((this->GetStyle() & LVS_SINGLESEL) == 0) + SetItemState(-1, 0, LVIS_SELECTED); - BOOL bRet = SetItemState(nIndex, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED); - if(bRet) - bRet = EnsureVisible(nIndex, FALSE); + bRet = SetItemState(nIndex, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED); + if(bRet) + { + SetSelectionMark(nIndex); + bRet = EnsureVisible(nIndex, FALSE); + } + } + else // no item specified, just de-select + { + bRet = SetItemState(-1, 0, LVIS_SELECTED); + } return bRet; } + + // multi-selection only + BOOL SelectAllItems(bool bSelect = true) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & LVS_SINGLESEL) == 0); + + return SetItemState(-1, bSelect ? LVIS_SELECTED : 0, LVIS_SELECTED); + } }; typedef CListViewCtrlT CListViewCtrl; @@ -3986,7 +3960,7 @@ public: CTreeViewCtrlT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -4005,51 +3979,51 @@ public: UINT GetCount() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (UINT)::SendMessage(m_hWnd, TVM_GETCOUNT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, TVM_GETCOUNT, 0, 0L); } UINT GetIndent() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (UINT)::SendMessage(m_hWnd, TVM_GETINDENT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, TVM_GETINDENT, 0, 0L); } void SetIndent(UINT nIndent) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TVM_SETINDENT, nIndent, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TVM_SETINDENT, nIndent, 0L); } CImageList GetImageList(int nImageListType = TVSIL_NORMAL) const { - ATLASSERT(::IsWindow(m_hWnd)); - return CImageList((HIMAGELIST)::SendMessage(m_hWnd, TVM_GETIMAGELIST, (WPARAM)nImageListType, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TVM_GETIMAGELIST, (WPARAM)nImageListType, 0L)); } CImageList SetImageList(HIMAGELIST hImageList, int nImageListType = TVSIL_NORMAL) { - ATLASSERT(::IsWindow(m_hWnd)); - return CImageList((HIMAGELIST)::SendMessage(m_hWnd, TVM_SETIMAGELIST, (WPARAM)nImageListType, (LPARAM)hImageList)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TVM_SETIMAGELIST, (WPARAM)nImageListType, (LPARAM)hImageList)); } BOOL GetItem(LPTVITEM pItem) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TVM_GETITEM, 0, (LPARAM)pItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_GETITEM, 0, (LPARAM)pItem); } BOOL SetItem(LPTVITEM pItem) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TVM_SETITEM, 0, (LPARAM)pItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_SETITEM, 0, (LPARAM)pItem); } BOOL SetItem(HTREEITEM hItem, UINT nMask, LPCTSTR lpszItem, int nImage, int nSelectedImage, UINT nState, UINT nStateMask, LPARAM lParam) { - ATLASSERT(::IsWindow(m_hWnd)); - TVITEM item = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + TVITEM item = {}; item.hItem = hItem; item.mask = nMask; item.pszText = (LPTSTR) lpszItem; @@ -4058,30 +4032,29 @@ public: item.state = nState; item.stateMask = nStateMask; item.lParam = lParam; - return (BOOL)::SendMessage(m_hWnd, TVM_SETITEM, 0, (LPARAM)&item); + return (BOOL)::SendMessage(this->m_hWnd, TVM_SETITEM, 0, (LPARAM)&item); } BOOL GetItemText(HTREEITEM hItem, LPTSTR lpstrText, int nLen) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(lpstrText != NULL); - TVITEM item = { 0 }; + TVITEM item = {}; item.hItem = hItem; item.mask = TVIF_TEXT; item.pszText = lpstrText; item.cchTextMax = nLen; - return (BOOL)::SendMessage(m_hWnd, TVM_GETITEM, 0, (LPARAM)&item); + return (BOOL)::SendMessage(this->m_hWnd, TVM_GETITEM, 0, (LPARAM)&item); } -#ifndef _ATL_NO_COM BOOL GetItemText(HTREEITEM hItem, BSTR& bstrText) const { USES_CONVERSION; - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(bstrText == NULL); - TVITEM item = { 0 }; + TVITEM item = {}; item.hItem = hItem; item.mask = TVIF_TEXT; @@ -4095,8 +4068,8 @@ public: lpstrText[0] = NULL; item.pszText = lpstrText; item.cchTextMax = nLen; - bRet = (BOOL)::SendMessage(m_hWnd, TVM_GETITEM, 0, (LPARAM)&item); - if(!bRet || (lstrlen(item.pszText) < nLen - 1)) + bRet = (BOOL)::SendMessage(this->m_hWnd, TVM_GETITEM, 0, (LPARAM)&item); + if(!bRet || (lstrlen(item.pszText) < (nLen - 1))) break; delete [] lpstrText; lpstrText = NULL; @@ -4111,13 +4084,12 @@ public: return (bstrText != NULL) ? TRUE : FALSE; } -#endif // !_ATL_NO_COM -#if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) - BOOL GetItemText(HTREEITEM hItem, _CSTRING_NS::CString& strText) const +#ifdef __ATLSTR_H__ + BOOL GetItemText(HTREEITEM hItem, ATL::CString& strText) const { - ATLASSERT(::IsWindow(m_hWnd)); - TVITEM item = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + TVITEM item = {}; item.hItem = hItem; item.mask = TVIF_TEXT; @@ -4132,28 +4104,28 @@ public: break; } item.cchTextMax = nLen; - bRet = (BOOL)::SendMessage(m_hWnd, TVM_GETITEM, 0, (LPARAM)&item); - if(!bRet || (lstrlen(item.pszText) < nLen - 1)) + bRet = (BOOL)::SendMessage(this->m_hWnd, TVM_GETITEM, 0, (LPARAM)&item); + if(!bRet || (lstrlen(item.pszText) < (nLen - 1))) break; } strText.ReleaseBuffer(); return bRet; } -#endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) +#endif // __ATLSTR_H__ BOOL SetItemText(HTREEITEM hItem, LPCTSTR lpszItem) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); return SetItem(hItem, TVIF_TEXT, lpszItem, 0, 0, 0, 0, NULL); } BOOL GetItemImage(HTREEITEM hItem, int& nImage, int& nSelectedImage) const { - ATLASSERT(::IsWindow(m_hWnd)); - TVITEM item = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + TVITEM item = {}; item.hItem = hItem; item.mask = TVIF_IMAGE|TVIF_SELECTEDIMAGE; - BOOL bRes = (BOOL)::SendMessage(m_hWnd, TVM_GETITEM, 0, (LPARAM)&item); + BOOL bRes = (BOOL)::SendMessage(this->m_hWnd, TVM_GETITEM, 0, (LPARAM)&item); if (bRes) { nImage = item.iImage; @@ -4164,270 +4136,265 @@ public: BOOL SetItemImage(HTREEITEM hItem, int nImage, int nSelectedImage) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); return SetItem(hItem, TVIF_IMAGE|TVIF_SELECTEDIMAGE, NULL, nImage, nSelectedImage, 0, 0, NULL); } UINT GetItemState(HTREEITEM hItem, UINT nStateMask) const { - ATLASSERT(::IsWindow(m_hWnd)); -#if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) - return (((UINT)::SendMessage(m_hWnd, TVM_GETITEMSTATE, (WPARAM)hItem, (LPARAM)nStateMask)) & nStateMask); -#else // !((_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE)) - TVITEM item = { 0 }; - item.hItem = hItem; - item.mask = TVIF_STATE; - item.state = 0; - item.stateMask = nStateMask; - ::SendMessage(m_hWnd, TVM_GETITEM, 0, (LPARAM)&item); - return (item.state & nStateMask); -#endif // !((_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE)) + ATLASSERT(::IsWindow(this->m_hWnd)); + return (((UINT)::SendMessage(this->m_hWnd, TVM_GETITEMSTATE, (WPARAM)hItem, (LPARAM)nStateMask)) & nStateMask); } BOOL SetItemState(HTREEITEM hItem, UINT nState, UINT nStateMask) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); return SetItem(hItem, TVIF_STATE, NULL, 0, 0, nState, nStateMask, NULL); } DWORD_PTR GetItemData(HTREEITEM hItem) const { - ATLASSERT(::IsWindow(m_hWnd)); - TVITEM item = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + TVITEM item = {}; item.hItem = hItem; item.mask = TVIF_PARAM; - BOOL bRet = (BOOL)::SendMessage(m_hWnd, TVM_GETITEM, 0, (LPARAM)&item); + BOOL bRet = (BOOL)::SendMessage(this->m_hWnd, TVM_GETITEM, 0, (LPARAM)&item); return (DWORD_PTR)(bRet ? item.lParam : NULL); } BOOL SetItemData(HTREEITEM hItem, DWORD_PTR dwData) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); return SetItem(hItem, TVIF_PARAM, NULL, 0, 0, 0, 0, (LPARAM)dwData); } CEdit GetEditControl() const { - ATLASSERT(::IsWindow(m_hWnd)); - return CEdit((HWND)::SendMessage(m_hWnd, TVM_GETEDITCONTROL, 0, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CEdit((HWND)::SendMessage(this->m_hWnd, TVM_GETEDITCONTROL, 0, 0L)); } UINT GetVisibleCount() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (UINT)::SendMessage(m_hWnd, TVM_GETVISIBLECOUNT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, TVM_GETVISIBLECOUNT, 0, 0L); } BOOL GetItemRect(HTREEITEM hItem, LPRECT lpRect, BOOL bTextOnly) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); *(HTREEITEM*)lpRect = hItem; - return (BOOL)::SendMessage(m_hWnd, TVM_GETITEMRECT, (WPARAM)bTextOnly, (LPARAM)lpRect); + return (BOOL)::SendMessage(this->m_hWnd, TVM_GETITEMRECT, (WPARAM)bTextOnly, (LPARAM)lpRect); } BOOL ItemHasChildren(HTREEITEM hItem) const { - ATLASSERT(::IsWindow(m_hWnd)); - TVITEM item = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + TVITEM item = {}; item.hItem = hItem; item.mask = TVIF_CHILDREN; - ::SendMessage(m_hWnd, TVM_GETITEM, 0, (LPARAM)&item); + ::SendMessage(this->m_hWnd, TVM_GETITEM, 0, (LPARAM)&item); return item.cChildren; } -#ifndef _WIN32_WCE CToolTipCtrl GetToolTips() const { - ATLASSERT(::IsWindow(m_hWnd)); - return CToolTipCtrl((HWND)::SendMessage(m_hWnd, TVM_GETTOOLTIPS, 0, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CToolTipCtrl((HWND)::SendMessage(this->m_hWnd, TVM_GETTOOLTIPS, 0, 0L)); } CToolTipCtrl SetToolTips(HWND hWndTT) { - ATLASSERT(::IsWindow(m_hWnd)); - return CToolTipCtrl((HWND)::SendMessage(m_hWnd, TVM_SETTOOLTIPS, (WPARAM)hWndTT, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CToolTipCtrl((HWND)::SendMessage(this->m_hWnd, TVM_SETTOOLTIPS, (WPARAM)hWndTT, 0L)); } -#endif // !_WIN32_WCE int GetISearchString(LPTSTR lpstr) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TVM_GETISEARCHSTRING, 0, (LPARAM)lpstr); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TVM_GETISEARCHSTRING, 0, (LPARAM)lpstr); } // checkboxes only BOOL GetCheckState(HTREEITEM hItem) const { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT((GetStyle() & TVS_CHECKBOXES) != 0); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & TVS_CHECKBOXES) != 0); UINT uRet = GetItemState(hItem, TVIS_STATEIMAGEMASK); return (uRet >> 12) - 1; } BOOL SetCheckState(HTREEITEM hItem, BOOL bCheck) { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & TVS_CHECKBOXES) != 0); int nCheck = bCheck ? 2 : 1; // one based index return SetItemState(hItem, INDEXTOSTATEIMAGEMASK(nCheck), TVIS_STATEIMAGEMASK); } -#if (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) + // for standard and extended checkboxes (0 = no checkbox, 1 = unchecked, 2 = checked, >2 = optional extended check states) + UINT GetCheckStateEx(HTREEITEM hItem) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(this->GetImageList(TVSIL_STATE) != NULL); + UINT uRet = GetItemState(hItem, TVIS_STATEIMAGEMASK); + return (uRet >> 12); + } + + BOOL SetCheckStateEx(HTREEITEM hItem, UINT uCheckState) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(this->GetImageList(TVSIL_STATE) != NULL); + ATLASSERT(uCheckState < (UINT)::ImageList_GetImageCount(this->GetImageList(TVSIL_STATE))); + return SetItemState(hItem, INDEXTOSTATEIMAGEMASK(uCheckState), TVIS_STATEIMAGEMASK); + } + COLORREF GetBkColor() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, TVM_GETBKCOLOR, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, TVM_GETBKCOLOR, 0, 0L); } COLORREF SetBkColor(COLORREF clr) { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, TVM_SETBKCOLOR, 0, (LPARAM)clr); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, TVM_SETBKCOLOR, 0, (LPARAM)clr); } COLORREF GetInsertMarkColor() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, TVM_GETINSERTMARKCOLOR, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, TVM_GETINSERTMARKCOLOR, 0, 0L); } COLORREF SetInsertMarkColor(COLORREF clr) { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, TVM_SETINSERTMARKCOLOR, 0, (LPARAM)clr); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, TVM_SETINSERTMARKCOLOR, 0, (LPARAM)clr); } int GetItemHeight() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TVM_GETITEMHEIGHT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TVM_GETITEMHEIGHT, 0, 0L); } int SetItemHeight(int cyHeight) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TVM_SETITEMHEIGHT, cyHeight, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TVM_SETITEMHEIGHT, cyHeight, 0L); } int GetScrollTime() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TVM_GETSCROLLTIME, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TVM_GETSCROLLTIME, 0, 0L); } int SetScrollTime(int nScrollTime) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TVM_SETSCROLLTIME, nScrollTime, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TVM_SETSCROLLTIME, nScrollTime, 0L); } COLORREF GetTextColor() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, TVM_GETTEXTCOLOR, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, TVM_GETTEXTCOLOR, 0, 0L); } COLORREF SetTextColor(COLORREF clr) { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, TVM_SETTEXTCOLOR, 0, (LPARAM)clr); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, TVM_SETTEXTCOLOR, 0, (LPARAM)clr); } BOOL GetUnicodeFormat() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TVM_GETUNICODEFORMAT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_GETUNICODEFORMAT, 0, 0L); } BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TVM_SETUNICODEFORMAT, bUnicode, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_SETUNICODEFORMAT, bUnicode, 0L); } -#endif // (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) -#if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) COLORREF GetLineColor() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, TVM_GETLINECOLOR, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, TVM_GETLINECOLOR, 0, 0L); } COLORREF SetLineColor(COLORREF clrNew /*= CLR_DEFAULT*/) { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, TVM_SETLINECOLOR, 0, (LPARAM)clrNew); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, TVM_SETLINECOLOR, 0, (LPARAM)clrNew); } -#endif // (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) -#if (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) BOOL GetItem(LPTVITEMEX pItem) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TVM_GETITEM, 0, (LPARAM)pItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_GETITEM, 0, (LPARAM)pItem); } BOOL SetItem(LPTVITEMEX pItem) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TVM_SETITEM, 0, (LPARAM)pItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_SETITEM, 0, (LPARAM)pItem); } -#endif // (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) DWORD GetExtendedStyle() const { -#ifndef TVM_GETEXTENDEDSTYLE - const UINT TVM_GETEXTENDEDSTYLE = (TV_FIRST + 45); -#endif - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, TVM_GETEXTENDEDSTYLE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, TVM_GETEXTENDEDSTYLE, 0, 0L); } DWORD SetExtendedStyle(DWORD dwStyle, DWORD dwMask) { -#ifndef TVM_SETEXTENDEDSTYLE - const UINT TVM_SETEXTENDEDSTYLE = (TV_FIRST + 44); -#endif - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, TVM_SETEXTENDEDSTYLE, dwMask, dwStyle); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, TVM_SETEXTENDEDSTYLE, dwMask, dwStyle); } #if (_WIN32_WINNT >= 0x0600) BOOL SetAutoScrollInfo(UINT uPixPerSec, UINT uUpdateTime) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TVM_SETAUTOSCROLLINFO, (WPARAM)uPixPerSec, (LPARAM)uUpdateTime); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_SETAUTOSCROLLINFO, (WPARAM)uPixPerSec, (LPARAM)uUpdateTime); } DWORD GetSelectedCount() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, TVM_GETSELECTEDCOUNT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, TVM_GETSELECTEDCOUNT, 0, 0L); } BOOL GetItemPartRect(HTREEITEM hItem, TVITEMPART partID, LPRECT lpRect) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); TVGETITEMPARTRECTINFO gipri = { hItem, lpRect, partID }; - return (BOOL)::SendMessage(m_hWnd, TVM_GETITEMPARTRECT, 0, (LPARAM)&gipri); + return (BOOL)::SendMessage(this->m_hWnd, TVM_GETITEMPARTRECT, 0, (LPARAM)&gipri); } #endif // (_WIN32_WINNT >= 0x0600) // Operations HTREEITEM InsertItem(LPTVINSERTSTRUCT lpInsertStruct) { - ATLASSERT(::IsWindow(m_hWnd)); - return (HTREEITEM)::SendMessage(m_hWnd, TVM_INSERTITEM, 0, (LPARAM)lpInsertStruct); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_INSERTITEM, 0, (LPARAM)lpInsertStruct); } HTREEITEM InsertItem(LPCTSTR lpszItem, int nImage, int nSelectedImage, HTREEITEM hParent, HTREEITEM hInsertAfter) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); return InsertItem(TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE, lpszItem, nImage, nSelectedImage, 0, 0, 0, hParent, hInsertAfter); } HTREEITEM InsertItem(LPCTSTR lpszItem, HTREEITEM hParent, HTREEITEM hInsertAfter) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); return InsertItem(TVIF_TEXT, lpszItem, 0, 0, 0, 0, 0, hParent, hInsertAfter); } @@ -4435,8 +4402,8 @@ public: int nSelectedImage, UINT nState, UINT nStateMask, LPARAM lParam, HTREEITEM hParent, HTREEITEM hInsertAfter) { - ATLASSERT(::IsWindow(m_hWnd)); - TVINSERTSTRUCT tvis = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + TVINSERTSTRUCT tvis = {}; tvis.hParent = hParent; tvis.hInsertAfter = hInsertAfter; tvis.item.mask = nMask; @@ -4446,160 +4413,153 @@ public: tvis.item.state = nState; tvis.item.stateMask = nStateMask; tvis.item.lParam = lParam; - return (HTREEITEM)::SendMessage(m_hWnd, TVM_INSERTITEM, 0, (LPARAM)&tvis); + return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_INSERTITEM, 0, (LPARAM)&tvis); } BOOL DeleteItem(HTREEITEM hItem) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TVM_DELETEITEM, 0, (LPARAM)hItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_DELETEITEM, 0, (LPARAM)hItem); } BOOL DeleteAllItems() { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TVM_DELETEITEM, 0, (LPARAM)TVI_ROOT); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_DELETEITEM, 0, (LPARAM)TVI_ROOT); } BOOL Expand(HTREEITEM hItem, UINT nCode = TVE_EXPAND) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TVM_EXPAND, nCode, (LPARAM)hItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_EXPAND, nCode, (LPARAM)hItem); } HTREEITEM GetNextItem(HTREEITEM hItem, UINT nCode) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, nCode, (LPARAM)hItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, nCode, (LPARAM)hItem); } HTREEITEM GetChildItem(HTREEITEM hItem) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_CHILD, (LPARAM)hItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_CHILD, (LPARAM)hItem); } HTREEITEM GetNextSiblingItem(HTREEITEM hItem) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_NEXT, (LPARAM)hItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_NEXT, (LPARAM)hItem); } HTREEITEM GetPrevSiblingItem(HTREEITEM hItem) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_PREVIOUS, (LPARAM)hItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_PREVIOUS, (LPARAM)hItem); } HTREEITEM GetParentItem(HTREEITEM hItem) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_PARENT, (LPARAM)hItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_PARENT, (LPARAM)hItem); } HTREEITEM GetFirstVisibleItem() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_FIRSTVISIBLE, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_FIRSTVISIBLE, 0L); } HTREEITEM GetNextVisibleItem(HTREEITEM hItem) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_NEXTVISIBLE, (LPARAM)hItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_NEXTVISIBLE, (LPARAM)hItem); } HTREEITEM GetPrevVisibleItem(HTREEITEM hItem) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_PREVIOUSVISIBLE, (LPARAM)hItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_PREVIOUSVISIBLE, (LPARAM)hItem); } HTREEITEM GetSelectedItem() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_CARET, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_CARET, 0L); } HTREEITEM GetDropHilightItem() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_DROPHILITE, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_DROPHILITE, 0L); } HTREEITEM GetRootItem() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_ROOT, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_ROOT, 0L); } -#if !defined(_WIN32_WCE) && (_WIN32_IE >= 0x0400) HTREEITEM GetLastVisibleItem() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_LASTVISIBLE, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_LASTVISIBLE, 0L); } -#endif // !defined(_WIN32_WCE) && (_WIN32_IE >= 0x0400) -#if (_WIN32_IE >= 0x0600) - HTREEITEM GetNextSelectedItem() const + HTREEITEM GetNextSelectedItem(HTREEITEM hItem) const { -#ifndef TVGN_NEXTSELECTED - const WORD TVGN_NEXTSELECTED = 0x000B; -#endif - ATLASSERT(::IsWindow(m_hWnd)); - return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_NEXTSELECTED, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_NEXTSELECTED, (LPARAM)hItem); } -#endif // (_WIN32_IE >= 0x0600) BOOL Select(HTREEITEM hItem, UINT nCode) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TVM_SELECTITEM, nCode, (LPARAM)hItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_SELECTITEM, nCode, (LPARAM)hItem); } BOOL SelectItem(HTREEITEM hItem) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TVM_SELECTITEM, TVGN_CARET, (LPARAM)hItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_SELECTITEM, TVGN_CARET, (LPARAM)hItem); } BOOL SelectDropTarget(HTREEITEM hItem) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TVM_SELECTITEM, TVGN_DROPHILITE, (LPARAM)hItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_SELECTITEM, TVGN_DROPHILITE, (LPARAM)hItem); } BOOL SelectSetFirstVisible(HTREEITEM hItem) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TVM_SELECTITEM, TVGN_FIRSTVISIBLE, (LPARAM)hItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_SELECTITEM, TVGN_FIRSTVISIBLE, (LPARAM)hItem); } CEdit EditLabel(HTREEITEM hItem) { - ATLASSERT(::IsWindow(m_hWnd)); - return CEdit((HWND)::SendMessage(m_hWnd, TVM_EDITLABEL, 0, (LPARAM)hItem)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CEdit((HWND)::SendMessage(this->m_hWnd, TVM_EDITLABEL, 0, (LPARAM)hItem)); } BOOL EndEditLabelNow(BOOL bCancel) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TVM_ENDEDITLABELNOW, bCancel, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_ENDEDITLABELNOW, bCancel, 0L); } HTREEITEM HitTest(TVHITTESTINFO* pHitTestInfo) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (HTREEITEM)::SendMessage(m_hWnd, TVM_HITTEST, 0, (LPARAM)pHitTestInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_HITTEST, 0, (LPARAM)pHitTestInfo); } HTREEITEM HitTest(POINT pt, UINT* pFlags) const { - ATLASSERT(::IsWindow(m_hWnd)); - TVHITTESTINFO hti = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + TVHITTESTINFO hti = {}; hti.pt = pt; - HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_HITTEST, 0, (LPARAM)&hti); + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_HITTEST, 0, (LPARAM)&hti); if (pFlags != NULL) *pFlags = hti.flags; return hTreeItem; @@ -4607,67 +4567,63 @@ public: BOOL SortChildren(HTREEITEM hItem, BOOL bRecurse = FALSE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TVM_SORTCHILDREN, (WPARAM)bRecurse, (LPARAM)hItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_SORTCHILDREN, (WPARAM)bRecurse, (LPARAM)hItem); } BOOL EnsureVisible(HTREEITEM hItem) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TVM_ENSUREVISIBLE, 0, (LPARAM)hItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_ENSUREVISIBLE, 0, (LPARAM)hItem); } BOOL SortChildrenCB(LPTVSORTCB pSort, BOOL bRecurse = FALSE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TVM_SORTCHILDRENCB, (WPARAM)bRecurse, (LPARAM)pSort); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_SORTCHILDRENCB, (WPARAM)bRecurse, (LPARAM)pSort); } CImageList RemoveImageList(int nImageList) { - ATLASSERT(::IsWindow(m_hWnd)); - return CImageList((HIMAGELIST)::SendMessage(m_hWnd, TVM_SETIMAGELIST, (WPARAM)nImageList, NULL)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TVM_SETIMAGELIST, (WPARAM)nImageList, NULL)); } CImageList CreateDragImage(HTREEITEM hItem) { - ATLASSERT(::IsWindow(m_hWnd)); - return CImageList((HIMAGELIST)::SendMessage(m_hWnd, TVM_CREATEDRAGIMAGE, 0, (LPARAM)hItem)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TVM_CREATEDRAGIMAGE, 0, (LPARAM)hItem)); } -#if (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) BOOL SetInsertMark(HTREEITEM hTreeItem, BOOL bAfter) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TVM_SETINSERTMARK, bAfter, (LPARAM)hTreeItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_SETINSERTMARK, bAfter, (LPARAM)hTreeItem); } BOOL RemoveInsertMark() { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TVM_SETINSERTMARK, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_SETINSERTMARK, 0, 0L); } -#endif // (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) -#if (_WIN32_WINNT >= 0x0501) HTREEITEM MapAccIDToHTREEITEM(UINT uID) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (HTREEITEM)::SendMessage(m_hWnd, TVM_MAPACCIDTOHTREEITEM, uID, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_MAPACCIDTOHTREEITEM, uID, 0L); } UINT MapHTREEITEMToAccID(HTREEITEM hTreeItem) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (UINT)::SendMessage(m_hWnd, TVM_MAPHTREEITEMTOACCID, (WPARAM)hTreeItem, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, TVM_MAPHTREEITEMTOACCID, (WPARAM)hTreeItem, 0L); } -#endif // (_WIN32_WINNT >= 0x0501) #if (_WIN32_WINNT >= 0x0600) void ShowInfoTip(HTREEITEM hItem) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TVM_SHOWINFOTIP, 0, (LPARAM)hItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TVM_SHOWINFOTIP, 0, (LPARAM)hItem); } #endif // (_WIN32_WINNT >= 0x0600) }; @@ -4716,12 +4672,10 @@ public: BOOL GetRect(LPRECT lpRect, BOOL bTextOnly) const; BOOL GetText(LPTSTR lpstrText, int nLen) const; -#ifndef _ATL_NO_COM BOOL GetText(BSTR& bstrText) const; -#endif // !_ATL_NO_COM -#if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) - BOOL GetText(_CSTRING_NS::CString& strText) const; -#endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) +#ifdef __ATLSTR_H__ + BOOL GetText(ATL::CString& strText) const; +#endif // __ATLSTR_H__ BOOL SetText(LPCTSTR lpszItem); BOOL GetImage(int& nImage, int& nSelectedImage) const; BOOL SetImage(int nImage, int nSelectedImage); @@ -4758,12 +4712,8 @@ public: CTreeItemT GetSelected() const; CTreeItemT GetDropHilight() const; CTreeItemT GetRoot() const; -#if !defined(_WIN32_WCE) && (_WIN32_IE >= 0x0400) CTreeItemT GetLastVisible() const; -#endif // !defined(_WIN32_WCE) && (_WIN32_IE >= 0x0400) -#if (_WIN32_IE >= 0x0600) CTreeItemT GetNextSelected() const; -#endif // (_WIN32_IE >= 0x0600) BOOL HasChildren() const; BOOL Delete(); BOOL Expand(UINT nCode = TVE_EXPAND); @@ -4777,12 +4727,8 @@ public: BOOL EnsureVisible(); CTreeItemT _Insert(LPCTSTR lpstrItem, int nImageIndex, HTREEITEM hItemAfter); int GetImageIndex() const; -#if (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) BOOL SetInsertMark(BOOL bAfter); -#endif // (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) -#if (_WIN32_WINNT >= 0x0501) UINT MapHTREEITEMToAccID() const; -#endif // (_WIN32_WINNT >= 0x0501) #if (_WIN32_WINNT >= 0x0600) void ShowInfoTip(); BOOL GetPartRect(TVITEMPART partID, LPRECT lpRect) const; @@ -4802,133 +4748,126 @@ public: CTreeViewCtrlExT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } // Operations (overides that return CTreeItem) CTreeItemT InsertItem(LPTVINSERTSTRUCT lpInsertStruct) { - ATLASSERT(::IsWindow(m_hWnd)); - HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_INSERTITEM, 0, (LPARAM)lpInsertStruct); + ATLASSERT(::IsWindow(this->m_hWnd)); + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_INSERTITEM, 0, (LPARAM)lpInsertStruct); return CTreeItemT(hTreeItem, this); } CTreeItemT InsertItem(LPCTSTR lpszItem, int nImage, int nSelectedImage, HTREEITEM hParent, HTREEITEM hInsertAfter) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); return InsertItem(TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE, lpszItem, nImage, nSelectedImage, 0, 0, 0, hParent, hInsertAfter); } CTreeItemT InsertItem(LPCTSTR lpszItem, HTREEITEM hParent, HTREEITEM hInsertAfter) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); return InsertItem(TVIF_TEXT, lpszItem, 0, 0, 0, 0, 0, hParent, hInsertAfter); } CTreeItemT GetNextItem(HTREEITEM hItem, UINT nCode) const { - ATLASSERT(::IsWindow(m_hWnd)); - HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, nCode, (LPARAM)hItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, nCode, (LPARAM)hItem); return CTreeItemT(hTreeItem, (CTreeViewCtrlExT*)this); } CTreeItemT GetChildItem(HTREEITEM hItem) const { - ATLASSERT(::IsWindow(m_hWnd)); - HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_CHILD, (LPARAM)hItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_CHILD, (LPARAM)hItem); return CTreeItemT(hTreeItem, (CTreeViewCtrlExT*)this); } CTreeItemT GetNextSiblingItem(HTREEITEM hItem) const { - ATLASSERT(::IsWindow(m_hWnd)); - HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_NEXT, (LPARAM)hItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_NEXT, (LPARAM)hItem); return CTreeItemT(hTreeItem, (CTreeViewCtrlExT*)this); } CTreeItemT GetPrevSiblingItem(HTREEITEM hItem) const { - ATLASSERT(::IsWindow(m_hWnd)); - HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_PREVIOUS, (LPARAM)hItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_PREVIOUS, (LPARAM)hItem); return CTreeItemT(hTreeItem, (CTreeViewCtrlExT*)this); } CTreeItemT GetParentItem(HTREEITEM hItem) const { - ATLASSERT(::IsWindow(m_hWnd)); - HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_PARENT, (LPARAM)hItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_PARENT, (LPARAM)hItem); return CTreeItemT(hTreeItem, (CTreeViewCtrlExT*)this); } CTreeItemT GetFirstVisibleItem() const { - ATLASSERT(::IsWindow(m_hWnd)); - HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_FIRSTVISIBLE, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_FIRSTVISIBLE, 0L); return CTreeItemT(hTreeItem, (CTreeViewCtrlExT*)this); } CTreeItemT GetNextVisibleItem(HTREEITEM hItem) const { - ATLASSERT(::IsWindow(m_hWnd)); - HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_NEXTVISIBLE, (LPARAM)hItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_NEXTVISIBLE, (LPARAM)hItem); return CTreeItemT(hTreeItem, (CTreeViewCtrlExT*)this); } CTreeItemT GetPrevVisibleItem(HTREEITEM hItem) const { - ATLASSERT(::IsWindow(m_hWnd)); - HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_PREVIOUSVISIBLE, (LPARAM)hItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_PREVIOUSVISIBLE, (LPARAM)hItem); return CTreeItemT(hTreeItem, (CTreeViewCtrlExT*)this); } CTreeItemT GetSelectedItem() const { - ATLASSERT(::IsWindow(m_hWnd)); - HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_CARET, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_CARET, 0L); return CTreeItemT(hTreeItem, (CTreeViewCtrlExT*)this); } CTreeItemT GetDropHilightItem() const { - ATLASSERT(::IsWindow(m_hWnd)); - HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_DROPHILITE, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_DROPHILITE, 0L); return CTreeItemT(hTreeItem, (CTreeViewCtrlExT*)this); } CTreeItemT GetRootItem() const { - ATLASSERT(::IsWindow(m_hWnd)); - HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_ROOT, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_ROOT, 0L); return CTreeItemT(hTreeItem, (CTreeViewCtrlExT*)this); } -#if !defined(_WIN32_WCE) && (_WIN32_IE >= 0x0400) CTreeItemT GetLastVisibleItem() const { - ATLASSERT(::IsWindow(m_hWnd)); - HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_LASTVISIBLE, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_LASTVISIBLE, 0L); return CTreeItemT(hTreeItem, (CTreeViewCtrlExT*)this); } -#endif // !defined(_WIN32_WCE) && (_WIN32_IE >= 0x0400) -#if (_WIN32_IE >= 0x0600) - CTreeItemT GetNextSelectedItem() const + CTreeItemT GetNextSelectedItem(HTREEITEM hItem) const { -#ifndef TVGN_NEXTSELECTED - const WORD TVGN_NEXTSELECTED = 0x000B; -#endif - ATLASSERT(::IsWindow(m_hWnd)); - HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_NEXTSELECTED, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_NEXTSELECTED, (LPARAM)hItem); return CTreeItemT(hTreeItem, (CTreeViewCtrlExT*)this); } -#endif // (_WIN32_IE >= 0x0600) CTreeItemT HitTest(TVHITTESTINFO* pHitTestInfo) const { - ATLASSERT(::IsWindow(m_hWnd)); - HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_HITTEST, 0, (LPARAM)pHitTestInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_HITTEST, 0, (LPARAM)pHitTestInfo); return CTreeItemT(hTreeItem, (CTreeViewCtrlExT*)this); } @@ -4936,8 +4875,8 @@ public: int nSelectedImage, UINT nState, UINT nStateMask, LPARAM lParam, HTREEITEM hParent, HTREEITEM hInsertAfter) { - ATLASSERT(::IsWindow(m_hWnd)); - TVINSERTSTRUCT tvis = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + TVINSERTSTRUCT tvis = {}; tvis.hParent = hParent; tvis.hInsertAfter = hInsertAfter; tvis.item.mask = nMask; @@ -4947,29 +4886,27 @@ public: tvis.item.state = nState; tvis.item.stateMask = nStateMask; tvis.item.lParam = lParam; - HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_INSERTITEM, 0, (LPARAM)&tvis); + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_INSERTITEM, 0, (LPARAM)&tvis); return CTreeItemT(hTreeItem, this); } CTreeItemT HitTest(POINT pt, UINT* pFlags) const { - ATLASSERT(::IsWindow(m_hWnd)); - TVHITTESTINFO hti = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + TVHITTESTINFO hti = {}; hti.pt = pt; - HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_HITTEST, 0, (LPARAM)&hti); + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_HITTEST, 0, (LPARAM)&hti); if (pFlags != NULL) *pFlags = hti.flags; return CTreeItemT(hTreeItem, (CTreeViewCtrlExT*)this); } -#if (_WIN32_WINNT >= 0x0501) CTreeItemT MapAccIDToHTREEITEM(UINT uID) const { - ATLASSERT(::IsWindow(m_hWnd)); - HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_MAPACCIDTOHTREEITEM, uID, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_MAPACCIDTOHTREEITEM, uID, 0L); return CTreeItemT(hTreeItem, (CTreeViewCtrlExT*)this); } -#endif // (_WIN32_WINNT >= 0x0501) }; typedef CTreeViewCtrlExT CTreeViewCtrlEx; @@ -5060,23 +4997,19 @@ inline CTreeItemT CTreeItemT::GetRoot() const return m_pTreeView->GetRootItem(); } -#if !defined(_WIN32_WCE) && (_WIN32_IE >= 0x0400) template inline CTreeItemT CTreeItemT::GetLastVisible() const { ATLASSERT(m_pTreeView != NULL); return m_pTreeView->GetLastVisibleItem(); } -#endif // !defined(_WIN32_WCE) && (_WIN32_IE >= 0x0400) -#if (_WIN32_IE >= 0x0600) template inline CTreeItemT CTreeItemT::GetNextSelected() const { ATLASSERT(m_pTreeView != NULL); - return m_pTreeView->GetNextSelectedItem(); + return m_pTreeView->GetNextSelectedItem(m_hTreeItem); } -#endif // (_WIN32_IE >= 0x0600) template inline BOOL CTreeItemT::GetText(LPTSTR lpstrText, int nLen) const @@ -5085,7 +5018,6 @@ inline BOOL CTreeItemT::GetText(LPTSTR lpstrText, int nLen) const return m_pTreeView->GetItemText(m_hTreeItem, lpstrText, nLen); } -#ifndef _ATL_NO_COM #ifdef _OLEAUTO_H_ template inline BOOL CTreeItemT::GetText(BSTR& bstrText) const @@ -5094,16 +5026,15 @@ inline BOOL CTreeItemT::GetText(BSTR& bstrText) const return m_pTreeView->GetItemText(m_hTreeItem, bstrText); } #endif // _OLEAUTO_H_ -#endif // !_ATL_NO_COM -#if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) +#ifdef __ATLSTR_H__ template -inline BOOL CTreeItemT::GetText(_CSTRING_NS::CString& strText) const +inline BOOL CTreeItemT::GetText(ATL::CString& strText) const { ATLASSERT(m_pTreeView != NULL); return m_pTreeView->GetItemText(m_hTreeItem, strText); } -#endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) +#endif // __ATLSTR_H__ template inline BOOL CTreeItemT::GetImage(int& nImage, int& nSelectedImage) const @@ -5243,7 +5174,7 @@ template inline CTreeItemT CTreeItemT::_Insert(LPCTSTR lpstrItem, int nImageIndex, HTREEITEM hItemAfter) { ATLASSERT(m_pTreeView != NULL); - TVINSERTSTRUCT ins = { 0 }; + TVINSERTSTRUCT ins = {}; ins.hParent = m_hTreeItem; ins.hInsertAfter = hItemAfter; ins.item.mask = TVIF_TEXT; @@ -5261,30 +5192,26 @@ template inline int CTreeItemT::GetImageIndex() const { ATLASSERT(m_pTreeView != NULL); - TVITEM item = { 0 }; + TVITEM item = {}; item.mask = TVIF_HANDLE | TVIF_IMAGE; item.hItem = m_hTreeItem; m_pTreeView->GetItem(&item); return item.iImage; } -#if (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) template inline BOOL CTreeItemT::SetInsertMark(BOOL bAfter) { ATLASSERT(m_pTreeView != NULL); return m_pTreeView->SetInsertMark(m_hTreeItem, bAfter); } -#endif // (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) -#if (_WIN32_WINNT >= 0x0501) template inline UINT CTreeItemT::MapHTREEITEMToAccID() const { ATLASSERT(m_pTreeView != NULL); return m_pTreeView->MapHTREEITEMToAccID(m_hTreeItem); } -#endif // (_WIN32_WINNT >= 0x0501) #if (_WIN32_WINNT >= 0x0600) template @@ -5316,7 +5243,7 @@ public: CToolBarCtrlT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -5335,282 +5262,275 @@ public: BOOL IsButtonEnabled(int nID) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_ISBUTTONENABLED, nID, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_ISBUTTONENABLED, nID, 0L); } BOOL IsButtonChecked(int nID) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_ISBUTTONCHECKED, nID, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_ISBUTTONCHECKED, nID, 0L); } BOOL IsButtonPressed(int nID) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_ISBUTTONPRESSED, nID, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_ISBUTTONPRESSED, nID, 0L); } BOOL IsButtonHidden(int nID) const { - ATLASSERT(::IsWindow(m_hWnd)); - return(BOOL) ::SendMessage(m_hWnd, TB_ISBUTTONHIDDEN, nID, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return(BOOL) ::SendMessage(this->m_hWnd, TB_ISBUTTONHIDDEN, nID, 0L); } BOOL IsButtonIndeterminate(int nID) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_ISBUTTONINDETERMINATE, nID, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_ISBUTTONINDETERMINATE, nID, 0L); } int GetState(int nID) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TB_GETSTATE, nID, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TB_GETSTATE, nID, 0L); } BOOL SetState(int nID, UINT nState) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_SETSTATE, nID, MAKELPARAM(nState, 0)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_SETSTATE, nID, MAKELPARAM(nState, 0)); } BOOL GetButton(int nIndex, LPTBBUTTON lpButton) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_GETBUTTON, nIndex, (LPARAM)lpButton); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_GETBUTTON, nIndex, (LPARAM)lpButton); } int GetButtonCount() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TB_BUTTONCOUNT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TB_BUTTONCOUNT, 0, 0L); } BOOL GetItemRect(int nIndex, LPRECT lpRect) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_GETITEMRECT, nIndex, (LPARAM)lpRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_GETITEMRECT, nIndex, (LPARAM)lpRect); } void SetButtonStructSize(int nSize = sizeof(TBBUTTON)) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TB_BUTTONSTRUCTSIZE, nSize, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TB_BUTTONSTRUCTSIZE, nSize, 0L); } BOOL SetButtonSize(SIZE size) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_SETBUTTONSIZE, 0, MAKELPARAM(size.cx, size.cy)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_SETBUTTONSIZE, 0, MAKELPARAM(size.cx, size.cy)); } BOOL SetButtonSize(int cx, int cy) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_SETBUTTONSIZE, 0, MAKELPARAM(cx, cy)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_SETBUTTONSIZE, 0, MAKELPARAM(cx, cy)); } BOOL SetBitmapSize(SIZE size) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_SETBITMAPSIZE, 0, MAKELPARAM(size.cx, size.cy)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_SETBITMAPSIZE, 0, MAKELPARAM(size.cx, size.cy)); } BOOL SetBitmapSize(int cx, int cy) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_SETBITMAPSIZE, 0, MAKELPARAM(cx, cy)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_SETBITMAPSIZE, 0, MAKELPARAM(cx, cy)); } -#ifndef _WIN32_WCE CToolTipCtrl GetToolTips() const { - ATLASSERT(::IsWindow(m_hWnd)); - return CToolTipCtrl((HWND)::SendMessage(m_hWnd, TB_GETTOOLTIPS, 0, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CToolTipCtrl((HWND)::SendMessage(this->m_hWnd, TB_GETTOOLTIPS, 0, 0L)); } void SetToolTips(HWND hWndToolTip) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TB_SETTOOLTIPS, (WPARAM)hWndToolTip, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TB_SETTOOLTIPS, (WPARAM)hWndToolTip, 0L); } -#endif // !_WIN32_WCE void SetNotifyWnd(HWND hWnd) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TB_SETPARENT, (WPARAM)hWnd, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TB_SETPARENT, (WPARAM)hWnd, 0L); } int GetRows() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TB_GETROWS, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TB_GETROWS, 0, 0L); } void SetRows(int nRows, BOOL bLarger, LPRECT lpRect) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TB_SETROWS, MAKELPARAM(nRows, bLarger), (LPARAM)lpRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TB_SETROWS, MAKELPARAM(nRows, bLarger), (LPARAM)lpRect); } BOOL SetCmdID(int nIndex, UINT nID) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_SETCMDID, nIndex, nID); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_SETCMDID, nIndex, nID); } DWORD GetBitmapFlags() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, TB_GETBITMAPFLAGS, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, TB_GETBITMAPFLAGS, 0, 0L); } int GetBitmap(int nID) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TB_GETBITMAP, nID, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TB_GETBITMAP, nID, 0L); } int GetButtonText(int nID, LPTSTR lpstrText) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TB_GETBUTTONTEXT, nID, (LPARAM)lpstrText); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TB_GETBUTTONTEXT, nID, (LPARAM)lpstrText); } // nIndex - IE5 or higher only CImageList GetImageList(int nIndex = 0) const { - ATLASSERT(::IsWindow(m_hWnd)); - return CImageList((HIMAGELIST)::SendMessage(m_hWnd, TB_GETIMAGELIST, nIndex, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TB_GETIMAGELIST, nIndex, 0L)); } // nIndex - IE5 or higher only CImageList SetImageList(HIMAGELIST hImageList, int nIndex = 0) { - ATLASSERT(::IsWindow(m_hWnd)); - return CImageList((HIMAGELIST)::SendMessage(m_hWnd, TB_SETIMAGELIST, nIndex, (LPARAM)hImageList)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TB_SETIMAGELIST, nIndex, (LPARAM)hImageList)); } // nIndex - IE5 or higher only CImageList GetDisabledImageList(int nIndex = 0) const { - ATLASSERT(::IsWindow(m_hWnd)); - return CImageList((HIMAGELIST)::SendMessage(m_hWnd, TB_GETDISABLEDIMAGELIST, nIndex, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TB_GETDISABLEDIMAGELIST, nIndex, 0L)); } // nIndex - IE5 or higher only CImageList SetDisabledImageList(HIMAGELIST hImageList, int nIndex = 0) { - ATLASSERT(::IsWindow(m_hWnd)); - return CImageList((HIMAGELIST)::SendMessage(m_hWnd, TB_SETDISABLEDIMAGELIST, nIndex, (LPARAM)hImageList)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TB_SETDISABLEDIMAGELIST, nIndex, (LPARAM)hImageList)); } -#ifndef _WIN32_WCE // nIndex - IE5 or higher only CImageList GetHotImageList(int nIndex = 0) const { - ATLASSERT(::IsWindow(m_hWnd)); - return CImageList((HIMAGELIST)::SendMessage(m_hWnd, TB_GETHOTIMAGELIST, nIndex, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TB_GETHOTIMAGELIST, nIndex, 0L)); } // nIndex - IE5 or higher only CImageList SetHotImageList(HIMAGELIST hImageList, int nIndex = 0) { - ATLASSERT(::IsWindow(m_hWnd)); - return CImageList((HIMAGELIST)::SendMessage(m_hWnd, TB_SETHOTIMAGELIST, nIndex, (LPARAM)hImageList)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TB_SETHOTIMAGELIST, nIndex, (LPARAM)hImageList)); } -#endif // !_WIN32_WCE DWORD GetStyle() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, TB_GETSTYLE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, TB_GETSTYLE, 0, 0L); } void SetStyle(DWORD dwStyle) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TB_SETSTYLE, 0, dwStyle); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TB_SETSTYLE, 0, dwStyle); } DWORD GetButtonSize() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, TB_GETBUTTONSIZE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, TB_GETBUTTONSIZE, 0, 0L); } void GetButtonSize(SIZE& size) const { - ATLASSERT(::IsWindow(m_hWnd)); - DWORD dwRet = (DWORD)::SendMessage(m_hWnd, TB_GETBUTTONSIZE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, TB_GETBUTTONSIZE, 0, 0L); size.cx = LOWORD(dwRet); size.cy = HIWORD(dwRet); } BOOL GetRect(int nID, LPRECT lpRect) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_GETRECT, nID, (LPARAM)lpRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_GETRECT, nID, (LPARAM)lpRect); } int GetTextRows() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TB_GETTEXTROWS, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TB_GETTEXTROWS, 0, 0L); } BOOL SetButtonWidth(int cxMin, int cxMax) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_SETBUTTONWIDTH, 0, MAKELPARAM(cxMin, cxMax)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_SETBUTTONWIDTH, 0, MAKELPARAM(cxMin, cxMax)); } BOOL SetIndent(int nIndent) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_SETINDENT, nIndent, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_SETINDENT, nIndent, 0L); } BOOL SetMaxTextRows(int nMaxTextRows) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_SETMAXTEXTROWS, nMaxTextRows, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_SETMAXTEXTROWS, nMaxTextRows, 0L); } -#if (_WIN32_IE >= 0x0400) -#ifndef _WIN32_WCE BOOL GetAnchorHighlight() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_GETANCHORHIGHLIGHT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_GETANCHORHIGHLIGHT, 0, 0L); } BOOL SetAnchorHighlight(BOOL bEnable = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_SETANCHORHIGHLIGHT, bEnable, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_SETANCHORHIGHLIGHT, bEnable, 0L); } -#endif // !_WIN32_WCE int GetButtonInfo(int nID, LPTBBUTTONINFO lptbbi) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TB_GETBUTTONINFO, nID, (LPARAM)lptbbi); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TB_GETBUTTONINFO, nID, (LPARAM)lptbbi); } BOOL SetButtonInfo(int nID, LPTBBUTTONINFO lptbbi) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_SETBUTTONINFO, nID, (LPARAM)lptbbi); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_SETBUTTONINFO, nID, (LPARAM)lptbbi); } BOOL SetButtonInfo(int nID, DWORD dwMask, BYTE Style, BYTE State, LPCTSTR lpszItem, int iImage, WORD cx, int iCommand, DWORD_PTR lParam) { - ATLASSERT(::IsWindow(m_hWnd)); - TBBUTTONINFO tbbi = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + TBBUTTONINFO tbbi = {}; tbbi.cbSize = sizeof(TBBUTTONINFO); tbbi.dwMask = dwMask; tbbi.idCommand = iCommand; @@ -5620,103 +5540,100 @@ public: tbbi.cx = cx; tbbi.pszText = (LPTSTR) lpszItem; tbbi.lParam = lParam; - return (BOOL)::SendMessage(m_hWnd, TB_SETBUTTONINFO, nID, (LPARAM)&tbbi); + return (BOOL)::SendMessage(this->m_hWnd, TB_SETBUTTONINFO, nID, (LPARAM)&tbbi); } -#ifndef _WIN32_WCE int GetHotItem() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TB_GETHOTITEM, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TB_GETHOTITEM, 0, 0L); } int SetHotItem(int nItem) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TB_SETHOTITEM, nItem, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TB_SETHOTITEM, nItem, 0L); } -#endif // !_WIN32_WCE BOOL IsButtonHighlighted(int nButtonID) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_ISBUTTONHIGHLIGHTED, nButtonID, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_ISBUTTONHIGHLIGHTED, nButtonID, 0L); } DWORD SetDrawTextFlags(DWORD dwMask, DWORD dwFlags) { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, TB_SETDRAWTEXTFLAGS, dwMask, dwFlags); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, TB_SETDRAWTEXTFLAGS, dwMask, dwFlags); } -#ifndef _WIN32_WCE BOOL GetColorScheme(LPCOLORSCHEME lpcs) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_GETCOLORSCHEME, 0, (LPARAM)lpcs); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_GETCOLORSCHEME, 0, (LPARAM)lpcs); } void SetColorScheme(LPCOLORSCHEME lpcs) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TB_SETCOLORSCHEME, 0, (LPARAM)lpcs); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TB_SETCOLORSCHEME, 0, (LPARAM)lpcs); } DWORD GetExtendedStyle() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, TB_GETEXTENDEDSTYLE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, TB_GETEXTENDEDSTYLE, 0, 0L); } DWORD SetExtendedStyle(DWORD dwStyle) { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, TB_SETEXTENDEDSTYLE, 0, dwStyle); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, TB_SETEXTENDEDSTYLE, 0, dwStyle); } void GetInsertMark(LPTBINSERTMARK lptbim) const { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TB_GETINSERTMARK, 0, (LPARAM)lptbim); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TB_GETINSERTMARK, 0, (LPARAM)lptbim); } void SetInsertMark(LPTBINSERTMARK lptbim) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TB_SETINSERTMARK, 0, (LPARAM)lptbim); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TB_SETINSERTMARK, 0, (LPARAM)lptbim); } COLORREF GetInsertMarkColor() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, TB_GETINSERTMARKCOLOR, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, TB_GETINSERTMARKCOLOR, 0, 0L); } COLORREF SetInsertMarkColor(COLORREF clr) { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, TB_SETINSERTMARKCOLOR, 0, (LPARAM)clr); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, TB_SETINSERTMARKCOLOR, 0, (LPARAM)clr); } BOOL GetMaxSize(LPSIZE lpSize) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_GETMAXSIZE, 0, (LPARAM)lpSize); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_GETMAXSIZE, 0, (LPARAM)lpSize); } void GetPadding(LPSIZE lpSizePadding) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(lpSizePadding != NULL); - DWORD dwRet = (DWORD)::SendMessage(m_hWnd, TB_GETPADDING, 0, 0L); + DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, TB_GETPADDING, 0, 0L); lpSizePadding->cx = GET_X_LPARAM(dwRet); lpSizePadding->cy = GET_Y_LPARAM(dwRet); } void SetPadding(int cx, int cy, LPSIZE lpSizePadding = NULL) { - ATLASSERT(::IsWindow(m_hWnd)); - DWORD dwRet = (DWORD)::SendMessage(m_hWnd, TB_SETPADDING, 0, MAKELPARAM(cx, cy)); + ATLASSERT(::IsWindow(this->m_hWnd)); + DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, TB_SETPADDING, 0, MAKELPARAM(cx, cy)); if(lpSizePadding != NULL) { lpSizePadding->cx = GET_X_LPARAM(dwRet); @@ -5726,38 +5643,35 @@ public: BOOL GetUnicodeFormat() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_GETUNICODEFORMAT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_GETUNICODEFORMAT, 0, 0L); } BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_SETUNICODEFORMAT, bUnicode, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_SETUNICODEFORMAT, bUnicode, 0L); } -#endif // !_WIN32_WCE -#endif // (_WIN32_IE >= 0x0400) -#if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) int GetString(int nString, LPTSTR lpstrString, int cchMaxLen) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TB_GETSTRING, MAKEWPARAM(cchMaxLen, nString), (LPARAM)lpstrString); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TB_GETSTRING, MAKEWPARAM(cchMaxLen, nString), (LPARAM)lpstrString); } int GetStringBSTR(int nString, BSTR& bstrString) const { USES_CONVERSION; - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(bstrString == NULL); - int nLength = (int)(short)LOWORD(::SendMessage(m_hWnd, TB_GETSTRING, MAKEWPARAM(0, nString), NULL)); + int nLength = (int)(short)LOWORD(::SendMessage(this->m_hWnd, TB_GETSTRING, MAKEWPARAM(0, nString), NULL)); if(nLength != -1) { - CTempBuffer buff; + ATL::CTempBuffer buff; LPTSTR lpstrText = buff.Allocate(nLength + 1); if(lpstrText != NULL) { - nLength = (int)::SendMessage(m_hWnd, TB_GETSTRING, MAKEWPARAM(nLength + 1, nString), (LPARAM)lpstrText); + nLength = (int)::SendMessage(this->m_hWnd, TB_GETSTRING, MAKEWPARAM(nLength + 1, nString), (LPARAM)lpstrText); if(nLength != -1) bstrString = ::SysAllocString(T2OLE(lpstrText)); } @@ -5770,56 +5684,53 @@ public: return nLength; } -#if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) - int GetString(int nString, _CSTRING_NS::CString& str) const +#ifdef __ATLSTR_H__ + int GetString(int nString, ATL::CString& str) const { - ATLASSERT(::IsWindow(m_hWnd)); - int nLength = (int)(short)LOWORD(::SendMessage(m_hWnd, TB_GETSTRING, MAKEWPARAM(0, nString), NULL)); + ATLASSERT(::IsWindow(this->m_hWnd)); + int nLength = (int)(short)LOWORD(::SendMessage(this->m_hWnd, TB_GETSTRING, MAKEWPARAM(0, nString), NULL)); if(nLength != -1) { LPTSTR lpstr = str.GetBufferSetLength(nLength + 1); if(lpstr != NULL) - nLength = (int)::SendMessage(m_hWnd, TB_GETSTRING, MAKEWPARAM(nLength + 1, nString), (LPARAM)lpstr); + nLength = (int)::SendMessage(this->m_hWnd, TB_GETSTRING, MAKEWPARAM(nLength + 1, nString), (LPARAM)lpstr); else nLength = -1; str.ReleaseBuffer(); } return nLength; } -#endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) -#endif // (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) +#endif // __ATLSTR_H__ -#if (_WIN32_WINNT >= 0x0501) void GetMetrics(LPTBMETRICS lptbm) const { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TB_GETMETRICS, 0, (LPARAM)lptbm); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TB_GETMETRICS, 0, (LPARAM)lptbm); } void SetMetrics(LPTBMETRICS lptbm) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TB_SETMETRICS, 0, (LPARAM)lptbm); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TB_SETMETRICS, 0, (LPARAM)lptbm); } void SetWindowTheme(LPCWSTR lpstrTheme) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TB_SETWINDOWTHEME, 0, (LPARAM)lpstrTheme); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TB_SETWINDOWTHEME, 0, (LPARAM)lpstrTheme); } -#endif // (_WIN32_WINNT >= 0x0501) #if (_WIN32_WINNT >= 0x0600) CImageList GetPressedImageList(int nIndex = 0) const { - ATLASSERT(::IsWindow(m_hWnd)); - return CImageList((HIMAGELIST)::SendMessage(m_hWnd, TB_GETPRESSEDIMAGELIST, nIndex, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TB_GETPRESSEDIMAGELIST, nIndex, 0L)); } CImageList SetPressedImageList(HIMAGELIST hImageList, int nIndex = 0) { - ATLASSERT(::IsWindow(m_hWnd)); - return CImageList((HIMAGELIST)::SendMessage(m_hWnd, TB_SETPRESSEDIMAGELIST, nIndex, (LPARAM)hImageList)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TB_SETPRESSEDIMAGELIST, nIndex, (LPARAM)hImageList)); } void GetItemDropDownRect(int nIndex, LPRECT lpRect) const @@ -5827,9 +5738,9 @@ public: #ifndef TB_GETITEMDROPDOWNRECT const int TB_GETITEMDROPDOWNRECT = WM_USER + 103; #endif - ATLASSERT(::IsWindow(m_hWnd)); - BOOL bRet = (BOOL)::SendMessage(m_hWnd, TB_GETITEMDROPDOWNRECT, nIndex, (LPARAM)lpRect); - bRet; // avoid level 4 warning + ATLASSERT(::IsWindow(this->m_hWnd)); + BOOL bRet = (BOOL)::SendMessage(this->m_hWnd, TB_GETITEMDROPDOWNRECT, nIndex, (LPARAM)lpRect); + (void)bRet; // avoid level 4 warning ATLASSERT(bRet != FALSE); } #endif // (_WIN32_WINNT >= 0x0600) @@ -5837,77 +5748,77 @@ public: // Operations BOOL EnableButton(int nID, BOOL bEnable = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_ENABLEBUTTON, nID, MAKELPARAM(bEnable, 0)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_ENABLEBUTTON, nID, MAKELPARAM(bEnable, 0)); } BOOL CheckButton(int nID, BOOL bCheck = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_CHECKBUTTON, nID, MAKELPARAM(bCheck, 0)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_CHECKBUTTON, nID, MAKELPARAM(bCheck, 0)); } BOOL PressButton(int nID, BOOL bPress = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_PRESSBUTTON, nID, MAKELPARAM(bPress, 0)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_PRESSBUTTON, nID, MAKELPARAM(bPress, 0)); } BOOL HideButton(int nID, BOOL bHide = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_HIDEBUTTON, nID, MAKELPARAM(bHide, 0)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_HIDEBUTTON, nID, MAKELPARAM(bHide, 0)); } BOOL Indeterminate(int nID, BOOL bIndeterminate = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_INDETERMINATE, nID, MAKELPARAM(bIndeterminate, 0)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_INDETERMINATE, nID, MAKELPARAM(bIndeterminate, 0)); } int AddBitmap(int nNumButtons, UINT nBitmapID) { - ATLASSERT(::IsWindow(m_hWnd)); - TBADDBITMAP tbab = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + TBADDBITMAP tbab = {}; tbab.hInst = ModuleHelper::GetResourceInstance(); ATLASSERT(tbab.hInst != NULL); tbab.nID = nBitmapID; - return (int)::SendMessage(m_hWnd, TB_ADDBITMAP, (WPARAM)nNumButtons, (LPARAM)&tbab); + return (int)::SendMessage(this->m_hWnd, TB_ADDBITMAP, (WPARAM)nNumButtons, (LPARAM)&tbab); } int AddBitmap(int nNumButtons, HBITMAP hBitmap) { - ATLASSERT(::IsWindow(m_hWnd)); - TBADDBITMAP tbab = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + TBADDBITMAP tbab = {}; tbab.hInst = NULL; tbab.nID = (UINT_PTR)hBitmap; - return (int)::SendMessage(m_hWnd, TB_ADDBITMAP, (WPARAM)nNumButtons, (LPARAM)&tbab); + return (int)::SendMessage(this->m_hWnd, TB_ADDBITMAP, (WPARAM)nNumButtons, (LPARAM)&tbab); } - BOOL AddButtons(int nNumButtons, LPTBBUTTON lpButtons) + BOOL AddButtons(int nNumButtons, LPCTBBUTTON lpButtons) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_ADDBUTTONS, nNumButtons, (LPARAM)lpButtons); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_ADDBUTTONS, nNumButtons, (LPARAM)lpButtons); } - BOOL InsertButton(int nIndex, LPTBBUTTON lpButton) + BOOL InsertButton(int nIndex, LPCTBBUTTON lpButton) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_INSERTBUTTON, nIndex, (LPARAM)lpButton); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_INSERTBUTTON, nIndex, (LPARAM)lpButton); } BOOL InsertButton(int nIndex, int iCommand, BYTE Style, BYTE State, int iBitmap, INT_PTR iString, DWORD_PTR lParam) { - ATLASSERT(::IsWindow(m_hWnd)); - TBBUTTON tbb = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + TBBUTTON tbb = {}; tbb.fsStyle = Style; tbb.fsState = State; tbb.idCommand = iCommand; tbb.iBitmap = iBitmap; tbb.iString = iString; tbb.dwData = lParam; - return (BOOL)::SendMessage(m_hWnd, TB_INSERTBUTTON, nIndex, (LPARAM)&tbb); + return (BOOL)::SendMessage(this->m_hWnd, TB_INSERTBUTTON, nIndex, (LPARAM)&tbb); } BOOL InsertButton(int nIndex, int iCommand, BYTE Style, BYTE State, int iBitmap, @@ -5933,8 +5844,8 @@ public: BOOL DeleteButton(int nIndex) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_DELETEBUTTON, nIndex, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_DELETEBUTTON, nIndex, 0L); } BOOL InsertSeparator(int nIndex, int cxWidth = 8) @@ -5949,126 +5860,120 @@ public: int CommandToIndex(UINT nID) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TB_COMMANDTOINDEX, nID, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TB_COMMANDTOINDEX, nID, 0L); } -#ifndef _WIN32_WCE void SaveState(HKEY hKeyRoot, LPCTSTR lpszSubKey, LPCTSTR lpszValueName) { - ATLASSERT(::IsWindow(m_hWnd)); - TBSAVEPARAMS tbs = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + TBSAVEPARAMS tbs = {}; tbs.hkr = hKeyRoot; tbs.pszSubKey = lpszSubKey; tbs.pszValueName = lpszValueName; - ::SendMessage(m_hWnd, TB_SAVERESTORE, (WPARAM)TRUE, (LPARAM)&tbs); + ::SendMessage(this->m_hWnd, TB_SAVERESTORE, (WPARAM)TRUE, (LPARAM)&tbs); } void RestoreState(HKEY hKeyRoot, LPCTSTR lpszSubKey, LPCTSTR lpszValueName) { - ATLASSERT(::IsWindow(m_hWnd)); - TBSAVEPARAMS tbs = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + TBSAVEPARAMS tbs = {}; tbs.hkr = hKeyRoot; tbs.pszSubKey = lpszSubKey; tbs.pszValueName = lpszValueName; - ::SendMessage(m_hWnd, TB_SAVERESTORE, (WPARAM)FALSE, (LPARAM)&tbs); + ::SendMessage(this->m_hWnd, TB_SAVERESTORE, (WPARAM)FALSE, (LPARAM)&tbs); } void Customize() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TB_CUSTOMIZE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TB_CUSTOMIZE, 0, 0L); } -#endif // !_WIN32_WCE int AddString(UINT nStringID) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TB_ADDSTRING, (WPARAM)ModuleHelper::GetResourceInstance(), (LPARAM)nStringID); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TB_ADDSTRING, (WPARAM)ModuleHelper::GetResourceInstance(), (LPARAM)nStringID); } int AddStrings(LPCTSTR lpszStrings) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TB_ADDSTRING, 0, (LPARAM)lpszStrings); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TB_ADDSTRING, 0, (LPARAM)lpszStrings); } void AutoSize() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TB_AUTOSIZE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TB_AUTOSIZE, 0, 0L); } BOOL ChangeBitmap(int nID, int nBitmap) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_CHANGEBITMAP, nID, MAKELPARAM(nBitmap, 0)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_CHANGEBITMAP, nID, MAKELPARAM(nBitmap, 0)); } int LoadImages(int nBitmapID) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TB_LOADIMAGES, nBitmapID, (LPARAM)ModuleHelper::GetResourceInstance()); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TB_LOADIMAGES, nBitmapID, (LPARAM)ModuleHelper::GetResourceInstance()); } int LoadStdImages(int nBitmapID) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TB_LOADIMAGES, nBitmapID, (LPARAM)HINST_COMMCTRL); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TB_LOADIMAGES, nBitmapID, (LPARAM)HINST_COMMCTRL); } BOOL ReplaceBitmap(LPTBREPLACEBITMAP ptbrb) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_REPLACEBITMAP, 0, (LPARAM)ptbrb); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_REPLACEBITMAP, 0, (LPARAM)ptbrb); } -#if (_WIN32_IE >= 0x0400) int HitTest(LPPOINT lpPoint) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TB_HITTEST, 0, (LPARAM)lpPoint); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TB_HITTEST, 0, (LPARAM)lpPoint); } -#ifndef _WIN32_WCE BOOL InsertMarkHitTest(LPPOINT lpPoint, LPTBINSERTMARK lptbim) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_INSERTMARKHITTEST, (WPARAM)lpPoint, (LPARAM)lptbim); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_INSERTMARKHITTEST, (WPARAM)lpPoint, (LPARAM)lptbim); } BOOL InsertMarkHitTest(int x, int y, LPTBINSERTMARK lptbim) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); POINT pt = { x, y }; - return (BOOL)::SendMessage(m_hWnd, TB_INSERTMARKHITTEST, (WPARAM)&pt, (LPARAM)lptbim); + return (BOOL)::SendMessage(this->m_hWnd, TB_INSERTMARKHITTEST, (WPARAM)&pt, (LPARAM)lptbim); } BOOL MapAccelerator(TCHAR chAccel, int& nID) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_MAPACCELERATOR, (WPARAM)chAccel, (LPARAM)&nID); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_MAPACCELERATOR, (WPARAM)chAccel, (LPARAM)&nID); } BOOL MarkButton(int nID, BOOL bHighlight = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_MARKBUTTON, nID, MAKELPARAM(bHighlight, 0)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_MARKBUTTON, nID, MAKELPARAM(bHighlight, 0)); } BOOL MoveButton(int nOldPos, int nNewPos) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_MOVEBUTTON, nOldPos, nNewPos); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_MOVEBUTTON, nOldPos, nNewPos); } HRESULT GetObject(REFIID iid, LPVOID* ppvObject) { - ATLASSERT(::IsWindow(m_hWnd)); - return (HRESULT)::SendMessage(m_hWnd, TB_GETOBJECT, (WPARAM)&iid, (LPARAM)ppvObject); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HRESULT)::SendMessage(this->m_hWnd, TB_GETOBJECT, (WPARAM)&iid, (LPARAM)ppvObject); } -#endif // !_WIN32_WCE -#endif // (_WIN32_IE >= 0x0400) }; typedef CToolBarCtrlT CToolBarCtrl; @@ -6087,7 +5992,7 @@ public: CStatusBarCtrlT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -6106,21 +6011,21 @@ public: int GetParts(int nParts, int* pParts) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, SB_GETPARTS, nParts, (LPARAM)pParts); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, SB_GETPARTS, nParts, (LPARAM)pParts); } BOOL SetParts(int nParts, int* pWidths) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, SB_SETPARTS, nParts, (LPARAM)pWidths); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, SB_SETPARTS, nParts, (LPARAM)pWidths); } int GetTextLength(int nPane, int* pType = NULL) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(nPane < 256); - DWORD dwRet = (DWORD)::SendMessage(m_hWnd, SB_GETTEXTLENGTH, (WPARAM)nPane, 0L); + DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, SB_GETTEXTLENGTH, (WPARAM)nPane, 0L); if (pType != NULL) *pType = (int)(short)HIWORD(dwRet); return (int)(short)LOWORD(dwRet); @@ -6128,26 +6033,25 @@ public: int GetText(int nPane, LPTSTR lpszText, int* pType = NULL) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(nPane < 256); - DWORD dwRet = (DWORD)::SendMessage(m_hWnd, SB_GETTEXT, (WPARAM)nPane, (LPARAM)lpszText); + DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, SB_GETTEXT, (WPARAM)nPane, (LPARAM)lpszText); if(pType != NULL) *pType = (int)(short)HIWORD(dwRet); return (int)(short)LOWORD(dwRet); } -#ifndef _ATL_NO_COM BOOL GetTextBSTR(int nPane, BSTR& bstrText, int* pType = NULL) const { USES_CONVERSION; - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(nPane < 256); ATLASSERT(bstrText == NULL); - int nLength = (int)(short)LOWORD(::SendMessage(m_hWnd, SB_GETTEXTLENGTH, (WPARAM)nPane, 0L)); + int nLength = (int)(short)LOWORD(::SendMessage(this->m_hWnd, SB_GETTEXTLENGTH, (WPARAM)nPane, 0L)); if(nLength == 0) return FALSE; - CTempBuffer buff; + ATL::CTempBuffer buff; LPTSTR lpstrText = buff.Allocate(nLength + 1); if(lpstrText == NULL) return FALSE; @@ -6158,14 +6062,13 @@ public: bstrText = ::SysAllocString(T2OLE(lpstrText)); return (bstrText != NULL) ? TRUE : FALSE; } -#endif // !_ATL_NO_COM -#if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) - int GetText(int nPane, _CSTRING_NS::CString& strText, int* pType = NULL) const +#ifdef __ATLSTR_H__ + int GetText(int nPane, ATL::CString& strText, int* pType = NULL) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(nPane < 256); - int nLength = (int)(short)LOWORD(::SendMessage(m_hWnd, SB_GETTEXTLENGTH, (WPARAM)nPane, 0L)); + int nLength = (int)(short)LOWORD(::SendMessage(this->m_hWnd, SB_GETTEXTLENGTH, (WPARAM)nPane, 0L)); if(nLength == 0) return 0; @@ -6174,33 +6077,33 @@ public: return 0; return GetText(nPane, lpstr, pType); } -#endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) +#endif // __ATLSTR_H__ BOOL SetText(int nPane, LPCTSTR lpszText, int nType = 0) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(nPane < 256); - return (BOOL)::SendMessage(m_hWnd, SB_SETTEXT, (nPane | nType), (LPARAM)lpszText); + return (BOOL)::SendMessage(this->m_hWnd, SB_SETTEXT, (nPane | nType), (LPARAM)lpszText); } BOOL GetRect(int nPane, LPRECT lpRect) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(nPane < 256); - return (BOOL)::SendMessage(m_hWnd, SB_GETRECT, nPane, (LPARAM)lpRect); + return (BOOL)::SendMessage(this->m_hWnd, SB_GETRECT, nPane, (LPARAM)lpRect); } BOOL GetBorders(int* pBorders) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, SB_GETBORDERS, 0, (LPARAM)pBorders); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, SB_GETBORDERS, 0, (LPARAM)pBorders); } BOOL GetBorders(int& nHorz, int& nVert, int& nSpacing) const { - ATLASSERT(::IsWindow(m_hWnd)); - int borders[3] = { 0, 0, 0 }; - BOOL bResult = (BOOL)::SendMessage(m_hWnd, SB_GETBORDERS, 0, (LPARAM)&borders); + ATLASSERT(::IsWindow(this->m_hWnd)); + int borders[3] = {}; + BOOL bResult = (BOOL)::SendMessage(this->m_hWnd, SB_GETBORDERS, 0, (LPARAM)&borders); if(bResult) { nHorz = borders[0]; @@ -6212,71 +6115,67 @@ public: void SetMinHeight(int nMin) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, SB_SETMINHEIGHT, nMin, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, SB_SETMINHEIGHT, nMin, 0L); } BOOL SetSimple(BOOL bSimple = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, SB_SIMPLE, bSimple, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, SB_SIMPLE, bSimple, 0L); } BOOL IsSimple() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, SB_ISSIMPLE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, SB_ISSIMPLE, 0, 0L); } -#if (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) BOOL GetUnicodeFormat() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, SB_GETUNICODEFORMAT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, SB_GETUNICODEFORMAT, 0, 0L); } BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, SB_SETUNICODEFORMAT, bUnicode, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, SB_SETUNICODEFORMAT, bUnicode, 0L); } void GetTipText(int nPane, LPTSTR lpstrText, int nSize) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(nPane < 256); - ::SendMessage(m_hWnd, SB_GETTIPTEXT, MAKEWPARAM(nPane, nSize), (LPARAM)lpstrText); + ::SendMessage(this->m_hWnd, SB_GETTIPTEXT, MAKEWPARAM(nPane, nSize), (LPARAM)lpstrText); } void SetTipText(int nPane, LPCTSTR lpstrText) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(nPane < 256); - ::SendMessage(m_hWnd, SB_SETTIPTEXT, nPane, (LPARAM)lpstrText); + ::SendMessage(this->m_hWnd, SB_SETTIPTEXT, nPane, (LPARAM)lpstrText); } -#endif // (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) -#if ((_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE)) || (defined(_WIN32_WCE) && (_WIN32_WCE >= 0x0500)) COLORREF SetBkColor(COLORREF clrBk) { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, SB_SETBKCOLOR, 0, (LPARAM)clrBk); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, SB_SETBKCOLOR, 0, (LPARAM)clrBk); } HICON GetIcon(int nPane) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(nPane < 256); - return (HICON)::SendMessage(m_hWnd, SB_GETICON, nPane, 0L); + return (HICON)::SendMessage(this->m_hWnd, SB_GETICON, nPane, 0L); } BOOL SetIcon(int nPane, HICON hIcon) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(nPane < 256); - return (BOOL)::SendMessage(m_hWnd, SB_SETICON, nPane, (LPARAM)hIcon); + return (BOOL)::SendMessage(this->m_hWnd, SB_SETICON, nPane, (LPARAM)hIcon); } -#endif // ((_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE)) || (defined(_WIN32_WCE) && (_WIN32_WCE >= 0x0500)) }; typedef CStatusBarCtrlT CStatusBarCtrl; @@ -6295,7 +6194,7 @@ public: CTabCtrlT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -6314,96 +6213,95 @@ public: CImageList GetImageList() const { - ATLASSERT(::IsWindow(m_hWnd)); - return CImageList((HIMAGELIST)::SendMessage(m_hWnd, TCM_GETIMAGELIST, 0, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TCM_GETIMAGELIST, 0, 0L)); } CImageList SetImageList(HIMAGELIST hImageList) { - ATLASSERT(::IsWindow(m_hWnd)); - return CImageList((HIMAGELIST)::SendMessage(m_hWnd, TCM_SETIMAGELIST, 0, (LPARAM)hImageList)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TCM_SETIMAGELIST, 0, (LPARAM)hImageList)); } int GetItemCount() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TCM_GETITEMCOUNT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TCM_GETITEMCOUNT, 0, 0L); } BOOL GetItem(int nItem, LPTCITEM pTabCtrlItem) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TCM_GETITEM, nItem, (LPARAM)pTabCtrlItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TCM_GETITEM, nItem, (LPARAM)pTabCtrlItem); } BOOL SetItem(int nItem, LPTCITEM pTabCtrlItem) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TCM_SETITEM, nItem, (LPARAM)pTabCtrlItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TCM_SETITEM, nItem, (LPARAM)pTabCtrlItem); } int SetItem(int nItem, UINT mask, LPCTSTR lpszItem, DWORD dwState, DWORD dwStateMask, int iImage, LPARAM lParam) { - ATLASSERT(::IsWindow(m_hWnd)); - TCITEM tci = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + TCITEM tci = {}; tci.mask = mask; tci.pszText = (LPTSTR) lpszItem; tci.dwState = dwState; tci.dwStateMask = dwStateMask; tci.iImage = iImage; tci.lParam = lParam; - return (int)::SendMessage(m_hWnd, TCM_SETITEM, nItem, (LPARAM)&tci); + return (int)::SendMessage(this->m_hWnd, TCM_SETITEM, nItem, (LPARAM)&tci); } BOOL GetItemRect(int nItem, LPRECT lpRect) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TCM_GETITEMRECT, nItem, (LPARAM)lpRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TCM_GETITEMRECT, nItem, (LPARAM)lpRect); } int GetCurSel() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TCM_GETCURSEL, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TCM_GETCURSEL, 0, 0L); } int SetCurSel(int nItem) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TCM_SETCURSEL, nItem, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TCM_SETCURSEL, nItem, 0L); } SIZE SetItemSize(SIZE size) { - ATLASSERT(::IsWindow(m_hWnd)); - DWORD dwSize = (DWORD)::SendMessage(m_hWnd, TCM_SETITEMSIZE, 0, MAKELPARAM(size.cx, size.cy)); + ATLASSERT(::IsWindow(this->m_hWnd)); + DWORD dwSize = (DWORD)::SendMessage(this->m_hWnd, TCM_SETITEMSIZE, 0, MAKELPARAM(size.cx, size.cy)); SIZE sizeRet = { GET_X_LPARAM(dwSize), GET_Y_LPARAM(dwSize) }; return sizeRet; } void SetItemSize(int cx, int cy) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TCM_SETITEMSIZE, 0, MAKELPARAM(cx, cy)); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TCM_SETITEMSIZE, 0, MAKELPARAM(cx, cy)); } void SetPadding(SIZE size) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TCM_SETPADDING, 0, MAKELPARAM(size.cx, size.cy)); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TCM_SETPADDING, 0, MAKELPARAM(size.cx, size.cy)); } int GetRowCount() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TCM_GETROWCOUNT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TCM_GETROWCOUNT, 0, 0L); } -#ifndef _WIN32_WCE CToolTipCtrl GetToolTips() const { - ATLASSERT(::IsWindow(m_hWnd)); - return CToolTipCtrl((HWND)::SendMessage(m_hWnd, TCM_GETTOOLTIPS, 0, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CToolTipCtrl((HWND)::SendMessage(this->m_hWnd, TCM_GETTOOLTIPS, 0, 0L)); } // this method is deprecated, please use GetToolTips @@ -6411,93 +6309,87 @@ public: void SetToolTips(HWND hWndToolTip) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TCM_SETTOOLTIPS, (WPARAM)hWndToolTip, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TCM_SETTOOLTIPS, (WPARAM)hWndToolTip, 0L); } // this method is deprecated, please use SetToolTips void SetTooltips(HWND hWndToolTip) { SetToolTips(hWndToolTip); } -#endif // !_WIN32_WCE - int GetCurFocus() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TCM_GETCURFOCUS, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TCM_GETCURFOCUS, 0, 0L); } void SetCurFocus(int nItem) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TCM_SETCURFOCUS, nItem, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TCM_SETCURFOCUS, nItem, 0L); } BOOL SetItemExtra(int cbExtra) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(GetItemCount() == 0); // must be empty - return (BOOL)::SendMessage(m_hWnd, TCM_SETITEMEXTRA, cbExtra, 0L); + return (BOOL)::SendMessage(this->m_hWnd, TCM_SETITEMEXTRA, cbExtra, 0L); } int SetMinTabWidth(int nWidth = -1) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TCM_SETMINTABWIDTH, 0, nWidth); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TCM_SETMINTABWIDTH, 0, nWidth); } -#if (_WIN32_IE >= 0x0400) DWORD GetExtendedStyle() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, TCM_GETEXTENDEDSTYLE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, TCM_GETEXTENDEDSTYLE, 0, 0L); } DWORD SetExtendedStyle(DWORD dwExMask, DWORD dwExStyle) { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, TCM_SETEXTENDEDSTYLE, dwExMask, dwExStyle); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, TCM_SETEXTENDEDSTYLE, dwExMask, dwExStyle); } -#ifndef _WIN32_WCE BOOL GetUnicodeFormat() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TCM_GETUNICODEFORMAT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TCM_GETUNICODEFORMAT, 0, 0L); } BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TCM_SETUNICODEFORMAT, bUnicode, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TCM_SETUNICODEFORMAT, bUnicode, 0L); } -#endif // !_WIN32_WCE -#endif // (_WIN32_IE >= 0x0400) // Operations int InsertItem(int nItem, LPTCITEM pTabCtrlItem) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TCM_INSERTITEM, nItem, (LPARAM)pTabCtrlItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TCM_INSERTITEM, nItem, (LPARAM)pTabCtrlItem); } int InsertItem(int nItem, UINT mask, LPCTSTR lpszItem, int iImage, LPARAM lParam) { - ATLASSERT(::IsWindow(m_hWnd)); - TCITEM tci = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + TCITEM tci = {}; tci.mask = mask; tci.pszText = (LPTSTR) lpszItem; tci.iImage = iImage; tci.lParam = lParam; - return (int)::SendMessage(m_hWnd, TCM_INSERTITEM, nItem, (LPARAM)&tci); + return (int)::SendMessage(this->m_hWnd, TCM_INSERTITEM, nItem, (LPARAM)&tci); } int InsertItem(int nItem, LPCTSTR lpszItem) { - ATLASSERT(::IsWindow(m_hWnd)); - TCITEM tci = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + TCITEM tci = {}; tci.mask = TCIF_TEXT; tci.pszText = (LPTSTR) lpszItem; - return (int)::SendMessage(m_hWnd, TCM_INSERTITEM, nItem, (LPARAM)&tci); + return (int)::SendMessage(this->m_hWnd, TCM_INSERTITEM, nItem, (LPARAM)&tci); } int AddItem(LPTCITEM pTabCtrlItem) @@ -6517,47 +6409,45 @@ public: BOOL DeleteItem(int nItem) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TCM_DELETEITEM, nItem, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TCM_DELETEITEM, nItem, 0L); } BOOL DeleteAllItems() { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TCM_DELETEALLITEMS, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TCM_DELETEALLITEMS, 0, 0L); } void AdjustRect(BOOL bLarger, LPRECT lpRect) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TCM_ADJUSTRECT, bLarger, (LPARAM)lpRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TCM_ADJUSTRECT, bLarger, (LPARAM)lpRect); } void RemoveImage(int nImage) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TCM_REMOVEIMAGE, nImage, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TCM_REMOVEIMAGE, nImage, 0L); } int HitTest(TC_HITTESTINFO* pHitTestInfo) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TCM_HITTEST, 0, (LPARAM)pHitTestInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TCM_HITTEST, 0, (LPARAM)pHitTestInfo); } void DeselectAll(BOOL bExcludeFocus = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TCM_DESELECTALL, bExcludeFocus, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TCM_DESELECTALL, bExcludeFocus, 0L); } -#if (_WIN32_IE >= 0x0400) BOOL HighlightItem(int nIndex, BOOL bHighlight = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TCM_HIGHLIGHTITEM, nIndex, MAKELPARAM(bHighlight, 0)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TCM_HIGHLIGHTITEM, nIndex, MAKELPARAM(bHighlight, 0)); } -#endif // (_WIN32_IE >= 0x0400) }; typedef CTabCtrlT CTabCtrl; @@ -6576,7 +6466,7 @@ public: CTrackBarCtrlT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -6595,50 +6485,50 @@ public: int GetLineSize() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TBM_GETLINESIZE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TBM_GETLINESIZE, 0, 0L); } int SetLineSize(int nSize) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TBM_SETLINESIZE, 0, nSize); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TBM_SETLINESIZE, 0, nSize); } int GetPageSize() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TBM_GETPAGESIZE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TBM_GETPAGESIZE, 0, 0L); } int SetPageSize(int nSize) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TBM_SETPAGESIZE, 0, nSize); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TBM_SETPAGESIZE, 0, nSize); } int GetRangeMin() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TBM_GETRANGEMIN, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TBM_GETRANGEMIN, 0, 0L); } void SetRangeMin(int nMin, BOOL bRedraw = FALSE) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TBM_SETRANGEMIN, bRedraw, nMin); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TBM_SETRANGEMIN, bRedraw, nMin); } int GetRangeMax() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TBM_GETRANGEMAX, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TBM_GETRANGEMAX, 0, 0L); } void SetRangeMax(int nMax, BOOL bRedraw = FALSE) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TBM_SETRANGEMAX, bRedraw, nMax); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TBM_SETRANGEMAX, bRedraw, nMax); } void GetRange(int& nMin, int& nMax) const @@ -6649,32 +6539,32 @@ public: void SetRange(int nMin, int nMax, BOOL bRedraw = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TBM_SETRANGE, bRedraw, MAKELPARAM(nMin, nMax)); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TBM_SETRANGE, bRedraw, MAKELPARAM(nMin, nMax)); } int GetSelStart() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TBM_GETSELSTART, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TBM_GETSELSTART, 0, 0L); } void SetSelStart(int nMin, BOOL bRedraw = FALSE) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TBM_SETSELSTART, bRedraw, (LPARAM)nMin); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TBM_SETSELSTART, bRedraw, (LPARAM)nMin); } int GetSelEnd() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TBM_GETSELEND, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TBM_GETSELEND, 0, 0L); } void SetSelEnd(int nMax, BOOL bRedraw = FALSE) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TBM_SETSELEND, bRedraw, (LPARAM)nMax); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TBM_SETSELEND, bRedraw, (LPARAM)nMax); } void GetSelection(int& nMin, int& nMax) const @@ -6691,146 +6581,142 @@ public: void GetChannelRect(LPRECT lprc) const { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TBM_GETCHANNELRECT, 0, (LPARAM)lprc); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TBM_GETCHANNELRECT, 0, (LPARAM)lprc); } void GetThumbRect(LPRECT lprc) const { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TBM_GETTHUMBRECT, 0, (LPARAM)lprc); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TBM_GETTHUMBRECT, 0, (LPARAM)lprc); } int GetPos() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TBM_GETPOS, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TBM_GETPOS, 0, 0L); } void SetPos(int nPos) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TBM_SETPOS, TRUE, nPos); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TBM_SETPOS, TRUE, nPos); } UINT GetNumTics() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (UINT)::SendMessage(m_hWnd, TBM_GETNUMTICS, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, TBM_GETNUMTICS, 0, 0L); } DWORD* GetTicArray() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD*)::SendMessage(m_hWnd, TBM_GETPTICS, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD*)::SendMessage(this->m_hWnd, TBM_GETPTICS, 0, 0L); } int GetTic(int nTic) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TBM_GETTIC, nTic, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TBM_GETTIC, nTic, 0L); } BOOL SetTic(int nTic) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TBM_SETTIC, 0, nTic); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TBM_SETTIC, 0, nTic); } int GetTicPos(int nTic) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TBM_GETTICPOS, nTic, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TBM_GETTICPOS, nTic, 0L); } void SetTicFreq(int nFreq) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TBM_SETTICFREQ, nFreq, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TBM_SETTICFREQ, nFreq, 0L); } int GetThumbLength() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TBM_GETTHUMBLENGTH, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TBM_GETTHUMBLENGTH, 0, 0L); } void SetThumbLength(int nLength) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TBM_SETTHUMBLENGTH, nLength, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TBM_SETTHUMBLENGTH, nLength, 0L); } void SetSel(int nStart, int nEnd, BOOL bRedraw = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT((GetStyle() & TBS_ENABLESELRANGE) != 0); - ::SendMessage(m_hWnd, TBM_SETSEL, bRedraw, MAKELPARAM(nStart, nEnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & TBS_ENABLESELRANGE) != 0); + ::SendMessage(this->m_hWnd, TBM_SETSEL, bRedraw, MAKELPARAM(nStart, nEnd)); } ATL::CWindow GetBuddy(BOOL bLeft = TRUE) const { - ATLASSERT(::IsWindow(m_hWnd)); - return ATL::CWindow((HWND)::SendMessage(m_hWnd, TBM_GETBUDDY, bLeft, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return ATL::CWindow((HWND)::SendMessage(this->m_hWnd, TBM_GETBUDDY, bLeft, 0L)); } ATL::CWindow SetBuddy(HWND hWndBuddy, BOOL bLeft = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return ATL::CWindow((HWND)::SendMessage(m_hWnd, TBM_SETBUDDY, bLeft, (LPARAM)hWndBuddy)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return ATL::CWindow((HWND)::SendMessage(this->m_hWnd, TBM_SETBUDDY, bLeft, (LPARAM)hWndBuddy)); } -#ifndef _WIN32_WCE CToolTipCtrl GetToolTips() const { - ATLASSERT(::IsWindow(m_hWnd)); - return CToolTipCtrl((HWND)::SendMessage(m_hWnd, TBM_GETTOOLTIPS, 0, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CToolTipCtrl((HWND)::SendMessage(this->m_hWnd, TBM_GETTOOLTIPS, 0, 0L)); } void SetToolTips(HWND hWndTT) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TBM_SETTOOLTIPS, (WPARAM)hWndTT, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TBM_SETTOOLTIPS, (WPARAM)hWndTT, 0L); } int SetTipSide(int nSide) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TBM_SETTIPSIDE, nSide, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TBM_SETTIPSIDE, nSide, 0L); } -#endif // !_WIN32_WCE -#if (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) BOOL GetUnicodeFormat() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TBM_GETUNICODEFORMAT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TBM_GETUNICODEFORMAT, 0, 0L); } BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TBM_SETUNICODEFORMAT, bUnicode, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TBM_SETUNICODEFORMAT, bUnicode, 0L); } -#endif // (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) // Operations void ClearSel(BOOL bRedraw = FALSE) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TBM_CLEARSEL, bRedraw, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TBM_CLEARSEL, bRedraw, 0L); } void VerifyPos() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TBM_SETPOS, FALSE, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TBM_SETPOS, FALSE, 0L); } void ClearTics(BOOL bRedraw = FALSE) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TBM_CLEARTICS, bRedraw, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TBM_CLEARTICS, bRedraw, 0L); } }; @@ -6850,7 +6736,7 @@ public: CUpDownCtrlT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -6869,44 +6755,44 @@ public: UINT GetAccel(int nAccel, UDACCEL* pAccel) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (UINT)LOWORD(::SendMessage(m_hWnd, UDM_GETACCEL, nAccel, (LPARAM)pAccel)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)LOWORD(::SendMessage(this->m_hWnd, UDM_GETACCEL, nAccel, (LPARAM)pAccel)); } BOOL SetAccel(int nAccel, UDACCEL* pAccel) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)LOWORD(::SendMessage(m_hWnd, UDM_SETACCEL, nAccel, (LPARAM)pAccel)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)LOWORD(::SendMessage(this->m_hWnd, UDM_SETACCEL, nAccel, (LPARAM)pAccel)); } UINT GetBase() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (UINT)LOWORD(::SendMessage(m_hWnd, UDM_GETBASE, 0, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)LOWORD(::SendMessage(this->m_hWnd, UDM_GETBASE, 0, 0L)); } int SetBase(int nBase) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, UDM_SETBASE, nBase, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, UDM_SETBASE, nBase, 0L); } ATL::CWindow GetBuddy() const { - ATLASSERT(::IsWindow(m_hWnd)); - return ATL::CWindow((HWND)::SendMessage(m_hWnd, UDM_GETBUDDY, 0, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return ATL::CWindow((HWND)::SendMessage(this->m_hWnd, UDM_GETBUDDY, 0, 0L)); } ATL::CWindow SetBuddy(HWND hWndBuddy) { - ATLASSERT(::IsWindow(m_hWnd)); - return ATL::CWindow((HWND)::SendMessage(m_hWnd, UDM_SETBUDDY, (WPARAM)hWndBuddy, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return ATL::CWindow((HWND)::SendMessage(this->m_hWnd, UDM_SETBUDDY, (WPARAM)hWndBuddy, 0L)); } int GetPos(LPBOOL lpbError = NULL) const { - ATLASSERT(::IsWindow(m_hWnd)); - DWORD dwRet = (DWORD)::SendMessage(m_hWnd, UDM_GETPOS, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, UDM_GETPOS, 0, 0L); // Note: Seems that Windows always sets error to TRUE if // UDS_SETBUDDYINT style is not used if(lpbError != NULL) @@ -6916,73 +6802,67 @@ public: int SetPos(int nPos) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)(short)LOWORD(::SendMessage(m_hWnd, UDM_SETPOS, 0, MAKELPARAM(nPos, 0))); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)(short)LOWORD(::SendMessage(this->m_hWnd, UDM_SETPOS, 0, MAKELPARAM(nPos, 0))); } DWORD GetRange() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, UDM_GETRANGE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, UDM_GETRANGE, 0, 0L); } void GetRange(int& nLower, int& nUpper) const { - ATLASSERT(::IsWindow(m_hWnd)); - DWORD dwRet = (DWORD)::SendMessage(m_hWnd, UDM_GETRANGE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, UDM_GETRANGE, 0, 0L); nLower = (int)(short)HIWORD(dwRet); nUpper = (int)(short)LOWORD(dwRet); } void SetRange(int nLower, int nUpper) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, UDM_SETRANGE, 0, MAKELPARAM(nUpper, nLower)); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, UDM_SETRANGE, 0, MAKELPARAM(nUpper, nLower)); } -#if (_WIN32_IE >= 0x0400) void SetRange32(int nLower, int nUpper) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, UDM_SETRANGE32, nLower, nUpper); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, UDM_SETRANGE32, nLower, nUpper); } void GetRange32(int& nLower, int& nUpper) const { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, UDM_GETRANGE32, (WPARAM)&nLower, (LPARAM)&nUpper); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, UDM_GETRANGE32, (WPARAM)&nLower, (LPARAM)&nUpper); } -#ifndef _WIN32_WCE BOOL GetUnicodeFormat() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, UDM_GETUNICODEFORMAT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, UDM_GETUNICODEFORMAT, 0, 0L); } BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, UDM_SETUNICODEFORMAT, bUnicode, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, UDM_SETUNICODEFORMAT, bUnicode, 0L); } -#endif // !_WIN32_WCE -#endif // (_WIN32_IE >= 0x0400) -#if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) int GetPos32(LPBOOL lpbError = NULL) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); // Note: Seems that Windows always sets error to TRUE if // UDS_SETBUDDYINT style is not used - return (int)::SendMessage(m_hWnd, UDM_GETPOS32, 0, (LPARAM)lpbError); + return (int)::SendMessage(this->m_hWnd, UDM_GETPOS32, 0, (LPARAM)lpbError); } int SetPos32(int nPos) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, UDM_SETPOS32, 0, (LPARAM)nPos); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, UDM_SETPOS32, 0, (LPARAM)nPos); } -#endif // (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) }; typedef CUpDownCtrlT CUpDownCtrl; @@ -7001,7 +6881,7 @@ public: CProgressBarCtrlT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -7020,121 +6900,119 @@ public: DWORD SetRange(int nLower, int nUpper) { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, PBM_SETRANGE, 0, MAKELPARAM(nLower, nUpper)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, PBM_SETRANGE, 0, MAKELPARAM(nLower, nUpper)); } int SetPos(int nPos) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)(short)LOWORD(::SendMessage(m_hWnd, PBM_SETPOS, nPos, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)(short)LOWORD(::SendMessage(this->m_hWnd, PBM_SETPOS, nPos, 0L)); } int OffsetPos(int nPos) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)(short)LOWORD(::SendMessage(m_hWnd, PBM_DELTAPOS, nPos, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)(short)LOWORD(::SendMessage(this->m_hWnd, PBM_DELTAPOS, nPos, 0L)); } int SetStep(int nStep) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)(short)LOWORD(::SendMessage(m_hWnd, PBM_SETSTEP, nStep, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)(short)LOWORD(::SendMessage(this->m_hWnd, PBM_SETSTEP, nStep, 0L)); } UINT GetPos() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (UINT)::SendMessage(m_hWnd, PBM_GETPOS, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, PBM_GETPOS, 0, 0L); } void GetRange(PPBRANGE pPBRange) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(pPBRange != NULL); - ::SendMessage(m_hWnd, PBM_GETRANGE, TRUE, (LPARAM)pPBRange); + ::SendMessage(this->m_hWnd, PBM_GETRANGE, TRUE, (LPARAM)pPBRange); } void GetRange(int& nLower, int& nUpper) const { - ATLASSERT(::IsWindow(m_hWnd)); - PBRANGE range = { 0 }; - ::SendMessage(m_hWnd, PBM_GETRANGE, TRUE, (LPARAM)&range); + ATLASSERT(::IsWindow(this->m_hWnd)); + PBRANGE range = {}; + ::SendMessage(this->m_hWnd, PBM_GETRANGE, TRUE, (LPARAM)&range); nLower = range.iLow; nUpper = range.iHigh; } int GetRangeLimit(BOOL bLowLimit) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, PBM_GETRANGE, bLowLimit, (LPARAM)NULL); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, PBM_GETRANGE, bLowLimit, (LPARAM)NULL); } DWORD SetRange32(int nMin, int nMax) { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, PBM_SETRANGE32, nMin, nMax); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, PBM_SETRANGE32, nMin, nMax); } -#if (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) COLORREF SetBarColor(COLORREF clr) { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, PBM_SETBARCOLOR, 0, (LPARAM)clr); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, PBM_SETBARCOLOR, 0, (LPARAM)clr); } COLORREF SetBkColor(COLORREF clr) { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, PBM_SETBKCOLOR, 0, (LPARAM)clr); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, PBM_SETBKCOLOR, 0, (LPARAM)clr); } -#endif // (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) -#if (_WIN32_WINNT >= 0x0501) && defined(PBM_SETMARQUEE) +#ifdef PBM_SETMARQUEE BOOL SetMarquee(BOOL bMarquee, UINT uUpdateTime = 0U) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, PBM_SETMARQUEE, (WPARAM)bMarquee, (LPARAM)uUpdateTime); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, PBM_SETMARQUEE, (WPARAM)bMarquee, (LPARAM)uUpdateTime); } -#endif // (_WIN32_WINNT >= 0x0501) && defined(PBM_SETMARQUEE) +#endif #if (_WIN32_WINNT >= 0x0600) int GetStep() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, PBM_GETSTEP, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, PBM_GETSTEP, 0, 0L); } COLORREF GetBkColor() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, PBM_GETBKCOLOR, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, PBM_GETBKCOLOR, 0, 0L); } COLORREF GetBarColor() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, PBM_GETBARCOLOR, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, PBM_GETBARCOLOR, 0, 0L); } int GetState() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, PBM_GETSTATE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, PBM_GETSTATE, 0, 0L); } int SetState(int nState) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, PBM_SETSTATE, nState, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, PBM_SETSTATE, nState, 0L); } #endif // (_WIN32_WINNT >= 0x0600) // Operations int StepIt() { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)(short)LOWORD(::SendMessage(m_hWnd, PBM_STEPIT, 0, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)(short)LOWORD(::SendMessage(this->m_hWnd, PBM_STEPIT, 0, 0L)); } }; @@ -7144,8 +7022,6 @@ typedef CProgressBarCtrlT CProgressBarCtrl; /////////////////////////////////////////////////////////////////////////////// // CHotKeyCtrl -#ifndef _WIN32_WCE - template class CHotKeyCtrlT : public TBase { @@ -7156,7 +7032,7 @@ public: CHotKeyCtrlT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -7175,41 +7051,37 @@ public: DWORD GetHotKey() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, HKM_GETHOTKEY, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, HKM_GETHOTKEY, 0, 0L); } void GetHotKey(WORD &wVirtualKeyCode, WORD &wModifiers) const { - ATLASSERT(::IsWindow(m_hWnd)); - DWORD dw = (DWORD)::SendMessage(m_hWnd, HKM_GETHOTKEY, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + DWORD dw = (DWORD)::SendMessage(this->m_hWnd, HKM_GETHOTKEY, 0, 0L); wVirtualKeyCode = LOBYTE(LOWORD(dw)); wModifiers = HIBYTE(LOWORD(dw)); } void SetHotKey(WORD wVirtualKeyCode, WORD wModifiers) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, HKM_SETHOTKEY, MAKEWORD(wVirtualKeyCode, wModifiers), 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, HKM_SETHOTKEY, MAKEWORD(wVirtualKeyCode, wModifiers), 0L); } void SetRules(WORD wInvalidComb, WORD wModifiers) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, HKM_SETRULES, wInvalidComb, MAKELPARAM(wModifiers, 0)); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, HKM_SETRULES, wInvalidComb, MAKELPARAM(wModifiers, 0)); } }; typedef CHotKeyCtrlT CHotKeyCtrl; -#endif // !_WIN32_WCE - /////////////////////////////////////////////////////////////////////////////// // CAnimateCtrl -#ifndef _WIN32_WCE - template class CAnimateCtrlT : public TBase { @@ -7220,7 +7092,7 @@ public: CAnimateCtrlT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -7240,60 +7112,48 @@ public: // Operations BOOL Open(ATL::_U_STRINGorID FileName) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, ACM_OPEN, 0, (LPARAM)FileName.m_lpstr); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, ACM_OPEN, 0, (LPARAM)FileName.m_lpstr); } BOOL Play(UINT nFrom, UINT nTo, UINT nRep) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, ACM_PLAY, nRep, MAKELPARAM(nFrom, nTo)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, ACM_PLAY, nRep, MAKELPARAM(nFrom, nTo)); } BOOL Stop() { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, ACM_STOP, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, ACM_STOP, 0, 0L); } BOOL Close() { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, ACM_OPEN, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, ACM_OPEN, 0, 0L); } BOOL Seek(UINT nTo) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, ACM_PLAY, 0, MAKELPARAM(nTo, nTo)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, ACM_PLAY, 0, MAKELPARAM(nTo, nTo)); } // Vista only BOOL IsPlaying() const { -#ifndef ACM_ISPLAYING - const UINT ACM_ISPLAYING = (WM_USER+104); -#endif - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, ACM_ISPLAYING, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, ACM_ISPLAYING, 0, 0L); } }; typedef CAnimateCtrlT CAnimateCtrl; -#endif // !_WIN32_WCE - /////////////////////////////////////////////////////////////////////////////// // CRichEditCtrl -#ifndef _WIN32_WCE - -#if defined(_UNICODE) && (_RICHEDIT_VER == 0x0100) - #undef RICHEDIT_CLASS - #define RICHEDIT_CLASS L"RICHEDIT" -#endif - #if !defined(_UNICODE) && (_RICHEDIT_VER >= 0x0500) #undef MSFTEDIT_CLASS #define MSFTEDIT_CLASS "RICHEDIT50W" @@ -7309,7 +7169,7 @@ public: CRichEditCtrlT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -7334,101 +7194,99 @@ public: { #if (_RICHEDIT_VER >= 0x0500) return _T("MSFTEDIT.DLL"); -#elif (_RICHEDIT_VER >= 0x0200) - return _T("RICHED20.DLL"); #else - return _T("RICHED32.DLL"); + return _T("RICHED20.DLL"); #endif } int GetLineCount() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, EM_GETLINECOUNT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, EM_GETLINECOUNT, 0, 0L); } BOOL GetModify() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_GETMODIFY, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_GETMODIFY, 0, 0L); } void SetModify(BOOL bModified = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_SETMODIFY, bModified, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SETMODIFY, bModified, 0L); } void GetRect(LPRECT lpRect) const { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_GETRECT, 0, (LPARAM)lpRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_GETRECT, 0, (LPARAM)lpRect); } DWORD GetOptions() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, EM_GETOPTIONS, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, EM_GETOPTIONS, 0, 0L); } DWORD SetOptions(WORD wOperation, DWORD dwOptions) { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, EM_SETOPTIONS, wOperation, dwOptions); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, EM_SETOPTIONS, wOperation, dwOptions); } // NOTE: first word in lpszBuffer must contain the size of the buffer! int GetLine(int nIndex, LPTSTR lpszBuffer) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, EM_GETLINE, nIndex, (LPARAM)lpszBuffer); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, EM_GETLINE, nIndex, (LPARAM)lpszBuffer); } int GetLine(int nIndex, LPTSTR lpszBuffer, int nMaxLength) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); *(LPWORD)lpszBuffer = (WORD)nMaxLength; - return (int)::SendMessage(m_hWnd, EM_GETLINE, nIndex, (LPARAM)lpszBuffer); + return (int)::SendMessage(this->m_hWnd, EM_GETLINE, nIndex, (LPARAM)lpszBuffer); } BOOL CanUndo() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_CANUNDO, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_CANUNDO, 0, 0L); } BOOL CanPaste(UINT nFormat = 0) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_CANPASTE, nFormat, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_CANPASTE, nFormat, 0L); } void GetSel(LONG& nStartChar, LONG& nEndChar) const { - ATLASSERT(::IsWindow(m_hWnd)); - CHARRANGE cr = { 0, 0 }; - ::SendMessage(m_hWnd, EM_EXGETSEL, 0, (LPARAM)&cr); + ATLASSERT(::IsWindow(this->m_hWnd)); + CHARRANGE cr = {}; + ::SendMessage(this->m_hWnd, EM_EXGETSEL, 0, (LPARAM)&cr); nStartChar = cr.cpMin; nEndChar = cr.cpMax; } void GetSel(CHARRANGE &cr) const { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_EXGETSEL, 0, (LPARAM)&cr); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_EXGETSEL, 0, (LPARAM)&cr); } int SetSel(LONG nStartChar, LONG nEndChar) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); CHARRANGE cr = { nStartChar, nEndChar }; - return (int)::SendMessage(m_hWnd, EM_EXSETSEL, 0, (LPARAM)&cr); + return (int)::SendMessage(this->m_hWnd, EM_EXSETSEL, 0, (LPARAM)&cr); } int SetSel(CHARRANGE &cr) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, EM_EXSETSEL, 0, (LPARAM)&cr); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, EM_EXSETSEL, 0, (LPARAM)&cr); } int SetSelAll() @@ -7443,341 +7301,279 @@ public: DWORD GetDefaultCharFormat(CHARFORMAT& cf) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); cf.cbSize = sizeof(CHARFORMAT); - return (DWORD)::SendMessage(m_hWnd, EM_GETCHARFORMAT, 0, (LPARAM)&cf); + return (DWORD)::SendMessage(this->m_hWnd, EM_GETCHARFORMAT, 0, (LPARAM)&cf); } DWORD GetSelectionCharFormat(CHARFORMAT& cf) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); cf.cbSize = sizeof(CHARFORMAT); - return (DWORD)::SendMessage(m_hWnd, EM_GETCHARFORMAT, 1, (LPARAM)&cf); + return (DWORD)::SendMessage(this->m_hWnd, EM_GETCHARFORMAT, 1, (LPARAM)&cf); } DWORD GetEventMask() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, EM_GETEVENTMASK, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, EM_GETEVENTMASK, 0, 0L); } LONG GetLimitText() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (LONG)::SendMessage(m_hWnd, EM_GETLIMITTEXT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (LONG)::SendMessage(this->m_hWnd, EM_GETLIMITTEXT, 0, 0L); } DWORD GetParaFormat(PARAFORMAT& pf) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); pf.cbSize = sizeof(PARAFORMAT); - return (DWORD)::SendMessage(m_hWnd, EM_GETPARAFORMAT, 0, (LPARAM)&pf); + return (DWORD)::SendMessage(this->m_hWnd, EM_GETPARAFORMAT, 0, (LPARAM)&pf); } -#if (_RICHEDIT_VER >= 0x0200) LONG GetSelText(LPTSTR lpstrBuff) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (LONG)::SendMessage(m_hWnd, EM_GETSELTEXT, 0, (LPARAM)lpstrBuff); - } -#else // !(_RICHEDIT_VER >= 0x0200) - // RichEdit 1.0 EM_GETSELTEXT is ANSI only - LONG GetSelText(LPSTR lpstrBuff) const - { - ATLASSERT(::IsWindow(m_hWnd)); - return (LONG)::SendMessage(m_hWnd, EM_GETSELTEXT, 0, (LPARAM)lpstrBuff); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (LONG)::SendMessage(this->m_hWnd, EM_GETSELTEXT, 0, (LPARAM)lpstrBuff); } -#endif // !(_RICHEDIT_VER >= 0x0200) -#ifndef _ATL_NO_COM BOOL GetSelTextBSTR(BSTR& bstrText) const { USES_CONVERSION; - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(bstrText == NULL); - CHARRANGE cr = { 0, 0 }; - ::SendMessage(m_hWnd, EM_EXGETSEL, 0, (LPARAM)&cr); + CHARRANGE cr = {}; + ::SendMessage(this->m_hWnd, EM_EXGETSEL, 0, (LPARAM)&cr); -#if (_RICHEDIT_VER >= 0x0200) - CTempBuffer buff; + ATL::CTempBuffer buff; LPTSTR lpstrText = buff.Allocate(cr.cpMax - cr.cpMin + 1); if(lpstrText == NULL) return FALSE; - if(::SendMessage(m_hWnd, EM_GETSELTEXT, 0, (LPARAM)lpstrText) == 0) + if(::SendMessage(this->m_hWnd, EM_GETSELTEXT, 0, (LPARAM)lpstrText) == 0) return FALSE; bstrText = ::SysAllocString(T2W(lpstrText)); -#else // !(_RICHEDIT_VER >= 0x0200) - CTempBuffer buff; - LPSTR lpstrText = buff.Allocate(cr.cpMax - cr.cpMin + 1); - if(lpstrText == NULL) - return FALSE; - if(::SendMessage(m_hWnd, EM_GETSELTEXT, 0, (LPARAM)lpstrText) == 0) - return FALSE; - - bstrText = ::SysAllocString(A2W(lpstrText)); -#endif // !(_RICHEDIT_VER >= 0x0200) return (bstrText != NULL) ? TRUE : FALSE; } -#endif // !_ATL_NO_COM -#if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) - LONG GetSelText(_CSTRING_NS::CString& strText) const +#ifdef __ATLSTR_H__ + LONG GetSelText(ATL::CString& strText) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); - CHARRANGE cr = { 0, 0 }; - ::SendMessage(m_hWnd, EM_EXGETSEL, 0, (LPARAM)&cr); + CHARRANGE cr = {}; + ::SendMessage(this->m_hWnd, EM_EXGETSEL, 0, (LPARAM)&cr); -#if (_RICHEDIT_VER >= 0x0200) LONG lLen = 0; LPTSTR lpstrText = strText.GetBufferSetLength(cr.cpMax - cr.cpMin); if(lpstrText != NULL) { - lLen = (LONG)::SendMessage(m_hWnd, EM_GETSELTEXT, 0, (LPARAM)lpstrText); + lLen = (LONG)::SendMessage(this->m_hWnd, EM_GETSELTEXT, 0, (LPARAM)lpstrText); strText.ReleaseBuffer(); } -#else // !(_RICHEDIT_VER >= 0x0200) - CTempBuffer buff; - LPSTR lpstrText = buff.Allocate(cr.cpMax - cr.cpMin + 1); - if(lpstrText == NULL) - return 0; - LONG lLen = (LONG)::SendMessage(m_hWnd, EM_GETSELTEXT, 0, (LPARAM)lpstrText); - if(lLen == 0) - return 0; - - USES_CONVERSION; - strText = A2T(lpstrText); -#endif // !(_RICHEDIT_VER >= 0x0200) return lLen; } -#endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) +#endif // __ATLSTR_H__ WORD GetSelectionType() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (WORD)::SendMessage(m_hWnd, EM_SELECTIONTYPE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (WORD)::SendMessage(this->m_hWnd, EM_SELECTIONTYPE, 0, 0L); } COLORREF SetBackgroundColor(COLORREF cr) { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, EM_SETBKGNDCOLOR, 0, cr); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, EM_SETBKGNDCOLOR, 0, cr); } COLORREF SetBackgroundColor() // sets to system background { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, EM_SETBKGNDCOLOR, 1, 0); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, EM_SETBKGNDCOLOR, 1, 0); } BOOL SetCharFormat(CHARFORMAT& cf, WORD wFlags) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); cf.cbSize = sizeof(CHARFORMAT); - return (BOOL)::SendMessage(m_hWnd, EM_SETCHARFORMAT, (WPARAM)wFlags, (LPARAM)&cf); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETCHARFORMAT, (WPARAM)wFlags, (LPARAM)&cf); } BOOL SetDefaultCharFormat(CHARFORMAT& cf) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); cf.cbSize = sizeof(CHARFORMAT); - return (BOOL)::SendMessage(m_hWnd, EM_SETCHARFORMAT, 0, (LPARAM)&cf); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETCHARFORMAT, 0, (LPARAM)&cf); } BOOL SetSelectionCharFormat(CHARFORMAT& cf) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); cf.cbSize = sizeof(CHARFORMAT); - return (BOOL)::SendMessage(m_hWnd, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf); } BOOL SetWordCharFormat(CHARFORMAT& cf) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); cf.cbSize = sizeof(CHARFORMAT); - return (BOOL)::SendMessage(m_hWnd, EM_SETCHARFORMAT, SCF_SELECTION | SCF_WORD, (LPARAM)&cf); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETCHARFORMAT, SCF_SELECTION | SCF_WORD, (LPARAM)&cf); } DWORD SetEventMask(DWORD dwEventMask) { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, EM_SETEVENTMASK, 0, dwEventMask); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, EM_SETEVENTMASK, 0, dwEventMask); } BOOL SetParaFormat(PARAFORMAT& pf) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); pf.cbSize = sizeof(PARAFORMAT); - return (BOOL)::SendMessage(m_hWnd, EM_SETPARAFORMAT, 0, (LPARAM)&pf); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETPARAFORMAT, 0, (LPARAM)&pf); } BOOL SetTargetDevice(HDC hDC, int cxLineWidth) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_SETTARGETDEVICE, (WPARAM)hDC, cxLineWidth); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETTARGETDEVICE, (WPARAM)hDC, cxLineWidth); } int GetTextLength() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, WM_GETTEXTLENGTH, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, WM_GETTEXTLENGTH, 0, 0L); } BOOL SetReadOnly(BOOL bReadOnly = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_SETREADONLY, bReadOnly, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETREADONLY, bReadOnly, 0L); } int GetFirstVisibleLine() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, EM_GETFIRSTVISIBLELINE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, EM_GETFIRSTVISIBLELINE, 0, 0L); } int GetTextRange(TEXTRANGE* pTextRange) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, EM_GETTEXTRANGE, 0, (LPARAM)pTextRange); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, EM_GETTEXTRANGE, 0, (LPARAM)pTextRange); } -#if (_RICHEDIT_VER < 0x0200) - EDITWORDBREAKPROCEX GetWordBreakProcEx() const - { - ATLASSERT(::IsWindow(m_hWnd)); - return (EDITWORDBREAKPROCEX)::SendMessage(m_hWnd, EM_GETWORDBREAKPROCEX, 0, 0L); - } - - EDITWORDBREAKPROCEX SetWordBreakProcEx(EDITWORDBREAKPROCEX pfnEditWordBreakProcEx) - { - ATLASSERT(::IsWindow(m_hWnd)); - return (EDITWORDBREAKPROCEX)::SendMessage(m_hWnd, EM_SETWORDBREAKPROCEX, 0, (LPARAM)pfnEditWordBreakProcEx); - } -#endif // (_RICHEDIT_VER < 0x0200) - -#if (_RICHEDIT_VER >= 0x0200) int GetTextRange(LONG nStartChar, LONG nEndChar, LPTSTR lpstrText) const { - ATLASSERT(::IsWindow(m_hWnd)); - TEXTRANGE tr = { 0 }; - tr.chrg.cpMin = nStartChar; - tr.chrg.cpMax = nEndChar; - tr.lpstrText = lpstrText; - return (int)::SendMessage(m_hWnd, EM_GETTEXTRANGE, 0, (LPARAM)&tr); - } -#else // !(_RICHEDIT_VER >= 0x0200) - int GetTextRange(LONG nStartChar, LONG nEndChar, LPSTR lpstrText) const - { - ATLASSERT(::IsWindow(m_hWnd)); - TEXTRANGE tr = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + TEXTRANGE tr = {}; tr.chrg.cpMin = nStartChar; tr.chrg.cpMax = nEndChar; tr.lpstrText = lpstrText; - return (int)::SendMessage(m_hWnd, EM_GETTEXTRANGE, 0, (LPARAM)&tr); + return (int)::SendMessage(this->m_hWnd, EM_GETTEXTRANGE, 0, (LPARAM)&tr); } -#endif // !(_RICHEDIT_VER >= 0x0200) -#if (_RICHEDIT_VER >= 0x0200) DWORD GetDefaultCharFormat(CHARFORMAT2& cf) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); cf.cbSize = sizeof(CHARFORMAT2); - return (DWORD)::SendMessage(m_hWnd, EM_GETCHARFORMAT, 0, (LPARAM)&cf); + return (DWORD)::SendMessage(this->m_hWnd, EM_GETCHARFORMAT, 0, (LPARAM)&cf); } BOOL SetCharFormat(CHARFORMAT2& cf, WORD wFlags) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); cf.cbSize = sizeof(CHARFORMAT2); - return (BOOL)::SendMessage(m_hWnd, EM_SETCHARFORMAT, (WPARAM)wFlags, (LPARAM)&cf); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETCHARFORMAT, (WPARAM)wFlags, (LPARAM)&cf); } BOOL SetDefaultCharFormat(CHARFORMAT2& cf) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); cf.cbSize = sizeof(CHARFORMAT2); - return (BOOL)::SendMessage(m_hWnd, EM_SETCHARFORMAT, 0, (LPARAM)&cf); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETCHARFORMAT, 0, (LPARAM)&cf); } DWORD GetSelectionCharFormat(CHARFORMAT2& cf) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); cf.cbSize = sizeof(CHARFORMAT2); - return (DWORD)::SendMessage(m_hWnd, EM_GETCHARFORMAT, 1, (LPARAM)&cf); + return (DWORD)::SendMessage(this->m_hWnd, EM_GETCHARFORMAT, 1, (LPARAM)&cf); } BOOL SetSelectionCharFormat(CHARFORMAT2& cf) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); cf.cbSize = sizeof(CHARFORMAT2); - return (BOOL)::SendMessage(m_hWnd, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf); } BOOL SetWordCharFormat(CHARFORMAT2& cf) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); cf.cbSize = sizeof(CHARFORMAT2); - return (BOOL)::SendMessage(m_hWnd, EM_SETCHARFORMAT, SCF_SELECTION | SCF_WORD, (LPARAM)&cf); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETCHARFORMAT, SCF_SELECTION | SCF_WORD, (LPARAM)&cf); } DWORD GetParaFormat(PARAFORMAT2& pf) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); pf.cbSize = sizeof(PARAFORMAT2); - return (DWORD)::SendMessage(m_hWnd, EM_GETPARAFORMAT, 0, (LPARAM)&pf); + return (DWORD)::SendMessage(this->m_hWnd, EM_GETPARAFORMAT, 0, (LPARAM)&pf); } BOOL SetParaFormat(PARAFORMAT2& pf) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); pf.cbSize = sizeof(PARAFORMAT2); - return (BOOL)::SendMessage(m_hWnd, EM_SETPARAFORMAT, 0, (LPARAM)&pf); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETPARAFORMAT, 0, (LPARAM)&pf); } TEXTMODE GetTextMode() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (TEXTMODE)::SendMessage(m_hWnd, EM_GETTEXTMODE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (TEXTMODE)::SendMessage(this->m_hWnd, EM_GETTEXTMODE, 0, 0L); } BOOL SetTextMode(TEXTMODE enumTextMode) { - ATLASSERT(::IsWindow(m_hWnd)); - return !(BOOL)::SendMessage(m_hWnd, EM_SETTEXTMODE, enumTextMode, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return !(BOOL)::SendMessage(this->m_hWnd, EM_SETTEXTMODE, enumTextMode, 0L); } UNDONAMEID GetUndoName() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (UNDONAMEID)::SendMessage(m_hWnd, EM_GETUNDONAME, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UNDONAMEID)::SendMessage(this->m_hWnd, EM_GETUNDONAME, 0, 0L); } UNDONAMEID GetRedoName() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (UNDONAMEID)::SendMessage(m_hWnd, EM_GETREDONAME, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UNDONAMEID)::SendMessage(this->m_hWnd, EM_GETREDONAME, 0, 0L); } BOOL CanRedo() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_CANREDO, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_CANREDO, 0, 0L); } BOOL GetAutoURLDetect() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_GETAUTOURLDETECT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_GETAUTOURLDETECT, 0, 0L); } BOOL SetAutoURLDetect(BOOL bAutoDetect = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return !(BOOL)::SendMessage(m_hWnd, EM_AUTOURLDETECT, bAutoDetect, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return !(BOOL)::SendMessage(this->m_hWnd, EM_AUTOURLDETECT, bAutoDetect, 0L); } // this method is deprecated, please use SetAutoURLDetect @@ -7785,284 +7581,293 @@ public: UINT SetUndoLimit(UINT uUndoLimit) { - ATLASSERT(::IsWindow(m_hWnd)); - return (UINT)::SendMessage(m_hWnd, EM_SETUNDOLIMIT, uUndoLimit, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, EM_SETUNDOLIMIT, uUndoLimit, 0L); } void SetPalette(HPALETTE hPalette) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_SETPALETTE, (WPARAM)hPalette, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SETPALETTE, (WPARAM)hPalette, 0L); } int GetTextEx(GETTEXTEX* pGetTextEx, LPTSTR lpstrText) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, EM_GETTEXTEX, (WPARAM)pGetTextEx, (LPARAM)lpstrText); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, EM_GETTEXTEX, (WPARAM)pGetTextEx, (LPARAM)lpstrText); } int GetTextEx(LPTSTR lpstrText, int nTextLen, DWORD dwFlags = GT_DEFAULT, UINT uCodePage = CP_ACP, LPCSTR lpDefaultChar = NULL, LPBOOL lpUsedDefChar = NULL) const { - ATLASSERT(::IsWindow(m_hWnd)); - GETTEXTEX gte = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + GETTEXTEX gte = {}; gte.cb = nTextLen * sizeof(TCHAR); gte.codepage = uCodePage; gte.flags = dwFlags; gte.lpDefaultChar = lpDefaultChar; gte.lpUsedDefChar = lpUsedDefChar; - return (int)::SendMessage(m_hWnd, EM_GETTEXTEX, (WPARAM)>e, (LPARAM)lpstrText); + return (int)::SendMessage(this->m_hWnd, EM_GETTEXTEX, (WPARAM)>e, (LPARAM)lpstrText); } int GetTextLengthEx(GETTEXTLENGTHEX* pGetTextLengthEx) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, EM_GETTEXTLENGTHEX, (WPARAM)pGetTextLengthEx, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, EM_GETTEXTLENGTHEX, (WPARAM)pGetTextLengthEx, 0L); } int GetTextLengthEx(DWORD dwFlags = GTL_DEFAULT, UINT uCodePage = CP_ACP) const { - ATLASSERT(::IsWindow(m_hWnd)); - GETTEXTLENGTHEX gtle = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + GETTEXTLENGTHEX gtle = {}; gtle.codepage = uCodePage; gtle.flags = dwFlags; - return (int)::SendMessage(m_hWnd, EM_GETTEXTLENGTHEX, (WPARAM)>le, 0L); + return (int)::SendMessage(this->m_hWnd, EM_GETTEXTLENGTHEX, (WPARAM)>le, 0L); } EDITWORDBREAKPROC GetWordBreakProc() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (EDITWORDBREAKPROC)::SendMessage(m_hWnd, EM_GETWORDBREAKPROC, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (EDITWORDBREAKPROC)::SendMessage(this->m_hWnd, EM_GETWORDBREAKPROC, 0, 0L); } void SetWordBreakProc(EDITWORDBREAKPROC ewbprc) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_SETWORDBREAKPROC, 0, (LPARAM)ewbprc); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SETWORDBREAKPROC, 0, (LPARAM)ewbprc); } -#endif // (_RICHEDIT_VER >= 0x0200) -#if (_RICHEDIT_VER >= 0x0300) int SetTextEx(SETTEXTEX* pSetTextEx, LPCTSTR lpstrText) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, EM_SETTEXTEX, (WPARAM)pSetTextEx, (LPARAM)lpstrText); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, EM_SETTEXTEX, (WPARAM)pSetTextEx, (LPARAM)lpstrText); } int SetTextEx(LPCTSTR lpstrText, DWORD dwFlags = ST_DEFAULT, UINT uCodePage = CP_ACP) { - ATLASSERT(::IsWindow(m_hWnd)); - SETTEXTEX ste = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + SETTEXTEX ste = {}; ste.flags = dwFlags; ste.codepage = uCodePage; - return (int)::SendMessage(m_hWnd, EM_SETTEXTEX, (WPARAM)&ste, (LPARAM)lpstrText); + return (int)::SendMessage(this->m_hWnd, EM_SETTEXTEX, (WPARAM)&ste, (LPARAM)lpstrText); } int GetEditStyle() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, EM_GETEDITSTYLE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, EM_GETEDITSTYLE, 0, 0L); } int SetEditStyle(int nStyle, int nMask = -1) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); if(nMask == -1) nMask = nStyle; // set everything specified - return (int)::SendMessage(m_hWnd, EM_SETEDITSTYLE, nStyle, nMask); + return (int)::SendMessage(this->m_hWnd, EM_SETEDITSTYLE, nStyle, nMask); } BOOL SetFontSize(int nFontSizeDelta) { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT(nFontSizeDelta >= -1637 && nFontSizeDelta <= 1638); - return (BOOL)::SendMessage(m_hWnd, EM_SETFONTSIZE, nFontSizeDelta, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((nFontSizeDelta >= -1637) && (nFontSizeDelta <= 1638)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETFONTSIZE, nFontSizeDelta, 0L); } void GetScrollPos(LPPOINT lpPoint) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(lpPoint != NULL); - ::SendMessage(m_hWnd, EM_GETSCROLLPOS, 0, (LPARAM)lpPoint); + ::SendMessage(this->m_hWnd, EM_GETSCROLLPOS, 0, (LPARAM)lpPoint); } void SetScrollPos(LPPOINT lpPoint) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(lpPoint != NULL); - ::SendMessage(m_hWnd, EM_SETSCROLLPOS, 0, (LPARAM)lpPoint); + ::SendMessage(this->m_hWnd, EM_SETSCROLLPOS, 0, (LPARAM)lpPoint); } BOOL GetZoom(int& nNum, int& nDen) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_GETZOOM, (WPARAM)&nNum, (LPARAM)&nDen); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_GETZOOM, (WPARAM)&nNum, (LPARAM)&nDen); } BOOL SetZoom(int nNum, int nDen) { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT(nNum >= 0 && nNum <= 64); - ATLASSERT(nDen >= 0 && nDen <= 64); - return (BOOL)::SendMessage(m_hWnd, EM_SETZOOM, nNum, nDen); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((nNum >= 0) && (nNum <= 64)); + ATLASSERT((nDen >= 0) && (nDen <= 64)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETZOOM, nNum, nDen); } BOOL SetZoomOff() { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_SETZOOM, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETZOOM, 0, 0L); } void SetMargins(UINT nLeft, UINT nRight, WORD wFlags = EC_LEFTMARGIN | EC_RIGHTMARGIN) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_SETMARGINS, wFlags, MAKELONG(nLeft, nRight)); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SETMARGINS, wFlags, MAKELONG(nLeft, nRight)); + } + + WORD GetTypographyOptions() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (WORD)::SendMessage(this->m_hWnd, EM_GETTYPOGRAPHYOPTIONS, 0, 0L); + } + + BOOL SetTypographyOptions(WORD wOptions, WORD wMask) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETTYPOGRAPHYOPTIONS, wOptions, wMask); } -#endif // (_RICHEDIT_VER >= 0x0300) // Operations void LimitText(LONG nChars = 0) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_EXLIMITTEXT, 0, nChars); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_EXLIMITTEXT, 0, nChars); } int LineFromChar(LONG nIndex) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, EM_EXLINEFROMCHAR, 0, nIndex); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, EM_EXLINEFROMCHAR, 0, nIndex); } POINT PosFromChar(LONG nChar) const { - ATLASSERT(::IsWindow(m_hWnd)); - POINT point = { 0, 0 }; - ::SendMessage(m_hWnd, EM_POSFROMCHAR, (WPARAM)&point, nChar); + ATLASSERT(::IsWindow(this->m_hWnd)); + POINT point = {}; + ::SendMessage(this->m_hWnd, EM_POSFROMCHAR, (WPARAM)&point, nChar); return point; } int CharFromPos(POINT pt) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); POINTL ptl = { pt.x, pt.y }; - return (int)::SendMessage(m_hWnd, EM_CHARFROMPOS, 0, (LPARAM)&ptl); + return (int)::SendMessage(this->m_hWnd, EM_CHARFROMPOS, 0, (LPARAM)&ptl); } void EmptyUndoBuffer() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_EMPTYUNDOBUFFER, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_EMPTYUNDOBUFFER, 0, 0L); } int LineIndex(int nLine = -1) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, EM_LINEINDEX, nLine, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, EM_LINEINDEX, nLine, 0L); } int LineLength(int nLine = -1) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, EM_LINELENGTH, nLine, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, EM_LINELENGTH, nLine, 0L); } BOOL LineScroll(int nLines) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_LINESCROLL, 0, nLines); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_LINESCROLL, 0, nLines); } void ReplaceSel(LPCTSTR lpszNewText, BOOL bCanUndo = FALSE) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_REPLACESEL, (WPARAM) bCanUndo, (LPARAM)lpszNewText); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_REPLACESEL, (WPARAM) bCanUndo, (LPARAM)lpszNewText); } void SetRect(LPCRECT lpRect) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_SETRECT, 0, (LPARAM)lpRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SETRECT, 0, (LPARAM)lpRect); } BOOL DisplayBand(LPRECT pDisplayRect) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_DISPLAYBAND, 0, (LPARAM)pDisplayRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_DISPLAYBAND, 0, (LPARAM)pDisplayRect); } LONG FindText(DWORD dwFlags, FINDTEXT& ft) const { - ATLASSERT(::IsWindow(m_hWnd)); -#if (_RICHEDIT_VER >= 0x0200) && defined(_UNICODE) - return (LONG)::SendMessage(m_hWnd, EM_FINDTEXTW, dwFlags, (LPARAM)&ft); + ATLASSERT(::IsWindow(this->m_hWnd)); +#ifdef _UNICODE + return (LONG)::SendMessage(this->m_hWnd, EM_FINDTEXTW, dwFlags, (LPARAM)&ft); #else - return (LONG)::SendMessage(m_hWnd, EM_FINDTEXT, dwFlags, (LPARAM)&ft); + return (LONG)::SendMessage(this->m_hWnd, EM_FINDTEXT, dwFlags, (LPARAM)&ft); #endif } LONG FindText(DWORD dwFlags, FINDTEXTEX& ft) const { - ATLASSERT(::IsWindow(m_hWnd)); -#if (_RICHEDIT_VER >= 0x0200) && defined(_UNICODE) - return (LONG)::SendMessage(m_hWnd, EM_FINDTEXTEXW, dwFlags, (LPARAM)&ft); + ATLASSERT(::IsWindow(this->m_hWnd)); +#ifdef _UNICODE + return (LONG)::SendMessage(this->m_hWnd, EM_FINDTEXTEXW, dwFlags, (LPARAM)&ft); #else - return (LONG)::SendMessage(m_hWnd, EM_FINDTEXTEX, dwFlags, (LPARAM)&ft); + return (LONG)::SendMessage(this->m_hWnd, EM_FINDTEXTEX, dwFlags, (LPARAM)&ft); #endif } LONG FormatRange(FORMATRANGE& fr, BOOL bDisplay = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (LONG)::SendMessage(m_hWnd, EM_FORMATRANGE, bDisplay, (LPARAM)&fr); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (LONG)::SendMessage(this->m_hWnd, EM_FORMATRANGE, bDisplay, (LPARAM)&fr); } LONG FormatRange(FORMATRANGE* pFormatRange, BOOL bDisplay = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (LONG)::SendMessage(m_hWnd, EM_FORMATRANGE, bDisplay, (LPARAM)pFormatRange); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (LONG)::SendMessage(this->m_hWnd, EM_FORMATRANGE, bDisplay, (LPARAM)pFormatRange); } void HideSelection(BOOL bHide = TRUE, BOOL bChangeStyle = FALSE) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_HIDESELECTION, bHide, bChangeStyle); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_HIDESELECTION, bHide, bChangeStyle); } void PasteSpecial(UINT uClipFormat, DWORD dwAspect = 0, HMETAFILE hMF = 0) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); REPASTESPECIAL reps = { dwAspect, (DWORD_PTR)hMF }; - ::SendMessage(m_hWnd, EM_PASTESPECIAL, uClipFormat, (LPARAM)&reps); + ::SendMessage(this->m_hWnd, EM_PASTESPECIAL, uClipFormat, (LPARAM)&reps); } void RequestResize() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_REQUESTRESIZE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_REQUESTRESIZE, 0, 0L); } LONG StreamIn(UINT uFormat, EDITSTREAM& es) { - ATLASSERT(::IsWindow(m_hWnd)); - return (LONG)::SendMessage(m_hWnd, EM_STREAMIN, uFormat, (LPARAM)&es); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (LONG)::SendMessage(this->m_hWnd, EM_STREAMIN, uFormat, (LPARAM)&es); } LONG StreamOut(UINT uFormat, EDITSTREAM& es) { - ATLASSERT(::IsWindow(m_hWnd)); - return (LONG)::SendMessage(m_hWnd, EM_STREAMOUT, uFormat, (LPARAM)&es); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (LONG)::SendMessage(this->m_hWnd, EM_STREAMOUT, uFormat, (LPARAM)&es); } DWORD FindWordBreak(int nCode, LONG nStartChar) { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, EM_FINDWORDBREAK, nCode, nStartChar); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, EM_FINDWORDBREAK, nCode, nStartChar); } // Additional operations void ScrollCaret() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_SCROLLCARET, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SCROLLCARET, 0, 0L); } int InsertText(long nInsertAfterChar, LPCTSTR lpstrText, BOOL bCanUndo = FALSE) @@ -8074,145 +7879,141 @@ public: int AppendText(LPCTSTR lpstrText, BOOL bCanUndo = FALSE) { - return InsertText(GetWindowTextLength(), lpstrText, bCanUndo); + return InsertText(this->GetWindowTextLength(), lpstrText, bCanUndo); } // Clipboard operations BOOL Undo() { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_UNDO, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_UNDO, 0, 0L); } void Clear() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, WM_CLEAR, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, WM_CLEAR, 0, 0L); } void Copy() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, WM_COPY, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, WM_COPY, 0, 0L); } void Cut() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, WM_CUT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, WM_CUT, 0, 0L); } void Paste() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, WM_PASTE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, WM_PASTE, 0, 0L); } // OLE support IRichEditOle* GetOleInterface() const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); IRichEditOle *pRichEditOle = NULL; - ::SendMessage(m_hWnd, EM_GETOLEINTERFACE, 0, (LPARAM)&pRichEditOle); + ::SendMessage(this->m_hWnd, EM_GETOLEINTERFACE, 0, (LPARAM)&pRichEditOle); return pRichEditOle; } BOOL SetOleCallback(IRichEditOleCallback* pCallback) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_SETOLECALLBACK, 0, (LPARAM)pCallback); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETOLECALLBACK, 0, (LPARAM)pCallback); } -#if (_RICHEDIT_VER >= 0x0200) BOOL Redo() { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_REDO, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_REDO, 0, 0L); } void StopGroupTyping() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_STOPGROUPTYPING, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_STOPGROUPTYPING, 0, 0L); } void ShowScrollBar(int nBarType, BOOL bVisible = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_SHOWSCROLLBAR, nBarType, bVisible); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SHOWSCROLLBAR, nBarType, bVisible); } -#endif // (_RICHEDIT_VER >= 0x0200) -#if (_RICHEDIT_VER >= 0x0300) BOOL SetTabStops(int nTabStops, LPINT rgTabStops) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_SETTABSTOPS, nTabStops, (LPARAM)rgTabStops); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETTABSTOPS, nTabStops, (LPARAM)rgTabStops); } BOOL SetTabStops() { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_SETTABSTOPS, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETTABSTOPS, 0, 0L); } BOOL SetTabStops(const int& cxEachStop) // takes an 'int' { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_SETTABSTOPS, 1, (LPARAM)(LPINT)&cxEachStop); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETTABSTOPS, 1, (LPARAM)(LPINT)&cxEachStop); } -#endif // (_RICHEDIT_VER >= 0x0300) #if (_RICHEDIT_VER >= 0x0800) AutoCorrectProc GetAutoCorrectProc() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (AutoCorrectProc)::SendMessage(m_hWnd, EM_GETAUTOCORRECTPROC, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (AutoCorrectProc)::SendMessage(this->m_hWnd, EM_GETAUTOCORRECTPROC, 0, 0L); } BOOL SetAutoCorrectProc(AutoCorrectProc pfn) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_SETAUTOCORRECTPROC, (WPARAM)pfn, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETAUTOCORRECTPROC, (WPARAM)pfn, 0L); } BOOL CallAutoCorrectProc(WCHAR ch) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_CALLAUTOCORRECTPROC, (WPARAM)ch, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_CALLAUTOCORRECTPROC, (WPARAM)ch, 0L); } DWORD GetEditStyleEx() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, EM_GETEDITSTYLEEX, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, EM_GETEDITSTYLEEX, 0, 0L); } DWORD SetEditStyleEx(DWORD dwStyleEx, DWORD dwMask) { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, EM_SETEDITSTYLEEX, dwStyleEx, dwMask); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, EM_SETEDITSTYLEEX, dwStyleEx, dwMask); } DWORD GetStoryType(int nStoryIndex) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, EM_GETSTORYTYPE, nStoryIndex, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, EM_GETSTORYTYPE, nStoryIndex, 0L); } DWORD SetStoryType(int nStoryIndex, DWORD dwStoryType) { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, EM_SETSTORYTYPE, nStoryIndex, dwStoryType); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, EM_SETSTORYTYPE, nStoryIndex, dwStoryType); } DWORD GetEllipsisMode() const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); DWORD dwMode = 0; - BOOL bRet = (BOOL)::SendMessage(m_hWnd, EM_GETELLIPSISMODE, 0, (LPARAM)&dwMode); - bRet; // avoid level 4 warning + BOOL bRet = (BOOL)::SendMessage(this->m_hWnd, EM_GETELLIPSISMODE, 0, (LPARAM)&dwMode); + (void)bRet; // avoid level 4 warning ATLASSERT(bRet != FALSE); return dwMode; @@ -8220,70 +8021,66 @@ public: BOOL SetEllipsisMode(DWORD dwEllipsisMode) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_SETELLIPSISMODE, 0, dwEllipsisMode); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETELLIPSISMODE, 0, dwEllipsisMode); } BOOL GetEllipsisState() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_GETELLIPSISSTATE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_GETELLIPSISSTATE, 0, 0L); } BOOL GetTouchOptions(int nTouchOptions) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_GETTOUCHOPTIONS, nTouchOptions, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_GETTOUCHOPTIONS, nTouchOptions, 0L); } void SetTouchOptions(int nTouchOptions, BOOL bEnable) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_SETTOUCHOPTIONS, nTouchOptions, bEnable); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SETTOUCHOPTIONS, nTouchOptions, bEnable); } HRESULT InsertTable(TABLEROWPARMS* pRowParams, TABLECELLPARMS* pCellParams) { - ATLASSERT(::IsWindow(m_hWnd)); - return (HRESULT)::SendMessage(m_hWnd, EM_INSERTTABLE, (WPARAM)pRowParams, (LPARAM)pCellParams); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HRESULT)::SendMessage(this->m_hWnd, EM_INSERTTABLE, (WPARAM)pRowParams, (LPARAM)pCellParams); } HRESULT GetTableParams(TABLEROWPARMS* pRowParams, TABLECELLPARMS* pCellParams) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (HRESULT)::SendMessage(m_hWnd, EM_GETTABLEPARMS, (WPARAM)pRowParams, (LPARAM)pCellParams); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HRESULT)::SendMessage(this->m_hWnd, EM_GETTABLEPARMS, (WPARAM)pRowParams, (LPARAM)pCellParams); } HRESULT SetTableParams(TABLEROWPARMS* pRowParams, TABLECELLPARMS* pCellParams) { - ATLASSERT(::IsWindow(m_hWnd)); - return (HRESULT)::SendMessage(m_hWnd, EM_SETTABLEPARMS, (WPARAM)pRowParams, (LPARAM)pCellParams); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HRESULT)::SendMessage(this->m_hWnd, EM_SETTABLEPARMS, (WPARAM)pRowParams, (LPARAM)pCellParams); } HRESULT InsertImage(RICHEDIT_IMAGE_PARAMETERS* pParams) { - ATLASSERT(::IsWindow(m_hWnd)); - return (HRESULT)::SendMessage(m_hWnd, EM_INSERTIMAGE, 0, (LPARAM)pParams); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HRESULT)::SendMessage(this->m_hWnd, EM_INSERTIMAGE, 0, (LPARAM)pParams); } BOOL SetUiaName(LPCTSTR lpstrName) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_SETUIANAME, 0, (LPARAM)lpstrName); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETUIANAME, 0, (LPARAM)lpstrName); } #endif // (_RICHEDIT_VER >= 0x0800) }; typedef CRichEditCtrlT CRichEditCtrl; -#endif // !_WIN32_WCE - /////////////////////////////////////////////////////////////////////////////// // CRichEditCommands - message handlers for standard EDIT commands -#ifndef _WIN32_WCE - // Chain to CRichEditCommands message map. Your class must also derive from CRichEditCtrl. // Example: // class CMyRichEdit : public CWindowImpl, @@ -8310,19 +8107,15 @@ public: COMMAND_ID_HANDLER(ID_EDIT_PASTE, CEditCommands< T >::OnEditPaste) COMMAND_ID_HANDLER(ID_EDIT_SELECT_ALL, CEditCommands< T >::OnEditSelectAll) COMMAND_ID_HANDLER(ID_EDIT_UNDO, CEditCommands< T >::OnEditUndo) -#if (_RICHEDIT_VER >= 0x0200) COMMAND_ID_HANDLER(ID_EDIT_REDO, OnEditRedo) -#endif // (_RICHEDIT_VER >= 0x0200) END_MSG_MAP() -#if (_RICHEDIT_VER >= 0x0200) LRESULT OnEditRedo(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { T* pT = static_cast(this); pT->Redo(); return 0; } -#endif // (_RICHEDIT_VER >= 0x0200) // State (update UI) helpers BOOL CanCut() const @@ -8342,14 +8135,10 @@ public: } }; -#endif // _WIN32_WCE - /////////////////////////////////////////////////////////////////////////////// // CDragListBox -#ifndef _WIN32_WCE - template class CDragListBoxT : public CListBoxT< TBase > { @@ -8360,7 +8149,7 @@ public: CDragListBoxT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -8368,7 +8157,7 @@ public: DWORD dwStyle = 0, DWORD dwExStyle = 0, ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) { - HWND hWnd = TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); + HWND hWnd = TBase::Create(TBase::GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); if(hWnd != NULL) MakeDragList(); return hWnd; @@ -8377,21 +8166,21 @@ public: // Operations BOOL MakeDragList() { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT((GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) == 0); - return ::MakeDragList(m_hWnd); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) == 0); + return ::MakeDragList(this->m_hWnd); } int LBItemFromPt(POINT pt, BOOL bAutoScroll = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return ::LBItemFromPt(m_hWnd, pt, bAutoScroll); + ATLASSERT(::IsWindow(this->m_hWnd)); + return ::LBItemFromPt(this->m_hWnd, pt, bAutoScroll); } void DrawInsert(int nItem) { - ATLASSERT(::IsWindow(m_hWnd)); - ::DrawInsert(GetParent(), m_hWnd, nItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::DrawInsert(this->GetParent(), this->m_hWnd, nItem); } static UINT GetDragListMessage() @@ -8429,7 +8218,7 @@ public: LRESULT OnDragListNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { - uMsg; // avoid level 4 warning + (void)uMsg; // avoid level 4 warning ATLASSERT(uMsg == CDragListBox::GetDragListMessage()); T* pT = static_cast(this); LPDRAGLISTINFO lpDragListInfo = (LPDRAGLISTINFO)lParam; @@ -8478,8 +8267,6 @@ public: } }; -#endif // _WIN32_WCE - /////////////////////////////////////////////////////////////////////////////// // CReBarCtrl @@ -8494,7 +8281,7 @@ public: CReBarCtrlT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -8513,208 +8300,192 @@ public: UINT GetBandCount() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (UINT)::SendMessage(m_hWnd, RB_GETBANDCOUNT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, RB_GETBANDCOUNT, 0, 0L); } BOOL GetBandInfo(int nBand, LPREBARBANDINFO lprbbi) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, RB_GETBANDINFO, nBand, (LPARAM)lprbbi); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, RB_GETBANDINFO, nBand, (LPARAM)lprbbi); } BOOL SetBandInfo(int nBand, LPREBARBANDINFO lprbbi) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, RB_SETBANDINFO, nBand, (LPARAM)lprbbi); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, RB_SETBANDINFO, nBand, (LPARAM)lprbbi); } BOOL GetBarInfo(LPREBARINFO lprbi) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, RB_GETBARINFO, 0, (LPARAM)lprbi); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, RB_GETBARINFO, 0, (LPARAM)lprbi); } BOOL SetBarInfo(LPREBARINFO lprbi) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, RB_SETBARINFO, 0, (LPARAM)lprbi); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, RB_SETBARINFO, 0, (LPARAM)lprbi); } CImageList GetImageList() const { - ATLASSERT(::IsWindow(m_hWnd)); - REBARINFO rbi = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + REBARINFO rbi = {}; rbi.cbSize = sizeof(REBARINFO); rbi.fMask = RBIM_IMAGELIST; - BOOL bRet = (BOOL)::SendMessage(m_hWnd, RB_GETBARINFO, 0, (LPARAM)&rbi); + BOOL bRet = (BOOL)::SendMessage(this->m_hWnd, RB_GETBARINFO, 0, (LPARAM)&rbi); return CImageList((bRet != FALSE) ? rbi.himl : NULL); } BOOL SetImageList(HIMAGELIST hImageList) { - ATLASSERT(::IsWindow(m_hWnd)); - REBARINFO rbi = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + REBARINFO rbi = {}; rbi.cbSize = sizeof(REBARINFO); rbi.fMask = RBIM_IMAGELIST; rbi.himl = hImageList; - return (BOOL)::SendMessage(m_hWnd, RB_SETBARINFO, 0, (LPARAM)&rbi); + return (BOOL)::SendMessage(this->m_hWnd, RB_SETBARINFO, 0, (LPARAM)&rbi); } UINT GetRowCount() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (UINT)::SendMessage(m_hWnd, RB_GETROWCOUNT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, RB_GETROWCOUNT, 0, 0L); } UINT GetRowHeight(int nBand) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (UINT)::SendMessage(m_hWnd, RB_GETROWHEIGHT, nBand, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, RB_GETROWHEIGHT, nBand, 0L); } -#if (_WIN32_IE >= 0x0400) COLORREF GetTextColor() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, RB_GETTEXTCOLOR, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, RB_GETTEXTCOLOR, 0, 0L); } COLORREF SetTextColor(COLORREF clr) { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, RB_SETTEXTCOLOR, 0, (LPARAM)clr); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, RB_SETTEXTCOLOR, 0, (LPARAM)clr); } COLORREF GetBkColor() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, RB_GETBKCOLOR, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, RB_GETBKCOLOR, 0, 0L); } COLORREF SetBkColor(COLORREF clr) { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, RB_SETBKCOLOR, 0, (LPARAM)clr); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, RB_SETBKCOLOR, 0, (LPARAM)clr); } UINT GetBarHeight() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (UINT)::SendMessage(m_hWnd, RB_GETBARHEIGHT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, RB_GETBARHEIGHT, 0, 0L); } BOOL GetRect(int nBand, LPRECT lpRect) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, RB_GETRECT, nBand, (LPARAM)lpRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, RB_GETRECT, nBand, (LPARAM)lpRect); } -#ifndef _WIN32_WCE CToolTipCtrl GetToolTips() const { - ATLASSERT(::IsWindow(m_hWnd)); - return CToolTipCtrl((HWND)::SendMessage(m_hWnd, RB_GETTOOLTIPS, 0, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CToolTipCtrl((HWND)::SendMessage(this->m_hWnd, RB_GETTOOLTIPS, 0, 0L)); } void SetToolTips(HWND hwndToolTip) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, RB_SETTOOLTIPS, (WPARAM)hwndToolTip, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, RB_SETTOOLTIPS, (WPARAM)hwndToolTip, 0L); } -#endif // !_WIN32_WCE void GetBandBorders(int nBand, LPRECT lpRect) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(lpRect != NULL); - ::SendMessage(m_hWnd, RB_GETBANDBORDERS, nBand, (LPARAM)lpRect); + ::SendMessage(this->m_hWnd, RB_GETBANDBORDERS, nBand, (LPARAM)lpRect); } -#ifndef _WIN32_WCE BOOL GetColorScheme(LPCOLORSCHEME lpColorScheme) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(lpColorScheme != NULL); - return (BOOL)::SendMessage(m_hWnd, RB_GETCOLORSCHEME, 0, (LPARAM)lpColorScheme); + return (BOOL)::SendMessage(this->m_hWnd, RB_GETCOLORSCHEME, 0, (LPARAM)lpColorScheme); } void SetColorScheme(LPCOLORSCHEME lpColorScheme) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(lpColorScheme != NULL); - ::SendMessage(m_hWnd, RB_SETCOLORSCHEME, 0, (LPARAM)lpColorScheme); + ::SendMessage(this->m_hWnd, RB_SETCOLORSCHEME, 0, (LPARAM)lpColorScheme); } HPALETTE GetPalette() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (HPALETTE)::SendMessage(m_hWnd, RB_GETPALETTE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HPALETTE)::SendMessage(this->m_hWnd, RB_GETPALETTE, 0, 0L); } HPALETTE SetPalette(HPALETTE hPalette) { - ATLASSERT(::IsWindow(m_hWnd)); - return (HPALETTE)::SendMessage(m_hWnd, RB_SETPALETTE, 0, (LPARAM)hPalette); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HPALETTE)::SendMessage(this->m_hWnd, RB_SETPALETTE, 0, (LPARAM)hPalette); } BOOL GetUnicodeFormat() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, RB_GETUNICODEFORMAT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, RB_GETUNICODEFORMAT, 0, 0L); } BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, RB_SETUNICODEFORMAT, bUnicode, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, RB_SETUNICODEFORMAT, bUnicode, 0L); } -#endif // !_WIN32_WCE -#endif // (_WIN32_IE >= 0x0400) -#if (_WIN32_WINNT >= 0x0501) // requires uxtheme.h to be included to use MARGINS struct #ifndef _UXTHEME_H_ typedef struct _MARGINS* PMARGINS; #endif // !_UXTHEME_H_ void GetBandMargins(PMARGINS pMargins) const { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, RB_GETBANDMARGINS, 0, (LPARAM)pMargins); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, RB_GETBANDMARGINS, 0, (LPARAM)pMargins); } void SetWindowTheme(LPCWSTR lpstrTheme) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, RB_SETWINDOWTHEME, 0, (LPARAM)lpstrTheme); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, RB_SETWINDOWTHEME, 0, (LPARAM)lpstrTheme); } -#endif // (_WIN32_WINNT >= 0x0501) -#if (_WIN32_IE >= 0x0600) DWORD GetExtendedStyle() const { -#ifndef RB_GETEXTENDEDSTYLE - const UINT RB_GETEXTENDEDSTYLE = WM_USER + 42; -#endif - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, RB_GETEXTENDEDSTYLE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, RB_GETEXTENDEDSTYLE, 0, 0L); } DWORD SetExtendedStyle(DWORD dwStyle, DWORD dwMask) { -#ifndef RB_SETEXTENDEDSTYLE - const UINT RB_SETEXTENDEDSTYLE = WM_USER + 41; -#endif - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, RB_SETEXTENDEDSTYLE, dwMask, dwStyle); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, RB_SETEXTENDEDSTYLE, dwMask, dwStyle); } -#endif // (_WIN32_IE >= 0x0600) // Operations BOOL InsertBand(int nBand, LPREBARBANDINFO lprbbi) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, RB_INSERTBAND, nBand, (LPARAM)lprbbi); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, RB_INSERTBAND, nBand, (LPARAM)lprbbi); } BOOL AddBand(LPREBARBANDINFO lprbbi) @@ -8724,111 +8495,102 @@ public: BOOL DeleteBand(int nBand) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, RB_DELETEBAND, nBand, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, RB_DELETEBAND, nBand, 0L); } ATL::CWindow SetNotifyWnd(HWND hWnd) { - ATLASSERT(::IsWindow(m_hWnd)); - return ATL::CWindow((HWND)::SendMessage(m_hWnd, RB_SETPARENT, (WPARAM)hWnd, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return ATL::CWindow((HWND)::SendMessage(this->m_hWnd, RB_SETPARENT, (WPARAM)hWnd, 0L)); } -#if (_WIN32_IE >= 0x0400) void BeginDrag(int nBand, DWORD dwPos) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, RB_BEGINDRAG, nBand, dwPos); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, RB_BEGINDRAG, nBand, dwPos); } void BeginDrag(int nBand, int xPos, int yPos) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, RB_BEGINDRAG, nBand, MAKELPARAM(xPos, yPos)); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, RB_BEGINDRAG, nBand, MAKELPARAM(xPos, yPos)); } void EndDrag() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, RB_ENDDRAG, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, RB_ENDDRAG, 0, 0L); } void DragMove(DWORD dwPos) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, RB_DRAGMOVE, 0, dwPos); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, RB_DRAGMOVE, 0, dwPos); } void DragMove(int xPos, int yPos) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, RB_DRAGMOVE, 0, MAKELPARAM(xPos, yPos)); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, RB_DRAGMOVE, 0, MAKELPARAM(xPos, yPos)); } -#ifndef _WIN32_WCE void GetDropTarget(IDropTarget** ppDropTarget) const { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, RB_GETDROPTARGET, 0, (LPARAM)ppDropTarget); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, RB_GETDROPTARGET, 0, (LPARAM)ppDropTarget); } -#endif // !_WIN32_WCE void MaximizeBand(int nBand, BOOL bIdeal = FALSE) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, RB_MAXIMIZEBAND, nBand, bIdeal); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, RB_MAXIMIZEBAND, nBand, bIdeal); } void MinimizeBand(int nBand) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, RB_MINIMIZEBAND, nBand, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, RB_MINIMIZEBAND, nBand, 0L); } BOOL SizeToRect(LPRECT lpRect) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, RB_SIZETORECT, 0, (LPARAM)lpRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, RB_SIZETORECT, 0, (LPARAM)lpRect); } int IdToIndex(UINT uBandID) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, RB_IDTOINDEX, uBandID, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, RB_IDTOINDEX, uBandID, 0L); } int HitTest(LPRBHITTESTINFO lprbht) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, RB_HITTEST, 0, (LPARAM)lprbht); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, RB_HITTEST, 0, (LPARAM)lprbht); } BOOL ShowBand(int nBand, BOOL bShow) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, RB_SHOWBAND, nBand, bShow); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, RB_SHOWBAND, nBand, bShow); } -#ifndef _WIN32_WCE BOOL MoveBand(int nBand, int nNewPos) { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT(nNewPos >= 0 && nNewPos <= ((int)GetBandCount() - 1)); - return (BOOL)::SendMessage(m_hWnd, RB_MOVEBAND, nBand, nNewPos); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((nNewPos >= 0) && (nNewPos <= ((int)GetBandCount() - 1))); + return (BOOL)::SendMessage(this->m_hWnd, RB_MOVEBAND, nBand, nNewPos); } -#endif // !_WIN32_WCE -#endif // (_WIN32_IE >= 0x0400) -#if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) void PushChevron(int nBand, LPARAM lAppValue) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, RB_PUSHCHEVRON, nBand, lAppValue); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, RB_PUSHCHEVRON, nBand, lAppValue); } -#endif // (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) // Extra operations -#if (_WIN32_IE >= 0x0400) void LockBands(bool bLock) { int nBandCount = GetBandCount(); @@ -8856,13 +8618,12 @@ public: ATLASSERT(bRet); } } -#endif // (_WIN32_IE >= 0x0400) #if (_WIN32_WINNT >= 0x0600) BOOL SetBandWidth(int nBand, int cxWidth) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, RB_SETBANDWIDTH, nBand, cxWidth); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, RB_SETBANDWIDTH, nBand, cxWidth); } #endif // (_WIN32_WINNT >= 0x0600) }; @@ -8873,8 +8634,6 @@ typedef CReBarCtrlT CReBarCtrl; /////////////////////////////////////////////////////////////////////////////// // CComboBoxEx -#ifndef _WIN32_WCE - template class CComboBoxExT : public CComboBoxT< TBase > { @@ -8885,7 +8644,7 @@ public: CComboBoxExT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -8904,62 +8663,58 @@ public: CImageList GetImageList() const { - ATLASSERT(::IsWindow(m_hWnd)); - return CImageList((HIMAGELIST)::SendMessage(m_hWnd, CBEM_GETIMAGELIST, 0, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, CBEM_GETIMAGELIST, 0, 0L)); } CImageList SetImageList(HIMAGELIST hImageList) { - ATLASSERT(::IsWindow(m_hWnd)); - return CImageList((HIMAGELIST)::SendMessage(m_hWnd, CBEM_SETIMAGELIST, 0, (LPARAM)hImageList)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, CBEM_SETIMAGELIST, 0, (LPARAM)hImageList)); } -#if (_WIN32_IE >= 0x0400) DWORD GetExtendedStyle() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, CBEM_GETEXTENDEDSTYLE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, CBEM_GETEXTENDEDSTYLE, 0, 0L); } DWORD SetExtendedStyle(DWORD dwExMask, DWORD dwExStyle) { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, CBEM_SETEXTENDEDSTYLE, dwExMask, dwExStyle); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, CBEM_SETEXTENDEDSTYLE, dwExMask, dwExStyle); } BOOL GetUnicodeFormat() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, CBEM_GETUNICODEFORMAT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, CBEM_GETUNICODEFORMAT, 0, 0L); } BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, CBEM_SETUNICODEFORMAT, bUnicode, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, CBEM_SETUNICODEFORMAT, bUnicode, 0L); } -#endif // (_WIN32_IE >= 0x0400) -#if (_WIN32_WINNT >= 0x0501) void SetWindowTheme(LPCWSTR lpstrTheme) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, CBEM_SETWINDOWTHEME, 0, (LPARAM)lpstrTheme); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, CBEM_SETWINDOWTHEME, 0, (LPARAM)lpstrTheme); } -#endif // (_WIN32_WINNT >= 0x0501) // Operations int InsertItem(const COMBOBOXEXITEM* lpcCBItem) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, CBEM_INSERTITEM, 0, (LPARAM)lpcCBItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CBEM_INSERTITEM, 0, (LPARAM)lpcCBItem); } int InsertItem(UINT nMask, int nIndex, LPCTSTR lpszItem, int nImage, int nSelImage, int iIndent, int iOverlay, LPARAM lParam) { - ATLASSERT(::IsWindow(m_hWnd)); - COMBOBOXEXITEM cbex = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + COMBOBOXEXITEM cbex = {}; cbex.mask = nMask; cbex.iItem = nIndex; cbex.pszText = (LPTSTR) lpszItem; @@ -8968,13 +8723,13 @@ public: cbex.iIndent = iIndent; cbex.iOverlay = iOverlay; cbex.lParam = lParam; - return (int)::SendMessage(m_hWnd, CBEM_INSERTITEM, 0, (LPARAM)&cbex); + return (int)::SendMessage(this->m_hWnd, CBEM_INSERTITEM, 0, (LPARAM)&cbex); } int InsertItem(int nIndex, LPCTSTR lpszItem, int nImage, int nSelImage, int iIndent, LPARAM lParam = 0) { - ATLASSERT(::IsWindow(m_hWnd)); - COMBOBOXEXITEM cbex = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + COMBOBOXEXITEM cbex = {}; cbex.mask = CBEIF_TEXT | CBEIF_IMAGE | CBEIF_SELECTEDIMAGE | CBEIF_INDENT | CBEIF_LPARAM; cbex.iItem = nIndex; cbex.pszText = (LPTSTR) lpszItem; @@ -8982,7 +8737,7 @@ public: cbex.iSelectedImage = nSelImage; cbex.iIndent = iIndent; cbex.lParam = lParam; - return (int)::SendMessage(m_hWnd, CBEM_INSERTITEM, 0, (LPARAM)&cbex); + return (int)::SendMessage(this->m_hWnd, CBEM_INSERTITEM, 0, (LPARAM)&cbex); } int AddItem(UINT nMask, LPCTSTR lpszItem, int nImage, int nSelImage, int iIndent, int iOverlay, LPARAM lParam) @@ -8997,27 +8752,27 @@ public: int DeleteItem(int nIndex) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, CBEM_DELETEITEM, nIndex, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CBEM_DELETEITEM, nIndex, 0L); } BOOL GetItem(PCOMBOBOXEXITEM pCBItem) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, CBEM_GETITEM, 0, (LPARAM)pCBItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, CBEM_GETITEM, 0, (LPARAM)pCBItem); } BOOL SetItem(const COMBOBOXEXITEM* lpcCBItem) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, CBEM_SETITEM, 0, (LPARAM)lpcCBItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, CBEM_SETITEM, 0, (LPARAM)lpcCBItem); } int SetItem(int nIndex, UINT nMask, LPCTSTR lpszItem, int nImage, int nSelImage, int iIndent, int iOverlay, LPARAM lParam) { - ATLASSERT(::IsWindow(m_hWnd)); - COMBOBOXEXITEM cbex = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + COMBOBOXEXITEM cbex = {}; cbex.mask = nMask; cbex.iItem = nIndex; cbex.pszText = (LPTSTR) lpszItem; @@ -9026,31 +8781,30 @@ public: cbex.iIndent = iIndent; cbex.iOverlay = iOverlay; cbex.lParam = lParam; - return (int)::SendMessage(m_hWnd, CBEM_SETITEM, 0, (LPARAM)&cbex); + return (int)::SendMessage(this->m_hWnd, CBEM_SETITEM, 0, (LPARAM)&cbex); } BOOL GetItemText(int nIndex, LPTSTR lpszItem, int nLen) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(lpszItem != NULL); - COMBOBOXEXITEM cbex = { 0 }; + COMBOBOXEXITEM cbex = {}; cbex.mask = CBEIF_TEXT; cbex.iItem = nIndex; cbex.pszText = lpszItem; cbex.cchTextMax = nLen; - return (BOOL)::SendMessage(m_hWnd, CBEM_GETITEM, 0, (LPARAM)&cbex); + return (BOOL)::SendMessage(this->m_hWnd, CBEM_GETITEM, 0, (LPARAM)&cbex); } -#ifndef _ATL_NO_COM BOOL GetItemText(int nIndex, BSTR& bstrText) const { USES_CONVERSION; - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(bstrText == NULL); - COMBOBOXEXITEM cbex = { 0 }; + COMBOBOXEXITEM cbex = {}; cbex.mask = CBEIF_TEXT; cbex.iItem = nIndex; @@ -9064,8 +8818,8 @@ public: lpstrText[0] = NULL; cbex.pszText = lpstrText; cbex.cchTextMax = nLen; - bRet = (BOOL)::SendMessage(m_hWnd, CBEM_GETITEM, 0, (LPARAM)&cbex); - if(!bRet || (lstrlen(cbex.pszText) < nLen - 1)) + bRet = (BOOL)::SendMessage(this->m_hWnd, CBEM_GETITEM, 0, (LPARAM)&cbex); + if(!bRet || (lstrlen(cbex.pszText) < (nLen - 1))) break; delete [] lpstrText; lpstrText = NULL; @@ -9080,14 +8834,13 @@ public: return (bstrText != NULL) ? TRUE : FALSE; } -#endif // !_ATL_NO_COM -#if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) - BOOL GetItemText(int nIndex, _CSTRING_NS::CString& strText) const +#ifdef __ATLSTR_H__ + BOOL GetItemText(int nIndex, ATL::CString& strText) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); - COMBOBOXEXITEM cbex = { 0 }; + COMBOBOXEXITEM cbex = {}; cbex.mask = CBEIF_TEXT; cbex.iItem = nIndex; @@ -9102,37 +8855,37 @@ public: break; } cbex.cchTextMax = nLen; - bRet = (BOOL)::SendMessage(m_hWnd, CBEM_GETITEM, 0, (LPARAM)&cbex); - if(!bRet || (lstrlen(cbex.pszText) < nLen - 1)) + bRet = (BOOL)::SendMessage(this->m_hWnd, CBEM_GETITEM, 0, (LPARAM)&cbex); + if(!bRet || (lstrlen(cbex.pszText) < (nLen - 1))) break; } strText.ReleaseBuffer(); return bRet; } -#endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) +#endif // __ATLSTR_H__ BOOL SetItemText(int nIndex, LPCTSTR lpszItem) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); return SetItem(nIndex, CBEIF_TEXT, lpszItem, 0, 0, 0, 0, 0); } CComboBox GetComboCtrl() const { - ATLASSERT(::IsWindow(m_hWnd)); - return CComboBox((HWND)::SendMessage(m_hWnd, CBEM_GETCOMBOCONTROL, 0, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CComboBox((HWND)::SendMessage(this->m_hWnd, CBEM_GETCOMBOCONTROL, 0, 0L)); } CEdit GetEditCtrl() const { - ATLASSERT(::IsWindow(m_hWnd)); - return CEdit((HWND)::SendMessage(m_hWnd, CBEM_GETEDITCONTROL, 0, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CEdit((HWND)::SendMessage(this->m_hWnd, CBEM_GETEDITCONTROL, 0, 0L)); } BOOL HasEditChanged() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, CBEM_HASEDITCHANGED, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, CBEM_HASEDITCHANGED, 0, 0L); } // Non-functional @@ -9163,8 +8916,6 @@ public: typedef CComboBoxExT CComboBoxEx; -#endif // !_WIN32_WCE - /////////////////////////////////////////////////////////////////////////////// // CMonthCalendarCtrl @@ -9179,7 +8930,7 @@ public: CMonthCalendarCtrlT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -9198,32 +8949,32 @@ public: COLORREF GetColor(int nColorType) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, MCM_GETCOLOR, nColorType, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, MCM_GETCOLOR, nColorType, 0L); } COLORREF SetColor(int nColorType, COLORREF clr) { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, MCM_SETCOLOR, nColorType, clr); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, MCM_SETCOLOR, nColorType, clr); } BOOL GetCurSel(LPSYSTEMTIME lpSysTime) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, MCM_GETCURSEL, 0, (LPARAM)lpSysTime); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, MCM_GETCURSEL, 0, (LPARAM)lpSysTime); } BOOL SetCurSel(LPSYSTEMTIME lpSysTime) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, MCM_SETCURSEL, 0, (LPARAM)lpSysTime); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, MCM_SETCURSEL, 0, (LPARAM)lpSysTime); } int GetFirstDayOfWeek(BOOL* pbLocaleVal = NULL) const { - ATLASSERT(::IsWindow(m_hWnd)); - DWORD dwRet = (DWORD)::SendMessage(m_hWnd, MCM_GETFIRSTDAYOFWEEK, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, MCM_GETFIRSTDAYOFWEEK, 0, 0L); if(pbLocaleVal != NULL) *pbLocaleVal = (BOOL)HIWORD(dwRet); return (int)(short)LOWORD(dwRet); @@ -9231,8 +8982,8 @@ public: int SetFirstDayOfWeek(int nDay, BOOL* pbLocaleVal = NULL) { - ATLASSERT(::IsWindow(m_hWnd)); - DWORD dwRet = (DWORD)::SendMessage(m_hWnd, MCM_SETFIRSTDAYOFWEEK, 0, nDay); + ATLASSERT(::IsWindow(this->m_hWnd)); + DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, MCM_SETFIRSTDAYOFWEEK, 0, nDay); if(pbLocaleVal != NULL) *pbLocaleVal = (BOOL)HIWORD(dwRet); return (int)(short)LOWORD(dwRet); @@ -9240,164 +8991,162 @@ public: int GetMaxSelCount() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, MCM_GETMAXSELCOUNT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, MCM_GETMAXSELCOUNT, 0, 0L); } BOOL SetMaxSelCount(int nMax) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, MCM_SETMAXSELCOUNT, nMax, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, MCM_SETMAXSELCOUNT, nMax, 0L); } int GetMonthDelta() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, MCM_GETMONTHDELTA, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, MCM_GETMONTHDELTA, 0, 0L); } int SetMonthDelta(int nDelta) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, MCM_SETMONTHDELTA, nDelta, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, MCM_SETMONTHDELTA, nDelta, 0L); } DWORD GetRange(LPSYSTEMTIME lprgSysTimeArray) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, MCM_GETRANGE, 0, (LPARAM)lprgSysTimeArray); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, MCM_GETRANGE, 0, (LPARAM)lprgSysTimeArray); } BOOL SetRange(DWORD dwFlags, LPSYSTEMTIME lprgSysTimeArray) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, MCM_SETRANGE, dwFlags, (LPARAM)lprgSysTimeArray); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, MCM_SETRANGE, dwFlags, (LPARAM)lprgSysTimeArray); } BOOL GetSelRange(LPSYSTEMTIME lprgSysTimeArray) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, MCM_GETSELRANGE, 0, (LPARAM)lprgSysTimeArray); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, MCM_GETSELRANGE, 0, (LPARAM)lprgSysTimeArray); } BOOL SetSelRange(LPSYSTEMTIME lprgSysTimeArray) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, MCM_SETSELRANGE, 0, (LPARAM)lprgSysTimeArray); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, MCM_SETSELRANGE, 0, (LPARAM)lprgSysTimeArray); } BOOL GetToday(LPSYSTEMTIME lpSysTime) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, MCM_GETTODAY, 0, (LPARAM)lpSysTime); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, MCM_GETTODAY, 0, (LPARAM)lpSysTime); } void SetToday(LPSYSTEMTIME lpSysTime) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, MCM_SETTODAY, 0, (LPARAM)lpSysTime); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, MCM_SETTODAY, 0, (LPARAM)lpSysTime); } BOOL GetMinReqRect(LPRECT lpRectInfo) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, MCM_GETMINREQRECT, 0, (LPARAM)lpRectInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, MCM_GETMINREQRECT, 0, (LPARAM)lpRectInfo); } int GetMaxTodayWidth() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, MCM_GETMAXTODAYWIDTH, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, MCM_GETMAXTODAYWIDTH, 0, 0L); } -#if (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) BOOL GetUnicodeFormat() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, MCM_GETUNICODEFORMAT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, MCM_GETUNICODEFORMAT, 0, 0L); } BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, MCM_SETUNICODEFORMAT, bUnicode, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, MCM_SETUNICODEFORMAT, bUnicode, 0L); } -#endif // (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) #if defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_LONGHORN) DWORD GetCurrentView() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, MCM_GETCURRENTVIEW, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, MCM_GETCURRENTVIEW, 0, 0L); } BOOL SetCurrentView(DWORD dwView) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, MCM_SETCURRENTVIEW, 0, dwView); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, MCM_SETCURRENTVIEW, 0, dwView); } DWORD GetCalendarCount() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, MCM_GETCALENDARCOUNT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, MCM_GETCALENDARCOUNT, 0, 0L); } BOOL GetCalendarGridInfo(PMCGRIDINFO pGridInfo) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, MCM_GETCALENDARGRIDINFO, 0, (LPARAM)pGridInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, MCM_GETCALENDARGRIDINFO, 0, (LPARAM)pGridInfo); } CALID GetCALID() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (CALID)::SendMessage(m_hWnd, MCM_GETCALID, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (CALID)::SendMessage(this->m_hWnd, MCM_GETCALID, 0, 0L); } void SetCALID(CALID calid) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, MCM_SETCALID, (LPARAM)calid, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, MCM_SETCALID, (LPARAM)calid, 0L); } int GetCalendarBorder() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, MCM_GETCALENDARBORDER, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, MCM_GETCALENDARBORDER, 0, 0L); } void SetCalendarBorder(int cxyBorder, BOOL bSet = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, MCM_SETCALENDARBORDER, (WPARAM)bSet, (LPARAM)cxyBorder); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, MCM_SETCALENDARBORDER, (WPARAM)bSet, (LPARAM)cxyBorder); } #endif // defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_LONGHORN) // Operations int GetMonthRange(DWORD dwFlags, LPSYSTEMTIME lprgSysTimeArray) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, MCM_GETMONTHRANGE, dwFlags, (LPARAM)lprgSysTimeArray); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, MCM_GETMONTHRANGE, dwFlags, (LPARAM)lprgSysTimeArray); } BOOL SetDayState(int nMonths, LPMONTHDAYSTATE lpDayStateArray) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, MCM_SETDAYSTATE, nMonths, (LPARAM)lpDayStateArray); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, MCM_SETDAYSTATE, nMonths, (LPARAM)lpDayStateArray); } DWORD HitTest(PMCHITTESTINFO pMCHitTest) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, MCM_HITTEST, 0, (LPARAM)pMCHitTest); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, MCM_HITTEST, 0, (LPARAM)pMCHitTest); } #if defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_LONGHORN) void SizeRectToMin(LPRECT lpRect) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, MCM_SIZERECTTOMIN, 0, (LPARAM)lpRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, MCM_SIZERECTTOMIN, 0, (LPARAM)lpRect); } #endif // defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_LONGHORN) }; @@ -9418,7 +9167,7 @@ public: CDateTimePickerCtrlT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -9437,95 +9186,93 @@ public: BOOL SetFormat(LPCTSTR lpszFormat) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, DTM_SETFORMAT, 0, (LPARAM)lpszFormat); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, DTM_SETFORMAT, 0, (LPARAM)lpszFormat); } COLORREF GetMonthCalColor(int nColorType) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, DTM_GETMCCOLOR, nColorType, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, DTM_GETMCCOLOR, nColorType, 0L); } COLORREF SetMonthCalColor(int nColorType, COLORREF clr) { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, DTM_SETMCCOLOR, nColorType, clr); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, DTM_SETMCCOLOR, nColorType, clr); } DWORD GetRange(LPSYSTEMTIME lpSysTimeArray) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, DTM_GETRANGE, 0, (LPARAM)lpSysTimeArray); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, DTM_GETRANGE, 0, (LPARAM)lpSysTimeArray); } BOOL SetRange(DWORD dwFlags, LPSYSTEMTIME lpSysTimeArray) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, DTM_SETRANGE, dwFlags, (LPARAM)lpSysTimeArray); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, DTM_SETRANGE, dwFlags, (LPARAM)lpSysTimeArray); } DWORD GetSystemTime(LPSYSTEMTIME lpSysTime) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, DTM_GETSYSTEMTIME, 0, (LPARAM)lpSysTime); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, DTM_GETSYSTEMTIME, 0, (LPARAM)lpSysTime); } BOOL SetSystemTime(DWORD dwFlags, LPSYSTEMTIME lpSysTime) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, DTM_SETSYSTEMTIME, dwFlags, (LPARAM)lpSysTime); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, DTM_SETSYSTEMTIME, dwFlags, (LPARAM)lpSysTime); } CMonthCalendarCtrl GetMonthCal() const { - ATLASSERT(::IsWindow(m_hWnd)); - return CMonthCalendarCtrl((HWND)::SendMessage(m_hWnd, DTM_GETMONTHCAL, 0, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CMonthCalendarCtrl((HWND)::SendMessage(this->m_hWnd, DTM_GETMONTHCAL, 0, 0L)); } -#if (_WIN32_IE >= 0x0400) CFontHandle GetMonthCalFont() const { - ATLASSERT(::IsWindow(m_hWnd)); - return CFontHandle((HFONT)::SendMessage(m_hWnd, DTM_GETMCFONT, 0, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CFontHandle((HFONT)::SendMessage(this->m_hWnd, DTM_GETMCFONT, 0, 0L)); } void SetMonthCalFont(HFONT hFont, BOOL bRedraw = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, DTM_SETMCFONT, (WPARAM)hFont, MAKELPARAM(bRedraw, 0)); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, DTM_SETMCFONT, (WPARAM)hFont, MAKELPARAM(bRedraw, 0)); } -#endif // (_WIN32_IE >= 0x0400) #if defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_LONGHORN) DWORD GetMonthCalStyle() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, DTM_GETMCSTYLE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, DTM_GETMCSTYLE, 0, 0L); } DWORD SetMonthCalStyle(DWORD dwStyle) { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, DTM_SETMCSTYLE, 0, (LPARAM)dwStyle); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, DTM_SETMCSTYLE, 0, (LPARAM)dwStyle); } void GetDateTimePickerInfo(LPDATETIMEPICKERINFO lpPickerInfo) const { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, DTM_GETDATETIMEPICKERINFO, 0, (LPARAM)lpPickerInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, DTM_GETDATETIMEPICKERINFO, 0, (LPARAM)lpPickerInfo); } BOOL GetIdealSize(LPSIZE lpSize) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, DTM_GETIDEALSIZE, 0, (LPARAM)lpSize); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, DTM_GETIDEALSIZE, 0, (LPARAM)lpSize); } void CloseMonthCal() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, DTM_CLOSEMONTHCAL, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, DTM_CLOSEMONTHCAL, 0, 0L); } #endif // defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_LONGHORN) }; @@ -9536,8 +9283,6 @@ typedef CDateTimePickerCtrlT CDateTimePickerCtrl; /////////////////////////////////////////////////////////////////////////////// // CFlatScrollBarImpl - support for flat scroll bars -#if (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) - template class CFlatScrollBarImpl { @@ -9640,21 +9385,17 @@ public: CFlatScrollBarT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } }; typedef CFlatScrollBarT CFlatScrollBar; -#endif // (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) - /////////////////////////////////////////////////////////////////////////////// // CIPAddressCtrl -#if (_WIN32_IE >= 0x0400) - template class CIPAddressCtrlT : public TBase { @@ -9665,7 +9406,7 @@ public: CIPAddressCtrlT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -9684,57 +9425,53 @@ public: BOOL IsBlank() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, IPM_ISBLANK, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, IPM_ISBLANK, 0, 0L); } int GetAddress(LPDWORD lpdwAddress) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, IPM_GETADDRESS, 0, (LPARAM)lpdwAddress); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, IPM_GETADDRESS, 0, (LPARAM)lpdwAddress); } void SetAddress(DWORD dwAddress) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, IPM_SETADDRESS, 0, dwAddress); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, IPM_SETADDRESS, 0, dwAddress); } void ClearAddress() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, IPM_CLEARADDRESS, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, IPM_CLEARADDRESS, 0, 0L); } void SetRange(int nField, WORD wRange) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, IPM_SETRANGE, nField, wRange); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, IPM_SETRANGE, nField, wRange); } void SetRange(int nField, BYTE nMin, BYTE nMax) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, IPM_SETRANGE, nField, MAKEIPRANGE(nMin, nMax)); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, IPM_SETRANGE, nField, MAKEIPRANGE(nMin, nMax)); } void SetFocus(int nField) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, IPM_SETFOCUS, nField, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, IPM_SETFOCUS, nField, 0L); } }; typedef CIPAddressCtrlT CIPAddressCtrl; -#endif // (_WIN32_IE >= 0x0400) - /////////////////////////////////////////////////////////////////////////////// // CPagerCtrl -#if (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) - template class CPagerCtrlT : public TBase { @@ -9745,7 +9482,7 @@ public: CPagerCtrlT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -9764,96 +9501,92 @@ public: int GetButtonSize() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, PGM_GETBUTTONSIZE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, PGM_GETBUTTONSIZE, 0, 0L); } int SetButtonSize(int nButtonSize) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, PGM_SETBUTTONSIZE, 0, nButtonSize); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, PGM_SETBUTTONSIZE, 0, nButtonSize); } DWORD GetButtonState(int nButton) const { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT(nButton == PGB_TOPORLEFT || nButton == PGB_BOTTOMORRIGHT); - return (DWORD)::SendMessage(m_hWnd, PGM_GETBUTTONSTATE, 0, nButton); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((nButton == PGB_TOPORLEFT) || (nButton == PGB_BOTTOMORRIGHT)); + return (DWORD)::SendMessage(this->m_hWnd, PGM_GETBUTTONSTATE, 0, nButton); } COLORREF GetBkColor() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, PGM_GETBKCOLOR, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, PGM_GETBKCOLOR, 0, 0L); } COLORREF SetBkColor(COLORREF clrBk) { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, PGM_SETBKCOLOR, 0, (LPARAM)clrBk); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, PGM_SETBKCOLOR, 0, (LPARAM)clrBk); } int GetBorder() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, PGM_GETBORDER, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, PGM_GETBORDER, 0, 0L); } int SetBorder(int nBorderSize) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, PGM_SETBORDER, 0, nBorderSize); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, PGM_SETBORDER, 0, nBorderSize); } int GetPos() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, PGM_GETPOS, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, PGM_GETPOS, 0, 0L); } int SetPos(int nPos) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, PGM_SETPOS, 0, nPos); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, PGM_SETPOS, 0, nPos); } // Operations void SetChild(HWND hWndChild) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, PGM_SETCHILD, 0, (LPARAM)hWndChild); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, PGM_SETCHILD, 0, (LPARAM)hWndChild); } void ForwardMouse(BOOL bForward = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, PGM_FORWARDMOUSE, bForward, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, PGM_FORWARDMOUSE, bForward, 0L); } void RecalcSize() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, PGM_RECALCSIZE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, PGM_RECALCSIZE, 0, 0L); } void GetDropTarget(IDropTarget** ppDropTarget) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(ppDropTarget != NULL); - ::SendMessage(m_hWnd, PGM_GETDROPTARGET, 0, (LPARAM)ppDropTarget); + ::SendMessage(this->m_hWnd, PGM_GETDROPTARGET, 0, (LPARAM)ppDropTarget); } }; typedef CPagerCtrlT CPagerCtrl; -#endif // (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) - /////////////////////////////////////////////////////////////////////////////// // CLinkCtrl - Windows SYSLINK control -#if (_WIN32_WINNT >= 0x0501) && !defined(_WIN32_WCE) - template class CLinkCtrlT : public TBase { @@ -9864,7 +9597,7 @@ public: CLinkCtrlT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -9887,44 +9620,39 @@ public: int GetIdealHeight(int cxMaxWidth = 0) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LM_GETIDEALHEIGHT, cxMaxWidth, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LM_GETIDEALHEIGHT, cxMaxWidth, 0L); } BOOL GetItem(PLITEM pLItem) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LM_GETITEM, 0, (LPARAM)pLItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LM_GETITEM, 0, (LPARAM)pLItem); } BOOL SetItem(PLITEM pLItem) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LM_SETITEM, 0, (LPARAM)pLItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LM_SETITEM, 0, (LPARAM)pLItem); } // Vista only int GetIdealSize(SIZE& size, int cxMaxWidth = 0) const { -#ifndef LM_GETIDEALSIZE - const UINT LM_GETIDEALSIZE = LM_GETIDEALHEIGHT; -#endif - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LM_GETIDEALSIZE, cxMaxWidth, (LPARAM)&size); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LM_GETIDEALSIZE, cxMaxWidth, (LPARAM)&size); } // Operations BOOL HitTest(PLHITTESTINFO pLHitTestInfo) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LM_HITTEST, 0, (LPARAM)pLHitTestInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LM_HITTEST, 0, (LPARAM)pLHitTestInfo); } }; typedef CLinkCtrlT CLinkCtrl; -#endif // (_WIN32_WINNT >= 0x0501) && !defined(_WIN32_WCE) - /////////////////////////////////////////////////////////////////////////////// // CCustomDraw - MI class for custom-draw support @@ -9933,20 +9661,6 @@ template class CCustomDraw { public: -#if (_ATL_VER < 0x0700) - BOOL m_bHandledCD; - - BOOL IsMsgHandled() const - { - return m_bHandledCD; - } - - void SetMsgHandled(BOOL bHandled) - { - m_bHandledCD = bHandled; - } -#endif // !(_ATL_VER < 0x0700) - // Message map and handlers BEGIN_MSG_MAP(CCustomDraw< T >) NOTIFY_CODE_HANDLER(NM_CUSTOMDRAW, OnCustomDraw) @@ -9987,11 +9701,9 @@ public: case CDDS_ITEMPOSTERASE: dwRet = pT->OnItemPostErase(idCtrl, lpNMCustomDraw); break; -#if (_WIN32_IE >= 0x0400) case (CDDS_ITEMPREPAINT | CDDS_SUBITEM): dwRet = pT->OnSubItemPrePaint(idCtrl, lpNMCustomDraw); break; -#endif // (_WIN32_IE >= 0x0400) default: pT->SetMsgHandled(FALSE); break; @@ -10041,212 +9753,12 @@ public: return CDRF_DODEFAULT; } -#if (_WIN32_IE >= 0x0400) DWORD OnSubItemPrePaint(int /*idCtrl*/, LPNMCUSTOMDRAW /*lpNMCustomDraw*/) { return CDRF_DODEFAULT; } -#endif // (_WIN32_IE >= 0x0400) }; - -// --- Windows CE common controls --- - -#ifdef _WIN32_WCE - -/////////////////////////////////////////////////////////////////////////////// -// CCECommandBarCtrl - -template -class CCECommandBarCtrlT : public TBase -{ -public: -// Constructors - CCECommandBarCtrlT(HWND hWnd = NULL) : TBase(hWnd) { } - - CCECommandBarCtrlT< TBase >& operator=(HWND hWnd) - { - m_hWnd = hWnd; - return *this; - } - -// Attributes - BOOL IsVisible() const - { - return IsWindowVisible(); - } - - int GetHeight() const - { - ATLASSERT(::IsWindow(m_hWnd)); - return ::CommandBar_Height(m_hWnd); - } - - HMENU GetMenu(WORD wButton) const - { - ATLASSERT(::IsWindow(m_hWnd)); - return ::CommandBar_GetMenu(m_hWnd, wButton); - } - -// Operations - HWND Create(HWND hWndParent, int nCmdBarID) - { - m_hWnd = ::CommandBar_Create(ModuleHelper::GetModuleInstance(), hWndParent, nCmdBarID); - ATLASSERT(::IsWindow(m_hWnd)); - return m_hWnd; - } - - void Destroy() - { - DestroyWindow(); - } - - BOOL Show(BOOL bShow = TRUE) - { - ATLASSERT(::IsWindow(m_hWnd)); - return ::CommandBar_Show(m_hWnd, bShow); - } - - BOOL DrawMenuBar(WORD wButton) - { - ATLASSERT(::IsWindow(m_hWnd)); - return ::CommandBar_DrawMenuBar(m_hWnd, wButton); - } - - BOOL AddAdornments(DWORD dwFlags = 0) - { - ATLASSERT(::IsWindow(m_hWnd)); - return ::CommandBar_AddAdornments(m_hWnd, dwFlags, 0); - } - - int AddBitmap(int nBitmapID, int nNumImages) - { - ATLASSERT(::IsWindow(m_hWnd)); - return ::CommandBar_AddBitmap(m_hWnd, ModuleHelper::GetResourceInstance(), nBitmapID, nNumImages, 16, 16); - } - - BOOL AddButtons(UINT uNumButtons, LPTBBUTTON lpButtons) - { - ATLASSERT(::IsWindow(m_hWnd)); - return CommandBar_AddButtons(m_hWnd, uNumButtons, lpButtons); - } - - BOOL AddToolTips(UINT uNumToolTips, LPTSTR lpToolTips) - { - ATLASSERT(::IsWindow(m_hWnd)); - return CommandBar_AddToolTips(m_hWnd, uNumToolTips, lpToolTips); - } - - BOOL InsertButton(int nButton, LPTBBUTTON lpButton) - { - ATLASSERT(::IsWindow(m_hWnd)); - return CommandBar_InsertButton(m_hWnd, nButton, lpButton); - } - - HWND InsertComboBox(int nWidth, UINT dwStyle, WORD wComboBoxID, WORD wButton) - { - ATLASSERT(::IsWindow(m_hWnd)); - return ::CommandBar_InsertComboBox(m_hWnd, ModuleHelper::GetModuleInstance(), nWidth, dwStyle, wComboBoxID, wButton); - } - - BOOL InsertMenubar(WORD wMenuID, WORD wButton) - { - ATLASSERT(::IsWindow(m_hWnd)); - return ::CommandBar_InsertMenubar(m_hWnd, ModuleHelper::GetResourceInstance(), wMenuID, wButton); - } - - BOOL InsertMenubarEx(ATL::_U_STRINGorID menu, WORD wButton) - { - ATLASSERT(::IsWindow(m_hWnd)); - return ::CommandBar_InsertMenubarEx(m_hWnd, ModuleHelper::GetResourceInstance(), (LPTSTR)menu.m_lpstr, wButton); - } - - BOOL IsCommandBarMessage(LPMSG lpMsg) - { - ATLASSERT(::IsWindow(m_hWnd)); - return ::IsCommandBarMessage(m_hWnd, lpMsg); - } -}; - -#if defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) // PPC MenuBar - typedef CCECommandBarCtrlT CMenuBarCtrl; -#else - typedef CCECommandBarCtrlT CCECommandBarCtrl; -#endif // defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) - -/////////////////////////////////////////////////////////////////////////////// -// CCECommandBandsCtrl - -template -class CCECommandBandsCtrlT : public TBase -{ -public: -// Constructors - CCECommandBandsCtrlT(HWND hWnd = NULL) : TBase(hWnd) { } - - CCECommandBandsCtrlT< TBase >& operator=(HWND hWnd) - { - m_hWnd = hWnd; - return *this; - } - -// Attributes - BOOL IsVisible() const - { - return IsWindowVisible(); - } - -#if (_WIN32_IE >= 0x0400) - UINT GetHeight() const - { - ATLASSERT(::IsWindow(m_hWnd)); - return CommandBands_Height(m_hWnd); - } -#endif // (_WIN32_IE >= 0x0400) - - HWND GetCommandBar(UINT uBand) const - { - ATLASSERT(::IsWindow(m_hWnd)); - return ::CommandBands_GetCommandBar(m_hWnd, uBand); - } - - BOOL GetRestoreInformation(UINT uBand, LPCOMMANDBANDSRESTOREINFO pcbr) const - { - ATLASSERT(::IsWindow(m_hWnd)); - return ::CommandBands_GetRestoreInformation(m_hWnd, uBand, pcbr); - } - -// Operations - HWND Create(HWND hWndParent, UINT wID, DWORD dwStyles, HIMAGELIST hImageList = NULL) - { - m_hWnd = ::CommandBands_Create(ModuleHelper::GetModuleInstance(), hWndParent, wID, dwStyles, hImageList); - ATLASSERT(::IsWindow(m_hWnd)); - return m_hWnd; - } - - BOOL AddAdornments(DWORD dwFlags = 0, LPREBARBANDINFO prbbi = NULL) - { - ATLASSERT(::IsWindow(m_hWnd)); - return ::CommandBands_AddAdornments(m_hWnd, ModuleHelper::GetModuleInstance(), dwFlags, prbbi); - } - - BOOL AddBands(UINT uBandCount, LPREBARBANDINFO prbbi) - { - ATLASSERT(::IsWindow(m_hWnd)); - return ::CommandBands_AddBands(m_hWnd, ModuleHelper::GetModuleInstance(), uBandCount, prbbi); - } - - BOOL Show(BOOL bShow = TRUE) - { - ATLASSERT(::IsWindow(m_hWnd)); - return ::CommandBands_Show(m_hWnd, bShow); - } -}; - -typedef CCECommandBandsCtrlT CCECommandBandsCtrl; - -#endif // _WIN32_WCE - -}; // namespace WTL +} // namespace WTL #endif // __ATLCTRLS_H__ diff --git a/WrlSDK/SampleCode/PluginWinExe/WTL/atlctrlw.h b/WrlSDK/SampleCode/PluginWinExe/WTL/atlctrlw.h index 0984551fed49c69a126b59fa8981df7190c358ec..73cac9f50324e52bb4139f46627b9ab25cde2600 100644 --- a/WrlSDK/SampleCode/PluginWinExe/WTL/atlctrlw.h +++ b/WrlSDK/SampleCode/PluginWinExe/WTL/atlctrlw.h @@ -1,4 +1,4 @@ -// Windows Template Library - WTL version 9.10 +// Windows Template Library - WTL version 10.0 // Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. // // This file is a part of the Windows Template Library. @@ -11,10 +11,6 @@ #pragma once -#ifdef _WIN32_WCE - #error atlctrlw.h is not supported on Windows CE -#endif - #ifndef __ATLAPP_H__ #error atlctrlw.h requires atlapp.h to be included first #endif @@ -23,21 +19,11 @@ #error atlctrlw.h requires atlctrls.h to be included first #endif -#if (_WIN32_IE < 0x0400) - #error atlctrlw.h requires _WIN32_IE >= 0x0400 -#endif - // Define _WTL_CMDBAR_VISTA_MENUS as 0 to exclude Vista menus support -#if !defined(_WTL_CMDBAR_VISTA_MENUS) && (WINVER >= 0x0500) && (_WIN32_WINNT >= 0x0501) && (_WIN32_IE >= 0x0501) +#ifndef _WTL_CMDBAR_VISTA_MENUS #define _WTL_CMDBAR_VISTA_MENUS 1 #endif -#if _WTL_CMDBAR_VISTA_MENUS - #if !((_WIN32_WINNT >= 0x0501) && (_WIN32_IE >= 0x0501)) - #error _WTL_CMDBAR_VISTA_MENUS requires (_WIN32_WINNT >= 0x0501) && (_WIN32_IE >= 0x0501) - #endif -#endif - // Note: Define _WTL_CMDBAR_VISTA_STD_MENUBAR to use Vista standard menubar look with Vista menus @@ -99,29 +85,29 @@ public: #ifdef _CMDBAR_EXTRA_TRACE ATLTRACE2(atlTraceUI, 0, _T("CmdBar - STACK-PUSH (%8.8X) size = %i\n"), t, GetSize()); #endif - return Add(t); + return this->Add(t); } T Pop() { - int nLast = GetSize() - 1; + int nLast = this->GetSize() - 1; if(nLast < 0) return NULL; // must be able to convert to NULL - T t = m_aT[nLast]; + T t = this->m_aT[nLast]; #ifdef _CMDBAR_EXTRA_TRACE ATLTRACE2(atlTraceUI, 0, _T("CmdBar - STACK-POP (%8.8X) size = %i\n"), t, GetSize()); #endif - if(!RemoveAt(nLast)) + if(!this->RemoveAt(nLast)) return NULL; return t; } T GetCurrent() { - int nLast = GetSize() - 1; + int nLast = this->GetSize() - 1; if(nLast < 0) return NULL; // must be able to convert to NULL - return m_aT[nLast]; + return this->m_aT[nLast]; } }; @@ -145,7 +131,6 @@ public: static CMsgHookMap* s_pmapMsgHook; static HHOOK s_hCreateHook; - static bool s_bW2K; // For animation flag static CCommandBarCtrlBase* s_pCurrentBar; static bool s_bStaticInit; @@ -173,8 +158,6 @@ public: { // Just in case... AtlInitCommonControls(ICC_COOL_CLASSES | ICC_BAR_CLASSES); - // Animation on Win2000 only - s_bW2K = !AtlIsOldWindows(); // done s_bStaticInit = true; } @@ -189,7 +172,6 @@ public: __declspec(selectany) CCommandBarCtrlBase::CMsgHookMap* CCommandBarCtrlBase::s_pmapMsgHook = NULL; __declspec(selectany) HHOOK CCommandBarCtrlBase::s_hCreateHook = NULL; __declspec(selectany) CCommandBarCtrlBase* CCommandBarCtrlBase::s_pCurrentBar = NULL; -__declspec(selectany) bool CCommandBarCtrlBase::s_bW2K = false; __declspec(selectany) bool CCommandBarCtrlBase::s_bStaticInit = false; @@ -200,7 +182,7 @@ template { public: - DECLARE_WND_SUPERCLASS(NULL, TBase::GetWndClassName()) + DECLARE_WND_SUPERCLASS2(NULL, T, TBase::GetWndClassName()) // Declarations struct _MenuItemData // menu item data @@ -211,7 +193,9 @@ public: UINT fState; int iButton; - _MenuItemData() { dwMagic = 0x1313; } + _MenuItemData() : dwMagic(0x1313), lpstrText(NULL), fType(0U), fState(0U), iButton(0) + { } + bool IsCmdBarMenuItem() { return (dwMagic == 0x1313); } }; @@ -242,10 +226,6 @@ public: _chChevronShortcut = _T('/') }; -#ifndef DT_HIDEPREFIX - enum { DT_HIDEPREFIX = 0x00100000 }; -#endif // !DT_HIDEPREFIX - // Data members HMENU m_hMenu; HIMAGELIST m_hImageList; @@ -296,31 +276,31 @@ public: CCommandBarCtrlImpl() : m_hMenu(NULL), m_hImageList(NULL), - m_wndParent(this, 1), + m_dwExtendedStyle(CBR_EX_TRANSPARENT | CBR_EX_SHAREMENU | CBR_EX_TRACKALWAYS), + m_wndParent(this, 1), m_bMenuActive(false), m_bAttachedMenu(false), - m_nPopBtn(-1), - m_nNextPopBtn(-1), - m_bPopupItem(false), m_bImagesVisible(true), - m_bSkipMsg(false), - m_uSysKey(0), - m_hWndFocus(NULL), + m_bPopupItem(false), m_bContextMenu(false), m_bEscapePressed(false), - m_clrMask(RGB(192, 192, 192)), - m_dwExtendedStyle(CBR_EX_TRANSPARENT | CBR_EX_SHAREMENU | CBR_EX_TRACKALWAYS), + m_bSkipMsg(false), m_bParentActive(true), m_bFlatMenus(false), m_bUseKeyboardCues(false), m_bShowKeyboardCues(false), m_bAllowKeyboardCues(true), m_bKeyboardInput(false), - m_cxExtraSpacing(0), m_bAlphaImages(false), m_bLayoutRTL(false), m_bSkipPostDown(false), - m_bVistaMenus(false) + m_bVistaMenus(false), + m_nPopBtn(-1), + m_nNextPopBtn(-1), + m_clrMask(RGB(192, 192, 192)), + m_uSysKey(0), + m_hWndFocus(NULL), + m_cxExtraSpacing(0) { SetImageSize(16, 15); // default } @@ -330,7 +310,7 @@ public: if(m_wndParent.IsWindow()) /*scary!*/ m_wndParent.UnsubclassWindow(); - if(m_hMenu != NULL && (m_dwExtendedStyle & CBR_EX_SHAREMENU) == 0) + if((m_hMenu != NULL) && ((m_dwExtendedStyle & CBR_EX_SHAREMENU) == 0)) ::DestroyMenu(m_hMenu); if(m_hImageList != NULL) @@ -355,7 +335,7 @@ public: CMenuHandle GetMenu() const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); return m_hMenu; } @@ -408,7 +388,7 @@ public: } } - if(cx == 0 || cy == 0) + if((cx == 0) || (cy == 0)) return false; m_szBitmap.cx = cx; @@ -445,8 +425,8 @@ public: HWND GetCmdBar() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (HWND)::SendMessage(m_hWnd, CBRM_GETCMDBAR, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HWND)::SendMessage(this->m_hWnd, CBRM_GETCMDBAR, 0, 0L); } // Methods @@ -456,19 +436,14 @@ public: { // These styles are required for command bars dwStyle |= TBSTYLE_LIST | TBSTYLE_FLAT; -#if (_MSC_VER >= 1300) return ATL::CWindowImpl< T, TBase, TWinTraits >::Create(hWndParent, rcPos, szWindowName, dwStyle, dwExStyle, nID, lpCreateParam); -#else // !(_MSC_VER >= 1300) - typedef ATL::CWindowImpl< T, TBase, TWinTraits > _baseClass; - return _baseClass::Create(hWndParent, rcPos, szWindowName, dwStyle, dwExStyle, nID, lpCreateParam); -#endif // !(_MSC_VER >= 1300) } BOOL AttachToWindow(HWND hWnd) { - ATLASSERT(m_hWnd == NULL); + ATLASSERT(this->m_hWnd == NULL); ATLASSERT(::IsWindow(hWnd)); - BOOL bRet = SubclassWindow(hWnd); + BOOL bRet = this->SubclassWindow(hWnd); if(bRet) { m_bAttachedMenu = true; @@ -480,7 +455,7 @@ public: BOOL LoadMenu(ATL::_U_STRINGorID menu) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); if(m_bAttachedMenu) // doesn't work in this mode return FALSE; @@ -496,9 +471,9 @@ public: BOOL AttachMenu(HMENU hMenu) { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT(hMenu == NULL || ::IsMenu(hMenu)); - if(hMenu != NULL && !::IsMenu(hMenu)) + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((hMenu == NULL) || ::IsMenu(hMenu)); + if((hMenu != NULL) && !::IsMenu(hMenu)) return FALSE; #if _WTL_CMDBAR_VISTA_MENUS @@ -511,7 +486,7 @@ public: #endif // _WTL_CMDBAR_VISTA_MENUS // destroy old menu, if needed, and set new one - if(m_hMenu != NULL && (m_dwExtendedStyle & CBR_EX_SHAREMENU) == 0) + if((m_hMenu != NULL) && ((m_dwExtendedStyle & CBR_EX_SHAREMENU) == 0)) ::DestroyMenu(m_hMenu); m_hMenu = hMenu; @@ -520,12 +495,12 @@ public: return TRUE; // Build buttons according to menu - SetRedraw(FALSE); + this->SetRedraw(FALSE); // Clear all buttons - int nCount = GetButtonCount(); + int nCount = this->GetButtonCount(); for(int i = 0; i < nCount; i++) - ATLVERIFY(DeleteButton(0) != FALSE); + ATLVERIFY(this->DeleteButton(0) != FALSE); // Add buttons for each menu item if(m_hMenu != NULL) @@ -533,8 +508,8 @@ public: int nItems = ::GetMenuItemCount(m_hMenu); T* pT = static_cast(this); - pT; // avoid level 4 warning - TCHAR szString[pT->_nMaxMenuItemTextLength] = { 0 }; + (void)pT; // avoid level 4 warning + TCHAR szString[pT->_nMaxMenuItemTextLength] = {}; for(int i = 0; i < nItems; i++) { CMenuItemInfo mii; @@ -555,7 +530,7 @@ public: // NOTE: Command Bar currently supports only drop-down menu items ATLASSERT(mii.hSubMenu != NULL); - TBBUTTON btn = { 0 }; + TBBUTTON btn = {}; btn.iBitmap = 0; btn.idCommand = i; btn.fsState = (BYTE)(((mii.fState & MFS_DISABLED) == 0) ? TBSTATE_ENABLED : 0); @@ -563,22 +538,22 @@ public: btn.dwData = 0; btn.iString = 0; - bRet = InsertButton(-1, &btn); + bRet = this->InsertButton(-1, &btn); ATLASSERT(bRet); - TBBUTTONINFO bi = { 0 }; + TBBUTTONINFO bi = {}; bi.cbSize = sizeof(TBBUTTONINFO); bi.dwMask = TBIF_TEXT; bi.pszText = szString; - bRet = SetButtonInfo(i, &bi); + bRet = this->SetButtonInfo(i, &bi); ATLASSERT(bRet); } } - SetRedraw(TRUE); - Invalidate(); - UpdateWindow(); + this->SetRedraw(TRUE); + this->Invalidate(); + this->UpdateWindow(); return TRUE; } @@ -595,7 +570,7 @@ public: BOOL _LoadImagesHelper(ATL::_U_STRINGorID image, bool bMapped, UINT nFlags = 0, LPCOLORMAP lpColorMap = NULL, int nMapSize = 0) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); HINSTANCE hInstance = ModuleHelper::GetResourceInstance(); HRSRC hRsrc = ::FindResource(hInstance, image.m_lpstr, (LPTSTR)RT_TOOLBAR); @@ -679,7 +654,7 @@ public: BOOL AddBitmap(ATL::_U_STRINGorID bitmap, int nCommandID) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); CBitmap bmp; bmp.LoadBitmap(bitmap.m_lpstr); if(bmp.m_hBitmap == NULL) @@ -689,7 +664,7 @@ public: BOOL AddBitmap(HBITMAP hBitmap, UINT nCommandID) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); T* pT = static_cast(this); // Create image list if it doesn't exist if(m_hImageList == NULL) @@ -699,9 +674,9 @@ public: } // check bitmap size CBitmapHandle bmp = hBitmap; - SIZE size = { 0, 0 }; + SIZE size = {}; bmp.GetSize(size); - if(size.cx != m_szBitmap.cx || size.cy != m_szBitmap.cy) + if((size.cx != m_szBitmap.cx) || (size.cy != m_szBitmap.cy)) { ATLASSERT(FALSE); // must match size! return FALSE; @@ -724,7 +699,7 @@ public: BOOL AddIcon(ATL::_U_STRINGorID icon, UINT nCommandID) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); HICON hIcon = ::LoadIcon(ModuleHelper::GetResourceInstance(), icon.m_lpstr); if(hIcon == NULL) return FALSE; @@ -733,7 +708,7 @@ public: BOOL AddIcon(HICON hIcon, UINT nCommandID) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); T* pT = static_cast(this); // create image list if it doesn't exist if(m_hImageList == NULL) @@ -759,7 +734,7 @@ public: BOOL ReplaceBitmap(ATL::_U_STRINGorID bitmap, int nCommandID) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); CBitmap bmp; bmp.LoadBitmap(bitmap.m_lpstr); if(bmp.m_hBitmap == NULL) @@ -769,7 +744,7 @@ public: BOOL ReplaceBitmap(HBITMAP hBitmap, UINT nCommandID) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); BOOL bRet = FALSE; for(int i = 0; i < m_arrCommand.GetSize(); i++) { @@ -798,7 +773,7 @@ public: BOOL ReplaceIcon(ATL::_U_STRINGorID icon, UINT nCommandID) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); HICON hIcon = ::LoadIcon(ModuleHelper::GetResourceInstance(), icon.m_lpstr); if(hIcon == NULL) return FALSE; @@ -807,7 +782,7 @@ public: BOOL ReplaceIcon(HICON hIcon, UINT nCommandID) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); BOOL bRet = FALSE; for(int i = 0; i < m_arrCommand.GetSize(); i++) { @@ -815,7 +790,7 @@ public: { bRet = (::ImageList_ReplaceIcon(m_hImageList, i, hIcon) != -1); #if _WTL_CMDBAR_VISTA_MENUS - if(RunTimeHelper::IsVista() && bRet != FALSE) + if(RunTimeHelper::IsVista() && (bRet != FALSE)) { T* pT = static_cast(this); pT->_ReplaceVistaBitmapFromImageList(i); @@ -829,7 +804,7 @@ public: BOOL RemoveImage(int nCommandID) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); BOOL bRet = FALSE; for(int i = 0; i < m_arrCommand.GetSize(); i++) @@ -857,7 +832,7 @@ public: BOOL RemoveAllImages() { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLTRACE2(atlTraceUI, 0, _T("CmdBar - Removing all images\n")); BOOL bRet = ::ImageList_RemoveAll(m_hImageList); @@ -878,7 +853,7 @@ public: BOOL TrackPopupMenu(HMENU hMenu, UINT uFlags, int x, int y, LPTPMPARAMS lpParams = NULL) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(::IsMenu(hMenu)); if(!::IsMenu(hMenu)) return FALSE; @@ -957,9 +932,9 @@ public: LRESULT OnForwardMsg(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/) { LPMSG pMsg = (LPMSG)lParam; - if(pMsg->message >= WM_MOUSEFIRST && pMsg->message <= WM_MOUSELAST) + if((pMsg->message >= WM_MOUSEFIRST) && (pMsg->message <= WM_MOUSELAST)) m_bKeyboardInput = false; - else if(pMsg->message >= WM_KEYFIRST && pMsg->message <= WM_KEYLAST) + else if((pMsg->message >= WM_KEYFIRST) && (pMsg->message <= WM_KEYLAST)) m_bKeyboardInput = true; LRESULT lRet = 0; ProcessWindowMessage(pMsg->hwnd, pMsg->message, pMsg->wParam, pMsg->lParam, lRet, 3); @@ -969,17 +944,17 @@ public: LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) { // Let the toolbar initialize itself - LRESULT lRet = DefWindowProc(uMsg, wParam, lParam); + LRESULT lRet = this->DefWindowProc(uMsg, wParam, lParam); // get and use system settings T* pT = static_cast(this); pT->GetSystemSettings(); // Parent init - ATL::CWindow wndParent = GetParent(); + ATL::CWindow wndParent = this->GetParent(); ATL::CWindow wndTopLevelParent = wndParent.GetTopLevelParent(); m_wndParent.SubclassWindow(wndTopLevelParent); // Toolbar Init - SetButtonStructSize(); - SetImageList(NULL); + this->SetButtonStructSize(); + this->SetImageList(NULL); // Create message hook if needed CWindowCreateCriticalSectionLock lock; @@ -990,28 +965,28 @@ public: return -1; } - if(s_pmapMsgHook == NULL) + if(this->s_pmapMsgHook == NULL) { - ATLTRY(s_pmapMsgHook = new CMsgHookMap); - ATLASSERT(s_pmapMsgHook != NULL); + ATLTRY(this->s_pmapMsgHook = new CCommandBarCtrlBase::CMsgHookMap); + ATLASSERT(this->s_pmapMsgHook != NULL); } - if(s_pmapMsgHook != NULL) + if(this->s_pmapMsgHook != NULL) { DWORD dwThreadID = ::GetCurrentThreadId(); - _MsgHookData* pData = s_pmapMsgHook->Lookup(dwThreadID); + CCommandBarCtrlBase::_MsgHookData* pData = this->s_pmapMsgHook->Lookup(dwThreadID); if(pData == NULL) { - ATLTRY(pData = new _MsgHookData); + ATLTRY(pData = new CCommandBarCtrlBase::_MsgHookData); ATLASSERT(pData != NULL); HHOOK hMsgHook = ::SetWindowsHookEx(WH_GETMESSAGE, MessageHookProc, ModuleHelper::GetModuleInstance(), dwThreadID); ATLASSERT(hMsgHook != NULL); - if(pData != NULL && hMsgHook != NULL) + if((pData != NULL) && (hMsgHook != NULL)) { pData->hMsgHook = hMsgHook; pData->dwUsage = 1; - BOOL bRet = s_pmapMsgHook->Add(dwThreadID, pData); - bRet; + BOOL bRet = this->s_pmapMsgHook->Add(dwThreadID, pData); + (void)bRet; // avoid level 4 warning ATLASSERT(bRet); } } @@ -1023,16 +998,14 @@ public: lock.Unlock(); // Get layout -#if (WINVER >= 0x0500) - m_bLayoutRTL = ((GetExStyle() & WS_EX_LAYOUTRTL) != 0); -#endif // (WINVER >= 0x0500) + m_bLayoutRTL = ((this->GetExStyle() & WS_EX_LAYOUTRTL) != 0); return lRet; } LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) { - LRESULT lRet = DefWindowProc(uMsg, wParam, lParam); + LRESULT lRet = this->DefWindowProc(uMsg, wParam, lParam); #if _WTL_CMDBAR_VISTA_MENUS if(m_bVistaMenus && (m_hMenu != NULL)) @@ -1059,10 +1032,10 @@ public: return lRet; } - if(s_pmapMsgHook != NULL) + if(this->s_pmapMsgHook != NULL) { DWORD dwThreadID = ::GetCurrentThreadId(); - _MsgHookData* pData = s_pmapMsgHook->Lookup(dwThreadID); + CCommandBarCtrlBase::_MsgHookData* pData = this->s_pmapMsgHook->Lookup(dwThreadID); if(pData != NULL) { (pData->dwUsage)--; @@ -1070,16 +1043,16 @@ public: { BOOL bRet = ::UnhookWindowsHookEx(pData->hMsgHook); ATLASSERT(bRet); - bRet = s_pmapMsgHook->Remove(dwThreadID); + bRet = this->s_pmapMsgHook->Remove(dwThreadID); ATLASSERT(bRet); if(bRet) delete pData; } - if(s_pmapMsgHook->GetSize() == 0) + if(this->s_pmapMsgHook->GetSize() == 0) { - delete s_pmapMsgHook; - s_pmapMsgHook = NULL; + delete this->s_pmapMsgHook; + this->s_pmapMsgHook = NULL; } } } @@ -1107,25 +1080,23 @@ public: m_wndParent.PostMessage(WM_SYSKEYDOWN, wParam, lParam | (1 << 29)); bHandled = TRUE; } -#if (_WIN32_IE >= 0x0500) - else if(wParam == VK_LEFT || wParam == VK_RIGHT) + else if((wParam == VK_LEFT) || (wParam == VK_RIGHT)) { WPARAM wpNext = m_bLayoutRTL ? VK_LEFT : VK_RIGHT; if(!m_bMenuActive) { T* pT = static_cast(this); - int nBtn = GetHotItem(); + int nBtn = this->GetHotItem(); int nNextBtn = (wParam == wpNext) ? pT->GetNextMenuItem(nBtn) : pT->GetPreviousMenuItem(nBtn); if(nNextBtn == -2) { - SetHotItem(-1); + this->SetHotItem(-1); if(pT->DisplayChevronMenu()) bHandled = TRUE; } } } -#endif // (_WIN32_IE >= 0x0500) return 0; } @@ -1162,41 +1133,35 @@ public: else return 0; // Security - if(!m_wndParent.IsWindowEnabled() || ::GetFocus() != m_hWnd) + if(!m_wndParent.IsWindowEnabled() || (::GetFocus() != this->m_hWnd)) return 0; // Handle mnemonic press when we have focus int nBtn = 0; - if(wParam != VK_RETURN && !MapAccelerator((TCHAR)LOWORD(wParam), nBtn)) + if((wParam != VK_RETURN) && !this->MapAccelerator((TCHAR)LOWORD(wParam), nBtn)) { -#if (_WIN32_IE >= 0x0500) if((TCHAR)LOWORD(wParam) != _chChevronShortcut) -#endif // (_WIN32_IE >= 0x0500) ::MessageBeep(0); } else { -#if (_WIN32_IE >= 0x0500) - RECT rcClient = { 0 }; - GetClientRect(&rcClient); - RECT rcBtn = { 0 }; - GetItemRect(nBtn, &rcBtn); - TBBUTTON tbb = { 0 }; - GetButton(nBtn, &tbb); - if((tbb.fsState & TBSTATE_ENABLED) != 0 && (tbb.fsState & TBSTATE_HIDDEN) == 0 && rcBtn.right <= rcClient.right) + RECT rcClient = {}; + this->GetClientRect(&rcClient); + RECT rcBtn = {}; + this->GetItemRect(nBtn, &rcBtn); + TBBUTTON tbb = {}; + this->GetButton(nBtn, &tbb); + if(((tbb.fsState & TBSTATE_ENABLED) != 0) && ((tbb.fsState & TBSTATE_HIDDEN) == 0) && (rcBtn.right <= rcClient.right)) { -#endif // (_WIN32_IE >= 0x0500) - PostMessage(WM_KEYDOWN, VK_DOWN, 0L); + this->PostMessage(WM_KEYDOWN, VK_DOWN, 0L); if(wParam != VK_RETURN) - SetHotItem(nBtn); -#if (_WIN32_IE >= 0x0500) + this->SetHotItem(nBtn); } else { ::MessageBeep(0); bHandled = TRUE; } -#endif // (_WIN32_IE >= 0x0500) } return 0; } @@ -1237,8 +1202,8 @@ public: } CDCHandle dc = (HDC)wParam; - RECT rect = { 0 }; - GetClientRect(&rect); + RECT rect = {}; + this->GetClientRect(&rect); dc.FillRect(&rect, COLOR_MENU); return 1; // don't do the default erase @@ -1246,8 +1211,8 @@ public: LRESULT OnInitMenu(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) { - int nIndex = GetHotItem(); - SendMessage(WM_MENUSELECT, MAKEWPARAM(nIndex, MF_POPUP|MF_HILITE), (LPARAM)m_hMenu); + int nIndex = this->GetHotItem(); + this->SendMessage(WM_MENUSELECT, MAKEWPARAM(nIndex, MF_POPUP|MF_HILITE), (LPARAM)m_hMenu); bHandled = FALSE; return 1; } @@ -1272,9 +1237,9 @@ public: // forward to the parent or subclassed window, so it can handle update UI LRESULT lRet = 0; if(m_bAttachedMenu) - lRet = DefWindowProc(uMsg, wParam, (lParam || m_bContextMenu) ? lParam : GetHotItem()); + lRet = this->DefWindowProc(uMsg, wParam, (lParam || m_bContextMenu) ? lParam : this->GetHotItem()); else - lRet = m_wndParent.DefWindowProc(uMsg, wParam, (lParam || m_bContextMenu) ? lParam : GetHotItem()); + lRet = m_wndParent.DefWindowProc(uMsg, wParam, (lParam || m_bContextMenu) ? lParam : this->GetHotItem()); #if _WTL_CMDBAR_VISTA_MENUS // If Vista menus are active, just set bitmaps and return @@ -1305,8 +1270,8 @@ public: ATLASSERT(menuPopup.m_hMenu != NULL); T* pT = static_cast(this); - pT; // avoid level 4 warning - TCHAR szString[pT->_nMaxMenuItemTextLength] = { 0 }; + (void)pT; // avoid level 4 warning + TCHAR szString[pT->_nMaxMenuItemTextLength] = {}; BOOL bRet = FALSE; for(int i = 0; i < menuPopup.GetMenuItemCount(); i++) { @@ -1342,7 +1307,7 @@ public: ATLTRY(pMI->lpstrText = new TCHAR[cchLen]); ATLASSERT(pMI->lpstrText != NULL); if(pMI->lpstrText != NULL) - SecureHelper::strcpy_x(pMI->lpstrText, cchLen, szString); + ATL::Checked::tcscpy_s(pMI->lpstrText, cchLen, szString); mii.dwItemData = (ULONG_PTR)pMI; bRet = menuPopup.SetMenuItemInfo(i, TRUE, &mii); ATLASSERT(bRet); @@ -1351,7 +1316,7 @@ public: } // Add it to the list - m_stackMenuHandle.Push(menuPopup.m_hMenu); + this->m_stackMenuHandle.Push(menuPopup.m_hMenu); } return lRet; @@ -1369,17 +1334,17 @@ public: } // Check if a menu is closing, do a cleanup - if(HIWORD(wParam) == 0xFFFF && lParam == NULL) // Menu closing + if((HIWORD(wParam) == 0xFFFF) && (lParam == NULL)) // Menu closing { #ifdef _CMDBAR_EXTRA_TRACE ATLTRACE2(atlTraceUI, 0, _T("CmdBar - OnMenuSelect - CLOSING!!!!\n")); #endif - ATLASSERT(m_stackMenuWnd.GetSize() == 0); + ATLASSERT(this->m_stackMenuWnd.GetSize() == 0); // Restore the menu items to the previous state for all menus that were converted if(m_bImagesVisible) { HMENU hMenu = NULL; - while((hMenu = m_stackMenuHandle.Pop()) != NULL) + while((hMenu = this->m_stackMenuHandle.Pop()) != NULL) { CMenuHandle menuPopup = hMenu; ATLASSERT(menuPopup.m_hMenu != NULL); @@ -1393,7 +1358,7 @@ public: ATLASSERT(bRet); _MenuItemData* pMI = (_MenuItemData*)mii.dwItemData; - if(pMI != NULL && pMI->IsCmdBarMenuItem()) + if(_IsValidMem(pMI) && pMI->IsCmdBarMenuItem()) { mii.fMask = MIIM_DATA | MIIM_TYPE | MIIM_STATE; mii.fType = pMI->fType; @@ -1430,7 +1395,7 @@ public: // Let's make sure we're not embedded in another process if((LPVOID)wParam != NULL) *((DWORD*)wParam) = GetCurrentProcessId(); - if(IsWindowVisible()) + if(this->IsWindowVisible()) return (LRESULT)static_cast(this); else return NULL; @@ -1438,14 +1403,7 @@ public: LRESULT OnSettingChange(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) { -#ifndef SPI_SETKEYBOARDCUES - const UINT SPI_SETKEYBOARDCUES = 0x100B; -#endif // !SPI_SETKEYBOARDCUES -#ifndef SPI_GETFLATMENU - const UINT SPI_SETFLATMENU = 0x1023; -#endif // !SPI_GETFLATMENU - - if(wParam == SPI_SETNONCLIENTMETRICS || wParam == SPI_SETKEYBOARDCUES || wParam == SPI_SETFLATMENU) + if((wParam == SPI_SETNONCLIENTMETRICS) || (wParam == SPI_SETKEYBOARDCUES) || (wParam == SPI_SETFLATMENU)) { T* pT = static_cast(this); pT->GetSystemSettings(); @@ -1456,7 +1414,7 @@ public: LRESULT OnWindowPosChanging(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) { - LRESULT lRet = DefWindowProc(uMsg, wParam, lParam); + LRESULT lRet = this->DefWindowProc(uMsg, wParam, lParam); LPWINDOWPOS lpWP = (LPWINDOWPOS)lParam; int cyMin = ::GetSystemMetrics(SM_CYMENU); @@ -1475,12 +1433,12 @@ public: T* pT = static_cast(this); LRESULT lRet; - if(m_bMenuActive && LOWORD(wParam) != 0x0D) + if(m_bMenuActive && (LOWORD(wParam) != 0x0D)) lRet = 0; else lRet = MAKELRESULT(1, 1); - if(m_bMenuActive && HIWORD(wParam) == MF_POPUP) + if(m_bMenuActive && (HIWORD(wParam) == MF_POPUP)) { // Convert character to lower/uppercase and possibly Unicode, using current keyboard layout TCHAR ch = (TCHAR)LOWORD(wParam); @@ -1488,7 +1446,7 @@ public: int nCount = ::GetMenuItemCount(menu); int nRetCode = MNC_EXECUTE; BOOL bRet = FALSE; - TCHAR szString[pT->_nMaxMenuItemTextLength] = { 0 }; + TCHAR szString[pT->_nMaxMenuItemTextLength] = {}; WORD wMnem = 0; bool bFound = false; for(int i = 0; i < nCount; i++) @@ -1501,15 +1459,15 @@ public: if(!bRet || (mii.fType & MFT_SEPARATOR)) continue; _MenuItemData* pmd = (_MenuItemData*)mii.dwItemData; - if(pmd != NULL && pmd->IsCmdBarMenuItem()) + if(_IsValidMem(pmd) && pmd->IsCmdBarMenuItem()) { LPTSTR p = pmd->lpstrText; if(p != NULL) { - while(*p && *p != _T('&')) + while(*p && (*p != _T('&'))) p = ::CharNext(p); - if(p != NULL && *p) + if((p != NULL) && *p) { DWORD dwP = MAKELONG(*(++p), 0); DWORD dwC = MAKELONG(ch, 0); @@ -1534,7 +1492,7 @@ public: { if(nRetCode == MNC_EXECUTE) { - PostMessage(TB_SETHOTITEM, (WPARAM)-1, 0L); + this->PostMessage(TB_SETHOTITEM, (WPARAM)-1, 0L); pT->GiveFocusBack(); } bHandled = TRUE; @@ -1544,48 +1502,42 @@ public: else if(!m_bMenuActive) { int nBtn = 0; - if(!MapAccelerator((TCHAR)LOWORD(wParam), nBtn)) + if(!this->MapAccelerator((TCHAR)LOWORD(wParam), nBtn)) { bHandled = FALSE; - PostMessage(TB_SETHOTITEM, (WPARAM)-1, 0L); + this->PostMessage(TB_SETHOTITEM, (WPARAM)-1, 0L); pT->GiveFocusBack(); -#if (_WIN32_IE >= 0x0500) // check if we should display chevron menu if((TCHAR)LOWORD(wParam) == pT->_chChevronShortcut) { if(pT->DisplayChevronMenu()) bHandled = TRUE; } -#endif // (_WIN32_IE >= 0x0500) } else if(m_wndParent.IsWindowEnabled()) { -#if (_WIN32_IE >= 0x0500) - RECT rcClient = { 0 }; - GetClientRect(&rcClient); - RECT rcBtn = { 0 }; - GetItemRect(nBtn, &rcBtn); - TBBUTTON tbb = { 0 }; - GetButton(nBtn, &tbb); - if((tbb.fsState & TBSTATE_ENABLED) != 0 && (tbb.fsState & TBSTATE_HIDDEN) == 0 && rcBtn.right <= rcClient.right) + RECT rcClient = {}; + this->GetClientRect(&rcClient); + RECT rcBtn = {}; + this->GetItemRect(nBtn, &rcBtn); + TBBUTTON tbb = {}; + this->GetButton(nBtn, &tbb); + if(((tbb.fsState & TBSTATE_ENABLED) != 0) && ((tbb.fsState & TBSTATE_HIDDEN) == 0) && (rcBtn.right <= rcClient.right)) { -#endif // (_WIN32_IE >= 0x0500) if(m_bUseKeyboardCues && !m_bShowKeyboardCues) { m_bAllowKeyboardCues = true; ShowKeyboardCues(true); } pT->TakeFocus(); - PostMessage(WM_KEYDOWN, VK_DOWN, 0L); - SetHotItem(nBtn); -#if (_WIN32_IE >= 0x0500) + this->PostMessage(WM_KEYDOWN, VK_DOWN, 0L); + this->SetHotItem(nBtn); } else { ::MessageBeep(0); } -#endif // (_WIN32_IE >= 0x0500) } } @@ -1605,7 +1557,7 @@ public: { LPDRAWITEMSTRUCT lpDrawItemStruct = (LPDRAWITEMSTRUCT)lParam; _MenuItemData* pmd = (_MenuItemData*)lpDrawItemStruct->itemData; - if(lpDrawItemStruct->CtlType == ODT_MENU && pmd != NULL && pmd->IsCmdBarMenuItem()) + if((lpDrawItemStruct->CtlType == ODT_MENU) && _IsValidMem(pmd) && pmd->IsCmdBarMenuItem()) { T* pT = static_cast(this); pT->DrawItem(lpDrawItemStruct); @@ -1621,7 +1573,7 @@ public: { LPMEASUREITEMSTRUCT lpMeasureItemStruct = (LPMEASUREITEMSTRUCT)lParam; _MenuItemData* pmd = (_MenuItemData*)lpMeasureItemStruct->itemData; - if(lpMeasureItemStruct->CtlType == ODT_MENU && pmd != NULL && pmd->IsCmdBarMenuItem()) + if((lpMeasureItemStruct->CtlType == ODT_MENU) && _IsValidMem(pmd) && pmd->IsCmdBarMenuItem()) { T* pT = static_cast(this); pT->MeasureItem(lpMeasureItemStruct); @@ -1653,7 +1605,7 @@ public: LRESULT OnAPIGetCmdBar(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { - return (LRESULT)m_hWnd; + return (LRESULT)this->m_hWnd; } // Parent window message handlers @@ -1662,7 +1614,7 @@ public: LPNMTBHOTITEM lpNMHT = (LPNMTBHOTITEM)pnmh; // Check if this comes from us - if(pnmh->hwndFrom != m_hWnd) + if(pnmh->hwndFrom != this->m_hWnd) { bHandled = FALSE; return 0; @@ -1677,45 +1629,36 @@ public: } if((!m_wndParent.IsWindowEnabled() || bBlockTracking) && (lpNMHT->dwFlags & HICF_MOUSE)) - { return 1; - } - else - { -#ifndef HICF_LMOUSE - const DWORD HICF_LMOUSE = 0x00000080; // left mouse button selected -#endif - bHandled = FALSE; - // Send WM_MENUSELECT to the app if it needs to display a status text - if(!(lpNMHT->dwFlags & HICF_MOUSE) - && !(lpNMHT->dwFlags & HICF_ACCELERATOR) - && !(lpNMHT->dwFlags & HICF_LMOUSE)) - { - if(lpNMHT->dwFlags & HICF_ENTERING) - m_wndParent.SendMessage(WM_MENUSELECT, 0, (LPARAM)m_hMenu); - if(lpNMHT->dwFlags & HICF_LEAVING) - m_wndParent.SendMessage(WM_MENUSELECT, MAKEWPARAM(0, 0xFFFF), NULL); - } + bHandled = FALSE; - return 0; + // Send WM_MENUSELECT to the app if it needs to display a status text + if(!(lpNMHT->dwFlags & HICF_MOUSE) && !(lpNMHT->dwFlags & HICF_ACCELERATOR) && !(lpNMHT->dwFlags & HICF_LMOUSE)) + { + if(lpNMHT->dwFlags & HICF_ENTERING) + m_wndParent.SendMessage(WM_MENUSELECT, 0, (LPARAM)m_hMenu); + if(lpNMHT->dwFlags & HICF_LEAVING) + m_wndParent.SendMessage(WM_MENUSELECT, MAKEWPARAM(0, 0xFFFF), NULL); } + + return 0; } LRESULT OnParentDropDown(int /*idCtrl*/, LPNMHDR pnmh, BOOL& bHandled) { // Check if this comes from us - if(pnmh->hwndFrom != m_hWnd) + if(pnmh->hwndFrom != this->m_hWnd) { bHandled = FALSE; return 1; } T* pT = static_cast(this); - if(::GetFocus() != m_hWnd) + if(::GetFocus() != this->m_hWnd) pT->TakeFocus(); LPNMTOOLBAR pNMToolBar = (LPNMTOOLBAR)pnmh; - int nIndex = CommandToIndex(pNMToolBar->iItem); + int nIndex = this->CommandToIndex(pNMToolBar->iItem); m_bContextMenu = false; m_bEscapePressed = false; pT->DoPopupMenu(nIndex, true); @@ -1736,18 +1679,18 @@ public: LRESULT OnParentSysCommand(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) { bHandled = FALSE; - if((m_uSysKey == VK_MENU - || (m_uSysKey == VK_F10 && !(::GetKeyState(VK_SHIFT) & 0x80)) - || m_uSysKey == VK_SPACE) - && wParam == SC_KEYMENU) + if(((m_uSysKey == VK_MENU) + || ((m_uSysKey == VK_F10) && !(::GetKeyState(VK_SHIFT) & 0x80)) + || (m_uSysKey == VK_SPACE)) + && (wParam == SC_KEYMENU)) { T* pT = static_cast(this); - if(::GetFocus() == m_hWnd) + if(::GetFocus() == this->m_hWnd) { pT->GiveFocusBack(); // exit menu "loop" - PostMessage(TB_SETHOTITEM, (WPARAM)-1, 0L); + this->PostMessage(TB_SETHOTITEM, (WPARAM)-1, 0L); } - else if(m_uSysKey != VK_SPACE && !m_bSkipMsg) + else if((m_uSysKey != VK_SPACE) && !m_bSkipMsg) { if(m_bUseKeyboardCues && !m_bShowKeyboardCues && m_bAllowKeyboardCues) ShowKeyboardCues(true); @@ -1810,8 +1753,8 @@ public: } else { - Invalidate(); - UpdateWindow(); + this->Invalidate(); + this->UpdateWindow(); } bHandled = FALSE; return 1; @@ -1821,7 +1764,7 @@ public: { LRESULT lRet = CDRF_DODEFAULT; bHandled = FALSE; - if(pnmh->hwndFrom == m_hWnd) + if(pnmh->hwndFrom == this->m_hWnd) { LPNMTBCUSTOMDRAW lpTBCustomDraw = (LPNMTBCUSTOMDRAW)pnmh; if(lpTBCustomDraw->nmcd.dwDrawStage == CDDS_PREPAINT) @@ -1843,11 +1786,8 @@ public: { if(m_bFlatMenus) { -#ifndef COLOR_MENUHILIGHT - const int COLOR_MENUHILIGHT = 29; -#endif // !COLOR_MENUHILIGHT bool bDisabled = ((lpTBCustomDraw->nmcd.uItemState & CDIS_DISABLED) == CDIS_DISABLED); - if(!bDisabled && ((lpTBCustomDraw->nmcd.uItemState & CDIS_HOT) == CDIS_HOT || + if(!bDisabled && (((lpTBCustomDraw->nmcd.uItemState & CDIS_HOT) == CDIS_HOT) || (lpTBCustomDraw->nmcd.uItemState & CDIS_SELECTED) == CDIS_SELECTED)) { ::FillRect(lpTBCustomDraw->nmcd.hdc, &lpTBCustomDraw->nmcd.rc, ::GetSysColorBrush(COLOR_MENUHILIGHT)); @@ -1894,19 +1834,19 @@ public: dc.SetTextColor(lpTBCustomDraw->clrText); dc.SetBkMode(lpTBCustomDraw->nStringBkMode); - HFONT hFont = GetFont(); + HFONT hFont = this->GetFont(); HFONT hFontOld = NULL; if(hFont != NULL) hFontOld = dc.SelectFont(hFont); const int cchText = 200; - TCHAR szText[cchText] = { 0 }; - TBBUTTONINFO tbbi = { 0 }; + TCHAR szText[cchText] = {}; + TBBUTTONINFO tbbi = {}; tbbi.cbSize = sizeof(TBBUTTONINFO); tbbi.dwMask = TBIF_TEXT; tbbi.pszText = szText; tbbi.cchText = cchText; - GetButtonInfo((int)lpTBCustomDraw->nmcd.dwItemSpec, &tbbi); + this->GetButtonInfo((int)lpTBCustomDraw->nmcd.dwItemSpec, &tbbi); dc.DrawText(szText, -1, &lpTBCustomDraw->nmcd.rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER | (m_bShowKeyboardCues ? 0 : DT_HIDEPREFIX)); @@ -1924,19 +1864,19 @@ public: bHandled = FALSE; if(m_bMenuActive) { - if(::WindowFromPoint(point) == m_hWnd) + if(::WindowFromPoint(point) == this->m_hWnd) { - ScreenToClient(&point); - int nHit = HitTest(&point); + this->ScreenToClient(&point); + int nHit = this->HitTest(&point); - if((point.x != s_point.x || point.y != s_point.y) && nHit >= 0 && nHit < ::GetMenuItemCount(m_hMenu) && nHit != m_nPopBtn && m_nPopBtn != -1) + if(((point.x != s_point.x) || (point.y != s_point.y)) && (nHit >= 0) && (nHit < ::GetMenuItemCount(m_hMenu)) && (nHit != m_nPopBtn) && (m_nPopBtn != -1)) { - TBBUTTON tbb = { 0 }; - GetButton(nHit, &tbb); + TBBUTTON tbb = {}; + this->GetButton(nHit, &tbb); if((tbb.fsState & TBSTATE_ENABLED) != 0) { m_nNextPopBtn = nHit | 0xFFFF0000; - HWND hWndMenu = m_stackMenuWnd.GetCurrent(); + HWND hWndMenu = this->m_stackMenuWnd.GetCurrent(); ATLASSERT(hWndMenu != NULL); // this one is needed to close a menu if mouse button was down @@ -1951,7 +1891,7 @@ public: } else { - ScreenToClient(&point); + this->ScreenToClient(&point); } s_point = point; @@ -1965,20 +1905,20 @@ public: ATLTRACE2(atlTraceUI, 0, _T("CmdBar - Hook WM_SYSKEYDOWN (0x%2.2X)\n"), wParam); #endif - if(wParam == VK_MENU && m_bParentActive && m_bUseKeyboardCues && !m_bShowKeyboardCues && m_bAllowKeyboardCues) + if((wParam == VK_MENU) && m_bParentActive && m_bUseKeyboardCues && !m_bShowKeyboardCues && m_bAllowKeyboardCues) ShowKeyboardCues(true); - if(wParam != VK_SPACE && !m_bMenuActive && ::GetFocus() == m_hWnd) + if((wParam != VK_SPACE) && !m_bMenuActive && (::GetFocus() == this->m_hWnd)) { m_bAllowKeyboardCues = false; - PostMessage(TB_SETHOTITEM, (WPARAM)-1, 0L); + this->PostMessage(TB_SETHOTITEM, (WPARAM)-1, 0L); T* pT = static_cast(this); pT->GiveFocusBack(); m_bSkipMsg = true; } else { - if(wParam == VK_SPACE && m_bUseKeyboardCues && m_bShowKeyboardCues) + if((wParam == VK_SPACE) && m_bUseKeyboardCues && m_bShowKeyboardCues) { m_bAllowKeyboardCues = true; ShowKeyboardCues(false); @@ -1993,7 +1933,7 @@ public: if(!m_bAllowKeyboardCues) m_bAllowKeyboardCues = true; bHandled = FALSE; - wParam; + (void)wParam; // avoid level 4 warning #ifdef _CMDBAR_EXTRA_TRACE ATLTRACE2(atlTraceUI, 0, _T("CmdBar - Hook WM_SYSKEYUP (0x%2.2X)\n"), wParam); #endif @@ -2007,7 +1947,7 @@ public: ATLTRACE2(atlTraceUI, 0, _T("CmdBar - Hook WM_SYSCHAR (0x%2.2X)\n"), wParam); #endif - if(!m_bMenuActive && m_hWndHook != m_hWnd && wParam != VK_SPACE) + if(!m_bMenuActive && (this->m_hWndHook != this->m_hWnd) && (wParam != VK_SPACE)) bHandled = TRUE; return 0; } @@ -2020,51 +1960,40 @@ public: bHandled = FALSE; T* pT = static_cast(this); - if(wParam == VK_ESCAPE && m_stackMenuWnd.GetSize() <= 1) + if((wParam == VK_ESCAPE) && (this->m_stackMenuWnd.GetSize() <= 1)) { if(m_bMenuActive && !m_bContextMenu) { - int nHot = GetHotItem(); + int nHot = this->GetHotItem(); if(nHot == -1) nHot = m_nPopBtn; if(nHot == -1) nHot = 0; - SetHotItem(nHot); + this->SetHotItem(nHot); bHandled = TRUE; pT->TakeFocus(); m_bEscapePressed = true; // To keep focus m_bSkipPostDown = false; } - else if(::GetFocus() == m_hWnd && m_wndParent.IsWindow()) + else if((::GetFocus() == this->m_hWnd) && m_wndParent.IsWindow()) { - SetHotItem(-1); + this->SetHotItem(-1); pT->GiveFocusBack(); bHandled = TRUE; } } - else if(wParam == VK_RETURN || wParam == VK_UP || wParam == VK_DOWN) + else if((wParam == VK_RETURN) || (wParam == VK_UP) || (wParam == VK_DOWN)) { - if(!m_bMenuActive && ::GetFocus() == m_hWnd && m_wndParent.IsWindow()) + if(!m_bMenuActive && (::GetFocus() == this->m_hWnd) && m_wndParent.IsWindow()) { - int nHot = GetHotItem(); + int nHot = this->GetHotItem(); if(nHot != -1) { if(wParam != VK_RETURN) { if(!m_bSkipPostDown) { -// IE4 only: WM_KEYDOWN doesn't generate TBN_DROPDOWN, we need to simulate a mouse click -#if (_WIN32_IE < 0x0500) - DWORD dwMajor = 0, dwMinor = 0; - ATL::AtlGetCommCtrlVersion(&dwMajor, &dwMinor); - if(dwMajor <= 4 || (dwMajor == 5 && dwMinor < 80)) - { - RECT rect = { 0 }; - GetItemRect(nHot, &rect); - PostMessage(WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(rect.left, rect.top)); - } -#endif // (_WIN32_IE < 0x0500) - PostMessage(WM_KEYDOWN, VK_DOWN, 0L); + this->PostMessage(WM_KEYDOWN, VK_DOWN, 0L); m_bSkipPostDown = true; } else @@ -2079,22 +2008,22 @@ public: ATLTRACE2(atlTraceUI, 0, _T("CmdBar - Can't find hot button\n")); } } - if(wParam == VK_RETURN && m_bMenuActive) + if((wParam == VK_RETURN) && m_bMenuActive) { - PostMessage(TB_SETHOTITEM, (WPARAM)-1, 0L); + this->PostMessage(TB_SETHOTITEM, (WPARAM)-1, 0L); m_nNextPopBtn = -1; pT->GiveFocusBack(); } } - else if(wParam == VK_LEFT || wParam == VK_RIGHT) + else if((wParam == VK_LEFT) || (wParam == VK_RIGHT)) { WPARAM wpNext = m_bLayoutRTL ? VK_LEFT : VK_RIGHT; WPARAM wpPrev = m_bLayoutRTL ? VK_RIGHT : VK_LEFT; - if(m_bMenuActive && !m_bContextMenu && !(wParam == wpNext && m_bPopupItem)) + if(m_bMenuActive && !m_bContextMenu && !((wParam == wpNext) && m_bPopupItem)) { bool bAction = false; - if(wParam == wpPrev && s_pCurrentBar->m_stackMenuWnd.GetSize() == 1) + if((wParam == wpPrev) && (this->s_pCurrentBar->m_stackMenuWnd.GetSize() == 1)) { m_nNextPopBtn = pT->GetPreviousMenuItem(m_nPopBtn); if(m_nNextPopBtn != -1) @@ -2106,7 +2035,7 @@ public: if(m_nNextPopBtn != -1) bAction = true; } - HWND hWndMenu = m_stackMenuWnd.GetCurrent(); + HWND hWndMenu = this->m_stackMenuWnd.GetCurrent(); ATLASSERT(hWndMenu != NULL); // Close the popup menu @@ -2115,22 +2044,20 @@ public: ::PostMessage(hWndMenu, WM_KEYDOWN, VK_ESCAPE, 0L); if(wParam == wpNext) { - int cItem = m_stackMenuWnd.GetSize() - 1; + int cItem = this->m_stackMenuWnd.GetSize() - 1; while(cItem >= 0) { - hWndMenu = m_stackMenuWnd[cItem]; + hWndMenu = this->m_stackMenuWnd[cItem]; if(hWndMenu != NULL) ::PostMessage(hWndMenu, WM_KEYDOWN, VK_ESCAPE, 0L); cItem--; } } -#if (_WIN32_IE >= 0x0500) if(m_nNextPopBtn == -2) { m_nNextPopBtn = -1; pT->DisplayChevronMenu(); } -#endif // (_WIN32_IE >= 0x0500) bHandled = TRUE; } } @@ -2247,7 +2174,7 @@ public: CMenuItemInfo info; info.fMask = MIIM_CHECKMARKS | MIIM_TYPE; ::GetMenuItemInfo((HMENU)lpDrawItemStruct->hwndItem, lpDrawItemStruct->itemID, MF_BYCOMMAND, &info); - if(bChecked || info.hbmpUnchecked != NULL) + if(bChecked || (info.hbmpUnchecked != NULL)) { BOOL bRadio = ((info.fType & MFT_RADIOCHECK) != 0); bHasImage = pT->DrawCheckmark(dc, rcButn, bSelected, bDisabled, bRadio, bChecked ? info.hbmpChecked : info.hbmpUnchecked); @@ -2257,7 +2184,7 @@ public: // draw item text int cxButn = m_szButton.cx; COLORREF colorBG = ::GetSysColor(bSelected ? COLOR_HIGHLIGHT : COLOR_MENU); - if(bSelected || lpDrawItemStruct->itemAction == ODA_SELECT) + if(bSelected || (lpDrawItemStruct->itemAction == ODA_SELECT)) { RECT rcBG = rcItem; if(bHasImage) @@ -2273,7 +2200,7 @@ public: COLORREF colorText = ::GetSysColor(bDisabled ? (bSelected ? COLOR_GRAYTEXT : COLOR_3DSHADOW) : (bSelected ? COLOR_HIGHLIGHTTEXT : COLOR_MENUTEXT)); // font already selected by Windows - if(bDisabled && (!bSelected || colorText == colorBG)) + if(bDisabled && (!bSelected || (colorText == colorBG))) { // disabled - draw shadow text shifted down and right 1 pixel (unles selected) RECT rcDisabled = rcText; @@ -2291,16 +2218,12 @@ public: const RECT& rcItem = lpDrawItemStruct->rcItem; T* pT = static_cast(this); -#ifndef COLOR_MENUHILIGHT - const int COLOR_MENUHILIGHT = 29; -#endif // !COLOR_MENUHILIGHT - BOOL bDisabled = lpDrawItemStruct->itemState & ODS_GRAYED; BOOL bSelected = lpDrawItemStruct->itemState & ODS_SELECTED; BOOL bChecked = lpDrawItemStruct->itemState & ODS_CHECKED; // paint background - if(bSelected || lpDrawItemStruct->itemAction == ODA_SELECT) + if(bSelected || (lpDrawItemStruct->itemAction == ODA_SELECT)) { if(bSelected) { @@ -2353,7 +2276,7 @@ public: } else { - HBRUSH hBrushBackground = ::GetSysColorBrush((bSelected && !(bDisabled && bChecked)) ? COLOR_MENUHILIGHT : COLOR_MENU); + HBRUSH hBrushBackground = ::GetSysColorBrush((bSelected && !bChecked) ? COLOR_MENUHILIGHT : COLOR_MENU); HBRUSH hBrushDisabledImage = ::GetSysColorBrush(COLOR_3DSHADOW); pT->DrawBitmapDisabled(dc, iButton, point, hBrushBackground, hBrushBackground, hBrushDisabledImage); } @@ -2364,7 +2287,7 @@ public: CMenuItemInfo info; info.fMask = MIIM_CHECKMARKS | MIIM_TYPE; ::GetMenuItemInfo((HMENU)lpDrawItemStruct->hwndItem, lpDrawItemStruct->itemID, MF_BYCOMMAND, &info); - if(bChecked || info.hbmpUnchecked != NULL) + if(bChecked || (info.hbmpUnchecked != NULL)) { BOOL bRadio = ((info.fType & MFT_RADIOCHECK) != 0); pT->DrawCheckmark(dc, rcButn, bSelected, bDisabled, bRadio, bChecked ? info.hbmpChecked : info.hbmpUnchecked); @@ -2407,10 +2330,9 @@ public: HBRUSH hBrush3DEffect = ::GetSysColorBrush(COLOR_3DHILIGHT), HBRUSH hBrushDisabledImage = ::GetSysColorBrush(COLOR_3DSHADOW)) { -#if (_WIN32_WINNT >= 0x0501) && (_WIN32_IE >= 0x0501) if(m_bAlphaImages) { - IMAGELISTDRAWPARAMS ildp = { 0 }; + IMAGELISTDRAWPARAMS ildp = {}; ildp.cbSize = sizeof(IMAGELISTDRAWPARAMS); ildp.himl = m_hImageList; ildp.i = nImage; @@ -2427,7 +2349,6 @@ public: ::ImageList_DrawIndirect(&ildp); } else -#endif // (_WIN32_WINNT >= 0x0501) && (_WIN32_IE >= 0x0501) { // create memory DC CDC dcMem; @@ -2457,7 +2378,7 @@ public: BOOL DrawCheckmark(CDCHandle& dc, const RECT& rc, BOOL bSelected, BOOL bDisabled, BOOL bRadio, HBITMAP hBmpCheck) { // get checkmark bitmap, if none, use Windows standard - SIZE size = { 0, 0 }; + SIZE size = {}; CBitmapHandle bmp = hBmpCheck; if(hBmpCheck != NULL) { @@ -2630,7 +2551,7 @@ public: if(pmd->fState & MFS_DEFAULT) { // need bold version of font - LOGFONT lf = { 0 }; + LOGFONT lf = {}; m_fontMenu.GetLogFont(lf); lf.lfWeight += 200; fontBold.CreateFontIndirect(&lf); @@ -2642,12 +2563,12 @@ public: hOldFont = dc.SelectFont(m_fontMenu); } - RECT rcText = { 0 }; + RECT rcText = {}; dc.DrawText(pmd->lpstrText, -1, &rcText, DT_SINGLELINE | DT_LEFT | DT_VCENTER | DT_CALCRECT); int cx = rcText.right - rcText.left; dc.SelectFont(hOldFont); - LOGFONT lf = { 0 }; + LOGFONT lf = {}; m_fontMenu.GetLogFont(lf); int cy = lf.lfHeight; if(cy < 0) @@ -2674,7 +2595,7 @@ public: static LRESULT CALLBACK CreateHookProc(int nCode, WPARAM wParam, LPARAM lParam) { const int cchClassName = 7; - TCHAR szClassName[cchClassName] = { 0 }; + TCHAR szClassName[cchClassName] = {}; if(nCode == HCBT_CREATEWND) { @@ -2685,7 +2606,7 @@ public: ::GetClassName(hWndMenu, szClassName, cchClassName); if(!lstrcmp(_T("#32768"), szClassName)) - s_pCurrentBar->m_stackMenuWnd.Push(hWndMenu); + CCommandBarCtrlBase::s_pCurrentBar->m_stackMenuWnd.Push(hWndMenu); } else if(nCode == HCBT_DESTROYWND) { @@ -2697,30 +2618,30 @@ public: ::GetClassName(hWndMenu, szClassName, cchClassName); if(!lstrcmp(_T("#32768"), szClassName)) { - ATLASSERT(hWndMenu == s_pCurrentBar->m_stackMenuWnd.GetCurrent()); - s_pCurrentBar->m_stackMenuWnd.Pop(); + ATLASSERT(hWndMenu == CCommandBarCtrlBase::s_pCurrentBar->m_stackMenuWnd.GetCurrent()); + CCommandBarCtrlBase::s_pCurrentBar->m_stackMenuWnd.Pop(); } } - return ::CallNextHookEx(s_hCreateHook, nCode, wParam, lParam); + return ::CallNextHookEx(CCommandBarCtrlBase::s_hCreateHook, nCode, wParam, lParam); } static LRESULT CALLBACK MessageHookProc(int nCode, WPARAM wParam, LPARAM lParam) { LPMSG pMsg = (LPMSG)lParam; - if(nCode == HC_ACTION && wParam == PM_REMOVE && pMsg->message != GetGetBarMessage() && pMsg->message != WM_FORWARDMSG) + if((nCode == HC_ACTION) && (wParam == PM_REMOVE) && (pMsg->message != GetGetBarMessage()) && (pMsg->message != WM_FORWARDMSG)) { CCommandBarCtrlBase* pCmdBar = NULL; HWND hWnd = pMsg->hwnd; DWORD dwPID = 0; - while(pCmdBar == NULL && hWnd != NULL) + while((pCmdBar == NULL) && (hWnd != NULL)) { pCmdBar = (CCommandBarCtrlBase*)::SendMessage(hWnd, GetGetBarMessage(), (WPARAM)&dwPID, 0L); hWnd = ::GetParent(hWnd); } - if(pCmdBar != NULL && dwPID == GetCurrentProcessId()) + if((pCmdBar != NULL) && (dwPID == GetCurrentProcessId())) { pCmdBar->m_hWndHook = pMsg->hwnd; ATLASSERT(pCmdBar->IsCommandBarBase()); @@ -2733,11 +2654,11 @@ public: } LRESULT lRet = 0; - ATLASSERT(s_pmapMsgHook != NULL); - if(s_pmapMsgHook != NULL) + ATLASSERT(CCommandBarCtrlBase::s_pmapMsgHook != NULL); + if(CCommandBarCtrlBase::s_pmapMsgHook != NULL) { DWORD dwThreadID = ::GetCurrentThreadId(); - _MsgHookData* pData = s_pmapMsgHook->Lookup(dwThreadID); + CCommandBarCtrlBase::_MsgHookData* pData = CCommandBarCtrlBase::s_pmapMsgHook->Lookup(dwThreadID); if(pData != NULL) { lRet = ::CallNextHookEx(pData->hMsgHook, nCode, wParam, lParam); @@ -2752,57 +2673,49 @@ public: #ifdef _CMDBAR_EXTRA_TRACE ATLTRACE2(atlTraceUI, 0, _T("CmdBar - DoPopupMenu, bAnimate = %s\n"), bAnimate ? "true" : "false"); #endif - - // Menu animation flags -#ifndef TPM_VERPOSANIMATION - const UINT TPM_VERPOSANIMATION = 0x1000L; -#endif -#ifndef TPM_NOANIMATION - const UINT TPM_NOANIMATION = 0x4000L; -#endif T* pT = static_cast(this); // get popup menu and it's position - RECT rect = { 0 }; - GetItemRect(nIndex, &rect); + RECT rect = {}; + this->GetItemRect(nIndex, &rect); POINT pt = { rect.left, rect.bottom }; - MapWindowPoints(NULL, &pt, 1); - MapWindowPoints(NULL, &rect); - TPMPARAMS TPMParams = { 0 }; + this->MapWindowPoints(NULL, &pt, 1); + this->MapWindowPoints(NULL, &rect); + TPMPARAMS TPMParams = {}; TPMParams.cbSize = sizeof(TPMPARAMS); TPMParams.rcExclude = rect; HMENU hMenuPopup = ::GetSubMenu(m_hMenu, nIndex); ATLASSERT(hMenuPopup != NULL); // get button ID - TBBUTTON tbb = { 0 }; - GetButton(nIndex, &tbb); + TBBUTTON tbb = {}; + this->GetButton(nIndex, &tbb); int nCmdID = tbb.idCommand; m_nPopBtn = nIndex; // remember current button's index // press button and display popup menu - PressButton(nCmdID, TRUE); - SetHotItem(nCmdID); + this->PressButton(nCmdID, TRUE); + this->SetHotItem(nCmdID); pT->DoTrackPopupMenu(hMenuPopup, TPM_LEFTBUTTON | TPM_VERTICAL | TPM_LEFTALIGN | TPM_TOPALIGN | - (s_bW2K ? (bAnimate ? TPM_VERPOSANIMATION : TPM_NOANIMATION) : 0), pt.x, pt.y, &TPMParams); - PressButton(nCmdID, FALSE); - if(::GetFocus() != m_hWnd) - SetHotItem(-1); + (bAnimate ? TPM_VERPOSANIMATION : TPM_NOANIMATION), pt.x, pt.y, &TPMParams); + this->PressButton(nCmdID, FALSE); + if(::GetFocus() != this->m_hWnd) + this->SetHotItem(-1); m_nPopBtn = -1; // restore // eat next message if click is on the same button - MSG msg = { 0 }; - if(::PeekMessage(&msg, m_hWnd, WM_LBUTTONDOWN, WM_LBUTTONDOWN, PM_NOREMOVE) && ::PtInRect(&rect, msg.pt)) - ::PeekMessage(&msg, m_hWnd, WM_LBUTTONDOWN, WM_LBUTTONDOWN, PM_REMOVE); + MSG msg = {}; + if(::PeekMessage(&msg, this->m_hWnd, WM_LBUTTONDOWN, WM_LBUTTONDOWN, PM_NOREMOVE) && ::PtInRect(&rect, msg.pt)) + ::PeekMessage(&msg, this->m_hWnd, WM_LBUTTONDOWN, WM_LBUTTONDOWN, PM_REMOVE); // check if another popup menu should be displayed if(m_nNextPopBtn != -1) { - PostMessage(GetAutoPopupMessage(), m_nNextPopBtn & 0xFFFF); + this->PostMessage(GetAutoPopupMessage(), m_nNextPopBtn & 0xFFFF); if(!(m_nNextPopBtn & 0xFFFF0000) && !m_bPopupItem) - PostMessage(WM_KEYDOWN, VK_DOWN, 0); + this->PostMessage(WM_KEYDOWN, VK_DOWN, 0); m_nNextPopBtn = -1; } else @@ -2817,8 +2730,8 @@ public: } else { - SetHotItem(nCmdID); - SetAnchorHighlight(TRUE); + this->SetHotItem(nCmdID); + this->SetAnchorHighlight(TRUE); } } } @@ -2835,23 +2748,23 @@ public: return FALSE; } - ATLASSERT(s_hCreateHook == NULL); + ATLASSERT(this->s_hCreateHook == NULL); - s_pCurrentBar = static_cast(this); + this->s_pCurrentBar = static_cast(this); - s_hCreateHook = ::SetWindowsHookEx(WH_CBT, CreateHookProc, ModuleHelper::GetModuleInstance(), GetCurrentThreadId()); - ATLASSERT(s_hCreateHook != NULL); + this->s_hCreateHook = ::SetWindowsHookEx(WH_CBT, CreateHookProc, ModuleHelper::GetModuleInstance(), GetCurrentThreadId()); + ATLASSERT(this->s_hCreateHook != NULL); m_bPopupItem = false; m_bMenuActive = true; - BOOL bTrackRet = menuPopup.TrackPopupMenuEx(uFlags, x, y, m_hWnd, lpParams); + BOOL bTrackRet = menuPopup.TrackPopupMenuEx(uFlags, x, y, this->m_hWnd, lpParams); m_bMenuActive = false; - ::UnhookWindowsHookEx(s_hCreateHook); + ::UnhookWindowsHookEx(this->s_hCreateHook); - s_hCreateHook = NULL; - s_pCurrentBar = NULL; + this->s_hCreateHook = NULL; + this->s_pCurrentBar = NULL; lock.Unlock(); @@ -2860,17 +2773,17 @@ public: ATLTRACE2(atlTraceUI, 0, _T("CmdBar - TrackPopupMenu - cleanup\n")); #endif - ATLASSERT(m_stackMenuWnd.GetSize() == 0); + ATLASSERT(this->m_stackMenuWnd.GetSize() == 0); - UpdateWindow(); - ATL::CWindow wndTL = GetTopLevelParent(); + this->UpdateWindow(); + ATL::CWindow wndTL = this->GetTopLevelParent(); wndTL.UpdateWindow(); // restore the menu items to the previous state for all menus that were converted if(m_bImagesVisible) { HMENU hMenuSav = NULL; - while((hMenuSav = m_stackMenuHandle.Pop()) != NULL) + while((hMenuSav = this->m_stackMenuHandle.Pop()) != NULL) { menuPopup = hMenuSav; BOOL bRet = FALSE; @@ -2883,7 +2796,7 @@ public: ATLASSERT(bRet); _MenuItemData* pMI = (_MenuItemData*)mii.dwItemData; - if(pMI != NULL && pMI->IsCmdBarMenuItem()) + if(_IsValidMem(pMI) && pMI->IsCmdBarMenuItem()) { mii.fMask = MIIM_DATA | MIIM_TYPE | MIIM_STATE; mii.fType = pMI->fType; @@ -2910,27 +2823,23 @@ public: { if(nBtn == -1) return -1; -#if (_WIN32_IE >= 0x0500) - RECT rcClient = { 0 }; - GetClientRect(&rcClient); -#endif // (_WIN32_IE >= 0x0500) + RECT rcClient = {}; + this->GetClientRect(&rcClient); int nNextBtn; for(nNextBtn = nBtn - 1; nNextBtn != nBtn; nNextBtn--) { if(nNextBtn < 0) nNextBtn = ::GetMenuItemCount(m_hMenu) - 1; - TBBUTTON tbb = { 0 }; - GetButton(nNextBtn, &tbb); -#if (_WIN32_IE >= 0x0500) - RECT rcBtn = { 0 }; - GetItemRect(nNextBtn, &rcBtn); + TBBUTTON tbb = {}; + this->GetButton(nNextBtn, &tbb); + RECT rcBtn = {}; + this->GetItemRect(nNextBtn, &rcBtn); if(rcBtn.right > rcClient.right) { nNextBtn = -2; // chevron break; } -#endif // (_WIN32_IE >= 0x0500) - if((tbb.fsState & TBSTATE_ENABLED) != 0 && (tbb.fsState & TBSTATE_HIDDEN) == 0) + if(((tbb.fsState & TBSTATE_ENABLED) != 0) && ((tbb.fsState & TBSTATE_HIDDEN) == 0)) break; } return (nNextBtn != nBtn) ? nNextBtn : -1; @@ -2940,50 +2849,45 @@ public: { if(nBtn == -1) return -1; -#if (_WIN32_IE >= 0x0500) - RECT rcClient = { 0 }; - GetClientRect(&rcClient); -#endif // (_WIN32_IE >= 0x0500) + RECT rcClient = {}; + this->GetClientRect(&rcClient); int nNextBtn = 0; int nCount = ::GetMenuItemCount(m_hMenu); for(nNextBtn = nBtn + 1; nNextBtn != nBtn; nNextBtn++) { if(nNextBtn >= nCount) nNextBtn = 0; - TBBUTTON tbb = { 0 }; - GetButton(nNextBtn, &tbb); -#if (_WIN32_IE >= 0x0500) - RECT rcBtn = { 0 }; - GetItemRect(nNextBtn, &rcBtn); + TBBUTTON tbb = {}; + this->GetButton(nNextBtn, &tbb); + RECT rcBtn = {}; + this->GetItemRect(nNextBtn, &rcBtn); if(rcBtn.right > rcClient.right) { nNextBtn = -2; // chevron break; } -#endif // (_WIN32_IE >= 0x0500) - if((tbb.fsState & TBSTATE_ENABLED) != 0 && (tbb.fsState & TBSTATE_HIDDEN) == 0) + if(((tbb.fsState & TBSTATE_ENABLED) != 0) && ((tbb.fsState & TBSTATE_HIDDEN) == 0)) break; } return (nNextBtn != nBtn) ? nNextBtn : -1; } -#if (_WIN32_IE >= 0x0500) bool DisplayChevronMenu() { // assume we are in a rebar - HWND hWndReBar = GetParent(); + HWND hWndReBar = this->GetParent(); int nCount = (int)::SendMessage(hWndReBar, RB_GETBANDCOUNT, 0, 0L); bool bRet = false; for(int i = 0; i < nCount; i++) { REBARBANDINFO rbbi = { RunTimeHelper::SizeOf_REBARBANDINFO(), RBBIM_CHILD | RBBIM_STYLE }; BOOL bRetBandInfo = (BOOL)::SendMessage(hWndReBar, RB_GETBANDINFO, i, (LPARAM)&rbbi); - if(bRetBandInfo && rbbi.hwndChild == m_hWnd) + if(bRetBandInfo && (rbbi.hwndChild == this->m_hWnd)) { if((rbbi.fStyle & RBBS_USECHEVRON) != 0) { ::PostMessage(hWndReBar, RB_PUSHCHEVRON, i, 0L); - PostMessage(WM_KEYDOWN, VK_DOWN, 0L); + this->PostMessage(WM_KEYDOWN, VK_DOWN, 0L); bRet = true; } break; @@ -2991,7 +2895,6 @@ public: } return bRet; } -#endif // (_WIN32_IE >= 0x0500) void GetSystemSettings() { @@ -3001,23 +2904,23 @@ public: ATLASSERT(bRet); if(bRet) { - LOGFONT logfont = { 0 }; + LOGFONT logfont = {}; if(m_fontMenu.m_hFont != NULL) m_fontMenu.GetLogFont(logfont); - if(logfont.lfHeight != info.lfMenuFont.lfHeight || - logfont.lfWidth != info.lfMenuFont.lfWidth || - logfont.lfEscapement != info.lfMenuFont.lfEscapement || - logfont.lfOrientation != info.lfMenuFont.lfOrientation || - logfont.lfWeight != info.lfMenuFont.lfWeight || - logfont.lfItalic != info.lfMenuFont.lfItalic || - logfont.lfUnderline != info.lfMenuFont.lfUnderline || - logfont.lfStrikeOut != info.lfMenuFont.lfStrikeOut || - logfont.lfCharSet != info.lfMenuFont.lfCharSet || - logfont.lfOutPrecision != info.lfMenuFont.lfOutPrecision || - logfont.lfClipPrecision != info.lfMenuFont.lfClipPrecision || - logfont.lfQuality != info.lfMenuFont.lfQuality || - logfont.lfPitchAndFamily != info.lfMenuFont.lfPitchAndFamily || - lstrcmp(logfont.lfFaceName, info.lfMenuFont.lfFaceName) != 0) + if((logfont.lfHeight != info.lfMenuFont.lfHeight) || + (logfont.lfWidth != info.lfMenuFont.lfWidth) || + (logfont.lfEscapement != info.lfMenuFont.lfEscapement) || + (logfont.lfOrientation != info.lfMenuFont.lfOrientation) || + (logfont.lfWeight != info.lfMenuFont.lfWeight) || + (logfont.lfItalic != info.lfMenuFont.lfItalic) || + (logfont.lfUnderline != info.lfMenuFont.lfUnderline) || + (logfont.lfStrikeOut != info.lfMenuFont.lfStrikeOut) || + (logfont.lfCharSet != info.lfMenuFont.lfCharSet) || + (logfont.lfOutPrecision != info.lfMenuFont.lfOutPrecision) || + (logfont.lfClipPrecision != info.lfMenuFont.lfClipPrecision) || + (logfont.lfQuality != info.lfMenuFont.lfQuality) || + (logfont.lfPitchAndFamily != info.lfMenuFont.lfPitchAndFamily) || + (lstrcmp(logfont.lfFaceName, info.lfMenuFont.lfFaceName) != 0)) { HFONT hFontMenu = ::CreateFontIndirect(&info.lfMenuFont); ATLASSERT(hFontMenu != NULL); @@ -3026,17 +2929,17 @@ public: if(m_fontMenu.m_hFont != NULL) m_fontMenu.DeleteObject(); m_fontMenu.Attach(hFontMenu); - SetFont(m_fontMenu); - AddStrings(_T("NS\0")); // for proper item height - AutoSize(); + this->SetFont(m_fontMenu); + this->AddStrings(_T("NS\0")); // for proper item height + this->AutoSize(); } } } // check if we need extra spacing for menu item text - CWindowDC dc(m_hWnd); + CWindowDC dc(this->m_hWnd); HFONT hFontOld = dc.SelectFont(m_fontMenu); - RECT rcText = { 0 }; + RECT rcText = {}; dc.DrawText(_T("\t"), -1, &rcText, DT_SINGLELINE | DT_LEFT | DT_VCENTER | DT_CALCRECT); if((rcText.right - rcText.left) < 4) { @@ -3063,9 +2966,6 @@ public: if (ovi.dwMajorVersion >= 5) #endif // _versionhelpers_H_INCLUDED_ { -#ifndef SPI_GETKEYBOARDCUES - const UINT SPI_GETKEYBOARDCUES = 0x100A; -#endif // !SPI_GETKEYBOARDCUES BOOL bRetVal = TRUE; bRet = ::SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, &bRetVal, 0); m_bUseKeyboardCues = (bRet && !bRetVal); @@ -3077,12 +2977,9 @@ public: #ifdef _versionhelpers_H_INCLUDED_ if(::IsWindowsXPOrGreater()) #else // !_versionhelpers_H_INCLUDED_ - if ((ovi.dwMajorVersion == 5 && ovi.dwMinorVersion >= 1) || (ovi.dwMajorVersion > 5)) + if (((ovi.dwMajorVersion == 5) && (ovi.dwMinorVersion >= 1)) || (ovi.dwMajorVersion > 5)) #endif // _versionhelpers_H_INCLUDED_ { -#ifndef SPI_GETFLATMENU - const UINT SPI_GETFLATMENU = 0x1022; -#endif // !SPI_GETFLATMENU BOOL bRetVal = FALSE; bRet = ::SystemParametersInfo(SPI_GETFLATMENU, 0, &bRetVal, 0); m_bFlatMenus = (bRet && bRetVal); @@ -3109,9 +3006,9 @@ public: // Implementation - alternate focus mode support void TakeFocus() { - if((m_dwExtendedStyle & CBR_EX_ALTFOCUSMODE) && m_hWndFocus == NULL) + if((m_dwExtendedStyle & CBR_EX_ALTFOCUSMODE) && (m_hWndFocus == NULL)) m_hWndFocus = ::GetFocus(); - SetFocus(); + this->SetFocus(); } void GiveFocusBack() @@ -3124,18 +3021,18 @@ public: m_wndParent.SetFocus(); } m_hWndFocus = NULL; - SetAnchorHighlight(FALSE); + this->SetAnchorHighlight(FALSE); if(m_bUseKeyboardCues && m_bShowKeyboardCues) - ShowKeyboardCues(false); + this->ShowKeyboardCues(false); m_bSkipPostDown = false; } void ShowKeyboardCues(bool bShow) { m_bShowKeyboardCues = bShow; - SetDrawTextFlags(DT_HIDEPREFIX, m_bShowKeyboardCues ? 0 : DT_HIDEPREFIX); - Invalidate(); - UpdateWindow(); + this->SetDrawTextFlags(DT_HIDEPREFIX, m_bShowKeyboardCues ? 0 : DT_HIDEPREFIX); + this->Invalidate(); + this->UpdateWindow(); } // Implementation - internal message helpers @@ -3253,7 +3150,7 @@ public: HBITMAP _CreateVistaBitmapHelper(int nIndex, HDC hDCSource, HDC hDCTarget) { // Create 32-bit bitmap - BITMAPINFO bi = { 0 }; + BITMAPINFO bi = {}; bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); bi.bmiHeader.biWidth = m_szBitmap.cx; bi.bmiHeader.biHeight = m_szBitmap.cy; @@ -3273,7 +3170,7 @@ public: { ::SelectObject(hDCTarget, hBitmap); - IMAGELISTDRAWPARAMS ildp = { 0 }; + IMAGELISTDRAWPARAMS ildp = {}; ildp.cbSize = sizeof(IMAGELISTDRAWPARAMS); ildp.himl = m_hImageList; ildp.i = nIndex; @@ -3305,6 +3202,20 @@ public: } } #endif // _WTL_CMDBAR_VISTA_MENUS + +// Implementation helper + static bool _IsValidMem(void* pMem) + { + bool bRet = false; + if(pMem != NULL) + { + MEMORY_BASIC_INFORMATION mbi = {}; + ::VirtualQuery(pMem, &mbi, sizeof(MEMORY_BASIC_INFORMATION)); + bRet = (mbi.BaseAddress != NULL) && ((mbi.Protect & (PAGE_READONLY | PAGE_READWRITE)) != 0); + } + + return bRet; + } }; @@ -3338,34 +3249,18 @@ public: int m_cxLeft; // left nonclient area width int m_cxRight; // right nonclient area width -// Theme declarations and data members -#ifndef _WTL_NO_AUTO_THEME -#ifndef _UXTHEME_H_ - typedef HANDLE HTHEME; -#endif // !_UXTHEME_H_ - typedef HTHEME (STDAPICALLTYPE *PFN_OpenThemeData)(HWND hwnd, LPCWSTR pszClassList); - typedef HRESULT (STDAPICALLTYPE *PFN_CloseThemeData)(HTHEME hTheme); - typedef HRESULT (STDAPICALLTYPE *PFN_DrawThemeBackground)(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, OPTIONAL const RECT *pClipRect); - typedef HRESULT (STDAPICALLTYPE *PFN_DrawThemeParentBackground)(HWND hwnd, HDC hdc, OPTIONAL RECT* prc); - - HMODULE m_hThemeDLL; HTHEME m_hTheme; - PFN_DrawThemeBackground m_pfnDrawThemeBackground; - PFN_DrawThemeParentBackground m_pfnDrawThemeParentBackground; -#endif // !_WTL_NO_AUTO_THEME // Constructor/destructor CMDICommandBarCtrlImpl() : m_wndMDIClient(this, 2), m_bChildMaximized(false), m_hWndChildMaximized(NULL), m_hIconChildMaximized(NULL), m_nBtnPressed(-1), m_nBtnWasPressed(-1), -#ifndef _WTL_NO_AUTO_THEME - m_hThemeDLL(NULL), m_hTheme(NULL), m_pfnDrawThemeBackground(NULL), m_pfnDrawThemeParentBackground(NULL), -#endif // !_WTL_NO_AUTO_THEME m_cxyOffset(2), m_cxIconWidth(16), m_cyIconHeight(16), m_cxBtnWidth(16), m_cyBtnHeight(14), - m_cxLeft(20), m_cxRight(55) + m_cxLeft(20), m_cxRight(55), + m_hTheme(NULL) { } ~CMDICommandBarCtrlImpl() @@ -3377,7 +3272,7 @@ public: // Operations BOOL SetMDIClient(HWND hWndMDIClient) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(::IsWindow(hWndMDIClient)); if(!::IsWindow(hWndMDIClient)) return FALSE; @@ -3387,7 +3282,7 @@ public: { LPCTSTR lpszMDIClientClass = _T("MDICLIENT"); const int nNameLen = 9 + 1; // "MDICLIENT" + NULL - TCHAR szClassName[nNameLen] = { 0 }; + TCHAR szClassName[nNameLen] = {}; ::GetClassName(hWndMDIClient, szClassName, nNameLen); ATLASSERT(lstrcmpi(szClassName, lpszMDIClientClass) == 0); } @@ -3404,9 +3299,7 @@ public: BEGIN_MSG_MAP(CMDICommandBarCtrlImpl) MESSAGE_HANDLER(WM_CREATE, OnCreate) MESSAGE_HANDLER(WM_DESTROY, OnDestroy) -#ifndef _WTL_NO_AUTO_THEME - MESSAGE_HANDLER(_GetThemeChangedMsg(), OnThemeChanged) -#endif // !_WTL_NO_AUTO_THEME + MESSAGE_HANDLER(WM_THEMECHANGED, OnThemeChanged) MESSAGE_HANDLER(WM_SIZE, OnSize) MESSAGE_HANDLER(WM_NCCALCSIZE, OnNcCalcSize) MESSAGE_HANDLER(WM_NCPAINT, OnNcPaint) @@ -3435,27 +3328,8 @@ public: if(lRet == (LRESULT)-1) return lRet; -#ifndef _WTL_NO_AUTO_THEME - // this will fail if theming is not supported - m_hThemeDLL = ::LoadLibrary(_T("uxtheme.dll")); - if(m_hThemeDLL != NULL) - { - m_pfnDrawThemeBackground = (PFN_DrawThemeBackground)::GetProcAddress(m_hThemeDLL, "DrawThemeBackground"); - ATLASSERT(m_pfnDrawThemeBackground != NULL); - if(m_pfnDrawThemeBackground != NULL) - { - T* pT = static_cast(this); - pT->_OpenThemeData(); - } - else - { - ::FreeLibrary(m_hThemeDLL); - m_hThemeDLL = NULL; - } - m_pfnDrawThemeParentBackground = (PFN_DrawThemeParentBackground)::GetProcAddress(m_hThemeDLL, "DrawThemeParentBackground"); - ATLASSERT(m_pfnDrawThemeParentBackground != NULL); - } -#endif // !_WTL_NO_AUTO_THEME + T* pT = static_cast(this); + pT->_OpenThemeData(); return lRet; } @@ -3464,35 +3338,24 @@ public: { LRESULT lRet = _baseClass::OnDestroy(uMsg, wParam, lParam, bHandled); -#ifndef _WTL_NO_AUTO_THEME - if(m_hThemeDLL != NULL) - { - T* pT = static_cast(this); - pT->_CloseThemeData(); - ::FreeLibrary(m_hThemeDLL); - m_hThemeDLL = NULL; - } -#endif // !_WTL_NO_AUTO_THEME + T* pT = static_cast(this); + pT->_CloseThemeData(); return lRet; } -#ifndef _WTL_NO_AUTO_THEME LRESULT OnThemeChanged(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { - if(m_hThemeDLL != NULL) - { - T* pT = static_cast(this); - pT->_CloseThemeData(); - pT->_OpenThemeData(); - } + T* pT = static_cast(this); + pT->_CloseThemeData(); + pT->_OpenThemeData(); + return 0; } -#endif // !_WTL_NO_AUTO_THEME LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) { - LRESULT lRet = DefWindowProc(uMsg, wParam, lParam); + LRESULT lRet = this->DefWindowProc(uMsg, wParam, lParam); T* pT = static_cast(this); pT->_AdjustBtnSize(GET_Y_LPARAM(lParam)); return lRet; @@ -3500,12 +3363,12 @@ public: LRESULT OnNcCalcSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) { - LRESULT lRet = DefWindowProc(uMsg, wParam, lParam); + LRESULT lRet = this->DefWindowProc(uMsg, wParam, lParam); if(m_bChildMaximized && (BOOL)wParam) { LPNCCALCSIZE_PARAMS lpParams = (LPNCCALCSIZE_PARAMS)lParam; - if(m_bLayoutRTL) + if(this->m_bLayoutRTL) { lpParams->rgrc[0].left += m_cxRight; lpParams->rgrc[0].right -= m_cxLeft; @@ -3522,79 +3385,65 @@ public: LRESULT OnNcPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) { - LRESULT lRet = DefWindowProc(uMsg, wParam, lParam); + LRESULT lRet = this->DefWindowProc(uMsg, wParam, lParam); if(!m_bChildMaximized) return lRet; - ATLASSERT(m_hWndChildMaximized != NULL && m_hIconChildMaximized != NULL); + ATLASSERT((m_hWndChildMaximized != NULL) && (m_hIconChildMaximized != NULL)); // get DC and window rectangle - CWindowDC dc(m_hWnd); - RECT rect = { 0 }; - GetWindowRect(&rect); + CWindowDC dc(this->m_hWnd); + RECT rect = {}; + this->GetWindowRect(&rect); int cxWidth = rect.right - rect.left; int cyHeight = rect.bottom - rect.top; // paint left side nonclient background and draw icon ::SetRect(&rect, 0, 0, m_cxLeft, cyHeight); -#ifndef _WTL_NO_AUTO_THEME if(m_hTheme != NULL) { - if(m_pfnDrawThemeParentBackground != NULL) - m_pfnDrawThemeParentBackground(m_hWnd, dc, &rect); - else - dc.FillRect(&rect, COLOR_WINDOW); + ::DrawThemeParentBackground(this->m_hWnd, dc, &rect); } else -#endif // !_WTL_NO_AUTO_THEME { - if((m_dwExtendedStyle & CBR_EX_TRANSPARENT) != 0) + if((this->m_dwExtendedStyle & CBR_EX_TRANSPARENT) != 0) dc.FillRect(&rect, COLOR_3DFACE); else dc.FillRect(&rect, COLOR_MENU); } - RECT rcIcon = { 0 }; + RECT rcIcon = {}; T* pT = static_cast(this); pT->_CalcIconRect(cxWidth, cyHeight, rcIcon); dc.DrawIconEx(rcIcon.left, rcIcon.top, m_hIconChildMaximized, m_cxIconWidth, m_cyIconHeight); // paint right side nonclient background ::SetRect(&rect, cxWidth - m_cxRight, 0, cxWidth, cyHeight); -#ifndef _WTL_NO_AUTO_THEME if(m_hTheme != NULL) { - if(m_pfnDrawThemeParentBackground != NULL) - { - // this is to account for the left non-client area - POINT ptOrg = { 0, 0 }; - dc.GetViewportOrg(&ptOrg); - dc.SetViewportOrg(ptOrg.x + m_cxLeft, ptOrg.y); - ::OffsetRect(&rect, -m_cxLeft, 0); + // this is to account for the left non-client area + POINT ptOrg = {}; + dc.GetViewportOrg(&ptOrg); + dc.SetViewportOrg(ptOrg.x + m_cxLeft, ptOrg.y); + ::OffsetRect(&rect, -m_cxLeft, 0); - m_pfnDrawThemeParentBackground(m_hWnd, dc, &rect); + ::DrawThemeParentBackground(this->m_hWnd, dc, &rect); - // restore - dc.SetViewportOrg(ptOrg); - ::OffsetRect(&rect, m_cxLeft, 0); - } - else - { - dc.FillRect(&rect, COLOR_3DFACE); - } + // restore + dc.SetViewportOrg(ptOrg); + ::OffsetRect(&rect, m_cxLeft, 0); } else -#endif // !_WTL_NO_AUTO_THEME { - if((m_dwExtendedStyle & CBR_EX_TRANSPARENT) != 0) + if((this->m_dwExtendedStyle & CBR_EX_TRANSPARENT) != 0) dc.FillRect(&rect, COLOR_3DFACE); else dc.FillRect(&rect, COLOR_MENU); } // draw buttons - RECT arrRect[3] = { 0 }; + RECT arrRect[3] = {}; pT->_CalcBtnRects(cxWidth, cyHeight, arrRect); pT->_DrawMDIButton(dc, arrRect, -1); // draw all buttons @@ -3603,13 +3452,13 @@ public: LRESULT OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) { - LRESULT lRet = DefWindowProc(uMsg, wParam, lParam); + LRESULT lRet = this->DefWindowProc(uMsg, wParam, lParam); if(m_bChildMaximized) { - RECT rect = { 0 }; - GetWindowRect(&rect); + RECT rect = {}; + this->GetWindowRect(&rect); POINT pt = { GET_X_LPARAM(lParam) - rect.left, GET_Y_LPARAM(lParam) - rect.top }; - if(m_bLayoutRTL) + if(this->m_bLayoutRTL) { if((pt.x < m_cxRight) || (pt.x > ((rect.right - rect.left) - m_cxLeft))) lRet = HTBORDER; @@ -3634,34 +3483,31 @@ public: ATLASSERT(_DebugCheckChild()); POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; - RECT rect = { 0 }; - GetWindowRect(&rect); + RECT rect = {}; + this->GetWindowRect(&rect); pt.x -= rect.left; pt.y -= rect.top; - RECT rcIcon = { 0 }; + RECT rcIcon = {}; T* pT = static_cast(this); - pT->_CalcIconRect(rect.right - rect.left, rect.bottom - rect.top, rcIcon, m_bLayoutRTL); - RECT arrRect[3] = { 0 }; - pT->_CalcBtnRects(rect.right - rect.left, rect.bottom - rect.top, arrRect, m_bLayoutRTL); + pT->_CalcIconRect(rect.right - rect.left, rect.bottom - rect.top, rcIcon, this->m_bLayoutRTL); + RECT arrRect[3] = {}; + pT->_CalcBtnRects(rect.right - rect.left, rect.bottom - rect.top, arrRect, this->m_bLayoutRTL); if(::PtInRect(&rcIcon, pt)) { #ifdef _CMDBAR_EXTRA_TRACE ATLTRACE2(atlTraceUI, 0, _T("MDI CmdBar - LButtonDown: icon\n")); -#endif -#ifndef TPM_VERPOSANIMATION - const UINT TPM_VERPOSANIMATION = 0x1000L; // Menu animation flag #endif CMenuHandle menu = ::GetSystemMenu(m_hWndChildMaximized, FALSE); UINT uRet = (UINT)menu.TrackPopupMenu(TPM_LEFTBUTTON | TPM_VERTICAL | TPM_LEFTALIGN | TPM_TOPALIGN | TPM_RETURNCMD | - (s_bW2K ? TPM_VERPOSANIMATION : 0), m_bLayoutRTL ? rect.right : rect.left, rect.bottom, m_hWndChildMaximized); + TPM_VERPOSANIMATION, this->m_bLayoutRTL ? rect.right : rect.left, rect.bottom, m_hWndChildMaximized); // eat next message if click is on the same button ::OffsetRect(&rcIcon, rect.left, rect.top); - MSG msg = { 0 }; - if(::PeekMessage(&msg, m_hWnd, WM_NCLBUTTONDOWN, WM_NCLBUTTONDOWN, PM_NOREMOVE) && ::PtInRect(&rcIcon, msg.pt)) - ::PeekMessage(&msg, m_hWnd, WM_NCLBUTTONDOWN, WM_NCLBUTTONDOWN, PM_REMOVE); + MSG msg = {}; + if(::PeekMessage(&msg, this->m_hWnd, WM_NCLBUTTONDOWN, WM_NCLBUTTONDOWN, PM_NOREMOVE) && ::PtInRect(&rcIcon, msg.pt)) + ::PeekMessage(&msg, this->m_hWnd, WM_NCLBUTTONDOWN, WM_NCLBUTTONDOWN, PM_REMOVE); if(uRet != 0) ::SendMessage(m_hWndChildMaximized, WM_SYSCOMMAND, uRet, 0L); @@ -3695,8 +3541,8 @@ public: // draw the button state if it was pressed if(m_nBtnPressed != -1) { - SetCapture(); - CWindowDC dc(m_hWnd); + this->SetCapture(); + CWindowDC dc(this->m_hWnd); pT->_CalcBtnRects(rect.right - rect.left, rect.bottom - rect.top, arrRect); pT->_DrawMDIButton(dc, arrRect, m_nBtnPressed); } @@ -3706,26 +3552,26 @@ public: LRESULT OnMouseMove(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled) { - if(!m_bChildMaximized || ::GetCapture() != m_hWnd || m_nBtnWasPressed == -1) + if(!m_bChildMaximized || (::GetCapture() != this->m_hWnd) || (m_nBtnWasPressed == -1)) { bHandled = FALSE; return 1; } POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; - ClientToScreen(&pt); - RECT rect = { 0 }; - GetWindowRect(&rect); + this->ClientToScreen(&pt); + RECT rect = {}; + this->GetWindowRect(&rect); pt.x -= rect.left; pt.y -= rect.top; - RECT arrRect[3] = { 0 }; + RECT arrRect[3] = {}; T* pT = static_cast(this); - pT->_CalcBtnRects(rect.right - rect.left, rect.bottom - rect.top, arrRect, m_bLayoutRTL); + pT->_CalcBtnRects(rect.right - rect.left, rect.bottom - rect.top, arrRect, this->m_bLayoutRTL); int nOldBtnPressed = m_nBtnPressed; m_nBtnPressed = ::PtInRect(&arrRect[m_nBtnWasPressed], pt) ? m_nBtnWasPressed : -1; if(nOldBtnPressed != m_nBtnPressed) { - CWindowDC dc(m_hWnd); + CWindowDC dc(this->m_hWnd); pT->_CalcBtnRects(rect.right - rect.left, rect.bottom - rect.top, arrRect); pT->_DrawMDIButton(dc, arrRect, (m_nBtnPressed != -1) ? m_nBtnPressed : nOldBtnPressed); } @@ -3735,7 +3581,7 @@ public: LRESULT OnLButtonUp(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled) { - if(!m_bChildMaximized || ::GetCapture() != m_hWnd || m_nBtnWasPressed == -1) + if(!m_bChildMaximized || (::GetCapture() != this->m_hWnd) || (m_nBtnWasPressed == -1)) { bHandled = FALSE; return 1; @@ -3744,18 +3590,18 @@ public: ATLASSERT(_DebugCheckChild()); POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; - ClientToScreen(&pt); - RECT rect = { 0 }; - GetWindowRect(&rect); + this->ClientToScreen(&pt); + RECT rect = {}; + this->GetWindowRect(&rect); pt.x -= rect.left; pt.y -= rect.top; int nBtn = m_nBtnWasPressed; ReleaseCapture(); - RECT arrRect[3] = { 0 }; + RECT arrRect[3] = {}; T* pT = static_cast(this); - pT->_CalcBtnRects(rect.right - rect.left, rect.bottom - rect.top, arrRect, m_bLayoutRTL); + pT->_CalcBtnRects(rect.right - rect.left, rect.bottom - rect.top, arrRect, this->m_bLayoutRTL); if(::PtInRect(&arrRect[nBtn], pt)) { switch(nBtn) @@ -3788,7 +3634,7 @@ public: LRESULT OnNcLButtonDblClk(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled) { - if(!m_bChildMaximized || m_nBtnWasPressed != -1) + if(!m_bChildMaximized || (m_nBtnWasPressed != -1)) { bHandled = FALSE; return 1; @@ -3797,16 +3643,16 @@ public: ATLASSERT(_DebugCheckChild()); POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; - RECT rect = { 0 }; - GetWindowRect(&rect); + RECT rect = {}; + this->GetWindowRect(&rect); pt.x -= rect.left; pt.y -= rect.top; - RECT rcIcon = { 0 }; + RECT rcIcon = {}; T* pT = static_cast(this); - pT->_CalcIconRect(rect.right - rect.left, rect.bottom - rect.top, rcIcon, m_bLayoutRTL); - RECT arrRect[3] = { 0 }; - pT->_CalcBtnRects(rect.right - rect.left, rect.bottom - rect.top, arrRect, m_bLayoutRTL); + pT->_CalcIconRect(rect.right - rect.left, rect.bottom - rect.top, rcIcon, this->m_bLayoutRTL); + RECT arrRect[3] = {}; + pT->_CalcBtnRects(rect.right - rect.left, rect.bottom - rect.top, arrRect, this->m_bLayoutRTL); if(::PtInRect(&rcIcon, pt)) { @@ -3828,12 +3674,12 @@ public: { ATLASSERT(m_nBtnPressed == m_nBtnWasPressed); // must be m_nBtnPressed = -1; - RECT rect = { 0 }; - GetWindowRect(&rect); - RECT arrRect[3] = { 0 }; + RECT rect = {}; + this->GetWindowRect(&rect); + RECT arrRect[3] = {}; T* pT = static_cast(this); pT->_CalcBtnRects(rect.right - rect.left, rect.bottom - rect.top, arrRect); - CWindowDC dc(m_hWnd); + CWindowDC dc(this->m_hWnd); pT->_DrawMDIButton(dc, arrRect, m_nBtnWasPressed); } m_nBtnWasPressed = -1; @@ -3848,8 +3694,8 @@ public: // Parent window message handlers LRESULT OnParentActivate(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) { - m_bParentActive = (LOWORD(wParam) != WA_INACTIVE); - RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_UPDATENOW); + this->m_bParentActive = (LOWORD(wParam) != WA_INACTIVE); + this->RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_UPDATENOW); bHandled = FALSE; return 1; } @@ -3858,15 +3704,13 @@ public: LRESULT OnMDISetMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) { m_wndMDIClient.DefWindowProc(uMsg, NULL, lParam); - HMENU hOldMenu = GetMenu(); - BOOL bRet = AttachMenu((HMENU)wParam); - bRet; // avoid level 4 warning + HMENU hOldMenu = this->GetMenu(); + BOOL bRet = this->AttachMenu((HMENU)wParam); + (void)bRet; // avoid level 4 warning ATLASSERT(bRet); -#if (_WIN32_IE >= 0x0400) T* pT = static_cast(this); pT->UpdateRebarBandIdealSize(); -#endif // (_WIN32_IE >= 0x0400) return (LRESULT)hOldMenu; } @@ -3887,23 +3731,24 @@ public: { // assuming we are in a rebar, change ideal size to our size // we hope that if we are not in a rebar, nCount will be 0 - int nCount = (int)::SendMessage(GetParent(), RB_GETBANDCOUNT, 0, 0L); + ATL::CWindow wndParent = this->GetParent(); + int nCount = (int)wndParent.SendMessage(RB_GETBANDCOUNT, 0, 0L); for(int i = 0; i < nCount; i++) { REBARBANDINFO rbi = { RunTimeHelper::SizeOf_REBARBANDINFO(), RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_IDEALSIZE }; - ::SendMessage(GetParent(), RB_GETBANDINFO, i, (LPARAM)&rbi); - if(rbi.hwndChild == m_hWnd) + wndParent.SendMessage(RB_GETBANDINFO, i, (LPARAM)&rbi); + if(rbi.hwndChild == this->m_hWnd) { rbi.fMask = RBBIM_IDEALSIZE; rbi.cxIdeal = m_bChildMaximized ? m_cxLeft + m_cxRight : 0; - int nBtnCount = GetButtonCount(); + int nBtnCount = this->GetButtonCount(); if(nBtnCount > 0) { - RECT rect = { 0 }; - GetItemRect(nBtnCount - 1, &rect); + RECT rect = {}; + this->GetItemRect(nBtnCount - 1, &rect); rbi.cxIdeal += rect.right; } - ::SendMessage(GetParent(), RB_SETBANDINFO, i, (LPARAM)&rbi); + wndParent.SendMessage(RB_SETBANDINFO, i, (LPARAM)&rbi); break; } } @@ -3912,13 +3757,13 @@ public: // all hook messages - check for the maximized MDI child window change void _ProcessAllHookMessages(UINT uMsg, WPARAM /*wParam*/, LPARAM /*lParam*/) { - if(uMsg == WM_MDIGETACTIVE || uMsg == WM_MDISETMENU) + if((uMsg == WM_MDIGETACTIVE) || (uMsg == WM_MDISETMENU)) return; BOOL bMaximized = FALSE; HWND hWndChild = (HWND)::SendMessage(m_wndMDIClient, WM_MDIGETACTIVE, 0, (LPARAM)&bMaximized); bool bMaxOld = m_bChildMaximized; - m_bChildMaximized = (hWndChild != NULL && bMaximized); + m_bChildMaximized = ((hWndChild != NULL) && bMaximized); HICON hIconOld = m_hIconChildMaximized; if(m_bChildMaximized) @@ -3930,16 +3775,8 @@ public: if(m_hIconChildMaximized == NULL) { m_hIconChildMaximized = wnd.GetIcon(TRUE); - if(m_hIconChildMaximized == NULL) - { - // no icon set with WM_SETICON, get the class one -// need conditional code because types don't match in winuser.h -#ifdef _WIN64 + if(m_hIconChildMaximized == NULL) // no icon set with WM_SETICON, get the class one m_hIconChildMaximized = (HICON)::GetClassLongPtr(wnd, GCLP_HICONSM); -#else - m_hIconChildMaximized = (HICON)LongToHandle(::GetClassLongPtr(wnd, GCLP_HICONSM)); -#endif - } } } } @@ -3956,60 +3793,38 @@ public: #endif // assuming we are in a rebar, change our size to accomodate new state // we hope that if we are not in a rebar, nCount will be 0 - int nCount = (int)::SendMessage(GetParent(), RB_GETBANDCOUNT, 0, 0L); + ATL::CWindow wndParent = this->GetParent(); + int nCount = (int)wndParent.SendMessage(RB_GETBANDCOUNT, 0, 0L); int cxDiff = (m_bChildMaximized ? 1 : -1) * (m_cxLeft + m_cxRight); for(int i = 0; i < nCount; i++) { -#if (_WIN32_IE >= 0x0500) REBARBANDINFO rbi = { RunTimeHelper::SizeOf_REBARBANDINFO(), RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_IDEALSIZE | RBBIM_STYLE }; - ::SendMessage(GetParent(), RB_GETBANDINFO, i, (LPARAM)&rbi); - if(rbi.hwndChild == m_hWnd) + wndParent.SendMessage(RB_GETBANDINFO, i, (LPARAM)&rbi); + if(rbi.hwndChild == this->m_hWnd) { if((rbi.fStyle & RBBS_USECHEVRON) != 0) { rbi.fMask = RBBIM_CHILDSIZE | RBBIM_IDEALSIZE; rbi.cxMinChild += cxDiff; rbi.cxIdeal += cxDiff; - ::SendMessage(GetParent(), RB_SETBANDINFO, i, (LPARAM)&rbi); + wndParent.SendMessage(RB_SETBANDINFO, i, (LPARAM)&rbi); } break; } -#elif (_WIN32_IE >= 0x0400) - REBARBANDINFO rbi = { RunTimeHelper::SizeOf_REBARBANDINFO(), RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_IDEALSIZE }; - ::SendMessage(GetParent(), RB_GETBANDINFO, i, (LPARAM)&rbi); - if(rbi.hwndChild == m_hWnd) - { - rbi.fMask = RBBIM_CHILDSIZE | RBBIM_IDEALSIZE; - rbi.cxMinChild += cxDiff; - rbi.cxIdeal += cxDiff; - ::SendMessage(GetParent(), RB_SETBANDINFO, i, (LPARAM)&rbi); - break; - } -#else // (_WIN32_IE < 0x0400) - REBARBANDINFO rbi = { RunTimeHelper::SizeOf_REBARBANDINFO(), RBBIM_CHILD | RBBIM_CHILDSIZE }; - ::SendMessage(GetParent(), RB_GETBANDINFO, i, (LPARAM)&rbi); - if(rbi.hwndChild == m_hWnd) - { - rbi.fMask = RBBIM_CHILDSIZE; - rbi.cxMinChild += cxDiff; - ::SendMessage(GetParent(), RB_SETBANDINFO, i, (LPARAM)&rbi); - break; - } -#endif // (_WIN32_IE < 0x0400) } } - if(bMaxOld != m_bChildMaximized || hIconOld != m_hIconChildMaximized) + if((bMaxOld != m_bChildMaximized) || (hIconOld != m_hIconChildMaximized)) { // force size change and redraw everything - RECT rect = { 0 }; - GetWindowRect(&rect); - ::MapWindowPoints(NULL, GetParent(), (LPPOINT)&rect, 2); - SetRedraw(FALSE); - SetWindowPos(NULL, 0, 0, 1, 1, SWP_NOZORDER | SWP_NOMOVE); - SetWindowPos(NULL, &rect, SWP_NOZORDER | SWP_NOMOVE); - SetRedraw(TRUE); - RedrawWindow(NULL, NULL, RDW_FRAME | RDW_INVALIDATE | RDW_UPDATENOW); + RECT rect = {}; + this->GetWindowRect(&rect); + ::MapWindowPoints(NULL, this->GetParent(), (LPPOINT)&rect, 2); + this->SetRedraw(FALSE); + this->SetWindowPos(NULL, 0, 0, 1, 1, SWP_NOZORDER | SWP_NOMOVE); + this->SetWindowPos(NULL, &rect, SWP_NOZORDER | SWP_NOMOVE); + this->SetRedraw(TRUE); + this->RedrawWindow(NULL, NULL, RDW_FRAME | RDW_INVALIDATE | RDW_UPDATENOW); } } @@ -4030,7 +3845,6 @@ public: m_cyIconHeight = ::GetSystemMetrics(SM_CYSMICON); m_cxLeft = m_cxIconWidth; -#ifndef _WTL_NO_AUTO_THEME if(m_hTheme != NULL) { m_cxBtnWidth = info.iCaptionWidth - 2 * m_cxyOffset; @@ -4038,7 +3852,6 @@ public: m_cxRight = 3 * m_cxBtnWidth; } else -#endif // !_WTL_NO_AUTO_THEME { m_cxBtnWidth = info.iCaptionWidth - m_cxyOffset; m_cyBtnHeight = info.iCaptionHeight - 2 * m_cxyOffset; @@ -4046,17 +3859,16 @@ public: } } - RECT rect = { 0 }; - GetClientRect(&rect); + RECT rect = {}; + this->GetClientRect(&rect); T* pT = static_cast(this); pT->_AdjustBtnSize(rect.bottom); } void _AdjustBtnSize(int cyHeight) { - if(cyHeight > 1 && m_cyBtnHeight > cyHeight) + if((cyHeight > 1) && (m_cyBtnHeight > cyHeight)) { -#ifndef _WTL_NO_AUTO_THEME if(m_hTheme != NULL) { m_cyBtnHeight = cyHeight; @@ -4064,7 +3876,6 @@ public: m_cxRight = 3 * m_cxBtnWidth; } else -#endif // !_WTL_NO_AUTO_THEME { m_cyBtnHeight = cyHeight; m_cxBtnWidth = cyHeight + m_cxyOffset; @@ -4103,11 +3914,9 @@ public: } arrRect[0] = rcBtn; -#ifndef _WTL_NO_AUTO_THEME if(m_hTheme != NULL) ::OffsetRect(&rcBtn, nDirection * m_cxBtnWidth, 0); else -#endif // !_WTL_NO_AUTO_THEME ::OffsetRect(&rcBtn, nDirection * (m_cxBtnWidth + m_cxyOffset), 0); arrRect[1] = rcBtn; ::OffsetRect(&rcBtn, nDirection * m_cxBtnWidth, 0); @@ -4116,10 +3925,9 @@ public: void _DrawMDIButton(CWindowDC& dc, LPRECT pRects, int nBtn) { -#ifndef _WTL_NO_AUTO_THEME if(m_hTheme != NULL) { -#if !defined(TMSCHEMA_H) && !defined(__VSSYM32_H__) +#ifndef __VSSYM32_H__ const int WP_MDICLOSEBUTTON = 20; const int CBS_NORMAL = 1; const int CBS_PUSHED = 3; @@ -4132,68 +3940,46 @@ public: const int MINBS_NORMAL = 1; const int MINBS_PUSHED = 3; const int MINBS_DISABLED = 4; -#endif // !defined(TMSCHEMA_H) && !defined(__VSSYM32_H__) - if(nBtn == -1 || nBtn == 0) - m_pfnDrawThemeBackground(m_hTheme, dc, WP_MDICLOSEBUTTON, m_bParentActive ? ((m_nBtnPressed == 0) ? CBS_PUSHED : CBS_NORMAL) : CBS_DISABLED, &pRects[0], NULL); - if(nBtn == -1 || nBtn == 1) - m_pfnDrawThemeBackground(m_hTheme, dc, WP_MDIRESTOREBUTTON, m_bParentActive ? ((m_nBtnPressed == 1) ? RBS_PUSHED : RBS_NORMAL) : RBS_DISABLED, &pRects[1], NULL); - if(nBtn == -1 || nBtn == 2) - m_pfnDrawThemeBackground(m_hTheme, dc, WP_MDIMINBUTTON, m_bParentActive ? ((m_nBtnPressed == 2) ? MINBS_PUSHED : MINBS_NORMAL) : MINBS_DISABLED, &pRects[2], NULL); +#endif // __VSSYM32_H__ + if((nBtn == -1) || (nBtn == 0)) + ::DrawThemeBackground(m_hTheme, dc, WP_MDICLOSEBUTTON, this->m_bParentActive ? ((m_nBtnPressed == 0) ? CBS_PUSHED : CBS_NORMAL) : CBS_DISABLED, &pRects[0], NULL); + if((nBtn == -1) || (nBtn == 1)) + ::DrawThemeBackground(m_hTheme, dc, WP_MDIRESTOREBUTTON, this->m_bParentActive ? ((m_nBtnPressed == 1) ? RBS_PUSHED : RBS_NORMAL) : RBS_DISABLED, &pRects[1], NULL); + if((nBtn == -1) || (nBtn == 2)) + ::DrawThemeBackground(m_hTheme, dc, WP_MDIMINBUTTON, this->m_bParentActive ? ((m_nBtnPressed == 2) ? MINBS_PUSHED : MINBS_NORMAL) : MINBS_DISABLED, &pRects[2], NULL); } else -#endif // !_WTL_NO_AUTO_THEME { - if(nBtn == -1 || nBtn == 0) + if((nBtn == -1) || (nBtn == 0)) dc.DrawFrameControl(&pRects[0], DFC_CAPTION, DFCS_CAPTIONCLOSE | ((m_nBtnPressed == 0) ? DFCS_PUSHED : 0)); - if(nBtn == -1 || nBtn == 1) + if((nBtn == -1) || (nBtn == 1)) dc.DrawFrameControl(&pRects[1], DFC_CAPTION, DFCS_CAPTIONRESTORE | ((m_nBtnPressed == 1) ? DFCS_PUSHED : 0)); - if(nBtn == -1 || nBtn == 2) + if((nBtn == -1) || (nBtn == 2)) dc.DrawFrameControl(&pRects[2], DFC_CAPTION, DFCS_CAPTIONMIN | ((m_nBtnPressed == 2) ? DFCS_PUSHED : 0)); } } -#ifndef _WTL_NO_AUTO_THEME - static UINT _GetThemeChangedMsg() - { -#ifndef WM_THEMECHANGED - static const UINT WM_THEMECHANGED = 0x031A; -#endif // !WM_THEMECHANGED - return WM_THEMECHANGED; - } - void _OpenThemeData() { - ATLASSERT(m_hThemeDLL != NULL); - - PFN_OpenThemeData pfnOpenThemeData = (PFN_OpenThemeData)::GetProcAddress(m_hThemeDLL, "OpenThemeData"); - ATLASSERT(pfnOpenThemeData != NULL); - if(pfnOpenThemeData != NULL) - m_hTheme = pfnOpenThemeData(m_hWnd, L"Window"); + if(RunTimeHelper::IsThemeAvailable()) + m_hTheme = ::OpenThemeData(this->m_hWnd, L"Window"); } void _CloseThemeData() { - ATLASSERT(m_hThemeDLL != NULL); - - if(m_hTheme == NULL) - return; // nothing to do - - PFN_CloseThemeData pfnCloseThemeData = (PFN_CloseThemeData)::GetProcAddress(m_hThemeDLL, "CloseThemeData"); - ATLASSERT(pfnCloseThemeData != NULL); - if(pfnCloseThemeData != NULL) + if(m_hTheme != NULL) { - pfnCloseThemeData(m_hTheme); + ::CloseThemeData(m_hTheme); m_hTheme = NULL; } } -#endif // !_WTL_NO_AUTO_THEME bool _DebugCheckChild() { #ifdef _DEBUG BOOL bMaximized = FALSE; HWND hWndChild = (HWND)::SendMessage(m_wndMDIClient, WM_MDIGETACTIVE, 0, (LPARAM)&bMaximized); - return (bMaximized && hWndChild == m_hWndChildMaximized); + return (bMaximized && (hWndChild == m_hWndChildMaximized)); #else // !_DEBUG return true; #endif // !_DEBUG @@ -4206,6 +3992,6 @@ public: DECLARE_WND_SUPERCLASS(_T("WTL_MDICommandBar"), GetWndClassName()) }; -}; // namespace WTL +} // namespace WTL #endif // __ATLCTRLW_H__ diff --git a/WrlSDK/SampleCode/PluginWinExe/WTL/atlctrlx.h b/WrlSDK/SampleCode/PluginWinExe/WTL/atlctrlx.h index c0ad456388d50ab178677d2701a1d405ec43dae4..5230ed17cb98416f2ec0982510a103061cb86b50 100644 --- a/WrlSDK/SampleCode/PluginWinExe/WTL/atlctrlx.h +++ b/WrlSDK/SampleCode/PluginWinExe/WTL/atlctrlx.h @@ -1,4 +1,4 @@ -// Windows Template Library - WTL version 9.10 +// Windows Template Library - WTL version 10.0 // Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. // // This file is a part of the Windows Template Library. @@ -19,10 +19,6 @@ #error atlctrlx.h requires atlctrls.h to be included first #endif -#ifndef WM_UPDATEUISTATE - #define WM_UPDATEUISTATE 0x0128 -#endif // !WM_UPDATEUISTATE - /////////////////////////////////////////////////////////////////////////////// // Classes in this file: @@ -51,8 +47,6 @@ namespace WTL /////////////////////////////////////////////////////////////////////////////// // CBitmapButton - bitmap button implementation -#ifndef _WIN32_WCE - // bitmap button extended styles #define BMPBTN_HOVER 0x00000001 #define BMPBTN_AUTO3D_SINGLE 0x00000002 @@ -70,7 +64,7 @@ template { public: - DECLARE_WND_SUPERCLASS(NULL, TBase::GetWndClassName()) + DECLARE_WND_SUPERCLASS2(NULL, T, TBase::GetWndClassName()) enum { @@ -131,12 +125,7 @@ public: // overridden to provide proper initialization BOOL SubclassWindow(HWND hWnd) { -#if (_MSC_VER >= 1300) BOOL bRet = ATL::CWindowImpl< T, TBase, TWinTraits >::SubclassWindow(hWnd); -#else // !(_MSC_VER >= 1300) - typedef ATL::CWindowImpl< T, TBase, TWinTraits > _baseClass; - BOOL bRet = _baseClass::SubclassWindow(hWnd); -#endif // !(_MSC_VER >= 1300) if(bRet != FALSE) { T* pT = static_cast(this); @@ -177,7 +166,7 @@ public: { HIMAGELIST hImageListPrev = m_ImageList; m_ImageList = hImageList; - if((m_dwExtendedStyle & BMPBTN_AUTOSIZE) != 0 && ::IsWindow(m_hWnd)) + if(((m_dwExtendedStyle & BMPBTN_AUTOSIZE) != 0) && ::IsWindow(this->m_hWnd)) SizeToImage(); return hImageListPrev; @@ -194,9 +183,9 @@ public: if(m_lpstrToolTipText == NULL) return false; - errno_t nRet = SecureHelper::strncpy_x(lpstrText, nLength, m_lpstrToolTipText, _TRUNCATE); + errno_t nRet = ATL::Checked::tcsncpy_s(lpstrText, nLength, m_lpstrToolTipText, _TRUNCATE); - return (nRet == 0 || nRet == STRUNCATE); + return ((nRet == 0) || (nRet == STRUNCATE)); } bool SetToolTipText(LPCTSTR lpstrText) @@ -219,11 +208,11 @@ public: if(m_lpstrToolTipText == NULL) return false; - SecureHelper::strcpy_x(m_lpstrToolTipText, cchLen, lpstrText); + ATL::Checked::tcscpy_s(m_lpstrToolTipText, cchLen, lpstrText); if(m_tip.IsWindow()) { m_tip.Activate(TRUE); - m_tip.AddTool(m_hWnd, m_lpstrToolTipText); + m_tip.AddTool(this->m_hWnd, m_lpstrToolTipText); } return true; @@ -240,8 +229,8 @@ public: if(bUpdate) { - Invalidate(); - UpdateWindow(); + this->Invalidate(); + this->UpdateWindow(); } } @@ -260,12 +249,12 @@ public: BOOL SizeToImage() { - ATLASSERT(::IsWindow(m_hWnd) && m_ImageList.m_hImageList != NULL); + ATLASSERT(::IsWindow(this->m_hWnd) && (m_ImageList.m_hImageList != NULL)); int cx = 0; int cy = 0; if(!m_ImageList.GetIconSize(cx, cy)) return FALSE; - return ResizeClient(cx, cy); + return this->ResizeClient(cx, cy); } // Overrideables @@ -278,7 +267,7 @@ public: bool bHover = IsHoverMode(); bool bPressed = (m_fPressed == 1) || (IsCheckMode() && (m_fChecked == 1)); int nImage = -1; - if(!IsWindowEnabled()) + if(!this->IsWindowEnabled()) nImage = m_nImage[_nImageDisabled]; else if(bPressed) nImage = m_nImage[_nImagePushed]; @@ -297,8 +286,8 @@ public: // draw 3D border if required if(bAuto3D) { - RECT rect = { 0 }; - GetClientRect(&rect); + RECT rect = {}; + this->GetClientRect(&rect); if(bPressed) dc.DrawEdge(&rect, ((m_dwExtendedStyle & BMPBTN_AUTO3D_SINGLE) != 0) ? BDR_SUNKENOUTER : EDGE_SUNKEN, BF_RECT); @@ -358,7 +347,7 @@ public: LRESULT OnMouseMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { - MSG msg = { m_hWnd, uMsg, wParam, lParam }; + MSG msg = { this->m_hWnd, uMsg, wParam, lParam }; if(m_tip.IsWindow()) m_tip.RelayEvent(&msg); bHandled = FALSE; @@ -379,7 +368,7 @@ public: } else { - CPaintDC dc(m_hWnd); + CPaintDC dc(this->m_hWnd); pT->DoPaint(dc.m_hDC); } return 0; @@ -388,8 +377,8 @@ public: LRESULT OnFocus(UINT uMsg, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) { m_fFocus = (uMsg == WM_SETFOCUS) ? 1 : 0; - Invalidate(); - UpdateWindow(); + this->Invalidate(); + this->UpdateWindow(); bHandled = FALSE; return 1; } @@ -398,14 +387,14 @@ public: { LRESULT lRet = 0; if(IsHoverMode()) - SetCapture(); + this->SetCapture(); else - lRet = DefWindowProc(uMsg, wParam, lParam); - if(::GetCapture() == m_hWnd) + lRet = this->DefWindowProc(uMsg, wParam, lParam); + if(::GetCapture() == this->m_hWnd) { m_fPressed = 1; - Invalidate(); - UpdateWindow(); + this->Invalidate(); + this->UpdateWindow(); } if(((m_dwExtendedStyle & BMPBTN_AUTOFIRE) != 0) && !IsCheckMode()) { @@ -413,7 +402,7 @@ public: int nDelay = 0; if(::SystemParametersInfo(SPI_GETKEYBOARDDELAY, 0, &nDelay, 0)) nElapse += nDelay * 250; // all milli-seconds - SetTimer(ID_TIMER_FIRST, nElapse); + this->SetTimer(ID_TIMER_FIRST, nElapse); } return lRet; } @@ -422,14 +411,14 @@ public: { LRESULT lRet = 0; if(!IsHoverMode() && !IsCheckMode()) - lRet = DefWindowProc(uMsg, wParam, lParam); - if(::GetCapture() != m_hWnd) - SetCapture(); + lRet = this->DefWindowProc(uMsg, wParam, lParam); + if(::GetCapture() != this->m_hWnd) + this->SetCapture(); if(m_fPressed == 0) { m_fPressed = 1; - Invalidate(); - UpdateWindow(); + this->Invalidate(); + this->UpdateWindow(); } return lRet; } @@ -441,11 +430,11 @@ public: LRESULT lRet = 0; if(!IsHoverMode() && !IsCheckMode()) - lRet = DefWindowProc(uMsg, wParam, lParam); - if(::GetCapture() == m_hWnd) + lRet = this->DefWindowProc(uMsg, wParam, lParam); + if(::GetCapture() == this->m_hWnd) { if((IsHoverMode() || IsCheckMode()) && (m_fPressed == 1)) - ::SendMessage(GetParent(), WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(), BN_CLICKED), (LPARAM)m_hWnd); + this->GetParent().SendMessage(WM_COMMAND, MAKEWPARAM(this->GetDlgCtrlID(), BN_CLICKED), (LPARAM)this->m_hWnd); ::ReleaseCapture(); } return lRet; @@ -456,8 +445,8 @@ public: if(m_fPressed == 1) { m_fPressed = 0; - Invalidate(); - UpdateWindow(); + this->Invalidate(); + this->UpdateWindow(); } bHandled = FALSE; return 1; @@ -465,33 +454,33 @@ public: LRESULT OnEnable(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) { - Invalidate(); - UpdateWindow(); + this->Invalidate(); + this->UpdateWindow(); bHandled = FALSE; return 1; } LRESULT OnMouseMove(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled) { - if(::GetCapture() == m_hWnd) + if(::GetCapture() == this->m_hWnd) { POINT ptCursor = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; - ClientToScreen(&ptCursor); - RECT rect = { 0 }; - GetWindowRect(&rect); + this->ClientToScreen(&ptCursor); + RECT rect = {}; + this->GetWindowRect(&rect); unsigned int uPressed = ::PtInRect(&rect, ptCursor) ? 1 : 0; if(m_fPressed != uPressed) { m_fPressed = uPressed; - Invalidate(); - UpdateWindow(); + this->Invalidate(); + this->UpdateWindow(); } } else if(IsHoverMode() && m_fMouseOver == 0) { m_fMouseOver = 1; - Invalidate(); - UpdateWindow(); + this->Invalidate(); + this->UpdateWindow(); StartTrackMouseLeave(); } bHandled = FALSE; @@ -503,21 +492,21 @@ public: if(m_fMouseOver == 1) { m_fMouseOver = 0; - Invalidate(); - UpdateWindow(); + this->Invalidate(); + this->UpdateWindow(); } return 0; } LRESULT OnKeyDown(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) { - if(wParam == VK_SPACE && IsHoverMode()) + if((wParam == VK_SPACE) && IsHoverMode()) return 0; // ignore if in hover mode - if(wParam == VK_SPACE && m_fPressed == 0) + if((wParam == VK_SPACE) && (m_fPressed == 0)) { m_fPressed = 1; - Invalidate(); - UpdateWindow(); + this->Invalidate(); + this->UpdateWindow(); } bHandled = FALSE; return 1; @@ -525,15 +514,15 @@ public: LRESULT OnKeyUp(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) { - if(wParam == VK_SPACE && IsHoverMode()) + if((wParam == VK_SPACE) && IsHoverMode()) return 0; // ignore if in hover mode - if(wParam == VK_SPACE && m_fPressed == 1) + if((wParam == VK_SPACE) && (m_fPressed == 1)) { m_fPressed = 0; if((m_dwExtendedStyle & BMPBTN_AUTOCHECK) != 0) SetCheck(!GetCheck(), false); - Invalidate(); - UpdateWindow(); + this->Invalidate(); + this->UpdateWindow(); } bHandled = FALSE; return 1; @@ -545,22 +534,22 @@ public: switch(wParam) // timer ID { case ID_TIMER_FIRST: - KillTimer(ID_TIMER_FIRST); + this->KillTimer(ID_TIMER_FIRST); if(m_fPressed == 1) { - ::SendMessage(GetParent(), WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(), BN_CLICKED), (LPARAM)m_hWnd); + this->GetParent().SendMessage(WM_COMMAND, MAKEWPARAM(this->GetDlgCtrlID(), BN_CLICKED), (LPARAM)this->m_hWnd); int nElapse = 250; int nRepeat = 40; if(::SystemParametersInfo(SPI_GETKEYBOARDSPEED, 0, &nRepeat, 0)) nElapse = 10000 / (10 * nRepeat + 25); // milli-seconds, approximated - SetTimer(ID_TIMER_REPEAT, nElapse); + this->SetTimer(ID_TIMER_REPEAT, nElapse); } break; case ID_TIMER_REPEAT: if(m_fPressed == 1) - ::SendMessage(GetParent(), WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(), BN_CLICKED), (LPARAM)m_hWnd); - else if(::GetCapture() != m_hWnd) - KillTimer(ID_TIMER_REPEAT); + this->GetParent().SendMessage(WM_COMMAND, MAKEWPARAM(this->GetDlgCtrlID(), BN_CLICKED), (LPARAM)this->m_hWnd); + else if(::GetCapture() != this->m_hWnd) + this->KillTimer(ID_TIMER_REPEAT); break; default: // not our timer break; @@ -579,28 +568,28 @@ public: void Init() { // We need this style to prevent Windows from painting the button - ModifyStyle(0, BS_OWNERDRAW); + this->ModifyStyle(0, BS_OWNERDRAW); // create a tool tip - m_tip.Create(m_hWnd); + m_tip.Create(this->m_hWnd); ATLASSERT(m_tip.IsWindow()); - if(m_tip.IsWindow() && m_lpstrToolTipText != NULL) + if(m_tip.IsWindow() && (m_lpstrToolTipText != NULL)) { m_tip.Activate(TRUE); - m_tip.AddTool(m_hWnd, m_lpstrToolTipText); + m_tip.AddTool(this->m_hWnd, m_lpstrToolTipText); } - if(m_ImageList.m_hImageList != NULL && (m_dwExtendedStyle & BMPBTN_AUTOSIZE) != 0) + if((m_ImageList.m_hImageList != NULL) && ((m_dwExtendedStyle & BMPBTN_AUTOSIZE) != 0)) SizeToImage(); } BOOL StartTrackMouseLeave() { - TRACKMOUSEEVENT tme = { 0 }; + TRACKMOUSEEVENT tme = {}; tme.cbSize = sizeof(tme); tme.dwFlags = TME_LEAVE; - tme.hwndTrack = m_hWnd; - return _TrackMouseEvent(&tme); + tme.hwndTrack = this->m_hWnd; + return ::TrackMouseEvent(&tme); } bool IsHoverMode() const @@ -624,8 +613,6 @@ public: { } }; -#endif // !_WIN32_WCE - /////////////////////////////////////////////////////////////////////////////// // CCheckListCtrlView - list view control with check boxes @@ -656,7 +643,7 @@ template { public: - DECLARE_WND_SUPERCLASS(NULL, TBase::GetWndClassName()) + DECLARE_WND_SUPERCLASS2(NULL, T, TBase::GetWndClassName()) // Attributes static DWORD GetExtendedLVStyle() @@ -667,12 +654,7 @@ public: // Operations BOOL SubclassWindow(HWND hWnd) { -#if (_MSC_VER >= 1300) BOOL bRet = ATL::CWindowImpl< T, TBase, TWinTraits >::SubclassWindow(hWnd); -#else // !(_MSC_VER >= 1300) - typedef ATL::CWindowImpl< T, TBase, TWinTraits > _baseClass; - BOOL bRet = _baseClass::SubclassWindow(hWnd); -#endif // !(_MSC_VER >= 1300) if(bRet != FALSE) { T* pT = static_cast(this); @@ -685,23 +667,23 @@ public: void CheckSelectedItems(int nCurrItem) { // first check if this item is selected - LVITEM lvi = { 0 }; + LVITEM lvi = {}; lvi.iItem = nCurrItem; lvi.iSubItem = 0; lvi.mask = LVIF_STATE; lvi.stateMask = LVIS_SELECTED; - GetItem(&lvi); + this->GetItem(&lvi); // if item is not selected, don't do anything if(!(lvi.state & LVIS_SELECTED)) return; // new check state will be reverse of the current state, - BOOL bCheck = !GetCheckState(nCurrItem); + BOOL bCheck = !this->GetCheckState(nCurrItem); int nItem = -1; int nOldItem = -1; - while((nItem = GetNextItem(nOldItem, LVNI_SELECTED)) != -1) + while((nItem = this->GetNextItem(nOldItem, LVNI_SELECTED)) != -1) { if(nItem != nCurrItem) - SetCheckState(nItem, bCheck); + this->SetCheckState(nItem, bCheck); nOldItem = nItem; } } @@ -710,9 +692,9 @@ public: void Init() { T* pT = static_cast(this); - pT; // avoid level 4 warning + (void)pT; // avoid level 4 warning ATLASSERT((pT->GetExtendedLVStyle() & LVS_EX_CHECKBOXES) != 0); - SetExtendedListViewStyle(pT->GetExtendedLVStyle()); + this->SetExtendedListViewStyle(pT->GetExtendedLVStyle()); } // Message map and handlers @@ -726,7 +708,7 @@ public: LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) { // first let list view control initialize everything - LRESULT lRet = DefWindowProc(uMsg, wParam, lParam); + LRESULT lRet = this->DefWindowProc(uMsg, wParam, lParam); if(lRet == 0) { T* pT = static_cast(this); @@ -739,9 +721,9 @@ public: LRESULT OnLButtonDown(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled) { POINT ptMsg = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; - LVHITTESTINFO lvh = { 0 }; + LVHITTESTINFO lvh = {}; lvh.pt = ptMsg; - if(HitTest(&lvh) != -1 && lvh.flags == LVHT_ONITEMSTATEICON && ::GetKeyState(VK_CONTROL) >= 0) + if((this->HitTest(&lvh) != -1) && (lvh.flags == LVHT_ONITEMSTATEICON) && (::GetKeyState(VK_CONTROL) >= 0)) { T* pT = static_cast(this); pT->CheckSelectedItems(lvh.iItem); @@ -754,8 +736,8 @@ public: { if(wParam == VK_SPACE) { - int nCurrItem = GetNextItem(-1, LVNI_FOCUSED); - if(nCurrItem != -1 && ::GetKeyState(VK_CONTROL) >= 0) + int nCurrItem = this->GetNextItem(-1, LVNI_FOCUSED); + if((nCurrItem != -1) && (::GetKeyState(VK_CONTROL) >= 0)) { T* pT = static_cast(this); pT->CheckSelectedItems(nCurrItem); @@ -776,40 +758,6 @@ public: /////////////////////////////////////////////////////////////////////////////// // CHyperLink - hyper link control implementation -#if (WINVER < 0x0500) && !defined(_WIN32_WCE) -__declspec(selectany) struct -{ - enum { cxWidth = 32, cyHeight = 32 }; - int xHotSpot; - int yHotSpot; - unsigned char arrANDPlane[cxWidth * cyHeight / 8]; - unsigned char arrXORPlane[cxWidth * cyHeight / 8]; -} _AtlHyperLink_CursorData = -{ - 5, 0, - { - 0xF9, 0xFF, 0xFF, 0xFF, 0xF0, 0xFF, 0xFF, 0xFF, 0xF0, 0xFF, 0xFF, 0xFF, 0xF0, 0xFF, 0xFF, 0xFF, - 0xF0, 0xFF, 0xFF, 0xFF, 0xF0, 0x3F, 0xFF, 0xFF, 0xF0, 0x07, 0xFF, 0xFF, 0xF0, 0x01, 0xFF, 0xFF, - 0xF0, 0x00, 0xFF, 0xFF, 0x10, 0x00, 0x7F, 0xFF, 0x00, 0x00, 0x7F, 0xFF, 0x00, 0x00, 0x7F, 0xFF, - 0x80, 0x00, 0x7F, 0xFF, 0xC0, 0x00, 0x7F, 0xFF, 0xC0, 0x00, 0x7F, 0xFF, 0xE0, 0x00, 0x7F, 0xFF, - 0xE0, 0x00, 0xFF, 0xFF, 0xF0, 0x00, 0xFF, 0xFF, 0xF0, 0x00, 0xFF, 0xFF, 0xF8, 0x01, 0xFF, 0xFF, - 0xF8, 0x01, 0xFF, 0xFF, 0xF8, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF - }, - { - 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x06, 0xC0, 0x00, 0x00, 0x06, 0xD8, 0x00, 0x00, - 0x06, 0xDA, 0x00, 0x00, 0x06, 0xDB, 0x00, 0x00, 0x67, 0xFB, 0x00, 0x00, 0x77, 0xFF, 0x00, 0x00, - 0x37, 0xFF, 0x00, 0x00, 0x17, 0xFF, 0x00, 0x00, 0x1F, 0xFF, 0x00, 0x00, 0x0F, 0xFF, 0x00, 0x00, - 0x0F, 0xFE, 0x00, 0x00, 0x07, 0xFE, 0x00, 0x00, 0x07, 0xFE, 0x00, 0x00, 0x03, 0xFC, 0x00, 0x00, - 0x03, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - } -}; -#endif // (WINVER < 0x0500) && !defined(_WIN32_WCE) - #define HLINK_UNDERLINED 0x00000000 #define HLINK_NOTUNDERLINED 0x00000001 #define HLINK_UNDERLINEHOVER 0x00000002 @@ -837,9 +785,7 @@ public: HFONT m_hFontNormal; RECT m_rcLink; -#ifndef _WIN32_WCE CToolTipCtrl m_tip; -#endif // !_WIN32_WCE COLORREF m_clrLink; COLORREF m_clrVisited; @@ -869,11 +815,6 @@ public: { delete [] m_lpstrLabel; delete [] m_lpstrHyperLink; -#if (WINVER < 0x0500) && !defined(_WIN32_WCE) - // It was created, not loaded, so we have to destroy it - if(m_hCursor != NULL) - ::DestroyCursor(m_hCursor); -#endif // (WINVER < 0x0500) && !defined(_WIN32_WCE) } // Attributes @@ -900,7 +841,7 @@ public: if(nLength <= lstrlen(m_lpstrLabel)) return false; - SecureHelper::strcpy_x(lpstrBuffer, nLength, m_lpstrLabel); + ATL::Checked::tcscpy_s(lpstrBuffer, nLength, m_lpstrLabel); return true; } @@ -914,12 +855,12 @@ public: if(m_lpstrLabel == NULL) return false; - SecureHelper::strcpy_x(m_lpstrLabel, cchLen, lpstrLabel); + ATL::Checked::tcscpy_s(m_lpstrLabel, cchLen, lpstrLabel); T* pT = static_cast(this); pT->CalcLabelRect(); - if(m_hWnd != NULL) - SetWindowText(lpstrLabel); // Set this for accessibility + if(this->m_hWnd != NULL) + this->SetWindowText(lpstrLabel); // Set this for accessibility return true; } @@ -932,7 +873,7 @@ public: if(nLength <= lstrlen(m_lpstrHyperLink)) return false; - SecureHelper::strcpy_x(lpstrBuffer, nLength, m_lpstrHyperLink); + ATL::Checked::tcscpy_s(lpstrBuffer, nLength, m_lpstrHyperLink); return true; } @@ -946,19 +887,19 @@ public: if(m_lpstrHyperLink == NULL) return false; - SecureHelper::strcpy_x(m_lpstrHyperLink, cchLen, lpstrLink); + ATL::Checked::tcscpy_s(m_lpstrHyperLink, cchLen, lpstrLink); if(m_lpstrLabel == NULL) { T* pT = static_cast(this); pT->CalcLabelRect(); } -#ifndef _WIN32_WCE + if(m_tip.IsWindow()) { m_tip.Activate(TRUE); - m_tip.AddTool(m_hWnd, m_lpstrHyperLink, &m_rcLink, 1); + m_tip.AddTool(this->m_hWnd, m_lpstrHyperLink, &m_rcLink, 1); } -#endif // !_WIN32_WCE + return true; } @@ -983,17 +924,17 @@ public: int GetIdealHeight() const { - ATLASSERT(::IsWindow(m_hWnd)); - if(m_lpstrLabel == NULL && m_lpstrHyperLink == NULL) + ATLASSERT(::IsWindow(this->m_hWnd)); + if((m_lpstrLabel == NULL) && (m_lpstrHyperLink == NULL)) return -1; if(!m_bPaintLabel) return -1; UINT uFormat = IsSingleLine() ? DT_SINGLELINE : DT_WORDBREAK; - CClientDC dc(m_hWnd); - RECT rect = { 0 }; - GetClientRect(&rect); + CClientDC dc(this->m_hWnd); + RECT rect = {}; + this->GetClientRect(&rect); HFONT hFontOld = dc.SelectFont(m_hFontNormal); RECT rcText = rect; dc.DrawText(_T("NS"), -1, &rcText, DT_LEFT | uFormat | DT_CALCRECT); @@ -1018,15 +959,15 @@ public: bool GetIdealSize(int& cx, int& cy) const { - ATLASSERT(::IsWindow(m_hWnd)); - if(m_lpstrLabel == NULL && m_lpstrHyperLink == NULL) + ATLASSERT(::IsWindow(this->m_hWnd)); + if((m_lpstrLabel == NULL) && (m_lpstrHyperLink == NULL)) return false; if(!m_bPaintLabel) return false; - CClientDC dc(m_hWnd); - RECT rcClient = { 0 }; - GetClientRect(&rcClient); + CClientDC dc(this->m_hWnd); + RECT rcClient = {}; + this->GetClientRect(&rcClient); RECT rcAll = rcClient; if(IsUsingTags()) @@ -1068,7 +1009,7 @@ public: if(m_hFontLink != NULL) hOldFont = dc.SelectFont(m_hFontLink); LPTSTR lpstrText = (m_lpstrLabel != NULL) ? m_lpstrLabel : m_lpstrHyperLink; - DWORD dwStyle = GetStyle(); + DWORD dwStyle = this->GetStyle(); UINT uFormat = DT_LEFT; if (dwStyle & SS_CENTER) uFormat = DT_CENTER; @@ -1112,17 +1053,12 @@ public: // Operations BOOL SubclassWindow(HWND hWnd) { - ATLASSERT(m_hWnd == NULL); + ATLASSERT(this->m_hWnd == NULL); ATLASSERT(::IsWindow(hWnd)); if(m_hFontNormal == NULL) m_hFontNormal = (HFONT)::SendMessage(hWnd, WM_GETFONT, 0, 0L); -#if (_MSC_VER >= 1300) BOOL bRet = ATL::CWindowImpl< T, TBase, TWinTraits >::SubclassWindow(hWnd); -#else // !(_MSC_VER >= 1300) - typedef ATL::CWindowImpl< T, TBase, TWinTraits > _baseClass; - BOOL bRet = _baseClass::SubclassWindow(hWnd); -#endif // !(_MSC_VER >= 1300) if(bRet != FALSE) { T* pT = static_cast(this); @@ -1134,34 +1070,27 @@ public: bool Navigate() { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); bool bRet = true; if(IsNotifyButton()) { - NMHDR nmhdr = { m_hWnd, (UINT_PTR)GetDlgCtrlID(), NM_CLICK }; - ::SendMessage(GetParent(), WM_NOTIFY, GetDlgCtrlID(), (LPARAM)&nmhdr); + NMHDR nmhdr = { this->m_hWnd, (UINT_PTR)this->GetDlgCtrlID(), NM_CLICK }; + this->GetParent().SendMessage(WM_NOTIFY, this->GetDlgCtrlID(), (LPARAM)&nmhdr); } else if(IsCommandButton()) { - ::SendMessage(GetParent(), WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(), BN_CLICKED), (LPARAM)m_hWnd); + this->GetParent().SendMessage(WM_COMMAND, MAKEWPARAM(this->GetDlgCtrlID(), BN_CLICKED), (LPARAM)this->m_hWnd); } else { ATLASSERT(m_lpstrHyperLink != NULL); -#ifndef _WIN32_WCE DWORD_PTR dwRet = (DWORD_PTR)::ShellExecute(0, _T("open"), m_lpstrHyperLink, 0, 0, SW_SHOWNORMAL); bRet = (dwRet > 32); -#else // CE specific - SHELLEXECUTEINFO shExeInfo = { sizeof(SHELLEXECUTEINFO), 0, 0, L"open", m_lpstrHyperLink, 0, 0, SW_SHOWNORMAL, 0, 0, 0, 0, 0, 0, 0 }; - ::ShellExecuteEx(&shExeInfo); - DWORD_PTR dwRet = (DWORD_PTR)shExeInfo.hInstApp; - bRet = (dwRet == 0) || (dwRet > 32); -#endif // _WIN32_WCE ATLASSERT(bRet); if(bRet) { m_bVisited = true; - Invalidate(); + this->Invalidate(); } } return bRet; @@ -1176,7 +1105,7 @@ public: } CFontHandle font = (m_hFontNormal != NULL) ? m_hFontNormal : (HFONT)::GetStockObject(SYSTEM_FONT); - LOGFONT lf = { 0 }; + LOGFONT lf = {}; font.GetLogFont(&lf); if(IsUsingTagsBold()) @@ -1192,21 +1121,15 @@ public: // Message map and handlers BEGIN_MSG_MAP(CHyperLinkImpl) MESSAGE_HANDLER(WM_CREATE, OnCreate) -#ifndef _WIN32_WCE MESSAGE_HANDLER(WM_DESTROY, OnDestroy) MESSAGE_RANGE_HANDLER(WM_MOUSEFIRST, WM_MOUSELAST, OnMouseMessage) -#endif // !_WIN32_WCE MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackground) MESSAGE_HANDLER(WM_PAINT, OnPaint) -#ifndef _WIN32_WCE MESSAGE_HANDLER(WM_PRINTCLIENT, OnPaint) -#endif // !_WIN32_WCE MESSAGE_HANDLER(WM_SETFOCUS, OnFocus) MESSAGE_HANDLER(WM_KILLFOCUS, OnFocus) MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove) -#ifndef _WIN32_WCE MESSAGE_HANDLER(WM_MOUSELEAVE, OnMouseLeave) -#endif // !_WIN32_WCE MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown) MESSAGE_HANDLER(WM_LBUTTONUP, OnLButtonUp) MESSAGE_HANDLER(WM_CHAR, OnChar) @@ -1226,7 +1149,6 @@ public: return 0; } -#ifndef _WIN32_WCE LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) { if(m_tip.IsWindow()) @@ -1255,13 +1177,12 @@ public: LRESULT OnMouseMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { - MSG msg = { m_hWnd, uMsg, wParam, lParam }; + MSG msg = { this->m_hWnd, uMsg, wParam, lParam }; if(m_tip.IsWindow() && IsUsingToolTip()) m_tip.RelayEvent(&msg); bHandled = FALSE; return 1; } -#endif // !_WIN32_WCE LRESULT OnEraseBackground(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { @@ -1284,7 +1205,7 @@ public: } else { - CPaintDC dc(m_hWnd); + CPaintDC dc(this->m_hWnd); pT->DoEraseBackground(dc.m_hDC); pT->DoPaint(dc.m_hDC); } @@ -1295,7 +1216,7 @@ public: LRESULT OnFocus(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) { if(m_bPaintLabel) - Invalidate(); + this->Invalidate(); else bHandled = FALSE; return 0; @@ -1304,7 +1225,7 @@ public: LRESULT OnMouseMove(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled) { POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; - if((m_lpstrHyperLink != NULL || IsCommandButton()) && ::PtInRect(&m_rcLink, pt)) + if(((m_lpstrHyperLink != NULL) || IsCommandButton()) && ::PtInRect(&m_rcLink, pt)) { ::SetCursor(m_hCursor); if(IsUnderlineHover()) @@ -1312,11 +1233,9 @@ public: if(!m_bHover) { m_bHover = true; - InvalidateRect(&m_rcLink); - UpdateWindow(); -#ifndef _WIN32_WCE + this->InvalidateRect(&m_rcLink); + this->UpdateWindow(); StartTrackMouseLeave(); -#endif // !_WIN32_WCE } } } @@ -1327,8 +1246,8 @@ public: if(m_bHover) { m_bHover = false; - InvalidateRect(&m_rcLink); - UpdateWindow(); + this->InvalidateRect(&m_rcLink); + this->UpdateWindow(); } } bHandled = FALSE; @@ -1336,33 +1255,31 @@ public: return 0; } -#ifndef _WIN32_WCE LRESULT OnMouseLeave(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { if(IsUnderlineHover() && m_bHover) { m_bHover = false; - InvalidateRect(&m_rcLink); - UpdateWindow(); + this->InvalidateRect(&m_rcLink); + this->UpdateWindow(); } return 0; } -#endif // !_WIN32_WCE LRESULT OnLButtonDown(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/) { POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; if(::PtInRect(&m_rcLink, pt)) { - SetFocus(); - SetCapture(); + this->SetFocus(); + this->SetCapture(); } return 0; } LRESULT OnLButtonUp(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/) { - if(GetCapture() == m_hWnd) + if(GetCapture() == this->m_hWnd) { ReleaseCapture(); POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; @@ -1377,7 +1294,7 @@ public: LRESULT OnChar(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) { - if(wParam == VK_RETURN || wParam == VK_SPACE) + if((wParam == VK_RETURN) || (wParam == VK_SPACE)) { T* pT = static_cast(this); pT->Navigate(); @@ -1392,10 +1309,10 @@ public: LRESULT OnSetCursor(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) { - POINT pt = { 0, 0 }; + POINT pt = {}; GetCursorPos(&pt); - ScreenToClient(&pt); - if((m_lpstrHyperLink != NULL || IsCommandButton()) && ::PtInRect(&m_rcLink, pt)) + this->ScreenToClient(&pt); + if(((m_lpstrHyperLink != NULL) || IsCommandButton()) && ::PtInRect(&m_rcLink, pt)) { return TRUE; } @@ -1405,8 +1322,8 @@ public: LRESULT OnEnable(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { - Invalidate(); - UpdateWindow(); + this->Invalidate(); + this->UpdateWindow(); return 0; } @@ -1435,8 +1352,8 @@ public: if((BOOL)lParam) { - Invalidate(); - UpdateWindow(); + this->Invalidate(); + this->UpdateWindow(); } return 0; @@ -1460,35 +1377,27 @@ public: // Implementation void Init() { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); // Check if we should paint a label const int cchBuff = 8; - TCHAR szBuffer[cchBuff] = { 0 }; - if(::GetClassName(m_hWnd, szBuffer, cchBuff)) + TCHAR szBuffer[cchBuff] = {}; + if(::GetClassName(this->m_hWnd, szBuffer, cchBuff)) { if(lstrcmpi(szBuffer, _T("static")) == 0) { - ModifyStyle(0, SS_NOTIFY); // we need this - DWORD dwStyle = GetStyle() & 0x000000FF; -#ifndef _WIN32_WCE - if(dwStyle == SS_ICON || dwStyle == SS_BLACKRECT || dwStyle == SS_GRAYRECT || - dwStyle == SS_WHITERECT || dwStyle == SS_BLACKFRAME || dwStyle == SS_GRAYFRAME || - dwStyle == SS_WHITEFRAME || dwStyle == SS_OWNERDRAW || - dwStyle == SS_BITMAP || dwStyle == SS_ENHMETAFILE) -#else // CE specific - if(dwStyle == SS_ICON || dwStyle == SS_BITMAP) -#endif // _WIN32_WCE + this->ModifyStyle(0, SS_NOTIFY); // we need this + DWORD dwStyle = this->GetStyle() & 0x000000FF; + if((dwStyle == SS_ICON) || (dwStyle == SS_BLACKRECT) || (dwStyle == SS_GRAYRECT) || + (dwStyle == SS_WHITERECT) || (dwStyle == SS_BLACKFRAME) || (dwStyle == SS_GRAYFRAME) || + (dwStyle == SS_WHITEFRAME) || (dwStyle == SS_OWNERDRAW) || + (dwStyle == SS_BITMAP) || (dwStyle == SS_ENHMETAFILE)) m_bPaintLabel = false; } } // create or load a cursor -#if (WINVER >= 0x0500) || defined(_WIN32_WCE) m_hCursor = ::LoadCursor(NULL, IDC_HAND); -#else - m_hCursor = ::CreateCursor(ModuleHelper::GetModuleInstance(), _AtlHyperLink_CursorData.xHotSpot, _AtlHyperLink_CursorData.yHotSpot, _AtlHyperLink_CursorData.cxWidth, _AtlHyperLink_CursorData.cyHeight, _AtlHyperLink_CursorData.arrANDPlane, _AtlHyperLink_CursorData.arrXORPlane); -#endif ATLASSERT(m_hCursor != NULL); // set fonts @@ -1504,21 +1413,19 @@ public: CreateLinkFontFromNormal(); } -#ifndef _WIN32_WCE // create a tool tip - m_tip.Create(m_hWnd); + m_tip.Create(this->m_hWnd); ATLASSERT(m_tip.IsWindow()); -#endif // !_WIN32_WCE // set label (defaults to window text) if(m_lpstrLabel == NULL) { - int nLen = GetWindowTextLength(); + int nLen = this->GetWindowTextLength(); if(nLen > 0) { ATLTRY(m_lpstrLabel = new TCHAR[nLen + 1]); if(m_lpstrLabel != NULL) - ATLVERIFY(GetWindowText(m_lpstrLabel, nLen + 1) > 0); + ATLVERIFY(this->GetWindowText(m_lpstrLabel, nLen + 1) > 0); } } @@ -1526,28 +1433,26 @@ public: pT->CalcLabelRect(); // set hyperlink (defaults to label), or just activate tool tip if already set - if(m_lpstrHyperLink == NULL && !IsCommandButton()) + if((m_lpstrHyperLink == NULL) && !IsCommandButton()) { if(m_lpstrLabel != NULL) SetHyperLink(m_lpstrLabel); } -#ifndef _WIN32_WCE else { m_tip.Activate(TRUE); - m_tip.AddTool(m_hWnd, m_lpstrHyperLink, &m_rcLink, 1); + m_tip.AddTool(this->m_hWnd, m_lpstrHyperLink, &m_rcLink, 1); } -#endif // !_WIN32_WCE // set link colors if(m_bPaintLabel) { - CRegKeyEx rk; + ATL::CRegKey rk; LONG lRet = rk.Open(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Internet Explorer\\Settings")); if(lRet == ERROR_SUCCESS) { const int cchValue = 12; - TCHAR szValue[cchValue] = { 0 }; + TCHAR szValue[cchValue] = {}; ULONG ulCount = cchValue; lRet = rk.QueryStringValue(_T("Anchor Color"), szValue, &ulCount); if(lRet == ERROR_SUCCESS) @@ -1582,7 +1487,7 @@ public: if(*p == _T(',')) { *p = _T('\0'); - c[i] = MinCrtHelper::_atoi(lpstr); + c[i] = _ttoi(lpstr); lpstr = &p[1]; break; } @@ -1592,21 +1497,21 @@ public: } if(*lpstr == _T('\0')) return CLR_INVALID; - c[2] = MinCrtHelper::_atoi(lpstr); + c[2] = _ttoi(lpstr); return RGB(c[0], c[1], c[2]); } bool CalcLabelRect() { - if(!::IsWindow(m_hWnd)) + if(!::IsWindow(this->m_hWnd)) return false; - if(m_lpstrLabel == NULL && m_lpstrHyperLink == NULL) + if((m_lpstrLabel == NULL) && (m_lpstrHyperLink == NULL)) return false; - CClientDC dc(m_hWnd); - RECT rcClient = { 0 }; - GetClientRect(&rcClient); + CClientDC dc(this->m_hWnd); + RECT rcClient = {}; + this->GetClientRect(&rcClient); m_rcLink = rcClient; if(!m_bPaintLabel) return true; @@ -1651,7 +1556,7 @@ public: if(m_hFontLink != NULL) hOldFont = dc.SelectFont(m_hFontLink); LPTSTR lpstrText = (m_lpstrLabel != NULL) ? m_lpstrLabel : m_lpstrHyperLink; - DWORD dwStyle = GetStyle(); + DWORD dwStyle = this->GetStyle(); UINT uFormat = DT_LEFT; if (dwStyle & SS_CENTER) uFormat = DT_CENTER; @@ -1725,11 +1630,11 @@ public: void DoEraseBackground(CDCHandle dc) { - HBRUSH hBrush = (HBRUSH)::SendMessage(GetParent(), WM_CTLCOLORSTATIC, (WPARAM)dc.m_hDC, (LPARAM)m_hWnd); + HBRUSH hBrush = (HBRUSH)this->GetParent().SendMessage(WM_CTLCOLORSTATIC, (WPARAM)dc.m_hDC, (LPARAM)this->m_hWnd); if(hBrush != NULL) { - RECT rect = { 0 }; - GetClientRect(&rect); + RECT rect = {}; + this->GetClientRect(&rect); dc.FillRect(&rect, hBrush); } } @@ -1750,8 +1655,8 @@ public: pT->CalcLabelParts(lpstrLeft, cchLeft, lpstrLink, cchLink, lpstrRight, cchRight); // get label part rects - RECT rcClient = { 0 }; - GetClientRect(&rcClient); + RECT rcClient = {}; + this->GetClientRect(&rcClient); dc.SetBkMode(TRANSPARENT); HFONT hFontOld = dc.SelectFont(m_hFontNormal); @@ -1761,8 +1666,8 @@ public: if(lpstrLeft != NULL) dc.DrawText(lpstrLeft, cchLeft, &rcClient, DT_LEFT | uFormat); - COLORREF clrOld = dc.SetTextColor(IsWindowEnabled() ? (m_bVisited ? m_clrVisited : m_clrLink) : (::GetSysColor(COLOR_GRAYTEXT))); - if(m_hFontLink != NULL && (!IsUnderlineHover() || (IsUnderlineHover() && m_bHover))) + COLORREF clrOld = dc.SetTextColor(this->IsWindowEnabled() ? (m_bVisited ? m_clrVisited : m_clrLink) : (::GetSysColor(COLOR_GRAYTEXT))); + if((m_hFontLink != NULL) && (!IsUnderlineHover() || (IsUnderlineHover() && m_bHover))) dc.SelectFont(m_hFontLink); else dc.SelectFont(m_hFontNormal); @@ -1777,7 +1682,7 @@ public: dc.DrawText(lpstrRight, cchRight, &rcRight, DT_LEFT | uFormat); } - if(GetFocus() == m_hWnd) + if(GetFocus() == this->m_hWnd) dc.DrawFocusRect(&m_rcLink); dc.SelectFont(hFontOld); @@ -1785,17 +1690,17 @@ public: else { dc.SetBkMode(TRANSPARENT); - COLORREF clrOld = dc.SetTextColor(IsWindowEnabled() ? (m_bVisited ? m_clrVisited : m_clrLink) : (::GetSysColor(COLOR_GRAYTEXT))); + COLORREF clrOld = dc.SetTextColor(this->IsWindowEnabled() ? (m_bVisited ? m_clrVisited : m_clrLink) : (::GetSysColor(COLOR_GRAYTEXT))); HFONT hFontOld = NULL; - if(m_hFontLink != NULL && (!IsUnderlineHover() || (IsUnderlineHover() && m_bHover))) + if((m_hFontLink != NULL) && (!IsUnderlineHover() || (IsUnderlineHover() && m_bHover))) hFontOld = dc.SelectFont(m_hFontLink); else hFontOld = dc.SelectFont(m_hFontNormal); LPTSTR lpstrText = (m_lpstrLabel != NULL) ? m_lpstrLabel : m_lpstrHyperLink; - DWORD dwStyle = GetStyle(); + DWORD dwStyle = this->GetStyle(); UINT uFormat = DT_LEFT; if (dwStyle & SS_CENTER) uFormat = DT_CENTER; @@ -1805,7 +1710,7 @@ public: dc.DrawText(lpstrText, -1, &m_rcLink, uFormat); - if(GetFocus() == m_hWnd) + if(GetFocus() == this->m_hWnd) dc.DrawFocusRect(&m_rcLink); dc.SetTextColor(clrOld); @@ -1813,16 +1718,14 @@ public: } } -#ifndef _WIN32_WCE BOOL StartTrackMouseLeave() { - TRACKMOUSEEVENT tme = { 0 }; + TRACKMOUSEEVENT tme = {}; tme.cbSize = sizeof(tme); tme.dwFlags = TME_LEAVE; - tme.hwndTrack = m_hWnd; - return _TrackMouseEvent(&tme); + tme.hwndTrack = this->m_hWnd; + return ::TrackMouseEvent(&tme); } -#endif // !_WIN32_WCE // Implementation helpers bool IsUnderlined() const @@ -1952,9 +1855,7 @@ public: ~CCustomWaitCursor() { Restore(); -#if !defined(_WIN32_WCE) || ((_WIN32_WCE >= 0x400) && !(defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP))) ::DestroyCursor(m_hWaitCursor); -#endif // !defined(_WIN32_WCE) || ((_WIN32_WCE >= 0x400) && !(defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP))) } }; @@ -1966,7 +1867,7 @@ template class ATL_NO_VTABLE CMultiPaneStatusBarCtrlImpl : public ATL::CWindowImpl< T, TBase > { public: - DECLARE_WND_SUPERCLASS(NULL, TBase::GetWndClassName()) + DECLARE_WND_SUPERCLASS2(NULL, T, TBase::GetWndClassName()) // Data enum { m_cxPaneMargin = 3 }; @@ -1986,25 +1887,20 @@ public: // Methods HWND Create(HWND hWndParent, LPCTSTR lpstrText, DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | SBARS_SIZEGRIP, UINT nID = ATL_IDW_STATUS_BAR) { -#if (_MSC_VER >= 1300) - return ATL::CWindowImpl< T, TBase >::Create(hWndParent, rcDefault, lpstrText, dwStyle, 0, nID); -#else // !(_MSC_VER >= 1300) - typedef ATL::CWindowImpl< T, TBase > _baseClass; - return _baseClass::Create(hWndParent, rcDefault, lpstrText, dwStyle, 0, nID); -#endif // !(_MSC_VER >= 1300) + return ATL::CWindowImpl< T, TBase >::Create(hWndParent, this->rcDefault, lpstrText, dwStyle, 0, nID); } HWND Create(HWND hWndParent, UINT nTextID = ATL_IDS_IDLEMESSAGE, DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | SBARS_SIZEGRIP, UINT nID = ATL_IDW_STATUS_BAR) { const int cchMax = 128; // max text length is 127 for status bars (+1 for null) - TCHAR szText[cchMax] = { 0 }; + TCHAR szText[cchMax] = {}; ::LoadString(ModuleHelper::GetResourceInstance(), nTextID, szText, cchMax); return Create(hWndParent, szText, dwStyle, nID); } BOOL SetPanes(int* pPanes, int nPanes, bool bSetText = true) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(nPanes > 0); m_nPanes = nPanes; @@ -2016,25 +1912,24 @@ public: if(m_pPane == NULL) return FALSE; - CTempBuffer buff; + ATL::CTempBuffer buff; int* pPanesPos = buff.Allocate(nPanes); ATLASSERT(pPanesPos != NULL); if(pPanesPos == NULL) return FALSE; - SecureHelper::memcpy_x(m_pPane, nPanes * sizeof(int), pPanes, nPanes * sizeof(int)); + ATL::Checked::memcpy_s(m_pPane, nPanes * sizeof(int), pPanes, nPanes * sizeof(int)); // get status bar DC and set font - CClientDC dc(m_hWnd); - HFONT hOldFont = dc.SelectFont(GetFont()); + CClientDC dc(this->m_hWnd); + HFONT hOldFont = dc.SelectFont(this->GetFont()); // get status bar borders - int arrBorders[3] = { 0 }; - GetBorders(arrBorders); + int arrBorders[3] = {}; + this->GetBorders(arrBorders); const int cchBuff = 128; - TCHAR szBuff[cchBuff] = { 0 }; - SIZE size = { 0, 0 }; + TCHAR szBuff[cchBuff] = {}; int cxLeft = arrBorders[0]; // calculate right edge of each part @@ -2048,15 +1943,16 @@ public: else { ::LoadString(ModuleHelper::GetResourceInstance(), pPanes[i], szBuff, cchBuff); + SIZE size = {}; dc.GetTextExtent(szBuff, lstrlen(szBuff), &size); T* pT = static_cast(this); - pT; + (void)pT; // avoid level 4 warning pPanesPos[i] = cxLeft + size.cx + arrBorders[2] + 2 * pT->m_cxPaneMargin; } cxLeft = pPanesPos[i]; } - BOOL bRet = SetParts(nPanes, pPanesPos); + BOOL bRet = this->SetParts(nPanes, pPanesPos); if(bRet && bSetText) { @@ -2076,12 +1972,12 @@ public: bool GetPaneTextLength(int nPaneID, int* pcchLength = NULL, int* pnType = NULL) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); int nIndex = GetPaneIndexFromID(nPaneID); if(nIndex == -1) return false; - int nLength = GetTextLength(nIndex, pnType); + int nLength = this->GetTextLength(nIndex, pnType); if(pcchLength != NULL) *pcchLength = nLength; @@ -2090,52 +1986,68 @@ public: BOOL GetPaneText(int nPaneID, LPTSTR lpstrText, int* pcchLength = NULL, int* pnType = NULL) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); + int nIndex = GetPaneIndexFromID(nPaneID); + if(nIndex == -1) + return FALSE; + + int nLength = this->GetText(nIndex, lpstrText, pnType); + if(pcchLength != NULL) + *pcchLength = nLength; + + return TRUE; + } + +#ifdef __ATLSTR_H__ + BOOL GetPaneText(int nPaneID, ATL::CString& strText, int* pcchLength = NULL, int* pnType = NULL) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); int nIndex = GetPaneIndexFromID(nPaneID); if(nIndex == -1) return FALSE; - int nLength = GetText(nIndex, lpstrText, pnType); + int nLength = this->GetText(nIndex, strText, pnType); if(pcchLength != NULL) *pcchLength = nLength; return TRUE; } +#endif // __ATLSTR_H__ BOOL SetPaneText(int nPaneID, LPCTSTR lpstrText, int nType = 0) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); int nIndex = GetPaneIndexFromID(nPaneID); if(nIndex == -1) return FALSE; - return SetText(nIndex, lpstrText, nType); + return this->SetText(nIndex, lpstrText, nType); } BOOL GetPaneRect(int nPaneID, LPRECT lpRect) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); int nIndex = GetPaneIndexFromID(nPaneID); if(nIndex == -1) return FALSE; - return GetRect(nIndex, lpRect); + return this->GetRect(nIndex, lpRect); } BOOL SetPaneWidth(int nPaneID, int cxWidth) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(nPaneID != ID_DEFAULT_PANE); // Can't resize this one int nIndex = GetPaneIndexFromID(nPaneID); if(nIndex == -1) return FALSE; // get pane positions - CTempBuffer buff; + ATL::CTempBuffer buff; int* pPanesPos = buff.Allocate(m_nPanes); if(pPanesPos == NULL) return FALSE; - GetParts(m_nPanes, pPanesPos); + this->GetParts(m_nPanes, pPanesPos); // calculate offset int cxPaneWidth = pPanesPos[nIndex] - ((nIndex == 0) ? 0 : pPanesPos[nIndex - 1]); int cxOff = cxWidth - cxPaneWidth; @@ -2162,55 +2074,51 @@ public: pPanesPos[i] -= cxOff; } // set pane postions - return SetParts(m_nPanes, pPanesPos); + return this->SetParts(m_nPanes, pPanesPos); } -#if (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) BOOL GetPaneTipText(int nPaneID, LPTSTR lpstrText, int nSize) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); int nIndex = GetPaneIndexFromID(nPaneID); if(nIndex == -1) return FALSE; - GetTipText(nIndex, lpstrText, nSize); + this->GetTipText(nIndex, lpstrText, nSize); return TRUE; } BOOL SetPaneTipText(int nPaneID, LPCTSTR lpstrText) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); int nIndex = GetPaneIndexFromID(nPaneID); if(nIndex == -1) return FALSE; - SetTipText(nIndex, lpstrText); + this->SetTipText(nIndex, lpstrText); return TRUE; } -#endif // (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) -#if ((_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE)) || (defined(_WIN32_WCE) && (_WIN32_WCE >= 0x0500)) BOOL GetPaneIcon(int nPaneID, HICON& hIcon) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); int nIndex = GetPaneIndexFromID(nPaneID); if(nIndex == -1) return FALSE; - hIcon = GetIcon(nIndex); + hIcon = this->GetIcon(nIndex); return TRUE; } BOOL SetPaneIcon(int nPaneID, HICON hIcon) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); int nIndex = GetPaneIndexFromID(nPaneID); if(nIndex == -1) return FALSE; - return SetIcon(nIndex, hIcon); + return this->SetIcon(nIndex, hIcon); } -#endif // ((_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE)) || (defined(_WIN32_WCE) && (_WIN32_WCE >= 0x0500)) // Message map and handlers BEGIN_MSG_MAP(CMultiPaneStatusBarCtrlImpl< T >) @@ -2219,8 +2127,8 @@ public: LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) { - LRESULT lRet = DefWindowProc(uMsg, wParam, lParam); - if(wParam != SIZE_MINIMIZED && m_nPanes > 0) + LRESULT lRet = this->DefWindowProc(uMsg, wParam, lParam); + if((wParam != SIZE_MINIMIZED) && (m_nPanes > 0)) { T* pT = static_cast(this); pT->UpdatePanesLayout(); @@ -2232,24 +2140,22 @@ public: BOOL UpdatePanesLayout() { // get pane positions - CTempBuffer buff; + ATL::CTempBuffer buff; int* pPanesPos = buff.Allocate(m_nPanes); ATLASSERT(pPanesPos != NULL); if(pPanesPos == NULL) return FALSE; - int nRet = GetParts(m_nPanes, pPanesPos); + int nRet = this->GetParts(m_nPanes, pPanesPos); ATLASSERT(nRet == m_nPanes); if(nRet != m_nPanes) return FALSE; // calculate offset - RECT rcClient = { 0 }; - GetClientRect(&rcClient); + RECT rcClient = {}; + this->GetClientRect(&rcClient); int cxOff = rcClient.right - pPanesPos[m_nPanes - 1]; -#ifndef _WIN32_WCE // Move panes left if size grip box is present - if((GetStyle() & SBARS_SIZEGRIP) != 0) + if((this->GetStyle() & SBARS_SIZEGRIP) != 0) cxOff -= ::GetSystemMetrics(SM_CXVSCROLL) + ::GetSystemMetrics(SM_CXEDGE); -#endif // !_WIN32_WCE // find variable width pane int i; for(i = 0; i < m_nPanes; i++) @@ -2264,7 +2170,7 @@ public: pPanesPos[i] += cxOff; } // set pane postions - return SetParts(m_nPanes, pPanesPos); + return this->SetParts(m_nPanes, pPanesPos); } int GetPaneIndexFromID(int nPaneID) const @@ -2297,13 +2203,11 @@ public: #define PANECNT_DIVIDER 0x00000010 #define PANECNT_GRADIENT 0x00000020 -// Note: PANECNT_GRADIENT doesn't work with _ATL_NO_MSIMG - template class ATL_NO_VTABLE CPaneContainerImpl : public ATL::CWindowImpl< T, TBase, TWinTraits >, public CCustomDraw< T > { public: - DECLARE_WND_CLASS_EX(NULL, 0, -1) + DECLARE_WND_CLASS_EX2(NULL, T, 0, -1) // Constants enum @@ -2357,7 +2261,7 @@ public: m_dwExtendedStyle = dwExtendedStyle; else m_dwExtendedStyle = (m_dwExtendedStyle & ~dwMask) | (dwExtendedStyle & dwMask); - if(m_hWnd != NULL) + if(this->m_hWnd != NULL) { T* pT = static_cast(this); bool bUpdate = false; @@ -2385,12 +2289,10 @@ public: bUpdate = true; } -#if (!defined(_WIN32_WCE) && !defined(_ATL_NO_MSIMG)) || (_WIN32_WCE >= 420) if((dwPrevStyle & PANECNT_GRADIENT) != (m_dwExtendedStyle & PANECNT_GRADIENT)) // change background { bUpdate = true; } -#endif // (!defined(_WIN32_WCE) && !defined(_ATL_NO_MSIMG)) || (_WIN32_WCE >= 420) if(bUpdate) pT->UpdateLayout(); @@ -2407,7 +2309,7 @@ public: { HWND hWndOldClient = m_wndClient; m_wndClient = hWndClient; - if(m_hWnd != NULL) + if(this->m_hWnd != NULL) { T* pT = static_cast(this); pT->UpdateLayout(); @@ -2419,18 +2321,18 @@ public: { ATLASSERT(lpstrTitle != NULL); - errno_t nRet = SecureHelper::strncpy_x(lpstrTitle, cchLength, m_szTitle, _TRUNCATE); + errno_t nRet = ATL::Checked::tcsncpy_s(lpstrTitle, cchLength, m_szTitle, _TRUNCATE); - return (nRet == 0 || nRet == STRUNCATE); + return ((nRet == 0) || (nRet == STRUNCATE)); } BOOL SetTitle(LPCTSTR lpstrTitle) { ATLASSERT(lpstrTitle != NULL); - errno_t nRet = SecureHelper::strncpy_x(m_szTitle, m_cchTitle, lpstrTitle, _TRUNCATE); - bool bRet = (nRet == 0 || nRet == STRUNCATE); - if(bRet && m_hWnd != NULL) + errno_t nRet = ATL::Checked::tcsncpy_s(m_szTitle, m_cchTitle, lpstrTitle, _TRUNCATE); + bool bRet = ((nRet == 0) || (nRet == STRUNCATE)); + if(bRet && (this->m_hWnd != NULL)) { T* pT = static_cast(this); pT->UpdateLayout(); @@ -2449,13 +2351,8 @@ public: DWORD dwExStyle = 0, UINT nID = 0, LPVOID lpCreateParam = NULL) { if(lpstrTitle != NULL) - SecureHelper::strncpy_x(m_szTitle, m_cchTitle, lpstrTitle, _TRUNCATE); -#if (_MSC_VER >= 1300) - return ATL::CWindowImpl< T, TBase, TWinTraits >::Create(hWndParent, rcDefault, NULL, dwStyle, dwExStyle, nID, lpCreateParam); -#else // !(_MSC_VER >= 1300) - typedef ATL::CWindowImpl< T, TBase, TWinTraits > _baseClass; - return _baseClass::Create(hWndParent, rcDefault, NULL, dwStyle, dwExStyle, nID, lpCreateParam); -#endif // !(_MSC_VER >= 1300) + ATL::Checked::tcsncpy_s(m_szTitle, m_cchTitle, lpstrTitle, _TRUNCATE); + return ATL::CWindowImpl< T, TBase, TWinTraits >::Create(hWndParent, this->rcDefault, NULL, dwStyle, dwExStyle, nID, lpCreateParam); } HWND Create(HWND hWndParent, UINT uTitleID, DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, @@ -2463,29 +2360,19 @@ public: { if(uTitleID != 0U) ::LoadString(ModuleHelper::GetResourceInstance(), uTitleID, m_szTitle, m_cchTitle); -#if (_MSC_VER >= 1300) - return ATL::CWindowImpl< T, TBase, TWinTraits >::Create(hWndParent, rcDefault, NULL, dwStyle, dwExStyle, nID, lpCreateParam); -#else // !(_MSC_VER >= 1300) - typedef ATL::CWindowImpl< T, TBase, TWinTraits > _baseClass; - return _baseClass::Create(hWndParent, rcDefault, NULL, dwStyle, dwExStyle, nID, lpCreateParam); -#endif // !(_MSC_VER >= 1300) + return ATL::CWindowImpl< T, TBase, TWinTraits >::Create(hWndParent, this->rcDefault, NULL, dwStyle, dwExStyle, nID, lpCreateParam); } BOOL SubclassWindow(HWND hWnd) { -#if (_MSC_VER >= 1300) BOOL bRet = ATL::CWindowImpl< T, TBase, TWinTraits >::SubclassWindow(hWnd); -#else // !(_MSC_VER >= 1300) - typedef ATL::CWindowImpl< T, TBase, TWinTraits > _baseClass; - BOOL bRet = _baseClass::SubclassWindow(hWnd); -#endif // !(_MSC_VER >= 1300) if(bRet != FALSE) { T* pT = static_cast(this); pT->Init(); - RECT rect = { 0 }; - GetClientRect(&rect); + RECT rect = {}; + this->GetClientRect(&rect); pT->UpdateLayout(rect.right, rect.bottom); } @@ -2494,16 +2381,16 @@ public: BOOL EnableCloseButton(BOOL bEnable) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); T* pT = static_cast(this); - pT; // avoid level 4 warning + (void)pT; // avoid level 4 warning return (m_tb.m_hWnd != NULL) ? m_tb.EnableButton(pT->m_nCloseBtnID, bEnable) : FALSE; } void UpdateLayout() { - RECT rcClient = { 0 }; - GetClientRect(&rcClient); + RECT rcClient = {}; + this->GetClientRect(&rcClient); T* pT = static_cast(this); pT->UpdateLayout(rcClient.right, rcClient.bottom); } @@ -2518,9 +2405,7 @@ public: MESSAGE_HANDLER(WM_SETFONT, OnSetFont) MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackground) MESSAGE_HANDLER(WM_PAINT, OnPaint) -#ifndef _WIN32_WCE MESSAGE_HANDLER(WM_PRINTCLIENT, OnPaint) -#endif // !_WIN32_WCE MESSAGE_HANDLER(WM_NOTIFY, OnNotify) MESSAGE_HANDLER(WM_COMMAND, OnCommand) FORWARD_NOTIFICATIONS() @@ -2604,7 +2489,7 @@ public: } else { - CPaintDC dc(m_hWnd); + CPaintDC dc(this->m_hWnd); pT->DrawPaneTitle(dc.m_hDC); if(m_wndClient.m_hWnd == NULL) // no client window @@ -2623,21 +2508,19 @@ public: } T* pT = static_cast(this); - pT; + (void)pT; // avoid level 4 warning LPNMHDR lpnmh = (LPNMHDR)lParam; LRESULT lRet = 0; // pass toolbar custom draw notifications to the base class - if(lpnmh->code == NM_CUSTOMDRAW && lpnmh->hwndFrom == m_tb.m_hWnd) + if((lpnmh->code == NM_CUSTOMDRAW) && (lpnmh->hwndFrom == m_tb.m_hWnd)) lRet = CCustomDraw< T >::OnCustomDraw(0, lpnmh, bHandled); -#ifndef _WIN32_WCE // tooltip notifications come with the tooltip window handle and button ID, // pass them to the parent if we don't handle them - else if(lpnmh->code == TTN_GETDISPINFO && lpnmh->idFrom == pT->m_nCloseBtnID) + else if((lpnmh->code == TTN_GETDISPINFO) && (lpnmh->idFrom == pT->m_nCloseBtnID)) bHandled = pT->GetToolTipText(lpnmh); -#endif // !_WIN32_WCE // only let notifications not from the toolbar go to the parent - else if(lpnmh->hwndFrom != m_tb.m_hWnd && lpnmh->idFrom != pT->m_nCloseBtnID) + else if((lpnmh->hwndFrom != m_tb.m_hWnd) && (lpnmh->idFrom != pT->m_nCloseBtnID)) bHandled = FALSE; return lRet; @@ -2646,8 +2529,8 @@ public: LRESULT OnCommand(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { // if command comes from the close button, substitute HWND of the pane container instead - if(m_tb.m_hWnd != NULL && (HWND)lParam == m_tb.m_hWnd) - return ::SendMessage(GetParent(), WM_COMMAND, wParam, (LPARAM)m_hWnd); + if((m_tb.m_hWnd != NULL) && ((HWND)lParam == m_tb.m_hWnd)) + return this->GetParent().SendMessage(WM_COMMAND, wParam, (LPARAM)this->m_hWnd); bHandled = FALSE; return 1; @@ -2667,12 +2550,7 @@ public: DWORD OnItemPostPaint(int /*idCtrl*/, LPNMCUSTOMDRAW lpNMCustomDraw) { CDCHandle dc = lpNMCustomDraw->hdc; -#if (_WIN32_IE >= 0x0400) RECT& rc = lpNMCustomDraw->rc; -#else // !(_WIN32_IE >= 0x0400) - RECT rc = { 0 }; - m_tb.GetItemRect(0, &rc); -#endif // !(_WIN32_IE >= 0x0400) RECT rcImage = { m_xBtnImageLeft, m_yBtnImageTop, m_xBtnImageRight + 1, m_yBtnImageBottom + 1 }; ::OffsetRect(&rcImage, rc.left, rc.top); @@ -2707,21 +2585,11 @@ public: if(m_hFont == NULL) { // The same as AtlCreateControlFont() for horizontal pane -#ifndef _WIN32_WCE - LOGFONT lf = { 0 }; + LOGFONT lf = {}; ATLVERIFY(::SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(LOGFONT), &lf, 0) != FALSE); if(IsVertical()) lf.lfEscapement = 900; // 90 degrees m_hFont = ::CreateFontIndirect(&lf); -#else // CE specific - m_hFont = (HFONT)::GetStockObject(SYSTEM_FONT); - if(IsVertical()) - { - CLogFont lf(m_hFont); - lf.lfEscapement = 900; // 90 degrees - m_hFont = ::CreateFontIndirect(&lf); - } -#endif // _WIN32_WCE m_bInternalFont = true; } @@ -2734,8 +2602,8 @@ public: void UpdateLayout(int cxWidth, int cyHeight) { - ATLASSERT(::IsWindow(m_hWnd)); - RECT rect = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + RECT rect = {}; if(IsVertical()) { @@ -2760,24 +2628,24 @@ public: rect.bottom = cyHeight; } - InvalidateRect(&rect); + this->InvalidateRect(&rect); } void CreateCloseButton() { ATLASSERT(m_tb.m_hWnd == NULL); // create toolbar for the "x" button - m_tb.Create(m_hWnd, rcDefault, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | CCS_NODIVIDER | CCS_NORESIZE | CCS_NOPARENTALIGN | CCS_NOMOVEY | TBSTYLE_TOOLTIPS | TBSTYLE_FLAT, 0); + m_tb.Create(this->m_hWnd, this->rcDefault, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | CCS_NODIVIDER | CCS_NORESIZE | CCS_NOPARENTALIGN | CCS_NOMOVEY | TBSTYLE_TOOLTIPS | TBSTYLE_FLAT, 0); ATLASSERT(m_tb.IsWindow()); if(m_tb.m_hWnd != NULL) { T* pT = static_cast(this); - pT; // avoid level 4 warning + (void)pT; // avoid level 4 warning m_tb.SetButtonStructSize(); - TBBUTTON tbbtn = { 0 }; + TBBUTTON tbbtn = {}; tbbtn.idCommand = pT->m_nCloseBtnID; tbbtn.fsState = TBSTATE_ENABLED; tbbtn.fsStyle = BTNS_BUTTON; @@ -2805,7 +2673,7 @@ public: CFontHandle font = pT->GetTitleFont(); if(font.IsNull()) font = (HFONT)::GetStockObject(SYSTEM_FONT); - LOGFONT lf = { 0 }; + LOGFONT lf = {}; font.GetLogFont(lf); if(IsVertical()) { @@ -2824,17 +2692,15 @@ public: return m_hFont; } -#ifndef _WIN32_WCE BOOL GetToolTipText(LPNMHDR /*lpnmh*/) { return FALSE; } -#endif // !_WIN32_WCE void DrawPaneTitle(CDCHandle dc) { - RECT rect = { 0 }; - GetClientRect(&rect); + RECT rect = {}; + this->GetClientRect(&rect); UINT uBorder = BF_LEFT | BF_TOP | BF_ADJUST; if(IsVertical()) @@ -2866,9 +2732,6 @@ public: dc.SetBkMode(TRANSPARENT); T* pT = static_cast(this); HFONT hFontOld = dc.SelectFont(pT->GetTitleFont()); -#if defined(_WIN32_WCE) && !defined(DT_END_ELLIPSIS) - const UINT DT_END_ELLIPSIS = 0; -#endif // defined(_WIN32_WCE) && !defined(DT_END_ELLIPSIS) if(IsVertical()) { @@ -2879,7 +2742,7 @@ public: RECT rcCalc = { rect.left, rect.bottom, rect.right, rect.top }; int cxFont = dc.DrawText(m_szTitle, -1, &rcCalc, DT_TOP | DT_SINGLELINE | DT_END_ELLIPSIS | DT_CALCRECT); - RECT rcText = { 0 }; + RECT rcText = {}; rcText.left = (rect.right - rect.left - cxFont) / 2; rcText.right = rcText.left + (rect.bottom - rect.top); rcText.top = rect.bottom; @@ -2901,31 +2764,29 @@ public: void DrawPaneTitleBackground(CDCHandle dc) { - RECT rect = { 0 }; - GetClientRect(&rect); + RECT rect = {}; + this->GetClientRect(&rect); if(IsVertical()) rect.right = m_cxyHeader; else rect.bottom = m_cxyHeader; -#if (!defined(_WIN32_WCE) && !defined(_ATL_NO_MSIMG)) || (_WIN32_WCE >= 420) if((m_dwExtendedStyle & PANECNT_GRADIENT) != 0) dc.GradientFillRect(rect, ::GetSysColor(COLOR_WINDOW), ::GetSysColor(COLOR_3DFACE), IsVertical()); else -#endif // (!defined(_WIN32_WCE) && !defined(_ATL_NO_MSIMG)) || (_WIN32_WCE >= 420) dc.FillRect(&rect, COLOR_3DFACE); } // called only if pane is empty void DrawPane(CDCHandle dc) { - RECT rect = { 0 }; - GetClientRect(&rect); + RECT rect = {}; + this->GetClientRect(&rect); if(IsVertical()) rect.left += m_cxyHeader; else rect.top += m_cxyHeader; - if((GetExStyle() & WS_EX_CLIENTEDGE) == 0) + if((this->GetExStyle() & WS_EX_CLIENTEDGE) == 0) dc.DrawEdge(&rect, EDGE_SUNKEN, BF_RECT | BF_ADJUST); dc.FillRect(&rect, COLOR_APPWORKSPACE); } @@ -2933,7 +2794,6 @@ public: // drawing helper - draws "x" button image void DrawButtonImage(CDCHandle dc, RECT& rcImage, HPEN hPen) { -#if !defined(_WIN32_WCE) || (_WIN32_WCE >= 400) HPEN hPenOld = dc.SelectPen(hPen); dc.MoveTo(rcImage.left, rcImage.top); @@ -2947,11 +2807,6 @@ public: dc.LineTo(rcImage.right + 1, rcImage.top - 1); dc.SelectPen(hPenOld); -#else // (_WIN32_WCE < 400) - rcImage; - hPen; - // no support for the "x" button image -#endif // (_WIN32_WCE < 400) } bool IsVertical() const @@ -3058,12 +2913,10 @@ public: m_dwSortLVExtendedStyle(SORTLV_USESHELLBITMAPS), m_bUseWaitCursor(true) { -#ifndef _WIN32_WCE DWORD dwMajor = 0; DWORD dwMinor = 0; HRESULT hRet = ATL::AtlGetCommCtrlVersion(&dwMajor, &dwMinor); - m_bCommCtrl6 = SUCCEEDED(hRet) && dwMajor >= 6; -#endif // !_WIN32_WCE + m_bCommCtrl6 = SUCCEEDED(hRet) && (dwMajor >= 6); } // Attributes @@ -3073,26 +2926,20 @@ public: ATLASSERT(::IsWindow(pT->m_hWnd)); CHeaderCtrl header = pT->GetHeader(); ATLASSERT(header.m_hWnd != NULL); - ATLASSERT(iCol >= -1 && iCol < m_arrColSortType.GetSize()); + ATLASSERT((iCol >= -1) && (iCol < m_arrColSortType.GetSize())); int iOldSortCol = m_iSortColumn; m_iSortColumn = iCol; if(m_bCommCtrl6) { -#ifndef HDF_SORTUP - const int HDF_SORTUP = 0x0400; -#endif // HDF_SORTUP -#ifndef HDF_SORTDOWN - const int HDF_SORTDOWN = 0x0200; -#endif // HDF_SORTDOWN const int nMask = HDF_SORTUP | HDF_SORTDOWN; HDITEM hditem = { HDI_FORMAT }; - if(iOldSortCol != iCol && iOldSortCol >= 0 && header.GetItem(iOldSortCol, &hditem)) + if((iOldSortCol != iCol) && (iOldSortCol >= 0) && header.GetItem(iOldSortCol, &hditem)) { hditem.fmt &= ~nMask; header.SetItem(iOldSortCol, &hditem); } - if(iCol >= 0 && header.GetItem(iCol, &hditem)) + if((iCol >= 0) && header.GetItem(iCol, &hditem)) { hditem.fmt &= ~nMask; hditem.fmt |= m_bSortDescending ? HDF_SORTDOWN : HDF_SORTUP; @@ -3106,7 +2953,7 @@ public: // restore previous sort column's bitmap, if any, and format HDITEM hditem = { HDI_BITMAP | HDI_FORMAT }; - if(iOldSortCol != iCol && iOldSortCol >= 0) + if((iOldSortCol != iCol) && (iOldSortCol >= 0)) { hditem.hbm = m_hbmOldSortCol; hditem.fmt = m_fmtOldSortCol; @@ -3114,7 +2961,7 @@ public: } // save new sort column's bitmap and format, and add our sort bitmap - if(iCol >= 0 && header.GetItem(iCol, &hditem)) + if((iCol >= 0) && header.GetItem(iCol, &hditem)) { if(iOldSortCol != iCol) { @@ -3136,14 +2983,14 @@ public: void SetColumnSortType(int iCol, WORD wType) { - ATLASSERT(iCol >= 0 && iCol < m_arrColSortType.GetSize()); - ATLASSERT(wType >= LVCOLSORT_NONE && wType <= LVCOLSORT_LAST); + ATLASSERT((iCol >= 0) && (iCol < m_arrColSortType.GetSize())); + ATLASSERT((wType >= LVCOLSORT_NONE) && (wType <= LVCOLSORT_LAST)); m_arrColSortType[iCol] = wType; } WORD GetColumnSortType(int iCol) const { - ATLASSERT((iCol >= 0) && iCol < m_arrColSortType.GetSize()); + ATLASSERT((iCol >= 0) && (iCol < m_arrColSortType.GetSize())); return m_arrColSortType[iCol]; } @@ -3180,7 +3027,7 @@ public: { T* pT = static_cast(this); ATLASSERT(::IsWindow(pT->m_hWnd)); - ATLASSERT(iCol >= 0 && iCol < m_arrColSortType.GetSize()); + ATLASSERT((iCol >= 0) && (iCol < m_arrColSortType.GetSize())); WORD wType = m_arrColSortType[iCol]; if(wType == LVCOLSORT_NONE) @@ -3201,7 +3048,7 @@ public: LVCompareParam* pParam = NULL; ATLTRY(pParam = new LVCompareParam[nCount]); PFNLVCOMPARE pFunc = NULL; - TCHAR pszTemp[pT->m_cchCmpTextMax] = { 0 }; + TCHAR pszTemp[pT->m_cchCmpTextMax] = {}; bool bStrValue = false; switch(wType) @@ -3339,11 +3186,7 @@ public: if(!m_bmSort[i].IsNull()) m_bmSort[i].DeleteObject(); m_bmSort[i] = (HBITMAP)::LoadImage(hShell, MAKEINTRESOURCE(m_nShellSortUpID + i), -#ifndef _WIN32_WCE IMAGE_BITMAP, 0, 0, LR_LOADMAP3DCOLORS); -#else // CE specific - IMAGE_BITMAP, 0, 0, 0); -#endif // _WIN32_WCE if(m_bmSort[i].IsNull()) { bSuccess = false; @@ -3426,7 +3269,7 @@ public: double DateStrToDouble(LPCTSTR lpstr, DWORD dwFlags) { ATLASSERT(lpstr != NULL); - if(lpstr == NULL || lpstr[0] == _T('\0')) + if((lpstr == NULL) || (lpstr[0] == _T('\0'))) return 0; USES_CONVERSION; @@ -3443,7 +3286,7 @@ public: long StrToLong(LPCTSTR lpstr) { ATLASSERT(lpstr != NULL); - if(lpstr == NULL || lpstr[0] == _T('\0')) + if((lpstr == NULL) || (lpstr[0] == _T('\0'))) return 0; USES_CONVERSION; @@ -3460,7 +3303,7 @@ public: double StrToDouble(LPCTSTR lpstr) { ATLASSERT(lpstr != NULL); - if(lpstr == NULL || lpstr[0] == _T('\0')) + if((lpstr == NULL) || (lpstr[0] == _T('\0'))) return 0; USES_CONVERSION; @@ -3478,7 +3321,7 @@ public: { ATLASSERT(lpstr != NULL); ATLASSERT(pDecimal != NULL); - if(lpstr == NULL || pDecimal == NULL) + if((lpstr == NULL) || (pDecimal == NULL)) return false; USES_CONVERSION; @@ -3497,7 +3340,7 @@ public: // Overrideable PFNLVCOMPARE functions static int CALLBACK LVCompareText(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) { - ATLASSERT(lParam1 != NULL && lParam2 != NULL && lParamSort != NULL); + ATLASSERT((lParam1 != NULL) && (lParam2 != NULL) && (lParamSort != NULL)); LVCompareParam* pParam1 = (LVCompareParam*)lParam1; LVCompareParam* pParam2 = (LVCompareParam*)lParam2; @@ -3509,7 +3352,7 @@ public: static int CALLBACK LVCompareTextNoCase(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) { - ATLASSERT(lParam1 != NULL && lParam2 != NULL && lParamSort != NULL); + ATLASSERT((lParam1 != NULL) && (lParam2 != NULL) && (lParamSort != NULL)); LVCompareParam* pParam1 = (LVCompareParam*)lParam1; LVCompareParam* pParam2 = (LVCompareParam*)lParam2; @@ -3521,7 +3364,7 @@ public: static int CALLBACK LVCompareLong(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) { - ATLASSERT(lParam1 != NULL && lParam2 != NULL && lParamSort != NULL); + ATLASSERT((lParam1 != NULL) && (lParam2 != NULL) && (lParamSort != NULL)); LVCompareParam* pParam1 = (LVCompareParam*)lParam1; LVCompareParam* pParam2 = (LVCompareParam*)lParam2; @@ -3537,7 +3380,7 @@ public: static int CALLBACK LVCompareDouble(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) { - ATLASSERT(lParam1 != NULL && lParam2 != NULL && lParamSort != NULL); + ATLASSERT((lParam1 != NULL) && (lParam2 != NULL) && (lParamSort != NULL)); LVCompareParam* pParam1 = (LVCompareParam*)lParam1; LVCompareParam* pParam2 = (LVCompareParam*)lParam2; @@ -3553,7 +3396,7 @@ public: static int CALLBACK LVCompareCustom(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) { - ATLASSERT(lParam1 != NULL && lParam2 != NULL && lParamSort != NULL); + ATLASSERT((lParam1 != NULL) && (lParam2 != NULL) && (lParamSort != NULL)); LVCompareParam* pParam1 = (LVCompareParam*)lParam1; LVCompareParam* pParam2 = (LVCompareParam*)lParam2; @@ -3563,10 +3406,9 @@ public: return pInfo->bDescending ? -nRet : nRet; } -#ifndef _WIN32_WCE static int CALLBACK LVCompareDecimal(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) { - ATLASSERT(lParam1 != NULL && lParam2 != NULL && lParamSort != NULL); + ATLASSERT((lParam1 != NULL) && (lParam2 != NULL) && (lParamSort != NULL)); LVCompareParam* pParam1 = (LVCompareParam*)lParam1; LVCompareParam* pParam2 = (LVCompareParam*)lParam2; @@ -3576,147 +3418,6 @@ public: nRet--; return pInfo->bDescending ? -nRet : nRet; } -#else - // Compare mantissas, ignore sign and scale - static int CompareMantissas(const DECIMAL& decLeft, const DECIMAL& decRight) - { - if (decLeft.Hi32 < decRight.Hi32) - { - return -1; - } - if (decLeft.Hi32 > decRight.Hi32) - { - return 1; - } - // Here, decLeft.Hi32 == decRight.Hi32 - if (decLeft.Lo64 < decRight.Lo64) - { - return -1; - } - if (decLeft.Lo64 > decRight.Lo64) - { - return 1; - } - return 0; - } - - // return values: VARCMP_LT, VARCMP_EQ, VARCMP_GT, VARCMP_NULL - static HRESULT VarDecCmp(const DECIMAL* pdecLeft, const DECIMAL* pdecRight) - { - static const ULONG powersOfTen[] = - { - 10ul, - 100ul, - 1000ul, - 10000ul, - 100000ul, - 1000000ul, - 10000000ul, - 100000000ul, - 1000000000ul - }; - static const int largestPower = sizeof(powersOfTen) / sizeof(powersOfTen[0]); - if (!pdecLeft || !pdecRight) - { - return VARCMP_NULL; - } - - // Degenerate case - at least one comparand is of the form - // [+-]0*10^N (denormalized zero) - bool bLeftZero = (!pdecLeft->Lo64 && !pdecLeft->Hi32); - bool bRightZero = (!pdecRight->Lo64 && !pdecRight->Hi32); - if (bLeftZero && bRightZero) - { - return VARCMP_EQ; - } - bool bLeftNeg = ((pdecLeft->sign & DECIMAL_NEG) != 0); - bool bRightNeg = ((pdecRight->sign & DECIMAL_NEG) != 0); - if (bLeftZero) - { - return (bRightNeg ? VARCMP_GT : VARCMP_LT); - } - // This also covers the case where the comparands have different signs - if (bRightZero || bLeftNeg != bRightNeg) - { - return (bLeftNeg ? VARCMP_LT : VARCMP_GT); - } - - // Here both comparands have the same sign and need to be compared - // on mantissa and scale. The result is obvious when - // 1. Scales are equal (then compare mantissas) - // 2. A number with smaller scale is also the one with larger mantissa - // (then this number is obviously larger) - // In the remaining case, we would multiply the number with smaller - // scale by 10 and simultaneously increment its scale (which amounts to - // adding trailing zeros after decimal point), until the numbers fall under - // one of the two cases above - DECIMAL temp; - bool bInvert = bLeftNeg; // the final result needs to be inverted - if (pdecLeft->scale < pdecRight->scale) - { - temp = *pdecLeft; - } - else - { - temp = *pdecRight; - pdecRight = pdecLeft; - bInvert = !bInvert; - } - - // Now temp is the number with smaller (or equal) scale, and - // we can modify it freely without touching original parameters - int comp; - while ((comp = CompareMantissas(temp, *pdecRight)) < 0 && - temp.scale < pdecRight->scale) - { - // Multiply by an appropriate power of 10 - int scaleDiff = pdecRight->scale - temp.scale; - if (scaleDiff > largestPower) - { - // Keep the multiplier representable in 32bit - scaleDiff = largestPower; - } - DWORDLONG power = powersOfTen[scaleDiff - 1]; - // Multiply temp's mantissa by power - DWORDLONG product = temp.Lo32 * power; - ULONG carry = static_cast(product >> 32); - temp.Lo32 = static_cast(product); - product = temp.Mid32 * power + carry; - carry = static_cast(product >> 32); - temp.Mid32 = static_cast(product); - product = temp.Hi32 * power + carry; - if (static_cast(product >> 32)) - { - // Multiplication overflowed - pdecLeft is clearly larger - break; - } - temp.Hi32 = static_cast(product); - temp.scale = (BYTE)(temp.scale + scaleDiff); - } - if (temp.scale < pdecRight->scale) - { - comp = 1; - } - if (bInvert) - { - comp = -comp; - } - return (comp > 0 ? VARCMP_GT : comp < 0 ? VARCMP_LT : VARCMP_EQ); - } - - static int CALLBACK LVCompareDecimal(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) - { - ATLASSERT(lParam1 != NULL && lParam2 != NULL && lParamSort != NULL); - - LVCompareParam* pParam1 = (LVCompareParam*)lParam1; - LVCompareParam* pParam2 = (LVCompareParam*)lParam2; - LVSortInfo* pInfo = (LVSortInfo*)lParamSort; - - int nRet = (int)VarDecCmp(&pParam1->decValue, &pParam2->decValue); - nRet--; - return pInfo->bDescending ? -nRet : nRet; - } -#endif // !_WIN32_WCE BEGIN_MSG_MAP(CSortListViewImpl) MESSAGE_HANDLER(LVM_INSERTCOLUMN, OnInsertColumn) @@ -3781,13 +3482,8 @@ public: LRESULT OnSettingChange(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) { -#ifndef _WIN32_WCE if(wParam == SPI_SETNONCLIENTMETRICS) GetSystemSettings(); -#else // CE specific - wParam; // avoid level 4 warning - GetSystemSettings(); -#endif // _WIN32_WCE bHandled = FALSE; return 0; } @@ -3812,11 +3508,11 @@ template , public CSortListViewImpl { public: - DECLARE_WND_SUPERCLASS(NULL, TBase::GetWndClassName()) + DECLARE_WND_SUPERCLASS2(NULL, T, TBase::GetWndClassName()) bool SortItems(int iCol, bool bDescending = false) { - return DoSortItems(iCol, bDescending); + return this->DoSortItems(iCol, bDescending); } BEGIN_MSG_MAP(CSortListViewCtrlImpl) @@ -3839,8 +3535,11 @@ public: // CTabView - implements tab view window // TabView Notifications -#define TBVN_PAGEACTIVATED (0U-741) -#define TBVN_CONTEXTMENU (0U-742) +#define TBVN_PAGEACTIVATED (0U-741) +#define TBVN_CONTEXTMENU (0U-742) +#define TBVN_TABCLOSEBTN (0U-743) // return 0 to close page, 1 to keep open +// internal +#define TBVN_CLOSEBTNMOUSELEAVE (0U-744) // Notification data for TBVN_CONTEXTMENU struct TBVCONTEXTMENUINFO @@ -3852,11 +3551,191 @@ struct TBVCONTEXTMENUINFO typedef TBVCONTEXTMENUINFO* LPTBVCONTEXTMENUINFO; +// Helper class for tab item hover close button +class CTabViewCloseBtn : public ATL::CWindowImpl +{ +public: + DECLARE_WND_CLASS_EX(_T("WTL_TabView_CloseBtn"), 0, -1) + + enum { _xyBtnImageLeftTop = 3, _xyBtnImageRightBottom = 9 }; + + bool m_bHover; + bool m_bPressed; + CToolTipCtrl m_tip; + + CTabViewCloseBtn() : m_bHover(false), m_bPressed(false) + { } + +// Message map and handlers + BEGIN_MSG_MAP(CTabViewCloseBtn) + MESSAGE_RANGE_HANDLER(WM_MOUSEFIRST, WM_MOUSELAST, OnMouseMessage) + MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown) + MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove) + MESSAGE_HANDLER(WM_MOUSELEAVE, OnMouseLeave) + MESSAGE_HANDLER(WM_LBUTTONUP, OnLButtonUp) + MESSAGE_HANDLER(WM_CAPTURECHANGED, OnCaptureChanged) + MESSAGE_HANDLER(WM_PAINT, OnPaint) + MESSAGE_HANDLER(WM_PRINTCLIENT, OnPaint) + FORWARD_NOTIFICATIONS() + END_MSG_MAP() + + LRESULT OnMouseMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) + { + MSG msg = { m_hWnd, uMsg, wParam, lParam }; + if(m_tip.IsWindow() != FALSE) + m_tip.RelayEvent(&msg); + + bHandled = FALSE; + return 1; + } + + LRESULT OnLButtonDown(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + SetCapture(); + m_bHover = false; + m_bPressed = true; + Invalidate(FALSE); + UpdateWindow(); + + return 0; + } + + LRESULT OnMouseMove(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/) + { + if(::GetCapture() == m_hWnd) + { + POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; + ClientToScreen(&pt); + RECT rect = {}; + GetWindowRect(&rect); + bool bPressed = (::PtInRect(&rect, pt) != FALSE); + if(m_bPressed != bPressed) + { + m_bPressed = bPressed; + Invalidate(FALSE); + UpdateWindow(); + } + } + else + { + if(!m_bHover) + { + m_bHover = true; + Invalidate(FALSE); + UpdateWindow(); + } + + TRACKMOUSEEVENT tme = { sizeof(TRACKMOUSEEVENT), TME_LEAVE, m_hWnd }; + ::TrackMouseEvent(&tme); + } + + return 0; + } + + LRESULT OnMouseLeave(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + if(m_bHover) + { + m_bHover = false; + Invalidate(FALSE); + UpdateWindow(); + } + + NMHDR nmhdr = { m_hWnd, (UINT_PTR)GetDlgCtrlID(), TBVN_CLOSEBTNMOUSELEAVE }; + GetParent().SendMessage(WM_NOTIFY, GetDlgCtrlID(), (LPARAM)&nmhdr); + + return 0; + } + + LRESULT OnLButtonUp(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + if(::GetCapture() == m_hWnd) + { + bool bAction = m_bPressed; + ReleaseCapture(); + + if(bAction) + GetParent().SendMessage(WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(), BN_CLICKED), (LPARAM)m_hWnd); + } + + return 0; + } + + LRESULT OnCaptureChanged(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + if(m_bPressed) + { + m_bPressed = false; + Invalidate(FALSE); + UpdateWindow(); + } + + return 0; + } + + LRESULT OnPaint(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + if(wParam != NULL) + { + DoPaint((HDC)wParam); + } + else + { + CPaintDC dc(this->m_hWnd); + DoPaint(dc.m_hDC); + } + + return 0; + } + + // painting helper + void DoPaint(CDCHandle dc) + { + RECT rect = {}; + GetClientRect(&rect); + + RECT rcImage = { _xyBtnImageLeftTop, _xyBtnImageLeftTop, _xyBtnImageRightBottom + 1, _xyBtnImageRightBottom + 1 }; + ::OffsetRect(&rcImage, rect.left, rect.top); + if(m_bPressed) + ::OffsetRect(&rcImage, 1, 0); + + // draw button frame and background + CPen penFrame; + penFrame.CreatePen(PS_SOLID, 0, ::GetSysColor((m_bHover || m_bPressed) ? COLOR_BTNTEXT : COLOR_BTNSHADOW)); + HPEN hPenOld = dc.SelectPen(penFrame); + + CBrush brush; + brush.CreateSysColorBrush(m_bPressed ? COLOR_BTNSHADOW : COLOR_WINDOW); + HBRUSH hBrushOld = dc.SelectBrush(brush); + + dc.Rectangle(&rect); + + // draw button "X" + CPen penX; + penX.CreatePen(PS_SOLID, 0, ::GetSysColor(COLOR_BTNTEXT)); + dc.SelectPen(penX); + + dc.MoveTo(rcImage.left, rcImage.top); + dc.LineTo(rcImage.right, rcImage.bottom); + dc.MoveTo(rcImage.left + 1, rcImage.top); + dc.LineTo(rcImage.right + 1, rcImage.bottom); + + dc.MoveTo(rcImage.left, rcImage.bottom - 1); + dc.LineTo(rcImage.right, rcImage.top - 1); + dc.MoveTo(rcImage.left + 1, rcImage.bottom - 1); + dc.LineTo(rcImage.right + 1, rcImage.top - 1); + + dc.SelectPen(hPenOld); + dc.SelectBrush(hBrushOld); + } +}; + + template class ATL_NO_VTABLE CTabViewImpl : public ATL::CWindowImpl< T, TBase, TWinTraits > { public: - DECLARE_WND_CLASS_EX(NULL, 0, COLOR_APPWORKSPACE) + DECLARE_WND_CLASS_EX2(NULL, T, 0, COLOR_APPWORKSPACE) // Declarations and enums struct TABVIEWPAGE @@ -3882,6 +3761,25 @@ public: m_nMenuItemsMax = (ID_WINDOW_TABLAST - ID_WINDOW_TABFIRST + 1) }; + enum { _nAutoScrollTimerID = 4321 }; + + enum AutoScroll + { + _AUTOSCROLL_NONE = 0, + _AUTOSCROLL_LEFT = -1, + _AUTOSCROLL_RIGHT = 1 + }; + + enum CloseBtn + { + _cxCloseBtn = 14, + _cyCloseBtn = 13, + _cxCloseBtnMargin = 4, + _cxCloseBtnMarginSel = 1, + + _nCloseBtnID = ID_PANE_CLOSE + }; + // Data members ATL::CContainedWindowT m_tab; int m_cyTabHeight; @@ -3903,6 +3801,12 @@ public: CImageList m_ilDrag; + AutoScroll m_AutoScroll; + CUpDownCtrl m_ud; + + CTabViewCloseBtn m_btnClose; + int m_nCloseItem; + bool m_bDestroyPageOnRemove:1; bool m_bDestroyImageList:1; bool m_bActivePageMenuItem:1; @@ -3910,6 +3814,8 @@ public: bool m_bEmptyMenuItem:1; bool m_bWindowsMenuItem:1; bool m_bNoTabDrag:1; + bool m_bNoTabDragAutoScroll:1; + bool m_bTabCloseButton:1; // internal bool m_bTabCapture:1; bool m_bTabDrag:1; @@ -3917,14 +3823,16 @@ public: // Constructor/destructor CTabViewImpl() : - m_nActivePage(-1), - m_cyTabHeight(0), - m_tab(this, 1), + m_tab(this, 1), + m_cyTabHeight(0), + m_nActivePage(-1), m_nInsertItem(-1), m_cchTabTextLength(30), m_nMenuItemsCount(10), m_lpstrTitleBarBase(NULL), m_cchTitleBarLength(100), + m_AutoScroll(_AUTOSCROLL_NONE), + m_nCloseItem(-1), m_bDestroyPageOnRemove(true), m_bDestroyImageList(true), m_bActivePageMenuItem(true), @@ -3932,6 +3840,8 @@ public: m_bEmptyMenuItem(false), m_bWindowsMenuItem(false), m_bNoTabDrag(false), + m_bNoTabDragAutoScroll(false), + m_bTabCloseButton(true), m_bTabCapture(false), m_bTabDrag(false), m_bInternalFont(false) @@ -3948,7 +3858,7 @@ public: // Message filter function - to be called from PreTranslateMessage of the main window BOOL PreTranslateMessage(MSG* pMsg) { - if(IsWindow() == FALSE) + if(this->IsWindow() == FALSE) return FALSE; BOOL bRet = FALSE; @@ -3981,7 +3891,7 @@ public: // If we are doing drag-drop, check for Escape key that cancels it if(bRet == FALSE) { - if(m_bTabCapture && pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_ESCAPE) + if(m_bTabCapture && (pMsg->message == WM_KEYDOWN) && (pMsg->wParam == VK_ESCAPE)) { ::ReleaseCapture(); bRet = TRUE; @@ -4001,7 +3911,7 @@ public: // Attributes int GetPageCount() const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); return m_tab.GetItemCount(); } @@ -4012,25 +3922,27 @@ public: void SetActivePage(int nPage) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(IsValidPageIndex(nPage)); T* pT = static_cast(this); - SetRedraw(FALSE); + this->SetRedraw(FALSE); if(m_nActivePage != -1) - ::ShowWindow(GetPageHWND(m_nActivePage), FALSE); + ::ShowWindow(GetPageHWND(m_nActivePage), SW_HIDE); m_nActivePage = nPage; m_tab.SetCurSel(m_nActivePage); - ::ShowWindow(GetPageHWND(m_nActivePage), TRUE); + ::ShowWindow(GetPageHWND(m_nActivePage), SW_SHOW); pT->UpdateLayout(); - SetRedraw(TRUE); - RedrawWindow(NULL, NULL, RDW_FRAME | RDW_INVALIDATE | RDW_UPDATENOW | RDW_ALLCHILDREN); + this->SetRedraw(TRUE); + this->RedrawWindow(NULL, NULL, RDW_FRAME | RDW_INVALIDATE | RDW_UPDATENOW | RDW_ALLCHILDREN); - if(::GetFocus() != m_tab.m_hWnd) + HWND hWndFocus = ::GetFocus(); + ATL::CWindow wndTop = this->GetTopLevelWindow(); + if((hWndFocus == wndTop.m_hWnd) || ((wndTop.IsChild(hWndFocus) != FALSE) && (hWndFocus != m_tab.m_hWnd))) ::SetFocus(GetPageHWND(m_nActivePage)); pT->UpdateTitleBar(); @@ -4039,19 +3951,19 @@ public: HIMAGELIST GetImageList() const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); return m_tab.GetImageList(); } HIMAGELIST SetImageList(HIMAGELIST hImageList) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); return m_tab.SetImageList(hImageList); } void SetWindowMenu(HMENU hMenu) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); m_menu = hMenu; @@ -4061,7 +3973,7 @@ public: void SetTitleBarWindow(HWND hWnd) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); delete [] m_lpstrTitleBarBase; m_lpstrTitleBarBase = NULL; @@ -4083,10 +3995,10 @@ public: // Page attributes HWND GetPageHWND(int nPage) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(IsValidPageIndex(nPage)); - TCITEMEXTRA tcix = { 0 }; + TCITEMEXTRA tcix = {}; tcix.tciheader.mask = TCIF_PARAM; m_tab.GetItem(nPage, tcix); @@ -4095,10 +4007,10 @@ public: LPCTSTR GetPageTitle(int nPage) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(IsValidPageIndex(nPage)); - TCITEMEXTRA tcix = { 0 }; + TCITEMEXTRA tcix = {}; tcix.tciheader.mask = TCIF_PARAM; if(m_tab.GetItem(nPage, tcix) == FALSE) return NULL; @@ -4108,7 +4020,7 @@ public: bool SetPageTitle(int nPage, LPCTSTR lpstrTitle) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(IsValidPageIndex(nPage)); T* pT = static_cast(this); @@ -4119,13 +4031,13 @@ public: if(lpstrBuff == NULL) return false; - SecureHelper::strcpy_x(lpstrBuff, cchBuff, lpstrTitle); - TCITEMEXTRA tcix = { 0 }; + ATL::Checked::tcscpy_s(lpstrBuff, cchBuff, lpstrTitle); + TCITEMEXTRA tcix = {}; tcix.tciheader.mask = TCIF_PARAM; if(m_tab.GetItem(nPage, tcix) == FALSE) return false; - CTempBuffer buff; + ATL::CTempBuffer buff; LPTSTR lpstrTabText = buff.Allocate(m_cchTabTextLength + 1); if(lpstrTabText == NULL) return false; @@ -4148,10 +4060,10 @@ public: LPVOID GetPageData(int nPage) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(IsValidPageIndex(nPage)); - TCITEMEXTRA tcix = { 0 }; + TCITEMEXTRA tcix = {}; tcix.tciheader.mask = TCIF_PARAM; m_tab.GetItem(nPage, tcix); @@ -4160,10 +4072,10 @@ public: LPVOID SetPageData(int nPage, LPVOID pData) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(IsValidPageIndex(nPage)); - TCITEMEXTRA tcix = { 0 }; + TCITEMEXTRA tcix = {}; tcix.tciheader.mask = TCIF_PARAM; m_tab.GetItem(nPage, tcix); LPVOID pDataOld = tcix.tvpage.pData; @@ -4176,10 +4088,10 @@ public: int GetPageImage(int nPage) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(IsValidPageIndex(nPage)); - TCITEMEXTRA tcix = { 0 }; + TCITEMEXTRA tcix = {}; tcix.tciheader.mask = TCIF_IMAGE; m_tab.GetItem(nPage, tcix); @@ -4188,10 +4100,10 @@ public: int SetPageImage(int nPage, int nImage) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(IsValidPageIndex(nPage)); - TCITEMEXTRA tcix = { 0 }; + TCITEMEXTRA tcix = {}; tcix.tciheader.mask = TCIF_IMAGE; m_tab.GetItem(nPage, tcix); int nImageOld = tcix.tciheader.iImage; @@ -4210,8 +4122,8 @@ public: bool InsertPage(int nPage, HWND hWndView, LPCTSTR lpstrTitle, int nImage = -1, LPVOID pData = NULL) { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT(nPage == GetPageCount() || IsValidPageIndex(nPage)); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((nPage == GetPageCount()) || IsValidPageIndex(nPage)); T* pT = static_cast(this); @@ -4221,18 +4133,18 @@ public: if(lpstrBuff == NULL) return false; - SecureHelper::strcpy_x(lpstrBuff, cchBuff, lpstrTitle); + ATL::Checked::tcscpy_s(lpstrBuff, cchBuff, lpstrTitle); - CTempBuffer buff; + ATL::CTempBuffer buff; LPTSTR lpstrTabText = buff.Allocate(m_cchTabTextLength + 1); if(lpstrTabText == NULL) return false; pT->ShortenTitle(lpstrTitle, lpstrTabText, m_cchTabTextLength + 1); - SetRedraw(FALSE); + this->SetRedraw(FALSE); - TCITEMEXTRA tcix = { 0 }; + TCITEMEXTRA tcix = {}; tcix.tciheader.mask = TCIF_TEXT | TCIF_IMAGE | TCIF_PARAM; tcix.tciheader.pszText = lpstrTabText; tcix.tciheader.iImage = nImage; @@ -4243,7 +4155,7 @@ public: if(nItem == -1) { delete [] lpstrBuff; - SetRedraw(TRUE); + this->SetRedraw(TRUE); return false; } @@ -4259,20 +4171,20 @@ public: pT->UpdateLayout(); - SetRedraw(TRUE); - RedrawWindow(NULL, NULL, RDW_FRAME | RDW_INVALIDATE | RDW_UPDATENOW | RDW_ALLCHILDREN); + this->SetRedraw(TRUE); + this->RedrawWindow(NULL, NULL, RDW_FRAME | RDW_INVALIDATE | RDW_UPDATENOW | RDW_ALLCHILDREN); return true; } void RemovePage(int nPage) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(IsValidPageIndex(nPage)); T* pT = static_cast(this); - SetRedraw(FALSE); + this->SetRedraw(FALSE); if(GetPageCount() == 1) pT->ShowTabControl(false); @@ -4280,7 +4192,7 @@ public: if(m_bDestroyPageOnRemove) ::DestroyWindow(GetPageHWND(nPage)); else - ::ShowWindow(GetPageHWND(nPage), FALSE); + ::ShowWindow(GetPageHWND(nPage), SW_HIDE); LPTSTR lpstrTitle = (LPTSTR)GetPageTitle(nPage); delete [] lpstrTitle; @@ -4300,9 +4212,9 @@ public: } else { - SetRedraw(TRUE); - Invalidate(); - UpdateWindow(); + this->SetRedraw(TRUE); + this->Invalidate(); + this->UpdateWindow(); pT->UpdateTitleBar(); pT->UpdateMenu(); } @@ -4319,14 +4231,14 @@ public: void RemoveAllPages() { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); if(GetPageCount() == 0) return; T* pT = static_cast(this); - SetRedraw(FALSE); + this->SetRedraw(FALSE); pT->ShowTabControl(false); @@ -4335,7 +4247,7 @@ public: if(m_bDestroyPageOnRemove) ::DestroyWindow(GetPageHWND(i)); else - ::ShowWindow(GetPageHWND(i), FALSE); + ::ShowWindow(GetPageHWND(i), SW_HIDE); LPTSTR lpstrTitle = (LPTSTR)GetPageTitle(i); delete [] lpstrTitle; } @@ -4344,9 +4256,9 @@ public: m_nActivePage = -1; pT->OnPageActivated(m_nActivePage); - SetRedraw(TRUE); - Invalidate(); - UpdateWindow(); + this->SetRedraw(TRUE); + this->Invalidate(); + this->UpdateWindow(); pT->UpdateTitleBar(); pT->UpdateMenu(); @@ -4370,33 +4282,20 @@ public: void BuildWindowMenu(HMENU hMenu, int nMenuItemsCount = 10, bool bEmptyMenuItem = true, bool bWindowsMenuItem = true, bool bActivePageMenuItem = true, bool bActiveAsDefaultMenuItem = false) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); CMenuHandle menu = hMenu; T* pT = static_cast(this); - pT; // avoid level 4 warning + (void)pT; // avoid level 4 warning int nFirstPos = 0; // Find first menu item in our range -#ifndef _WIN32_WCE for(nFirstPos = 0; nFirstPos < menu.GetMenuItemCount(); nFirstPos++) { UINT nID = menu.GetMenuItemID(nFirstPos); - if((nID >= ID_WINDOW_TABFIRST && nID <= ID_WINDOW_TABLAST) || nID == ID_WINDOW_SHOWTABLIST) - break; - } -#else // CE specific - for(nFirstPos = 0; ; nFirstPos++) - { - CMenuItemInfo mii; - mii.fMask = MIIM_ID; - BOOL bRet = menu.GetMenuItemInfo(nFirstPos, TRUE, &mii); - if(bRet == FALSE) - break; - if((mii.wID >= ID_WINDOW_TABFIRST && mii.wID <= ID_WINDOW_TABLAST) || mii.wID == ID_WINDOW_SHOWTABLIST) + if(((nID >= ID_WINDOW_TABFIRST) && (nID <= ID_WINDOW_TABLAST)) || (nID == ID_WINDOW_SHOWTABLIST)) break; } -#endif // _WIN32_WCE // Remove all menu items for tab pages BOOL bRet = TRUE; @@ -4410,7 +4309,7 @@ public: CMenuItemInfo mii; mii.fMask = MIIM_TYPE; menu.GetMenuItemInfo(nFirstPos - 1, TRUE, &mii); - if((nFirstPos <= 0) || ((mii.fType & MFT_SEPARATOR) == 0)) + if((mii.fType & MFT_SEPARATOR) == 0) { menu.AppendMenu(MF_SEPARATOR); nFirstPos++; @@ -4431,13 +4330,13 @@ public: { LPCTSTR lpstrTitle = GetPageTitle(i); int nLen = lstrlen(lpstrTitle); - CTempBuffer buff; + ATL::CTempBuffer buff; LPTSTR lpstrText = buff.Allocate(cchPrefix + nLen + 1); ATLASSERT(lpstrText != NULL); if(lpstrText != NULL) { LPCTSTR lpstrFormat = (i < 9) ? _T("&%i %s") : _T("%i %s"); - SecureHelper::wsprintf_x(lpstrText, cchPrefix + nLen + 1, lpstrFormat, i + 1, lpstrTitle); + _stprintf_s(lpstrText, cchPrefix + nLen + 1, lpstrFormat, i + 1, lpstrTitle); menu.AppendMenu(MF_STRING, ID_WINDOW_TABFIRST + i, lpstrText); } } @@ -4445,16 +4344,12 @@ public: // Mark active page if(bActivePageMenuItem && (m_nActivePage != -1)) { -#ifndef _WIN32_WCE if(bActiveAsDefaultMenuItem) { menu.SetMenuDefaultItem((UINT)-1, TRUE); menu.SetMenuDefaultItem(nFirstPos + m_nActivePage, TRUE); } else -#else // CE specific - bActiveAsDefaultMenuItem; // avoid level 4 warning -#endif // _WIN32_WCE { menu.CheckMenuRadioItem(nFirstPos, nFirstPos + nMenuItemsCount, nFirstPos + m_nActivePage, MF_BYPOSITION); } @@ -4486,12 +4381,7 @@ public: BOOL SubclassWindow(HWND hWnd) { -#if (_MSC_VER >= 1300) BOOL bRet = ATL::CWindowImpl< T, TBase, TWinTraits >::SubclassWindow(hWnd); -#else // !(_MSC_VER >= 1300) - typedef ATL::CWindowImpl< T, TBase, TWinTraits > _baseClass; - BOOL bRet = _baseClass::SubclassWindow(hWnd); -#endif // !(_MSC_VER >= 1300) if(bRet != FALSE) { T* pT = static_cast(this); @@ -4510,19 +4400,20 @@ public: MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus) MESSAGE_HANDLER(WM_GETFONT, OnGetFont) MESSAGE_HANDLER(WM_SETFONT, OnSetFont) + MESSAGE_HANDLER(WM_TIMER, OnTimer) + MESSAGE_HANDLER(WM_CONTEXTMENU, OnTabContextMenu) NOTIFY_HANDLER(m_nTabID, TCN_SELCHANGE, OnTabChanged) NOTIFY_ID_HANDLER(m_nTabID, OnTabNotification) -#ifndef _WIN32_WCE NOTIFY_CODE_HANDLER(TTN_GETDISPINFO, OnTabGetDispInfo) -#endif // !_WIN32_WCE FORWARD_NOTIFICATIONS() ALT_MSG_MAP(1) // tab control MESSAGE_HANDLER(WM_LBUTTONDOWN, OnTabLButtonDown) MESSAGE_HANDLER(WM_LBUTTONUP, OnTabLButtonUp) MESSAGE_HANDLER(WM_CAPTURECHANGED, OnTabCaptureChanged) MESSAGE_HANDLER(WM_MOUSEMOVE, OnTabMouseMove) - MESSAGE_HANDLER(WM_RBUTTONUP, OnTabRButtonUp) - MESSAGE_HANDLER(WM_SYSKEYDOWN, OnTabSysKeyDown) + MESSAGE_HANDLER(WM_MOUSELEAVE, OnTabMouseLeave) + NOTIFY_HANDLER(T::_nCloseBtnID, TBVN_CLOSEBTNMOUSELEAVE, OnTabCloseBtnMouseLeave) + COMMAND_HANDLER(T::_nCloseBtnID, BN_CLICKED, OnTabCloseBtnClicked) END_MSG_MAP() LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) @@ -4552,6 +4443,8 @@ public: m_bInternalFont = false; } + m_ud.m_hWnd = NULL; + return 0; } @@ -4595,8 +4488,71 @@ public: return 0; } + LRESULT OnTimer(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) + { + if(wParam == _nAutoScrollTimerID) + { + T* pT = static_cast(this); + pT->DoAutoScroll(); + } + else + { + bHandled = FALSE; + } + + return 0; + } + + LRESULT OnTabContextMenu(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled) + { + POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; + int nPage = m_nActivePage; + bool bAction = false; + if((HWND)wParam == m_tab.m_hWnd) + { + if((pt.x == -1) && (pt.y == -1)) // keyboard + { + RECT rect = {}; + m_tab.GetItemRect(m_nActivePage, &rect); + pt.x = rect.left; + pt.y = rect.bottom; + m_tab.ClientToScreen(&pt); + bAction = true; + } + else if(::WindowFromPoint(pt) == m_tab.m_hWnd) + { + TCHITTESTINFO hti = {}; + hti.pt = pt; + this->ScreenToClient(&hti.pt); + nPage = m_tab.HitTest(&hti); + + bAction = true; + } + } + + if(bAction) + { + T* pT = static_cast(this); + pT->OnContextMenu(nPage, pt); + } + else + { + bHandled = FALSE; + } + + return 0; + } + LRESULT OnTabChanged(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/) { + if(m_bTabCloseButton && (m_btnClose.m_hWnd != NULL)) + { + T* pT = static_cast(this); + RECT rcClose = {}; + pT->CalcCloseButtonRect(m_nCloseItem, rcClose); + m_btnClose.SetWindowPos(NULL, &rcClose, SWP_NOZORDER | SWP_NOACTIVATE); + } + SetActivePage(m_tab.GetCurSel()); T* pT = static_cast(this); pT->OnPageActivated(m_nActivePage); @@ -4611,7 +4567,6 @@ public: return 0; } -#ifndef _WIN32_WCE LRESULT OnTabGetDispInfo(int /*idCtrl*/, LPNMHDR pnmh, BOOL& bHandled) { LPNMTTDISPINFO pTTDI = (LPNMTTDISPINFO)pnmh; @@ -4627,7 +4582,6 @@ public: return 0; } -#endif // !_WIN32_WCE // Tab control message handlers LRESULT OnTabLButtonDown(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled) @@ -4651,10 +4605,9 @@ public: { if(m_bTabDrag) { - TCHITTESTINFO hti = { 0 }; - hti.pt.x = GET_X_LPARAM(lParam); - hti.pt.y = GET_Y_LPARAM(lParam); - int nItem = m_tab.HitTest(&hti); + T* pT = static_cast(this); + POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; + int nItem = pT->DragHitTest(pt); if(nItem != -1) MovePage(m_nActivePage, nItem); } @@ -4675,12 +4628,14 @@ public: if(m_bTabDrag) { m_bTabDrag = false; + T* pT = static_cast(this); + if(!m_bNoTabDragAutoScroll) + pT->StartStopAutoScroll(-1); + pT->DrawMoveMark(-1); -#ifndef _WIN32_WCE m_ilDrag.DragLeave(GetDesktopWindow()); -#endif // !_WIN32_WCE m_ilDrag.EndDrag(); m_ilDrag.Destroy(); @@ -4702,13 +4657,8 @@ public: if(!m_bTabDrag) { -#ifndef _WIN32_WCE - if(abs(m_ptStartDrag.x - GET_X_LPARAM(lParam)) >= ::GetSystemMetrics(SM_CXDRAG) || - abs(m_ptStartDrag.y - GET_Y_LPARAM(lParam)) >= ::GetSystemMetrics(SM_CYDRAG)) -#else // CE specific - if(abs(m_ptStartDrag.x - GET_X_LPARAM(lParam)) >= 4 || - abs(m_ptStartDrag.y - GET_Y_LPARAM(lParam)) >= 4) -#endif // _WIN32_WCE + if((abs(m_ptStartDrag.x - GET_X_LPARAM(lParam)) >= ::GetSystemMetrics(SM_CXDRAG)) || + (abs(m_ptStartDrag.y - GET_Y_LPARAM(lParam)) >= ::GetSystemMetrics(SM_CYDRAG))) { T* pT = static_cast(this); pT->GenerateDragImage(m_nActivePage); @@ -4716,11 +4666,9 @@ public: int cxCursor = ::GetSystemMetrics(SM_CXCURSOR); int cyCursor = ::GetSystemMetrics(SM_CYCURSOR); m_ilDrag.BeginDrag(0, -(cxCursor / 2), -(cyCursor / 2)); -#ifndef _WIN32_WCE POINT ptEnter = m_ptStartDrag; m_tab.ClientToScreen(&ptEnter); m_ilDrag.DragEnter(GetDesktopWindow(), ptEnter); -#endif // !_WIN32_WCE m_bTabDrag = true; } @@ -4728,16 +4676,17 @@ public: if(m_bTabDrag) { - TCHITTESTINFO hti = { 0 }; - hti.pt = pt; - int nItem = m_tab.HitTest(&hti); - T* pT = static_cast(this); + int nItem = pT->DragHitTest(pt); + pT->SetMoveCursor(nItem != -1); if(m_nInsertItem != nItem) pT->DrawMoveMark(nItem); + if(!m_bNoTabDragAutoScroll) + pT->StartStopAutoScroll(pt.x); + m_ilDrag.DragShowNolock((nItem != -1) ? TRUE : FALSE); m_tab.ClientToScreen(&pt); m_ilDrag.DragMove(pt); @@ -4745,43 +4694,80 @@ public: bHandled = TRUE; } } + else if(m_bTabCloseButton) + { + TCHITTESTINFO thti = {}; + thti.pt.x = GET_X_LPARAM(lParam); + thti.pt.y = GET_Y_LPARAM(lParam); - return 0; - } + int nItem = m_tab.HitTest(&thti); + if(nItem >= 0) + { + ATLTRACE(_T("+++++ item = %i\n"), nItem); - LRESULT OnTabRButtonUp(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/) - { - TCHITTESTINFO hti = { 0 }; - hti.pt.x = GET_X_LPARAM(lParam); - hti.pt.y = GET_Y_LPARAM(lParam); - int nItem = m_tab.HitTest(&hti); - if(nItem != -1) - { - T* pT = static_cast(this); - pT->OnContextMenu(nItem, hti.pt); + T* pT = static_cast(this); + if(m_btnClose.m_hWnd == NULL) + { + pT->CreateCloseButton(nItem); + m_nCloseItem = nItem; + } + else if(m_nCloseItem != nItem) + { + RECT rcClose = {}; + pT->CalcCloseButtonRect(nItem, rcClose); + m_btnClose.SetWindowPos(NULL, &rcClose, SWP_NOZORDER | SWP_NOACTIVATE); + m_nCloseItem = nItem; + } + + TRACKMOUSEEVENT tme = { sizeof(TRACKMOUSEEVENT), TME_LEAVE, m_tab.m_hWnd }; + ::TrackMouseEvent(&tme); + } } return 0; } - LRESULT OnTabSysKeyDown(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) + LRESULT OnTabMouseLeave(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) { - bool bShift = (::GetKeyState(VK_SHIFT) < 0); - if(wParam == VK_F10 && bShift) + bHandled = FALSE; + + if(m_btnClose.m_hWnd != NULL) { - if(m_nActivePage != -1) + POINT pt = {}; + ::GetCursorPos(&pt); + RECT rect = {}; + m_btnClose.GetWindowRect(&rect); + if(::PtInRect(&rect, pt) == FALSE) { - RECT rect = { 0 }; - m_tab.GetItemRect(m_nActivePage, &rect); - POINT pt = { rect.left, rect.bottom }; + m_nCloseItem = -1; T* pT = static_cast(this); - pT->OnContextMenu(m_nActivePage, pt); + pT->DestroyCloseButton(); + } + else + { + bHandled = TRUE; } } - else - { - bHandled = FALSE; - } + + return 0; + } + + LRESULT OnTabCloseBtnMouseLeave(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/) + { + TCHITTESTINFO thti = {}; + ::GetCursorPos(&thti.pt); + m_tab.ScreenToClient(&thti.pt); + int nItem = m_tab.HitTest(&thti); + if(nItem == -1) + m_tab.SendMessage(WM_MOUSELEAVE); + + return 0; + } + + LRESULT OnTabCloseBtnClicked(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) + { + T* pT = static_cast(this); + pT->OnTabCloseBtn(m_nCloseItem); return 0; } @@ -4789,7 +4775,7 @@ public: // Implementation helpers bool IsValidPageIndex(int nPage) const { - return (nPage >= 0 && nPage < GetPageCount()); + return ((nPage >= 0) && (nPage < GetPageCount())); } bool MovePage(int nMovePage, int nInsertBeforePage) @@ -4803,11 +4789,11 @@ public: if(nMovePage == nInsertBeforePage) return true; // nothing to do - CTempBuffer buff; + ATL::CTempBuffer buff; LPTSTR lpstrTabText = buff.Allocate(m_cchTabTextLength + 1); if(lpstrTabText == NULL) return false; - TCITEMEXTRA tcix = { 0 }; + TCITEMEXTRA tcix = {}; tcix.tciheader.mask = TCIF_TEXT | TCIF_IMAGE | TCIF_PARAM; tcix.tciheader.pszText = lpstrTabText; tcix.tciheader.cchTextMax = m_cchTabTextLength + 1; @@ -4840,11 +4826,7 @@ public: // Implementation overrideables bool CreateTabControl() { -#ifndef _WIN32_WCE - m_tab.Create(m_hWnd, rcDefault, NULL, WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | TCS_TOOLTIPS, 0, m_nTabID); -#else // CE specific - m_tab.Create(m_hWnd, rcDefault, NULL, WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, 0, m_nTabID); -#endif // _WIN32_WCE + m_tab.Create(this->m_hWnd, this->rcDefault, NULL, WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | TCS_TOOLTIPS, 0, m_nTabID); ATLASSERT(m_tab.m_hWnd != NULL); if(m_tab.m_hWnd == NULL) return false; @@ -4864,7 +4846,7 @@ public: { int nCount = m_tab.GetItemCount(); TCHAR szText[] = _T("NS"); - TCITEMEXTRA tcix = { 0 }; + TCITEMEXTRA tcix = {}; tcix.tciheader.mask = TCIF_TEXT; tcix.tciheader.pszText = szText; int nIndex = m_tab.InsertItem(nCount, tcix); @@ -4891,8 +4873,8 @@ public: void UpdateLayout() { - RECT rect = { 0 }; - GetClientRect(&rect); + RECT rect = {}; + this->GetClientRect(&rect); int cyOffset = 0; if(m_tab.IsWindow() && ((m_tab.GetStyle() & WS_VISIBLE) != 0)) @@ -4913,7 +4895,7 @@ public: void UpdateTitleBar() { - if(!m_wndTitleBar.IsWindow() || m_lpstrTitleBarBase == NULL) + if(!m_wndTitleBar.IsWindow() || (m_lpstrTitleBarBase == NULL)) return; // nothing to do if(m_nActivePage != -1) @@ -4922,14 +4904,14 @@ public: LPCTSTR lpstrTitle = pT->GetPageTitle(m_nActivePage); LPCTSTR lpstrDivider = pT->GetTitleDividerText(); int cchBuffer = m_cchTitleBarLength + lstrlen(lpstrDivider) + lstrlen(m_lpstrTitleBarBase) + 1; - CTempBuffer buff; + ATL::CTempBuffer buff; LPTSTR lpstrPageTitle = buff.Allocate(cchBuffer); ATLASSERT(lpstrPageTitle != NULL); if(lpstrPageTitle != NULL) { pT->ShortenTitle(lpstrTitle, lpstrPageTitle, m_cchTitleBarLength + 1); - SecureHelper::strcat_x(lpstrPageTitle, cchBuffer, lpstrDivider); - SecureHelper::strcat_x(lpstrPageTitle, cchBuffer, m_lpstrTitleBarBase); + ATL::Checked::tcscat_s(lpstrPageTitle, cchBuffer, lpstrDivider); + ATL::Checked::tcscat_s(lpstrPageTitle, cchBuffer, m_lpstrTitleBarBase); } else { @@ -4950,7 +4932,7 @@ public: if(m_nInsertItem != -1) { - RECT rect = { 0 }; + RECT rect = {}; pT->GetMoveMarkRect(rect); m_tab.InvalidateRect(&rect); } @@ -4961,7 +4943,7 @@ public: { CClientDC dc(m_tab.m_hWnd); - RECT rect = { 0 }; + RECT rect = {}; pT->GetMoveMarkRect(rect); CPen pen; @@ -4990,7 +4972,7 @@ public: { m_tab.GetClientRect(&rect); - RECT rcItem = { 0 }; + RECT rcItem = {}; m_tab.GetItemRect(m_nInsertItem, &rcItem); if(m_nInsertItem <= m_nActivePage) @@ -5014,19 +4996,14 @@ public: { ATLASSERT(IsValidPageIndex(nItem)); -#ifndef _WIN32_WCE - RECT rcItem = { 0 }; + RECT rcItem = {}; m_tab.GetItemRect(nItem, &rcItem); ::InflateRect(&rcItem, 2, 2); // make bigger to cover selected item -#else // CE specific - nItem; // avoid level 4 warning - RECT rcItem = { 0, 0, 40, 20 }; -#endif // _WIN32_WCE ATLASSERT(m_ilDrag.m_hImageList == NULL); m_ilDrag.Create(rcItem.right - rcItem.left, rcItem.bottom - rcItem.top, ILC_COLORDDB | ILC_MASK, 1, 1); - CClientDC dc(m_hWnd); + CClientDC dc(this->m_hWnd); CDC dcMem; dcMem.CreateCompatibleDC(dc); ATLASSERT(dcMem.m_hDC != NULL); @@ -5037,11 +5014,7 @@ public: ATLASSERT(bmp.m_hBitmap != NULL); HBITMAP hBmpOld = dcMem.SelectBitmap(bmp); -#ifndef _WIN32_WCE m_tab.SendMessage(WM_PRINTCLIENT, (WPARAM)dcMem.m_hDC); -#else // CE specific - dcMem.Rectangle(&rcItem); -#endif // _WIN32_WCE dcMem.SelectBitmap(hBmpOld); ATLVERIFY(m_ilDrag.Add(bmp.m_hBitmap, RGB(255, 0, 255)) != -1); @@ -5053,22 +5026,111 @@ public: { LPCTSTR lpstrEllipsis = _T("..."); int cchEllipsis = lstrlen(lpstrEllipsis); - SecureHelper::strncpy_x(lpstrShortTitle, cchShortTitle, lpstrTitle, cchShortTitle - cchEllipsis - 1); - SecureHelper::strcat_x(lpstrShortTitle, cchShortTitle, lpstrEllipsis); + ATL::Checked::tcsncpy_s(lpstrShortTitle, cchShortTitle, lpstrTitle, cchShortTitle - cchEllipsis - 1); + ATL::Checked::tcscat_s(lpstrShortTitle, cchShortTitle, lpstrEllipsis); } else { - SecureHelper::strcpy_x(lpstrShortTitle, cchShortTitle, lpstrTitle); + ATL::Checked::tcscpy_s(lpstrShortTitle, cchShortTitle, lpstrTitle); } } -#ifndef _WIN32_WCE void UpdateTooltipText(LPNMTTDISPINFO pTTDI) { ATLASSERT(pTTDI != NULL); pTTDI->lpszText = (LPTSTR)GetPageTitle((int)pTTDI->hdr.idFrom); } -#endif // !_WIN32_WCE + + int DragHitTest(POINT pt) const + { + RECT rect = {}; + this->GetClientRect(&rect); + if(::PtInRect(&rect, pt) == FALSE) + return -1; + + m_tab.GetClientRect(&rect); + TCHITTESTINFO hti = {}; + hti.pt.x = pt.x; + hti.pt.y = rect.bottom / 2; // use middle to ignore + int nItem = m_tab.HitTest(&hti); + if(nItem == -1) + { + int nLast = m_tab.GetItemCount() - 1; + RECT rcItem = {}; + m_tab.GetItemRect(nLast, &rcItem); + if(pt.x >= rcItem.right) + nItem = nLast; + } + + return nItem; + } + + void StartStopAutoScroll(int x) + { + AutoScroll scroll = _AUTOSCROLL_NONE; + if(x != -1) + { + RECT rect = {}; + m_tab.GetClientRect(&rect); + int dx = ::GetSystemMetrics(SM_CXVSCROLL); + if((x >= 0) && (x < dx)) + { + RECT rcItem = {}; + m_tab.GetItemRect(0, &rcItem); + if(rcItem.left < rect.left) + scroll = _AUTOSCROLL_LEFT; + } + else if((x >= (rect.right - dx)) && (x < rect.right)) + { + RECT rcItem = {}; + m_tab.GetItemRect(m_tab.GetItemCount() - 1, &rcItem); + if(rcItem.right > rect.right) + scroll = _AUTOSCROLL_RIGHT; + } + } + + if(scroll != _AUTOSCROLL_NONE) + { + if(m_ud.m_hWnd == NULL) + m_ud = m_tab.GetWindow(GW_CHILD); + + if(m_AutoScroll != scroll) + { + m_AutoScroll = scroll; + this->SetTimer(_nAutoScrollTimerID, 300); + } + } + else + { + this->KillTimer(_nAutoScrollTimerID); + m_AutoScroll = _AUTOSCROLL_NONE; + } + } + + void DoAutoScroll() + { + ATLASSERT(m_AutoScroll != _AUTOSCROLL_NONE); + + int nMin = -1, nMax = -1; + m_ud.GetRange(nMin, nMax); + int nPos = m_ud.GetPos(); + + int nNewPos = -1; + if((m_AutoScroll == _AUTOSCROLL_LEFT) && (nPos > nMin)) + nNewPos = nPos - 1; + else if((m_AutoScroll == _AUTOSCROLL_RIGHT) && (nPos < nMax)) + nNewPos = nPos + 1; + if(nNewPos != -1) + { + m_tab.SendMessage(WM_HSCROLL, MAKEWPARAM(SB_THUMBPOSITION, nNewPos)); + m_tab.SendMessage(WM_HSCROLL, MAKEWPARAM(SB_ENDSCROLL, 0)); + + POINT pt = {}; + ::GetCursorPos(&pt); + m_tab.ScreenToClient(&pt); + m_tab.SendMessage(WM_MOUSEMOVE, NULL, MAKELPARAM(pt.x, pt.y)); + } + } // Text for menu items and title bar - override to provide different strings static LPCTSTR GetEmptyListText() @@ -5089,23 +5151,99 @@ public: // Notifications - override to provide different behavior void OnPageActivated(int nPage) { - NMHDR nmhdr = { 0 }; - nmhdr.hwndFrom = m_hWnd; + NMHDR nmhdr = {}; + nmhdr.hwndFrom = this->m_hWnd; nmhdr.idFrom = nPage; nmhdr.code = TBVN_PAGEACTIVATED; - ::SendMessage(GetParent(), WM_NOTIFY, GetDlgCtrlID(), (LPARAM)&nmhdr); + this->GetParent().SendMessage(WM_NOTIFY, this->GetDlgCtrlID(), (LPARAM)&nmhdr); } void OnContextMenu(int nPage, POINT pt) { - m_tab.ClientToScreen(&pt); - - TBVCONTEXTMENUINFO cmi = { 0 }; - cmi.hdr.hwndFrom = m_hWnd; + TBVCONTEXTMENUINFO cmi = {}; + cmi.hdr.hwndFrom = this->m_hWnd; cmi.hdr.idFrom = nPage; cmi.hdr.code = TBVN_CONTEXTMENU; cmi.pt = pt; - ::SendMessage(GetParent(), WM_NOTIFY, GetDlgCtrlID(), (LPARAM)&cmi); + this->GetParent().SendMessage(WM_NOTIFY, this->GetDlgCtrlID(), (LPARAM)&cmi); + } + + void OnTabCloseBtn(int nPage) + { + NMHDR nmhdr = {}; + nmhdr.hwndFrom = this->m_hWnd; + nmhdr.idFrom = nPage; + nmhdr.code = TBVN_TABCLOSEBTN; + LRESULT lRet = this->GetParent().SendMessage(WM_NOTIFY, this->GetDlgCtrlID(), (LPARAM)&nmhdr); + if(lRet == 0) // default - close page + { + T* pT = static_cast(this); + pT->RemovePage(m_nCloseItem); + m_nCloseItem = -1; + pT->DestroyCloseButton(); + } + else + { + m_tab.SendMessage(WM_MOUSELEAVE); + } + } + +// Close button overrideables + void CreateCloseButton(int nItem) + { + ATLASSERT(m_btnClose.m_hWnd == NULL); + + m_btnClose.m_bPressed = false; + + T* pT = static_cast(this); + RECT rcClose = {}; + pT->CalcCloseButtonRect(nItem, rcClose); + m_btnClose.Create(m_tab.m_hWnd, rcClose, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 0, T::_nCloseBtnID); + ATLASSERT(m_btnClose.IsWindow()); + + if(m_btnClose.m_hWnd != NULL) + { + // create a tool tip + ATLASSERT(m_btnClose.m_tip.m_hWnd == NULL); + m_btnClose.m_tip.Create(m_btnClose.m_hWnd); + ATLASSERT(m_btnClose.m_tip.IsWindow()); + + if(m_btnClose.m_tip.IsWindow()) + { + m_btnClose.m_tip.Activate(TRUE); + + RECT rect = {}; + m_btnClose.GetClientRect(&rect); + m_btnClose.m_tip.AddTool(m_btnClose.m_hWnd, LPSTR_TEXTCALLBACK, &rect, T::_nCloseBtnID); + } + } + } + + void DestroyCloseButton() + { + ATLASSERT(m_btnClose.m_hWnd != NULL); + + if(m_btnClose.m_hWnd != NULL) + { + if(m_btnClose.m_tip.IsWindow()) + { + m_btnClose.m_tip.DestroyWindow(); + m_btnClose.m_tip.m_hWnd = NULL; + } + + m_btnClose.DestroyWindow(); + } + } + + void CalcCloseButtonRect(int nItem, RECT& rcClose) + { + RECT rcItem = {}; + m_tab.GetItemRect(nItem, &rcItem); + + int cy = (rcItem.bottom - rcItem.top - _cyCloseBtn) / 2; + int cx = (nItem == m_tab.GetCurSel()) ? _cxCloseBtnMarginSel : _cxCloseBtnMargin; + ::SetRect(&rcClose, rcItem.right - cx - _cxCloseBtn, rcItem.top + cy, + rcItem.right - cx, rcItem.top + cy + _cyCloseBtn); } }; @@ -5115,6 +5253,6 @@ public: DECLARE_WND_CLASS_EX(_T("WTL_TabView"), 0, COLOR_APPWORKSPACE) }; -}; // namespace WTL +} // namespace WTL #endif // __ATLCTRLX_H__ diff --git a/WrlSDK/SampleCode/PluginWinExe/WTL/atlddx.h b/WrlSDK/SampleCode/PluginWinExe/WTL/atlddx.h index aa12bbb0cc7557bd229d91f79c80ca3b195763c2..7723b99a825fc65fff4a61d158e188d927b3c33c 100644 --- a/WrlSDK/SampleCode/PluginWinExe/WTL/atlddx.h +++ b/WrlSDK/SampleCode/PluginWinExe/WTL/atlddx.h @@ -1,4 +1,4 @@ -// Windows Template Library - WTL version 9.10 +// Windows Template Library - WTL version 10.0 // Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. // // This file is a part of the Windows Template Library. @@ -15,13 +15,7 @@ #error atlddx.h requires atlapp.h to be included first #endif -#if defined(_ATL_USE_DDX_FLOAT) && defined(_ATL_MIN_CRT) - #error Cannot use floating point DDX with _ATL_MIN_CRT defined -#endif // defined(_ATL_USE_DDX_FLOAT) && defined(_ATL_MIN_CRT) - -#ifdef _ATL_USE_DDX_FLOAT - #include -#endif // _ATL_USE_DDX_FLOAT +#include /////////////////////////////////////////////////////////////////////////////// @@ -45,90 +39,88 @@ namespace WTL (nCtlID); #define DDX_TEXT(nID, var) \ - if(nCtlID == (UINT)-1 || nCtlID == nID) \ + if((nCtlID == (UINT)-1) || (nCtlID == nID)) \ { \ if(!DDX_Text(nID, var, sizeof(var), bSaveAndValidate)) \ return FALSE; \ } #define DDX_TEXT_LEN(nID, var, len) \ - if(nCtlID == (UINT)-1 || nCtlID == nID) \ + if((nCtlID == (UINT)-1) || (nCtlID == nID)) \ { \ if(!DDX_Text(nID, var, sizeof(var), bSaveAndValidate, TRUE, len)) \ return FALSE; \ } #define DDX_INT(nID, var) \ - if(nCtlID == (UINT)-1 || nCtlID == nID) \ + if((nCtlID == (UINT)-1) || (nCtlID == nID)) \ { \ if(!DDX_Int(nID, var, TRUE, bSaveAndValidate)) \ return FALSE; \ } #define DDX_INT_RANGE(nID, var, min, max) \ - if(nCtlID == (UINT)-1 || nCtlID == nID) \ + if((nCtlID == (UINT)-1) || (nCtlID == nID)) \ { \ if(!DDX_Int(nID, var, TRUE, bSaveAndValidate, TRUE, min, max)) \ return FALSE; \ } #define DDX_UINT(nID, var) \ - if(nCtlID == (UINT)-1 || nCtlID == nID) \ + if((nCtlID == (UINT)-1) || (nCtlID == nID)) \ { \ if(!DDX_Int(nID, var, FALSE, bSaveAndValidate)) \ return FALSE; \ } #define DDX_UINT_RANGE(nID, var, min, max) \ - if(nCtlID == (UINT)-1 || nCtlID == nID) \ + if((nCtlID == (UINT)-1) || (nCtlID == nID)) \ { \ if(!DDX_Int(nID, var, FALSE, bSaveAndValidate, TRUE, min, max)) \ return FALSE; \ } -#ifdef _ATL_USE_DDX_FLOAT #define DDX_FLOAT(nID, var) \ - if(nCtlID == (UINT)-1 || nCtlID == nID) \ + if((nCtlID == (UINT)-1) || (nCtlID == nID)) \ { \ if(!DDX_Float(nID, var, bSaveAndValidate)) \ return FALSE; \ } #define DDX_FLOAT_RANGE(nID, var, min, max) \ - if(nCtlID == (UINT)-1 || nCtlID == nID) \ + if((nCtlID == (UINT)-1) || (nCtlID == nID)) \ { \ if(!DDX_Float(nID, var, bSaveAndValidate, TRUE, min, max)) \ return FALSE; \ } #define DDX_FLOAT_P(nID, var, precision) \ - if(nCtlID == (UINT)-1 || nCtlID == nID) \ + if((nCtlID == (UINT)-1) || (nCtlID == nID)) \ { \ if(!DDX_Float(nID, var, bSaveAndValidate, FALSE, 0, 0, precision)) \ return FALSE; \ } #define DDX_FLOAT_P_RANGE(nID, var, min, max, precision) \ - if(nCtlID == (UINT)-1 || nCtlID == nID) \ + if((nCtlID == (UINT)-1) || (nCtlID == nID)) \ { \ if(!DDX_Float(nID, var, bSaveAndValidate, TRUE, min, max, precision)) \ return FALSE; \ } -#endif // _ATL_USE_DDX_FLOAT #define DDX_CONTROL(nID, obj) \ - if(nCtlID == (UINT)-1 || nCtlID == nID) \ + if((nCtlID == (UINT)-1) || (nCtlID == nID)) \ DDX_Control(nID, obj, bSaveAndValidate); #define DDX_CONTROL_HANDLE(nID, obj) \ - if(nCtlID == (UINT)-1 || nCtlID == nID) \ + if((nCtlID == (UINT)-1) || (nCtlID == nID)) \ DDX_Control_Handle(nID, obj, bSaveAndValidate); #define DDX_CHECK(nID, var) \ - if(nCtlID == (UINT)-1 || nCtlID == nID) \ + if((nCtlID == (UINT)-1) || (nCtlID == nID)) \ DDX_Check(nID, var, bSaveAndValidate); #define DDX_RADIO(nID, var) \ - if(nCtlID == (UINT)-1 || nCtlID == nID) \ + if((nCtlID == (UINT)-1) || (nCtlID == nID)) \ DDX_Radio(nID, var, bSaveAndValidate); #define END_DDX_MAP() \ @@ -137,23 +129,18 @@ namespace WTL // DDX support for Tab, Combo, ListBox and ListView selection index // Note: Specialized versions require atlctrls.h to be included first -#if (_MSC_VER >= 1300) #define DDX_INDEX(CtrlClass, nID, var) \ - if(nCtlID == (UINT)-1 || nCtlID == nID) \ + if((nCtlID == (UINT)-1) || (nCtlID == nID)) \ DDX_Index(nID, var, bSaveAndValidate); #ifdef __ATLCTRLS_H__ #define DDX_TAB_INDEX(nID, var) DDX_INDEX(WTL::CTabCtrl, nID, var) - #ifndef WIN32_PLATFORM_WFSP // No COMBOBOX on SmartPhones - #define DDX_COMBO_INDEX(nID, var) DDX_INDEX(WTL::CComboBox, nID, var) - #endif + #define DDX_COMBO_INDEX(nID, var) DDX_INDEX(WTL::CComboBox, nID, var) #define DDX_LISTBOX_INDEX(nID, var) DDX_INDEX(WTL::CListBox, nID, var) #define DDX_LISTVIEW_INDEX(nID, var) DDX_INDEX(WTL::CListViewCtrl, nID, var) #endif // __ATLCTRLS_H__ -#endif // (_MSC_VER >= 1300) - /////////////////////////////////////////////////////////////////////////////// // CWinDataExchange - provides support for DDX @@ -322,8 +309,8 @@ public: return bSuccess; } -#if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) - BOOL DDX_Text(UINT nID, _CSTRING_NS::CString& strText, int /*cbSize*/, BOOL bSave, BOOL bValidate = FALSE, int nLength = 0) +#ifdef __ATLSTR_H__ + BOOL DDX_Text(UINT nID, ATL::CString& strText, int /*cbSize*/, BOOL bSave, BOOL bValidate = FALSE, int nLength = 0) { T* pT = static_cast(this); BOOL bSuccess = TRUE; @@ -365,7 +352,7 @@ public: } return bSuccess; } -#endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) +#endif // __ATLSTR_H__ // Numeric exchange template @@ -380,7 +367,7 @@ public: } else { - ATLASSERT(!bValidate || (nVal >= nMin && nVal <= nMax)); + ATLASSERT(!bValidate || ((nVal >= nMin) && (nVal <= nMax))); bSuccess = pT->SetDlgItemInt(nID, nVal, bSigned); } @@ -391,7 +378,7 @@ public: else if(bSave && bValidate) // validation { ATLASSERT(nMin != nMax); - if(nVal < nMin || nVal > nMax) + if((nVal < nMin) || (nVal > nMax)) { _XData data = { ddxDataInt }; data.intData.nVal = (long)nVal; @@ -405,18 +392,17 @@ public: } // Float exchange -#ifdef _ATL_USE_DDX_FLOAT static BOOL _AtlSimpleFloatParse(LPCTSTR lpszText, double& d) { ATLASSERT(lpszText != NULL); - while (*lpszText == _T(' ') || *lpszText == _T('\t')) + while ((*lpszText == _T(' ')) || (*lpszText == _T('\t'))) lpszText++; TCHAR chFirst = lpszText[0]; d = _tcstod(lpszText, (LPTSTR*)&lpszText); - if (d == 0.0 && chFirst != _T('0')) + if ((d == 0.0) && (chFirst != _T('0'))) return FALSE; // could not convert - while (*lpszText == _T(' ') || *lpszText == _T('\t')) + while ((*lpszText == _T(' ')) || (*lpszText == _T('\t'))) lpszText++; if (*lpszText != _T('\0')) @@ -430,7 +416,7 @@ public: T* pT = static_cast(this); BOOL bSuccess = TRUE; const int cchBuff = 32; - TCHAR szBuff[cchBuff] = { 0 }; + TCHAR szBuff[cchBuff] = {}; if(bSave) { @@ -443,8 +429,8 @@ public: } else { - ATLASSERT(!bValidate || (nVal >= nMin && nVal <= nMax)); - SecureHelper::sprintf_x(szBuff, cchBuff, _T("%.*g"), nPrecision, nVal); + ATLASSERT(!bValidate || ((nVal >= nMin) && (nVal <= nMax))); + _stprintf_s(szBuff, cchBuff, _T("%.*g"), nPrecision, nVal); bSuccess = pT->SetDlgItemText(nID, szBuff); } @@ -455,7 +441,7 @@ public: else if(bSave && bValidate) // validation { ATLASSERT(nMin != nMax); - if(nVal < nMin || nVal > nMax) + if((nVal < nMin) || (nVal > nMax)) { _XData data = { ddxDataFloat }; data.floatData.nVal = (double)nVal; @@ -473,7 +459,7 @@ public: T* pT = static_cast(this); BOOL bSuccess = TRUE; const int cchBuff = 32; - TCHAR szBuff[cchBuff] = { 0 }; + TCHAR szBuff[cchBuff] = {}; if(bSave) { @@ -486,8 +472,8 @@ public: } else { - ATLASSERT(!bValidate || (nVal >= nMin && nVal <= nMax)); - SecureHelper::sprintf_x(szBuff, cchBuff, _T("%.*g"), nPrecision, nVal); + ATLASSERT(!bValidate || ((nVal >= nMin) && (nVal <= nMax))); + _stprintf_s(szBuff, cchBuff, _T("%.*g"), nPrecision, nVal); bSuccess = pT->SetDlgItemText(nID, szBuff); } @@ -498,7 +484,7 @@ public: else if(bSave && bValidate) // validation { ATLASSERT(nMin != nMax); - if(nVal < nMin || nVal > nMax) + if((nVal < nMin) || (nVal > nMax)) { _XData data = { ddxDataFloat }; data.floatData.nVal = nVal; @@ -510,13 +496,12 @@ public: } return bSuccess; } -#endif // _ATL_USE_DDX_FLOAT // Full control subclassing (for CWindowImpl derived controls) template void DDX_Control(UINT nID, TControl& ctrl, BOOL bSave) { - if(!bSave && ctrl.m_hWnd == NULL) + if(!bSave && (ctrl.m_hWnd == NULL)) { T* pT = static_cast(this); ctrl.SubclassWindow(pT->GetDlgItem(nID)); @@ -527,7 +512,7 @@ public: template void DDX_Control_Handle(UINT nID, TControl& ctrl, BOOL bSave) { - if(!bSave && ctrl.m_hWnd == NULL) + if(!bSave && (ctrl.m_hWnd == NULL)) { T* pT = static_cast(this); ctrl = pT->GetDlgItem(nID); @@ -542,11 +527,11 @@ public: if(bSave) { nValue = (int)::SendMessage(hWndCtrl, BM_GETCHECK, 0, 0L); - ATLASSERT(nValue >= 0 && nValue <= 2); + ATLASSERT((nValue >= 0) && (nValue <= 2)); } else { - if(nValue < 0 || nValue > 2) + if((nValue < 0) || (nValue > 2)) { ATLTRACE2(atlTraceUI, 0, _T("ATL: Warning - dialog data checkbox value (%d) out of range.\n"), nValue); nValue = 0; // default to off @@ -610,11 +595,10 @@ public: } hWndCtrl = ::GetWindow(hWndCtrl, GW_HWNDNEXT); } - while (hWndCtrl != NULL && !(GetWindowLong(hWndCtrl, GWL_STYLE) & WS_GROUP)); + while ((hWndCtrl != NULL) && !(GetWindowLong(hWndCtrl, GWL_STYLE) & WS_GROUP)); } // DDX support for Tab, Combo, ListBox and ListView selection index -#if (_MSC_VER >= 1300) template INT _getSel(TCtrl& tCtrl) { @@ -659,7 +643,6 @@ public: else _setSel(ctrl, nVal); } -#endif // (_MSC_VER >= 1300) // Overrideables void OnDataExchangeError(UINT nCtrlID, BOOL /*bSave*/) @@ -679,6 +662,6 @@ public: } }; -}; // namespace WTL +} // namespace WTL #endif // __ATLDDX_H__ diff --git a/WrlSDK/SampleCode/PluginWinExe/WTL/atldlgs.h b/WrlSDK/SampleCode/PluginWinExe/WTL/atldlgs.h index 3ff14944252f9635b79d41cc824945595b8d7ced..3622945c6ff7f3e8f7f9e6468f33b40242c3dff4 100644 --- a/WrlSDK/SampleCode/PluginWinExe/WTL/atldlgs.h +++ b/WrlSDK/SampleCode/PluginWinExe/WTL/atldlgs.h @@ -1,4 +1,4 @@ -// Windows Template Library - WTL version 9.10 +// Windows Template Library - WTL version 10.0 // Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. // // This file is a part of the Windows Template Library. @@ -19,12 +19,11 @@ #error atldlgs.h requires atlwin.h to be included first #endif -#include #include -#if (_WIN32_WINNT >= 0x0600) && !defined(_WIN32_WCE) +#if (_WIN32_WINNT >= 0x0600) #include -#endif // (_WIN32_WINNT >= 0x0600) && !defined(_WIN32_WCE) +#endif // (_WIN32_WINNT >= 0x0600) /////////////////////////////////////////////////////////////////////////////// @@ -32,7 +31,7 @@ // // CFileDialogImpl // CFileDialog -// CFileDialogEx +// CSimpleFileDialog // CMultiFileDialogImpl // CMultiFileDialog // CShellFileDialogImpl @@ -101,33 +100,11 @@ namespace WTL /////////////////////////////////////////////////////////////////////////////// // CFileDialogImpl - used for File Open or File Save As -// compatibility with the old (vc6.0) headers -#if (_WIN32_WINNT >= 0x0500) && !defined(OPENFILENAME_SIZE_VERSION_400) - #ifndef CDSIZEOF_STRUCT - #define CDSIZEOF_STRUCT(structname, member) (((int)((LPBYTE)(&((structname*)0)->member) - ((LPBYTE)((structname*)0)))) + sizeof(((structname*)0)->member)) - #endif - #define OPENFILENAME_SIZE_VERSION_400A CDSIZEOF_STRUCT(OPENFILENAMEA,lpTemplateName) - #define OPENFILENAME_SIZE_VERSION_400W CDSIZEOF_STRUCT(OPENFILENAMEW,lpTemplateName) - #ifdef UNICODE - #define OPENFILENAME_SIZE_VERSION_400 OPENFILENAME_SIZE_VERSION_400W - #else - #define OPENFILENAME_SIZE_VERSION_400 OPENFILENAME_SIZE_VERSION_400A - #endif // !UNICODE -#endif // (_WIN32_WINNT >= 0x0500) && !defined(OPENFILENAME_SIZE_VERSION_400) - -#if !defined(_WIN32_WCE) && !defined(CDN_INCLUDEITEM) - #define CDN_INCLUDEITEM (CDN_FIRST - 0x0007) -#endif - template class ATL_NO_VTABLE CFileDialogImpl : public ATL::CDialogImplBase { public: -#if defined(__AYGSHELL_H__) && (_WIN32_WCE >= 0x0501) - OPENFILENAMEEX m_ofn; -#else OPENFILENAME m_ofn; -#endif BOOL m_bOpenFileDialog; // TRUE for file open, FALSE for file save TCHAR m_szFileTitle[_MAX_FNAME]; // contains file title after return TCHAR m_szFileName[_MAX_PATH]; // contains full path name after return @@ -137,46 +114,27 @@ public: LPCTSTR lpszFileName = NULL, DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, LPCTSTR lpszFilter = NULL, - HWND hWndParent = NULL) + HWND hWndParent = NULL) : m_bOpenFileDialog(bOpenFileDialog) { memset(&m_ofn, 0, sizeof(m_ofn)); // initialize structure to 0/NULL - m_szFileName[0] = _T('\0'); - m_szFileTitle[0] = _T('\0'); - - m_bOpenFileDialog = bOpenFileDialog; - -#if defined(__AYGSHELL_H__) && (_WIN32_WCE >= 0x0501) - m_ofn.lStructSize = bOpenFileDialog ? sizeof(m_ofn) : sizeof(OPENFILENAME); -#else m_ofn.lStructSize = sizeof(m_ofn); -#endif - -#if (_WIN32_WINNT >= 0x0500) - // adjust struct size if running on older version of Windows - if(AtlIsOldWindows()) - { - ATLASSERT(sizeof(m_ofn) > OPENFILENAME_SIZE_VERSION_400); // must be - m_ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; - } -#endif // (_WIN32_WINNT >= 0x0500) m_ofn.lpstrFile = m_szFileName; m_ofn.nMaxFile = _MAX_PATH; m_ofn.lpstrDefExt = lpszDefExt; m_ofn.lpstrFileTitle = (LPTSTR)m_szFileTitle; m_ofn.nMaxFileTitle = _MAX_FNAME; -#ifndef _WIN32_WCE m_ofn.Flags = dwFlags | OFN_EXPLORER | OFN_ENABLEHOOK | OFN_ENABLESIZING; -#else // CE specific - m_ofn.Flags = dwFlags | OFN_EXPLORER | OFN_ENABLEHOOK; -#endif // !_WIN32_WCE m_ofn.lpstrFilter = lpszFilter; m_ofn.hInstance = ModuleHelper::GetResourceInstance(); m_ofn.lpfnHook = (LPOFNHOOKPROC)T::StartDialogProc; m_ofn.hwndOwner = hWndParent; + m_szFileName[0] = _T('\0'); + m_szFileTitle[0] = _T('\0'); + // setup initial file name if(lpszFileName != NULL) - SecureHelper::strncpy_x(m_szFileName, _countof(m_szFileName), lpszFileName, _TRUNCATE); + ATL::Checked::tcsncpy_s(m_szFileName, _countof(m_szFileName), lpszFileName, _TRUNCATE); } INT_PTR DoModal(HWND hWndParent = ::GetActiveWindow()) @@ -191,7 +149,6 @@ public: ATLASSERT(m_hWnd == NULL); -#if (_ATL_VER >= 0x0800) // Allocate the thunk structure here, where we can fail gracefully. BOOL bRetTh = m_thunk.Init(NULL, NULL); if(bRetTh == FALSE) @@ -199,25 +156,14 @@ public: ::SetLastError(ERROR_OUTOFMEMORY); return -1; } -#endif // (_ATL_VER >= 0x0800) ModuleHelper::AddCreateWndData(&m_thunk.cd, (ATL::CDialogImplBase*)this); - BOOL bRet; - if(m_bOpenFileDialog) -#if defined(__AYGSHELL_H__) && (_WIN32_WCE >= 0x0501) - bRet = ::GetOpenFileNameEx(&m_ofn); - else - bRet = ::GetSaveFileName((LPOPENFILENAME)&m_ofn); -#else - bRet = ::GetOpenFileName(&m_ofn); - else - bRet = ::GetSaveFileName(&m_ofn); -#endif + BOOL bRet = (m_bOpenFileDialog != FALSE) ? ::GetOpenFileName(&m_ofn) : ::GetSaveFileName(&m_ofn); m_hWnd = NULL; - return bRet ? IDOK : IDCANCEL; + return (bRet != FALSE) ? IDOK : IDCANCEL; } // Attributes @@ -306,9 +252,7 @@ public: NOTIFY_CODE_HANDLER(CDN_SELCHANGE, _OnSelChange) NOTIFY_CODE_HANDLER(CDN_SHAREVIOLATION, _OnShareViolation) NOTIFY_CODE_HANDLER(CDN_TYPECHANGE, _OnTypeChange) -#ifndef _WIN32_WCE NOTIFY_CODE_HANDLER(CDN_INCLUDEITEM, _OnIncludeItem) -#endif // !_WIN32_WCE END_MSG_MAP() LRESULT _OnFileOK(int /*idCtrl*/, LPNMHDR pnmh, BOOL& /*bHandled*/) @@ -365,14 +309,12 @@ public: return 0; } -#ifndef _WIN32_WCE LRESULT _OnIncludeItem(int /*idCtrl*/, LPNMHDR pnmh, BOOL& /*bHandled*/) { ATLASSERT(::IsWindow(m_hWnd)); T* pT = static_cast(this); return pT->OnIncludeItem((LPOFNOTIFYEX)pnmh); } -#endif // !_WIN32_WCE // Overrideables BOOL OnFileOK(LPOFNOTIFY /*lpon*/) @@ -405,12 +347,10 @@ public: { } -#ifndef _WIN32_WCE BOOL OnIncludeItem(LPOFNOTIFYEX /*lponex*/) { return TRUE; // include item } -#endif // !_WIN32_WCE }; class CFileDialog : public CFileDialogImpl @@ -429,35 +369,62 @@ public: DECLARE_EMPTY_MSG_MAP() }; -#if defined(__AYGSHELL_H__) && (_WIN32_WCE >= 0x0501) -class CFileDialogEx : public CFileDialogImpl + +/////////////////////////////////////////////////////////////////////////////// +// CSimpleFileDialog - simple class for non-customized Open/SaveAs dialogs + +class CSimpleFileDialog { public: - CFileDialogEx( // Supports only FileOpen - LPCTSTR lpszDefExt = NULL, - LPCTSTR lpszFileName = NULL, - DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, - OFN_EXFLAG ExFlags = OFN_EXFLAG_THUMBNAILVIEW, - OFN_SORTORDER dwSortOrder = OFN_SORTORDER_AUTO, - LPCTSTR lpszFilter = NULL, - HWND hWndParent = NULL) - : CFileDialogImpl(TRUE, lpszDefExt, lpszFileName, dwFlags, lpszFilter, hWndParent) + OPENFILENAME m_ofn; + BOOL m_bOpenFileDialog; // TRUE for file open, FALSE for file save + TCHAR m_szFileTitle[_MAX_FNAME]; // contains file title after return + TCHAR m_szFileName[_MAX_PATH]; // contains full path name after return + + CSimpleFileDialog(BOOL bOpenFileDialog, // TRUE for FileOpen, FALSE for FileSaveAs + LPCTSTR lpszDefExt = NULL, + LPCTSTR lpszFileName = NULL, + DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, + LPCTSTR lpszFilter = NULL, + HWND hWndParent = NULL) : m_bOpenFileDialog(bOpenFileDialog) { - m_ofn.ExFlags = ExFlags; - m_ofn.dwSortOrder = dwSortOrder; + memset(&m_ofn, 0, sizeof(m_ofn)); // initialize structure to 0/NULL + m_ofn.lStructSize = sizeof(m_ofn); + m_ofn.lpstrFile = m_szFileName; + m_ofn.nMaxFile = _MAX_PATH; + m_ofn.lpstrDefExt = lpszDefExt; + m_ofn.lpstrFileTitle = (LPTSTR)m_szFileTitle; + m_ofn.nMaxFileTitle = _MAX_FNAME; + m_ofn.Flags = dwFlags | OFN_EXPLORER | OFN_ENABLESIZING; + m_ofn.lpstrFilter = lpszFilter; + m_ofn.hInstance = ModuleHelper::GetResourceInstance(); + m_ofn.hwndOwner = hWndParent; + + m_szFileName[0] = _T('\0'); + m_szFileTitle[0] = _T('\0'); + + // setup initial file name + if(lpszFileName != NULL) + ATL::Checked::tcsncpy_s(m_szFileName, _countof(m_szFileName), lpszFileName, _TRUNCATE); } - // override base class map and references to handlers - DECLARE_EMPTY_MSG_MAP() + INT_PTR DoModal(HWND hWndParent = ::GetActiveWindow()) + { + ATLASSERT((m_ofn.Flags & OFN_EXPLORER) != 0); + + if(m_ofn.hwndOwner == NULL) // set only if not specified before + m_ofn.hwndOwner = hWndParent; + + BOOL bRet = (m_bOpenFileDialog != FALSE) ? ::GetOpenFileName(&m_ofn) : ::GetSaveFileName(&m_ofn); + + return (bRet != FALSE) ? IDOK : IDCANCEL; + } }; -#endif // defined(__AYGSHELL_H__) && (_WIN32_WCE >= 0x0501) /////////////////////////////////////////////////////////////////////////////// // Multi File Dialog - Multi-select File Open dialog -#ifndef _WIN32_WCE - // The class dynamically resizes the buffer as the file selection changes // (as described in Knowledge Base article 131462). It also expands selected // shortcut files to take into account the full path of the target file. @@ -486,7 +453,7 @@ public: : CFileDialogImpl(TRUE, lpszDefExt, lpszFileName, dwFlags, lpszFilter, hWndParent), m_pNextFile(NULL) { - m_ofn.Flags |= OFN_ALLOWMULTISELECT; // Force multiple selection mode + this->m_ofn.Flags |= OFN_ALLOWMULTISELECT; // Force multiple selection mode #ifndef _UNICODE #ifdef _versionhelpers_H_INCLUDED_ @@ -510,8 +477,8 @@ public: ~CMultiFileDialogImpl() { - if (m_ofn.lpstrFile != m_szFileName) // Free the buffer if we allocated it - delete[] m_ofn.lpstrFile; + if (this->m_ofn.lpstrFile != this->m_szFileName) // Free the buffer if we allocated it + delete[] this->m_ofn.lpstrFile; } // Operations @@ -521,15 +488,15 @@ public: // If the function fails, the return value is zero. int GetDirectory(LPTSTR pBuffer, int nBufLen) const { - if (m_ofn.lpstrFile == NULL) + if (this->m_ofn.lpstrFile == NULL) return 0; - LPCTSTR pStr = m_ofn.lpstrFile; + LPCTSTR pStr = this->m_ofn.lpstrFile; int nLength = lstrlen(pStr); if (pStr[nLength + 1] == 0) { // The OFN buffer contains a single item so extract its path. - LPCTSTR pSep = MinCrtHelper::_strrchr(pStr, _T('\\')); + LPCTSTR pSep = _tcsrchr(pStr, _T('\\')); if (pSep != NULL) nLength = (int)(DWORD_PTR)(pSep - pStr); } @@ -541,15 +508,15 @@ public: } else if (nBufLen > nLength) { - SecureHelper::strncpy_x(pBuffer, nBufLen, pStr, nLength); + ATL::Checked::tcsncpy_s(pBuffer, nBufLen, pStr, nLength); nRet = nLength; } return nRet; } -#if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) - bool GetDirectory(_CSTRING_NS::CString& strDir) const +#ifdef __ATLSTR_H__ + bool GetDirectory(ATL::CString& strDir) const { bool bRet = false; @@ -562,17 +529,17 @@ public: return bRet; } -#endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) +#endif // __ATLSTR_H__ // Get the first filename as a pointer into the buffer. LPCTSTR GetFirstFileName() const { - if (m_ofn.lpstrFile == NULL) + if (this->m_ofn.lpstrFile == NULL) return NULL; m_pNextFile = NULL; // Reset internal buffer pointer - LPCTSTR pStr = m_ofn.lpstrFile; + LPCTSTR pStr = this->m_ofn.lpstrFile; int nLength = lstrlen(pStr); if (pStr[nLength + 1] != 0) { @@ -587,7 +554,7 @@ public: else { // A single item was selected. Skip forward past the path. - LPCTSTR pSep = MinCrtHelper::_strrchr(pStr, _T('\\')); + LPCTSTR pSep = _tcsrchr(pStr, _T('\\')); if (pSep != NULL) pStr = pSep + 1; } @@ -632,16 +599,16 @@ public: else if (nBufLen > nLengthTotal) // If the buffer is big enough, go ahead and construct the path { GetDirectory(pBuffer, nBufLen); - SecureHelper::strcat_x(pBuffer, nBufLen, _T("\\")); - SecureHelper::strcat_x(pBuffer, nBufLen, pStr); + ATL::Checked::tcscat_s(pBuffer, nBufLen, _T("\\")); + ATL::Checked::tcscat_s(pBuffer, nBufLen, pStr); nRet = nLengthTotal; } return nRet; } -#if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) - bool GetFirstPathName(_CSTRING_NS::CString& strPath) const +#ifdef __ATLSTR_H__ + bool GetFirstPathName(ATL::CString& strPath) const { bool bRet = false; @@ -654,7 +621,7 @@ public: return bRet; } -#endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) +#endif // __ATLSTR_H__ // Get the next filename as a full path. // The function returns the number of characters copied, not including the terminating zero. @@ -669,7 +636,7 @@ public: int nRet = 0; LPCTSTR pStr = m_pNextFile; // Does the filename contain a backslash? - if (MinCrtHelper::_strrchr(pStr, _T('\\')) != NULL) + if (_tcsrchr(pStr, _T('\\')) != NULL) { // Yes, so we'll assume it's a full path. int nLength = lstrlen(pStr); @@ -680,7 +647,7 @@ public: } else if (nBufLen > nLength) // The buffer is big enough, so go ahead and copy the filename { - SecureHelper::strcpy_x(pBuffer, nBufLen, GetNextFileName()); + ATL::Checked::tcscpy_s(pBuffer, nBufLen, GetNextFileName()); nRet = nBufLen; } } @@ -700,8 +667,8 @@ public: else if (nBufLen > nLengthTotal) // If the buffer is big enough, go ahead and construct the path { GetDirectory(pBuffer, nBufLen); - SecureHelper::strcat_x(pBuffer, nBufLen, _T("\\")); - SecureHelper::strcat_x(pBuffer, nBufLen, GetNextFileName()); + ATL::Checked::tcscat_s(pBuffer, nBufLen, _T("\\")); + ATL::Checked::tcscat_s(pBuffer, nBufLen, GetNextFileName()); nRet = nLengthTotal; } } @@ -710,8 +677,8 @@ public: return nRet; } -#if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) - bool GetNextPathName(_CSTRING_NS::CString& strPath) const +#ifdef __ATLSTR_H__ + bool GetNextPathName(ATL::CString& strPath) const { bool bRet = false; @@ -724,19 +691,19 @@ public: return bRet; } -#endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) +#endif // __ATLSTR_H__ // Implementation bool ResizeFilenameBuffer(DWORD dwLength) { - if (dwLength > m_ofn.nMaxFile) + if (dwLength > this->m_ofn.nMaxFile) { // Free the old buffer. - if (m_ofn.lpstrFile != m_szFileName) + if (this->m_ofn.lpstrFile != this->m_szFileName) { - delete[] m_ofn.lpstrFile; - m_ofn.lpstrFile = NULL; - m_ofn.nMaxFile = 0; + delete[] this->m_ofn.lpstrFile; + this->m_ofn.lpstrFile = NULL; + this->m_ofn.nMaxFile = 0; } // Allocate the new buffer. @@ -744,13 +711,13 @@ public: ATLTRY(lpstrBuff = new TCHAR[dwLength]); if (lpstrBuff != NULL) { - m_ofn.lpstrFile = lpstrBuff; - m_ofn.lpstrFile[0] = 0; - m_ofn.nMaxFile = dwLength; + this->m_ofn.lpstrFile = lpstrBuff; + this->m_ofn.lpstrFile[0] = 0; + this->m_ofn.nMaxFile = dwLength; } } - return (m_ofn.lpstrFile != NULL); + return (this->m_ofn.lpstrFile != NULL); } void OnSelChange(LPOFNOTIFY /*lpon*/) @@ -762,12 +729,12 @@ public: #endif // Get the buffer length required to hold the spec. - int nLength = GetSpec(NULL, 0); + int nLength = this->GetSpec(NULL, 0); if (nLength <= 1) return; // no files are selected, presumably // Add room for the directory, and an extra terminating zero. - nLength += GetFolderPath(NULL, 0) + 1; + nLength += this->GetFolderPath(NULL, 0) + 1; if (!ResizeFilenameBuffer(nLength)) { @@ -776,22 +743,22 @@ public: } // If we are not following links then our work is done. - if ((m_ofn.Flags & OFN_NODEREFERENCELINKS) != 0) + if ((this->m_ofn.Flags & OFN_NODEREFERENCELINKS) != 0) return; // Get the file spec, which is the text in the edit control. - if (GetSpec(m_ofn.lpstrFile, m_ofn.nMaxFile) <= 0) + if (this->GetSpec(this->m_ofn.lpstrFile, this->m_ofn.nMaxFile) <= 0) return; // Get the ID-list of the current folder. - int nBytes = GetFolderIDList(NULL, 0); + int nBytes = this->GetFolderIDList(NULL, 0); #ifdef STRICT_TYPED_ITEMIDS - CTempBuffer idlist; + ATL::CTempBuffer idlist; #else - CTempBuffer idlist; + ATL::CTempBuffer idlist; #endif idlist.AllocateBytes(nBytes); - if ((nBytes <= 0) || (GetFolderIDList(idlist, nBytes) <= 0)) + if ((nBytes <= 0) || (this->GetFolderIDList(idlist, nBytes) <= 0)) return; // First bind to the desktop folder, then to the current folder. @@ -805,8 +772,8 @@ public: // we need to add enough extra buffer space to hold its target path. DWORD nExtraChars = 0; bool bInsideQuotes = false; - LPCTSTR pAnchor = m_ofn.lpstrFile; - LPCTSTR pChar = m_ofn.lpstrFile; + LPCTSTR pAnchor = this->m_ofn.lpstrFile; + LPCTSTR pChar = this->m_ofn.lpstrFile; for ( ; *pChar; ++pChar) { // Look for quotation marks. @@ -830,8 +797,8 @@ public: // Get the ID-list and attributes of the file. USES_CONVERSION; int nFileNameLength = (int)(DWORD_PTR)(pChar - pAnchor); - TCHAR szFileName[MAX_PATH] = { 0 }; - SecureHelper::strncpy_x(szFileName, MAX_PATH, pAnchor, nFileNameLength); + TCHAR szFileName[MAX_PATH] = {}; + ATL::Checked::tcsncpy_s(szFileName, MAX_PATH, pAnchor, nFileNameLength); #ifdef STRICT_TYPED_ITEMIDS PIDLIST_RELATIVE pidl = NULL; #else @@ -848,7 +815,7 @@ public: if (SUCCEEDED(pFolder->BindToObject(pidl, NULL, IID_IShellLink, (void**)&pLink))) { // Get the shortcut's target path. - TCHAR szPath[MAX_PATH] = { 0 }; + TCHAR szPath[MAX_PATH] = {}; if (SUCCEEDED(pLink->GetPath(szPath, MAX_PATH, NULL, 0))) { // If the target path is longer than the shortcut name, then add on the number @@ -869,7 +836,7 @@ public: // If we need more space for shortcut targets, then reallocate. if (nExtraChars > 0) - ATLVERIFY(ResizeFilenameBuffer(m_ofn.nMaxFile + nExtraChars)); + ATLVERIFY(ResizeFilenameBuffer(this->m_ofn.nMaxFile + nExtraChars)); } }; @@ -890,8 +857,6 @@ public: END_MSG_MAP() }; -#endif // !_WIN32_WCE - /////////////////////////////////////////////////////////////////////////////// // Shell File Dialog - new Shell File Open and Save dialogs in Vista @@ -901,7 +866,7 @@ public: // CShellFileOpenDialog dlg; // dlg.GetPtr()->SetTitle(L"MyFileOpenDialog"); -#if (_WIN32_WINNT >= 0x0600) && !defined(_WIN32_WCE) +#if (_WIN32_WINNT >= 0x0600) /////////////////////////////////////////////////////////////////////////////// // CShellFileDialogImpl - base class for CShellFileOpenDialogImpl and CShellFileSaveDialogImpl @@ -973,8 +938,8 @@ public: return hRet; } -#if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) - HRESULT GetFilePath(_CSTRING_NS::CString& strFilePath) +#ifdef __ATLSTR_H__ + HRESULT GetFilePath(ATL::CString& strFilePath) { T* pT = static_cast(this); ATLASSERT(pT->m_spFileDlg != NULL); @@ -988,7 +953,7 @@ public: return hRet; } - HRESULT GetFileTitle(_CSTRING_NS::CString& strFileTitle) + HRESULT GetFileTitle(ATL::CString& strFileTitle) { T* pT = static_cast(this); ATLASSERT(pT->m_spFileDlg != NULL); @@ -1001,7 +966,7 @@ public: return hRet; } -#endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) +#endif // __ATLSTR_H__ // Helpers for IShellItem static HRESULT GetFileNameFromShellItem(IShellItem* pShellItem, SIGDN type, LPWSTR lpstr, int cchLength) @@ -1015,7 +980,7 @@ public: { if(lstrlenW(lpstrName) < cchLength) { - SecureHelper::strcpyW_x(lpstr, cchLength, lpstrName); + ATL::Checked::wcscpy_s(lpstr, cchLength, lpstrName); } else { @@ -1029,8 +994,8 @@ public: return hRet; } -#if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) - static HRESULT GetFileNameFromShellItem(IShellItem* pShellItem, SIGDN type, _CSTRING_NS::CString& str) +#ifdef __ATLSTR_H__ + static HRESULT GetFileNameFromShellItem(IShellItem* pShellItem, SIGDN type, ATL::CString& str) { ATLASSERT(pShellItem != NULL); @@ -1045,7 +1010,7 @@ public: return hRet; } -#endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) +#endif // __ATLSTR_H__ // Implementation void _Advise(DWORD& dwCookie) @@ -1086,7 +1051,7 @@ public: ATLASSERT(SUCCEEDED(hRet)); } - if(arrFilterSpec != NULL && uFilterSpecCount != 0U) + if((arrFilterSpec != NULL) && (uFilterSpecCount != 0U)) { hRet = pT->m_spFileDlg->SetFileTypes(uFilterSpecCount, arrFilterSpec); ATLASSERT(SUCCEEDED(hRet)); @@ -1121,59 +1086,59 @@ public: } // Implementation - IFileDialogEvents interface - virtual HRESULT STDMETHODCALLTYPE IFileDialogEvents::OnFileOk(IFileDialog* pfd) + virtual HRESULT STDMETHODCALLTYPE OnFileOk(IFileDialog* pfd) { T* pT = static_cast(this); ATLASSERT(pT->m_spFileDlg.IsEqualObject(pfd)); - pfd; // avoid level 4 warning + (void)pfd; // avoid level 4 warning return pT->OnFileOk(); } - virtual HRESULT STDMETHODCALLTYPE IFileDialogEvents::OnFolderChanging(IFileDialog* pfd, IShellItem* psiFolder) + virtual HRESULT STDMETHODCALLTYPE OnFolderChanging(IFileDialog* pfd, IShellItem* psiFolder) { T* pT = static_cast(this); ATLASSERT(pT->m_spFileDlg.IsEqualObject(pfd)); - pfd; // avoid level 4 warning + (void)pfd; // avoid level 4 warning return pT->OnFolderChanging(psiFolder); } - virtual HRESULT STDMETHODCALLTYPE IFileDialogEvents::OnFolderChange(IFileDialog* pfd) + virtual HRESULT STDMETHODCALLTYPE OnFolderChange(IFileDialog* pfd) { T* pT = static_cast(this); ATLASSERT(pT->m_spFileDlg.IsEqualObject(pfd)); - pfd; // avoid level 4 warning + (void)pfd; // avoid level 4 warning return pT->OnFolderChange(); } - virtual HRESULT STDMETHODCALLTYPE IFileDialogEvents::OnSelectionChange(IFileDialog* pfd) + virtual HRESULT STDMETHODCALLTYPE OnSelectionChange(IFileDialog* pfd) { T* pT = static_cast(this); ATLASSERT(pT->m_spFileDlg.IsEqualObject(pfd)); - pfd; // avoid level 4 warning + (void)pfd; // avoid level 4 warning return pT->OnSelectionChange(); } - virtual HRESULT STDMETHODCALLTYPE IFileDialogEvents::OnShareViolation(IFileDialog* pfd, IShellItem* psi, FDE_SHAREVIOLATION_RESPONSE* pResponse) + virtual HRESULT STDMETHODCALLTYPE OnShareViolation(IFileDialog* pfd, IShellItem* psi, FDE_SHAREVIOLATION_RESPONSE* pResponse) { T* pT = static_cast(this); ATLASSERT(pT->m_spFileDlg.IsEqualObject(pfd)); - pfd; // avoid level 4 warning + (void)pfd; // avoid level 4 warning return pT->OnShareViolation(psi, pResponse); } - virtual HRESULT STDMETHODCALLTYPE IFileDialogEvents::OnTypeChange(IFileDialog* pfd) + virtual HRESULT STDMETHODCALLTYPE OnTypeChange(IFileDialog* pfd) { T* pT = static_cast(this); ATLASSERT(pT->m_spFileDlg.IsEqualObject(pfd)); - pfd; // avoid level 4 warning + (void)pfd; // avoid level 4 warning return pT->OnTypeChange(); } - virtual HRESULT STDMETHODCALLTYPE IFileDialogEvents::OnOverwrite(IFileDialog* pfd, IShellItem* psi, FDE_OVERWRITE_RESPONSE* pResponse) + virtual HRESULT STDMETHODCALLTYPE OnOverwrite(IFileDialog* pfd, IShellItem* psi, FDE_OVERWRITE_RESPONSE* pResponse) { T* pT = static_cast(this); ATLASSERT(pT->m_spFileDlg.IsEqualObject(pfd)); - pfd; // avoid level 4 warning + (void)pfd; // avoid level 4 warning return pT->OnOverwrite(psi, pResponse); } @@ -1233,9 +1198,12 @@ public: HRESULT hRet = m_spFileDlg.CoCreateInstance(CLSID_FileOpenDialog); if(SUCCEEDED(hRet)) - _Init(lpszFileName, dwOptions, lpszDefExt, arrFilterSpec, uFilterSpecCount); + this->_Init(lpszFileName, dwOptions, lpszDefExt, arrFilterSpec, uFilterSpecCount); } + virtual ~CShellFileOpenDialogImpl() + { } + IFileOpenDialog* GetPtr() { return m_spFileDlg; @@ -1256,6 +1224,9 @@ public: UINT uFilterSpecCount = 0U) : CShellFileOpenDialogImpl(lpszFileName, dwOptions, lpszDefExt, arrFilterSpec, uFilterSpecCount) { } + virtual ~CShellFileOpenDialog() + { } + // Implementation (remove _Advise/_Unadvise code using template magic) void _Advise(DWORD& /*dwCookie*/) { } @@ -1283,9 +1254,12 @@ public: HRESULT hRet = m_spFileDlg.CoCreateInstance(CLSID_FileSaveDialog); if(SUCCEEDED(hRet)) - _Init(lpszFileName, dwOptions, lpszDefExt, arrFilterSpec, uFilterSpecCount); + this->_Init(lpszFileName, dwOptions, lpszDefExt, arrFilterSpec, uFilterSpecCount); } + virtual ~CShellFileSaveDialogImpl() + { } + IFileSaveDialog* GetPtr() { return m_spFileDlg; @@ -1306,6 +1280,9 @@ public: UINT uFilterSpecCount = 0U) : CShellFileSaveDialogImpl(lpszFileName, dwOptions, lpszDefExt, arrFilterSpec, uFilterSpecCount) { } + virtual ~CShellFileSaveDialog() + { } + // Implementation (remove _Advise/_Unadvise code using template magic) void _Advise(DWORD& /*dwCookie*/) { } @@ -1314,14 +1291,12 @@ public: { } }; -#endif // (_WIN32_WINNT >= 0x0600) && !defined(_WIN32_WCE) +#endif // (_WIN32_WINNT >= 0x0600) /////////////////////////////////////////////////////////////////////////////// // CFolderDialogImpl - used for browsing for a folder -#ifndef _WIN32_WCE - template class ATL_NO_VTABLE CFolderDialogImpl { @@ -1443,20 +1418,6 @@ public: // Callback function and overrideables static int CALLBACK BrowseCallbackProc(HWND hWnd, UINT uMsg, LPARAM lParam, LPARAM lpData) { -#ifndef BFFM_VALIDATEFAILED - #ifdef UNICODE - const int BFFM_VALIDATEFAILED = 4; - #else - const int BFFM_VALIDATEFAILED = 3; - #endif -#endif // !BFFM_VALIDATEFAILED -#ifndef BFFM_IUNKNOWN - const int BFFM_IUNKNOWN = 5; -#endif // !BFFM_IUNKNOWN -#ifndef BIF_NEWDIALOGSTYLE - const UINT BIF_NEWDIALOGSTYLE = 0x0040; -#endif // !BIF_NEWDIALOGSTYLE - int nRet = 0; T* pT = (T*)lpData; bool bClear = false; @@ -1553,9 +1514,6 @@ public: void SetOKText(LPCTSTR lpstrOKText) { -#ifndef BFFM_SETOKTEXT - const UINT BFFM_SETOKTEXT = WM_USER + 105; -#endif ATLASSERT(m_hWnd != NULL); USES_CONVERSION; LPCWSTR lpstr = T2CW(lpstrOKText); @@ -1564,18 +1522,12 @@ public: void SetExpanded(LPCITEMIDLIST pItemIDList) { -#ifndef BFFM_SETEXPANDED - const UINT BFFM_SETEXPANDED = WM_USER + 106; -#endif ATLASSERT(m_hWnd != NULL); ::SendMessage(m_hWnd, BFFM_SETEXPANDED, FALSE, (LPARAM)pItemIDList); } void SetExpanded(LPCTSTR lpstrFolderPath) { -#ifndef BFFM_SETEXPANDED - const UINT BFFM_SETEXPANDED = WM_USER + 106; -#endif ATLASSERT(m_hWnd != NULL); USES_CONVERSION; LPCWSTR lpstr = T2CW(lpstrFolderPath); @@ -1591,8 +1543,6 @@ public: { } }; -#endif // !_WIN32_WCE - /////////////////////////////////////////////////////////////////////////////// // CCommonDialogImplBase - base class for common dialog classes @@ -1647,8 +1597,6 @@ public: /////////////////////////////////////////////////////////////////////////////// // CFontDialogImpl - font selection dialog -#ifndef _WIN32_WCE - template class ATL_NO_VTABLE CFontDialogImpl : public CCommonDialogImplBase { @@ -1705,7 +1653,6 @@ public: ATLASSERT(m_hWnd == NULL); -#if (_ATL_VER >= 0x0800) // Allocate the thunk structure here, where we can fail gracefully. BOOL bRetTh = m_thunk.Init(NULL, NULL); if(bRetTh == FALSE) @@ -1713,7 +1660,6 @@ public: ::SetLastError(ERROR_OUTOFMEMORY); return -1; } -#endif // (_ATL_VER >= 0x0800) ModuleHelper::AddCreateWndData(&m_thunk.cd, (CCommonDialogImplBase*)this); @@ -1722,7 +1668,7 @@ public: m_hWnd = NULL; if(bRet) // copy logical font from user's initialization buffer (if needed) - SecureHelper::memcpy_x(&m_lf, sizeof(m_lf), m_cf.lpLogFont, sizeof(m_lf)); + ATL::Checked::memcpy_s(&m_lf, sizeof(m_lf), m_cf.lpLogFont, sizeof(m_lf)); return bRet ? IDOK : IDCANCEL; } @@ -1739,13 +1685,10 @@ public: } // works only when the dialog is dislayed or before -#ifndef _WIN32_WCE void SetLogFont(LPLOGFONT lplf) { ATLASSERT(lplf != NULL); -#ifndef WM_CHOOSEFONT_SETLOGFONT - const UINT WM_CHOOSEFONT_SETLOGFONT = (WM_USER + 101); -#endif + if(m_hWnd != NULL) { ::SendMessage(m_hWnd, WM_CHOOSEFONT_SETLOGFONT, 0, (LPARAM)lplf); @@ -1759,9 +1702,6 @@ public: void SetFlags(DWORD dwFlags) { -#ifndef WM_CHOOSEFONT_SETFLAGS - const UINT WM_CHOOSEFONT_SETFLAGS = (WM_USER + 102); -#endif if(m_hWnd != NULL) { CHOOSEFONT cf = { sizeof(CHOOSEFONT) }; @@ -1773,7 +1713,6 @@ public: m_cf.Flags = dwFlags; } } -#endif // !_WIN32_WCE // Helpers for parsing information after successful return LPCTSTR GetFaceName() const // return the face name of the font @@ -1835,13 +1774,11 @@ public: DECLARE_EMPTY_MSG_MAP() }; -#endif // _WIN32_WCE - /////////////////////////////////////////////////////////////////////////////// // CRichEditFontDialogImpl - font selection for the Rich Edit ctrl -#if defined(_RICHEDIT_) && !defined(_WIN32_WCE) +#ifdef _RICHEDIT_ template class ATL_NO_VTABLE CRichEditFontDialogImpl : public CFontDialogImpl< T > @@ -1853,12 +1790,12 @@ public: HWND hWndParent = NULL) : CFontDialogImpl< T >(NULL, dwFlags, hDCPrinter, hWndParent) { - m_cf.Flags |= CF_INITTOLOGFONTSTRUCT; - m_cf.Flags |= FillInLogFont(charformat); - m_cf.lpLogFont = &m_lf; + this->m_cf.Flags |= CF_INITTOLOGFONTSTRUCT; + this->m_cf.Flags |= FillInLogFont(charformat); + this->m_cf.lpLogFont = &this->m_lf; if((charformat.dwMask & CFM_COLOR) != 0) - m_cf.rgbColors = charformat.crTextColor; + this->m_cf.rgbColors = charformat.crTextColor; } void GetCharFormat(CHARFORMAT& cf) const @@ -1866,40 +1803,36 @@ public: USES_CONVERSION; cf.dwEffects = 0; cf.dwMask = 0; - if((m_cf.Flags & CF_NOSTYLESEL) == 0) + if((this->m_cf.Flags & CF_NOSTYLESEL) == 0) { cf.dwMask |= CFM_BOLD | CFM_ITALIC; - cf.dwEffects |= IsBold() ? CFE_BOLD : 0; - cf.dwEffects |= IsItalic() ? CFE_ITALIC : 0; + cf.dwEffects |= this->IsBold() ? CFE_BOLD : 0; + cf.dwEffects |= this->IsItalic() ? CFE_ITALIC : 0; } - if((m_cf.Flags & CF_NOSIZESEL) == 0) + if((this->m_cf.Flags & CF_NOSIZESEL) == 0) { cf.dwMask |= CFM_SIZE; // GetSize() returns in tenths of points so mulitply by 2 to get twips - cf.yHeight = GetSize() * 2; + cf.yHeight = this->GetSize() * 2; } - if((m_cf.Flags & CF_NOFACESEL) == 0) + if((this->m_cf.Flags & CF_NOFACESEL) == 0) { cf.dwMask |= CFM_FACE; - cf.bPitchAndFamily = m_cf.lpLogFont->lfPitchAndFamily; -#if (_RICHEDIT_VER >= 0x0200) - SecureHelper::strcpy_x(cf.szFaceName, _countof(cf.szFaceName), GetFaceName()); -#else // !(_RICHEDIT_VER >= 0x0200) - SecureHelper::strcpyA_x(cf.szFaceName, _countof(cf.szFaceName), T2A((LPTSTR)(LPCTSTR)GetFaceName())); -#endif // !(_RICHEDIT_VER >= 0x0200) + cf.bPitchAndFamily = this->m_cf.lpLogFont->lfPitchAndFamily; + ATL::Checked::tcscpy_s(cf.szFaceName, _countof(cf.szFaceName), this->GetFaceName()); } - if((m_cf.Flags & CF_EFFECTS) != 0) + if((this->m_cf.Flags & CF_EFFECTS) != 0) { cf.dwMask |= CFM_UNDERLINE | CFM_STRIKEOUT | CFM_COLOR; - cf.dwEffects |= IsUnderline() ? CFE_UNDERLINE : 0; - cf.dwEffects |= IsStrikeOut() ? CFE_STRIKEOUT : 0; - cf.crTextColor = GetColor(); + cf.dwEffects |= this->IsUnderline() ? CFE_UNDERLINE : 0; + cf.dwEffects |= this->IsStrikeOut() ? CFE_STRIKEOUT : 0; + cf.crTextColor = this->GetColor(); } - if((m_cf.Flags & CF_NOSCRIPTSEL) == 0) + if((this->m_cf.Flags & CF_NOSCRIPTSEL) == 0) { - cf.bCharSet = m_cf.lpLogFont->lfCharSet; + cf.bCharSet = this->m_cf.lpLogFont->lfCharSet; cf.dwMask |= CFM_CHARSET; } cf.yOffset = 0; @@ -1913,59 +1846,55 @@ public: { HDC hDC = ::CreateDC(_T("DISPLAY"), NULL, NULL, NULL); LONG yPerInch = ::GetDeviceCaps(hDC, LOGPIXELSY); - m_lf.lfHeight = -(int)((cf.yHeight * yPerInch) / 1440); + this->m_lf.lfHeight = -(int)((cf.yHeight * yPerInch) / 1440); } else - m_lf.lfHeight = 0; + this->m_lf.lfHeight = 0; - m_lf.lfWidth = 0; - m_lf.lfEscapement = 0; - m_lf.lfOrientation = 0; + this->m_lf.lfWidth = 0; + this->m_lf.lfEscapement = 0; + this->m_lf.lfOrientation = 0; if((cf.dwMask & (CFM_ITALIC | CFM_BOLD)) == (CFM_ITALIC | CFM_BOLD)) { - m_lf.lfWeight = ((cf.dwEffects & CFE_BOLD) != 0) ? FW_BOLD : FW_NORMAL; - m_lf.lfItalic = (BYTE)(((cf.dwEffects & CFE_ITALIC) != 0) ? TRUE : FALSE); + this->m_lf.lfWeight = ((cf.dwEffects & CFE_BOLD) != 0) ? FW_BOLD : FW_NORMAL; + this->m_lf.lfItalic = (BYTE)(((cf.dwEffects & CFE_ITALIC) != 0) ? TRUE : FALSE); } else { dwFlags |= CF_NOSTYLESEL; - m_lf.lfWeight = FW_DONTCARE; - m_lf.lfItalic = FALSE; + this->m_lf.lfWeight = FW_DONTCARE; + this->m_lf.lfItalic = FALSE; } if((cf.dwMask & (CFM_UNDERLINE | CFM_STRIKEOUT | CFM_COLOR)) == (CFM_UNDERLINE|CFM_STRIKEOUT|CFM_COLOR)) { dwFlags |= CF_EFFECTS; - m_lf.lfUnderline = (BYTE)(((cf.dwEffects & CFE_UNDERLINE) != 0) ? TRUE : FALSE); - m_lf.lfStrikeOut = (BYTE)(((cf.dwEffects & CFE_STRIKEOUT) != 0) ? TRUE : FALSE); + this->m_lf.lfUnderline = (BYTE)(((cf.dwEffects & CFE_UNDERLINE) != 0) ? TRUE : FALSE); + this->m_lf.lfStrikeOut = (BYTE)(((cf.dwEffects & CFE_STRIKEOUT) != 0) ? TRUE : FALSE); } else { - m_lf.lfUnderline = (BYTE)FALSE; - m_lf.lfStrikeOut = (BYTE)FALSE; + this->m_lf.lfUnderline = (BYTE)FALSE; + this->m_lf.lfStrikeOut = (BYTE)FALSE; } if((cf.dwMask & CFM_CHARSET) != 0) - m_lf.lfCharSet = cf.bCharSet; + this->m_lf.lfCharSet = cf.bCharSet; else dwFlags |= CF_NOSCRIPTSEL; - m_lf.lfOutPrecision = OUT_DEFAULT_PRECIS; - m_lf.lfClipPrecision = CLIP_DEFAULT_PRECIS; - m_lf.lfQuality = DEFAULT_QUALITY; + this->m_lf.lfOutPrecision = OUT_DEFAULT_PRECIS; + this->m_lf.lfClipPrecision = CLIP_DEFAULT_PRECIS; + this->m_lf.lfQuality = DEFAULT_QUALITY; if((cf.dwMask & CFM_FACE) != 0) { - m_lf.lfPitchAndFamily = cf.bPitchAndFamily; -#if (_RICHEDIT_VER >= 0x0200) - SecureHelper::strcpy_x(m_lf.lfFaceName, _countof(m_lf.lfFaceName), cf.szFaceName); -#else // !(_RICHEDIT_VER >= 0x0200) - SecureHelper::strcpy_x(m_lf.lfFaceName, _countof(m_lf.lfFaceName), A2T((LPSTR)cf.szFaceName)); -#endif // !(_RICHEDIT_VER >= 0x0200) + this->m_lf.lfPitchAndFamily = cf.bPitchAndFamily; + ATL::Checked::tcscpy_s(this->m_lf.lfFaceName, _countof(this->m_lf.lfFaceName), cf.szFaceName); } else { - m_lf.lfPitchAndFamily = DEFAULT_PITCH|FF_DONTCARE; - m_lf.lfFaceName[0] = (TCHAR)0; + this->m_lf.lfPitchAndFamily = DEFAULT_PITCH|FF_DONTCARE; + this->m_lf.lfFaceName[0] = (TCHAR)0; } return dwFlags; } @@ -1984,26 +1913,12 @@ public: DECLARE_EMPTY_MSG_MAP() }; -#endif // defined(_RICHEDIT_) && !defined(_WIN32_WCE) +#endif // _RICHEDIT_ /////////////////////////////////////////////////////////////////////////////// // CColorDialogImpl - color selection -#if !defined(_WIN32_WCE) || ((_WIN32_WCE > 420) && !(defined(WIN32_PLATFORM_WFSP) && (_WIN32_WCE > 0x0500))) - -#ifdef _WIN32_WCE - #pragma comment(lib, "commdlg.lib") - - #ifndef SETRGBSTRING - #define SETRGBSTRING _T("commdlg_SetRGBColor") - #endif - - #ifndef COLOROKSTRING - #define COLOROKSTRING _T("commdlg_ColorOK") - #endif -#endif - template class ATL_NO_VTABLE CColorDialogImpl : public CCommonDialogImplBase { @@ -2039,7 +1954,6 @@ public: ATLASSERT(m_hWnd == NULL); -#if (_ATL_VER >= 0x0800) // Allocate the thunk structure here, where we can fail gracefully. BOOL bRetTh = m_thunk.Init(NULL, NULL); if(bRetTh == FALSE) @@ -2047,7 +1961,6 @@ public: ::SetLastError(ERROR_OUTOFMEMORY); return -1; } -#endif // (_ATL_VER >= 0x0800) ModuleHelper::AddCreateWndData(&m_thunk.cd, (CCommonDialogImplBase*)this); @@ -2074,7 +1987,7 @@ public: // Special override for the color dialog static UINT_PTR APIENTRY HookProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - if(uMsg != WM_INITDIALOG && uMsg != _GetColorOKMessage()) + if((uMsg != WM_INITDIALOG) && (uMsg != _GetColorOKMessage())) return 0; LPCHOOSECOLOR lpCC = (LPCHOOSECOLOR)lParam; @@ -2205,14 +2118,10 @@ public: DECLARE_EMPTY_MSG_MAP() }; -#endif // !defined(_WIN32_WCE) || ((_WIN32_WCE > 420) && !(defined(WIN32_PLATFORM_WFSP) && (_WIN32_WCE > 0x0500))) - /////////////////////////////////////////////////////////////////////////////// // CPrintDialogImpl - used for Print... and PrintSetup... -#ifndef _WIN32_WCE - // global helper static inline HDC _AtlCreateDC(HGLOBAL hDevNames, HGLOBAL hDevMode) { @@ -2282,7 +2191,6 @@ public: ATLASSERT(m_hWnd == NULL); -#if (_ATL_VER >= 0x0800) // Allocate the thunk structure here, where we can fail gracefully. BOOL bRetTh = m_thunk.Init(NULL, NULL); if(bRetTh == FALSE) @@ -2290,7 +2198,6 @@ public: ::SetLastError(ERROR_OUTOFMEMORY); return -1; } -#endif // (_ATL_VER >= 0x0800) ModuleHelper::AddCreateWndData(&m_thunk.cd, (CCommonDialogImplBase*)this); @@ -2424,7 +2331,9 @@ public: // The following handle the case of print setup... from the print dialog CPrintDialogImpl(PRINTDLG& pdInit) : m_pd(pdInit) - { } + { + memset(&m_pdActual, 0, sizeof(m_pdActual)); + } BEGIN_MSG_MAP(CPrintDialogImpl) #ifdef psh1 @@ -2457,15 +2366,11 @@ public: #pragma warning(pop) -#endif // _WIN32_WCE - /////////////////////////////////////////////////////////////////////////////// // CPrintDialogExImpl - new print dialog for Windows 2000 -#if (WINVER >= 0x0500) && !defined(_WIN32_WCE) - -}; // namespace WTL +} // namespace WTL #include @@ -2694,10 +2599,10 @@ public: // call message map HRESULT hRet = ProcessWindowMessage(hWnd, uMsg, wParam, lParam, *plResult, 0) ? S_OK : S_FALSE; - if(hRet == S_OK && uMsg == WM_NOTIFY) // return in DWLP_MSGRESULT + if((hRet == S_OK) && (uMsg == WM_NOTIFY)) // return in DWLP_MSGRESULT ::SetWindowLongPtr(GetParent(), DWLP_MSGRESULT, (LONG_PTR)*plResult); - if(uMsg == WM_INITDIALOG && hRet == S_OK && (BOOL)*plResult != FALSE) + if((uMsg == WM_INITDIALOG) && (hRet == S_OK) && ((BOOL)*plResult != FALSE)) hRet = S_FALSE; return hRet; @@ -2716,14 +2621,10 @@ public: DECLARE_EMPTY_MSG_MAP() }; -#endif // (WINVER >= 0x0500) && !defined(_WIN32_WCE) - /////////////////////////////////////////////////////////////////////////////// // CPageSetupDialogImpl - Page Setup dialog -#ifndef _WIN32_WCE - template class ATL_NO_VTABLE CPageSetupDialogImpl : public CCommonDialogImplBase { @@ -2741,11 +2642,7 @@ public: m_psd.Flags = (dwFlags | PSD_ENABLEPAGESETUPHOOK | PSD_ENABLEPAGEPAINTHOOK); m_psd.lpfnPageSetupHook = (LPPAGESETUPHOOK)T::HookProc; m_thunkPaint.Init((WNDPROC)T::PaintHookProc, this); -#if (_ATL_VER >= 0x0700) m_psd.lpfnPagePaintHook = (LPPAGEPAINTHOOK)m_thunkPaint.GetWNDPROC(); -#else - m_psd.lpfnPagePaintHook = (LPPAGEPAINTHOOK)&(m_thunkPaint.thunk); -#endif } DECLARE_EMPTY_MSG_MAP() @@ -2818,7 +2715,6 @@ public: ATLASSERT(m_hWnd == NULL); -#if (_ATL_VER >= 0x0800) // Allocate the thunk structure here, where we can fail gracefully. BOOL bRetTh = m_thunk.Init(NULL, NULL); if(bRetTh == FALSE) @@ -2826,7 +2722,6 @@ public: ::SetLastError(ERROR_OUTOFMEMORY); return -1; } -#endif // (_ATL_VER >= 0x0800) ModuleHelper::AddCreateWndData(&m_thunk.cd, (CCommonDialogImplBase*)this); @@ -2889,14 +2784,10 @@ public: } }; -#endif // _WIN32_WCE - /////////////////////////////////////////////////////////////////////////////// // CFindReplaceDialogImpl - Find/FindReplace modeless dialogs -#ifndef _WIN32_WCE - template class ATL_NO_VTABLE CFindReplaceDialogImpl : public CCommonDialogImplBase { @@ -2948,14 +2839,13 @@ public: ATLASSERT(m_fr.hwndOwner != NULL); // must have an owner for modeless dialog if(lpszFindWhat != NULL) - SecureHelper::strncpy_x(m_szFindWhat, _countof(m_szFindWhat), lpszFindWhat, _TRUNCATE); + ATL::Checked::tcsncpy_s(m_szFindWhat, _countof(m_szFindWhat), lpszFindWhat, _TRUNCATE); if(lpszReplaceWith != NULL) - SecureHelper::strncpy_x(m_szReplaceWith, _countof(m_szReplaceWith), lpszReplaceWith, _TRUNCATE); + ATL::Checked::tcsncpy_s(m_szReplaceWith, _countof(m_szReplaceWith), lpszReplaceWith, _TRUNCATE); ATLASSERT(m_hWnd == NULL); -#if (_ATL_VER >= 0x0800) // Allocate the thunk structure here, where we can fail gracefully. BOOL bRet = m_thunk.Init(NULL, NULL); if(bRet == FALSE) @@ -2963,7 +2853,6 @@ public: ::SetLastError(ERROR_OUTOFMEMORY); return NULL; } -#endif // (_ATL_VER >= 0x0800) ModuleHelper::AddCreateWndData(&m_thunk.cd, (CCommonDialogImplBase*)this); @@ -2977,7 +2866,7 @@ public: return hWnd; } - static const UINT GetFindReplaceMsg() + static UINT GetFindReplaceMsg() { static const UINT nMsgFindReplace = ::RegisterWindowMessage(FINDMSGSTRING); return nMsgFindReplace; @@ -3045,8 +2934,6 @@ public: DECLARE_EMPTY_MSG_MAP() }; -#endif // !_WIN32_WCE - ///////////////////////////////////////////////////////////////////////// // CDialogBaseUnits - Dialog Units helper @@ -3084,7 +2971,7 @@ public: } } - CDialogBaseUnits(LOGFONT lf, HWND hWnd = NULL) + CDialogBaseUnits(const LOGFONT& lf, HWND hWnd = NULL) { if(!InitDialogBaseUnits(lf, hWnd)) { LONG nDlgBaseUnits = ::GetDialogBaseUnits(); @@ -3104,7 +2991,7 @@ public: return TRUE; } - BOOL InitDialogBaseUnits(LOGFONT lf, HWND hWnd = NULL) + BOOL InitDialogBaseUnits(const LOGFONT& lf, HWND hWnd = NULL) { CFont font; font.CreateFontIndirect(&lf); @@ -3116,8 +3003,8 @@ public: { ATLASSERT(hFont != NULL); CWindowDC dc = hWnd; - TEXTMETRIC tmText = { 0 }; - SIZE sizeText = { 0 }; + TEXTMETRIC tmText = {}; + SIZE sizeText = {}; HFONT hFontOld = dc.SelectFont(hFont); dc.GetTextMetrics(&tmText); m_sizeUnits.cy = tmText.tmHeight + tmText.tmExternalLeading; @@ -3193,31 +3080,16 @@ public: /////////////////////////////////////////////////////////////////////////////// // CMemDlgTemplate - in-memory dialog template - DLGTEMPLATE or DLGTEMPLATEEX -#if (_ATL_VER >= 0x800) - typedef ATL::_DialogSplitHelper::DLGTEMPLATEEX DLGTEMPLATEEX; - typedef ATL::_DialogSplitHelper::DLGITEMTEMPLATEEX DLGITEMTEMPLATEEX; -#else // (_ATL_VER >= 0x800) - typedef ATL::_DialogSizeHelper::_ATL_DLGTEMPLATEEX DLGTEMPLATEEX; - #pragma pack(push, 4) - struct DLGITEMTEMPLATEEX - { - DWORD helpID; - DWORD exStyle; - DWORD style; - short x; - short y; - short cx; - short cy; - DWORD id; - }; - #pragma pack(pop) -#endif // (_ATL_VER >= 0x800) - +// traits suitable for dialog controls +typedef ATL::CWinTraits CDlgControlWinTraits; template class CMemDlgTemplateT { public: + typedef ATL::_DialogSplitHelper::DLGTEMPLATEEX DLGTEMPLATEEX; + typedef ATL::_DialogSplitHelper::DLGITEMTEMPLATEEX DLGITEMTEMPLATEEX; + enum StdCtrlType { CTRL_BUTTON = 0x0080, @@ -3263,10 +3135,9 @@ public: void Reset() { - if (IsValid()) { -#ifndef UNDER_CE + if (IsValid()) + { ::GlobalUnlock(m_pData); -#endif ATLVERIFY(::GlobalFree(m_hData) == NULL); } @@ -3309,7 +3180,6 @@ public: AddData(&dlg, sizeof(dlg)); } -#ifndef _WIN32_WCE if (Menu.m_lpstr == NULL) { WORD menuData = 0; @@ -3324,13 +3194,6 @@ public: { AddString(Menu.m_lpstr); } -#else // _WIN32_WCE - // Windows CE doesn't support the addition of menus to a dialog box - ATLASSERT(Menu.m_lpstr == NULL); - Menu.m_lpstr; // avoid level 4 warning - WORD menuData = 0; - AddData(&menuData, sizeof(WORD)); -#endif // _WIN32_WCE if (ClassName.m_lpstr == NULL) { @@ -3450,32 +3313,22 @@ public: m_cAllocated = ((nData / ALLOCATION_INCREMENT) + 1) * ALLOCATION_INCREMENT; m_hData = ::GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, m_cAllocated); ATLASSERT(m_hData != NULL); -#ifndef UNDER_CE m_pPtr = m_pData = static_cast(::GlobalLock(m_hData)); -#else - m_pPtr = m_pData = static_cast(m_hData); -#endif ATLASSERT(m_pData != NULL); } else if (((m_pPtr - m_pData) + nData) > m_cAllocated) { SIZE_T ptrPos = (m_pPtr - m_pData); m_cAllocated += ((nData / ALLOCATION_INCREMENT) + 1) * ALLOCATION_INCREMENT; -#ifndef UNDER_CE ::GlobalUnlock(m_pData); -#endif m_hData = ::GlobalReAlloc(m_hData, m_cAllocated, GMEM_MOVEABLE | GMEM_ZEROINIT); ATLASSERT(m_hData != NULL); -#ifndef UNDER_CE m_pData = static_cast(::GlobalLock(m_hData)); -#else - m_pData = static_cast(m_hData); -#endif ATLASSERT(m_pData != NULL); m_pPtr = m_pData + ptrPos; } - SecureHelper::memcpy_x(m_pPtr, m_cAllocated - (m_pPtr - m_pData), pData, nData); + ATL::Checked::memcpy_s(m_pPtr, m_cAllocated - (m_pPtr - m_pData), pData, nData); m_pPtr += nData; } @@ -3497,7 +3350,7 @@ public: } }; -typedef CMemDlgTemplateT CMemDlgTemplate; +typedef CMemDlgTemplateT CMemDlgTemplate; /////////////////////////////////////////////////////////////////////////////// @@ -3541,7 +3394,7 @@ typedef CMemDlgTemplateT CMemDlgTemplate; #define END_DIALOG() \ m_Template.Create(bExTemplate, szCaption, nX, nY, nWidth, nHeight, dwStyle, dwExStyle, szFontName, wFontSize, wWeight, bItalic, bCharset, dwHelpID, ClassName, Menu); \ - }; + } #define DIALOG_CAPTION(caption) \ szCaption = caption; @@ -3569,7 +3422,7 @@ typedef CMemDlgTemplateT CMemDlgTemplate; { #define END_CONTROLS_MAP() \ - }; + } #define CONTROL_LTEXT(text, id, x, y, width, height, style, exStyle) \ @@ -3582,10 +3435,8 @@ typedef CMemDlgTemplateT CMemDlgTemplate; m_Template.AddStdControl(m_Template.CTRL_BUTTON, (WORD)id, x, y, width, height, style | BS_PUSHBUTTON | WS_TABSTOP, exStyle, text, NULL, 0); #define CONTROL_DEFPUSHBUTTON(text, id, x, y, width, height, style, exStyle) \ m_Template.AddStdControl(m_Template.CTRL_BUTTON, (WORD)id, x, y, width, height, style | BS_DEFPUSHBUTTON | WS_TABSTOP, exStyle, text, NULL, 0); -#ifndef _WIN32_WCE #define CONTROL_PUSHBOX(text, id, x, y, width, height, style, exStyle) \ m_Template.AddStdControl(m_Template.CTRL_BUTTON, (WORD)id, x, y, width, height, style | BS_PUSHBOX | WS_TABSTOP, exStyle, text, NULL, 0); -#endif // !_WIN32_WCE #define CONTROL_STATE3(text, id, x, y, width, height, style, exStyle) \ m_Template.AddStdControl(m_Template.CTRL_BUTTON, (WORD)id, x, y, width, height, style | BS_3STATE | WS_TABSTOP, exStyle, text, NULL, 0); #define CONTROL_AUTO3STATE(text, id, x, y, width, height, style, exStyle) \ @@ -3640,20 +3491,18 @@ public: if(!m_Template.IsValid()) CreateTemplate(); -#if (_ATL_VER >= 0x0800) // Allocate the thunk structure here, where we can fail gracefully. - BOOL bRet = m_thunk.Init(NULL, NULL); + BOOL bRet = this->m_thunk.Init(NULL, NULL); if(bRet == FALSE) { ::SetLastError(ERROR_OUTOFMEMORY); return -1; } -#endif // (_ATL_VER >= 0x0800) - ModuleHelper::AddCreateWndData(&m_thunk.cd, (ATL::CDialogImplBaseT< TBase >*)pT); + ModuleHelper::AddCreateWndData(&this->m_thunk.cd, (ATL::CDialogImplBaseT< TBase >*)pT); #ifdef _DEBUG - m_bModal = true; + this->m_bModal = true; #endif // _DEBUG return ::DialogBoxIndirectParam(ModuleHelper::GetResourceInstance(), m_Template.GetTemplatePtr(), hWndParent, (DLGPROC)T::StartDialogProc, dwInitParam); @@ -3667,24 +3516,22 @@ public: if(!m_Template.IsValid()) CreateTemplate(); -#if (_ATL_VER >= 0x0800) // Allocate the thunk structure here, where we can fail gracefully. - BOOL bRet = m_thunk.Init(NULL, NULL); + BOOL bRet = this->m_thunk.Init(NULL, NULL); if(bRet == FALSE) { ::SetLastError(ERROR_OUTOFMEMORY); return NULL; } -#endif // (_ATL_VER >= 0x0800) - ModuleHelper::AddCreateWndData(&m_thunk.cd, (ATL::CDialogImplBaseT< TBase >*)pT); + ModuleHelper::AddCreateWndData(&this->m_thunk.cd, (ATL::CDialogImplBaseT< TBase >*)pT); #ifdef _DEBUG - m_bModal = false; + this->m_bModal = false; #endif // _DEBUG HWND hWnd = ::CreateDialogIndirectParam(ModuleHelper::GetResourceInstance(), (LPCDLGTEMPLATE)m_Template.GetTemplatePtr(), hWndParent, (DLGPROC)T::StartDialogProc, dwInitParam); - ATLASSERT(m_hWnd == hWnd); + ATLASSERT(this->m_hWnd == hWnd); return hWnd; } @@ -3809,7 +3656,6 @@ public: return (BOOL)::SendMessage(m_hWnd, PSM_ADDPAGE, 0, (LPARAM)hPage); } -#ifndef _WIN32_WCE BOOL InsertPage(int nNewPageIndex, HPROPSHEETPAGE hPage) { ATLASSERT(::IsWindow(m_hWnd)); @@ -3843,7 +3689,6 @@ public: return FALSE; return (BOOL)::SendMessage(m_hWnd, PSM_INSERTPAGE, (WPARAM)hPageInsertAfter, (LPARAM)hPage); } -#endif // !_WIN32_WCE void RemovePage(int nPageIndex) { @@ -3908,7 +3753,6 @@ public: return (BOOL)::SendMessage(m_hWnd, PSM_ISDIALOGMESSAGE, 0, (LPARAM)lpMsg); } -#if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) int HwndToIndex(HWND hWnd) const { ATLASSERT(::IsWindow(m_hWnd)); @@ -3968,7 +3812,6 @@ public: ATLASSERT(::IsWindow(m_hWnd)); ::SendMessage(m_hWnd, PSM_SETHEADERSUBTITLE, nIndex, (LPARAM)lpstrHeaderSubTitle); } -#endif // (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) // Implementation - override to prevent usage HWND Create(LPCTSTR, HWND, ATL::_U_RECT = NULL, LPCTSTR = NULL, DWORD = 0, DWORD = 0, ATL::_U_MENUorID = 0U, LPVOID = NULL) @@ -3988,15 +3831,6 @@ public: PROPSHEETHEADER m_psh; ATL::CSimpleArray m_arrPages; -#if defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) // PPC specific - #ifndef PROPSHEET_LINK_SIZE - #define PROPSHEET_LINK_SIZE 128 - #endif // PROPSHEET_LINK_SIZE - TCHAR m_szLink[PROPSHEET_LINK_SIZE]; - static LPCTSTR m_pszTitle; - static LPCTSTR m_pszLink; -#endif // defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) - // Construction/Destruction CPropertySheetImpl(ATL::_U_STRINGorID title = (LPCTSTR)NULL, UINT uStartPage = 0, HWND hWndParent = NULL) { @@ -4010,11 +3844,6 @@ public: m_psh.nStartPage = uStartPage; m_psh.hwndParent = hWndParent; // if NULL, will be set in DoModal/Create m_psh.pfnCallback = T::PropSheetCallback; - -#if defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) // PPC specific - m_psh.dwFlags |= PSH_MAXIMIZE; - m_szLink[0] = 0; -#endif // defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) } ~CPropertySheetImpl() @@ -4029,7 +3858,7 @@ public: // Callback function and overrideables static int CALLBACK PropSheetCallback(HWND hWnd, UINT uMsg, LPARAM lParam) { - lParam; // avoid level 4 warning + (void)lParam; // avoid level 4 warning int nRet = 0; if(uMsg == PSCB_INITIALIZED) @@ -4041,41 +3870,8 @@ public: // remove page handles array pT->_CleanUpPages(); -#if defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) // PPC specific - m_pszTitle = pT->m_psh.pszCaption; - if(*pT->m_szLink != 0) - m_pszLink = pT->m_szLink; -#endif // defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) // PPC specific - pT->OnSheetInitialized(); } -#if defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) // PPC specific uMsg - else - { - switch(uMsg) - { - case PSCB_GETVERSION : - nRet = COMCTL32_VERSION; - break; - case PSCB_GETTITLE : - if(m_pszTitle != NULL) - { - lstrcpy((LPTSTR)lParam, m_pszTitle); - m_pszTitle = NULL; - } - break; - case PSCB_GETLINKTEXT: - if(m_pszLink != NULL) - { - lstrcpy((LPTSTR)lParam, m_pszLink); - m_pszLink = NULL; - } - break; - default: - break; - } - } -#endif // defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) return nRet; } @@ -4087,7 +3883,7 @@ public: // Create method HWND Create(HWND hWndParent = NULL) { - ATLASSERT(m_hWnd == NULL); + ATLASSERT(this->m_hWnd == NULL); m_psh.dwFlags |= PSH_MODELESS; if(m_psh.hwndParent == NULL) @@ -4097,7 +3893,6 @@ public: T* pT = static_cast(this); -#if (_ATL_VER >= 0x0800) // Allocate the thunk structure here, where we can fail gracefully. BOOL bRet = pT->m_thunk.Init(NULL, NULL); if(bRet == FALSE) @@ -4105,21 +3900,20 @@ public: ::SetLastError(ERROR_OUTOFMEMORY); return NULL; } -#endif // (_ATL_VER >= 0x0800) ModuleHelper::AddCreateWndData(&pT->m_thunk.cd, pT); HWND hWnd = (HWND)::PropertySheet(&m_psh); _CleanUpPages(); // ensure clean-up, required if call failed - ATLASSERT(m_hWnd == hWnd); + ATLASSERT(this->m_hWnd == hWnd); return hWnd; } INT_PTR DoModal(HWND hWndParent = ::GetActiveWindow()) { - ATLASSERT(m_hWnd == NULL); + ATLASSERT(this->m_hWnd == NULL); m_psh.dwFlags &= ~PSH_MODELESS; if(m_psh.hwndParent == NULL) @@ -4129,7 +3923,6 @@ public: T* pT = static_cast(this); -#if (_ATL_VER >= 0x0800) // Allocate the thunk structure here, where we can fail gracefully. BOOL bRet = pT->m_thunk.Init(NULL, NULL); if(bRet == FALSE) @@ -4137,7 +3930,6 @@ public: ::SetLastError(ERROR_OUTOFMEMORY); return -1; } -#endif // (_ATL_VER >= 0x0800) ModuleHelper::AddCreateWndData(&pT->m_thunk.cd, pT); @@ -4160,35 +3952,35 @@ public: // Note: Calling these after the sheet is created gives unpredictable results int GetPageCount() const { - if(m_hWnd == NULL) // not created yet + if(this->m_hWnd == NULL) // not created yet return m_arrPages.GetSize(); return TBase::GetPageCount(); } int GetActiveIndex() const { - if(m_hWnd == NULL) // not created yet + if(this->m_hWnd == NULL) // not created yet return m_psh.nStartPage; return TBase::GetActiveIndex(); } HPROPSHEETPAGE GetPage(int nPageIndex) const { - ATLASSERT(m_hWnd == NULL); // can't do this after it's created + ATLASSERT(this->m_hWnd == NULL); // can't do this after it's created return (HPROPSHEETPAGE)m_arrPages[nPageIndex]; } int GetPageIndex(HPROPSHEETPAGE hPage) const { - ATLASSERT(m_hWnd == NULL); // can't do this after it's created + ATLASSERT(this->m_hWnd == NULL); // can't do this after it's created return m_arrPages.Find((HPROPSHEETPAGE&)hPage); } BOOL SetActivePage(int nPageIndex) { - if(m_hWnd == NULL) // not created yet + if(this->m_hWnd == NULL) // not created yet { - ATLASSERT(nPageIndex >= 0 && nPageIndex < m_arrPages.GetSize()); + ATLASSERT((nPageIndex >= 0) && (nPageIndex < m_arrPages.GetSize())); m_psh.nStartPage = nPageIndex; return TRUE; } @@ -4198,7 +3990,7 @@ public: BOOL SetActivePage(HPROPSHEETPAGE hPage) { ATLASSERT(hPage != NULL); - if (m_hWnd == NULL) // not created yet + if(this->m_hWnd == NULL) // not created yet { int nPageIndex = GetPageIndex(hPage); if(nPageIndex == -1) @@ -4215,7 +4007,7 @@ public: ATLASSERT((nStyle & ~PSH_PROPTITLE) == 0); // only PSH_PROPTITLE is valid ATLASSERT(lpszText != NULL); - if(m_hWnd == NULL) + if(this->m_hWnd == NULL) { // set internal state m_psh.pszCaption = lpszText; // must exist until sheet is created @@ -4229,15 +4021,6 @@ public: } } -#if defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) // PPC specific Link field - void SetLinkText(LPCTSTR lpszText) - { - ATLASSERT(lpszText != NULL); - ATLASSERT(lstrlen(lpszText) < PROPSHEET_LINK_SIZE); - lstrcpy(m_szLink, lpszText); - } -#endif // defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) - void SetWizardMode() { m_psh.dwFlags |= PSH_WIZARD; @@ -4253,7 +4036,7 @@ public: { ATLASSERT(hPage != NULL); BOOL bRet = FALSE; - if(m_hWnd != NULL) + if(this->m_hWnd != NULL) bRet = TBase::AddPage(hPage); else // sheet not created yet, use internal data bRet = m_arrPages.Add((HPROPSHEETPAGE&)hPage); @@ -4275,7 +4058,7 @@ public: BOOL RemovePage(HPROPSHEETPAGE hPage) { ATLASSERT(hPage != NULL); - if (m_hWnd == NULL) // not created yet + if(this->m_hWnd == NULL) // not created yet { int nPage = GetPageIndex(hPage); if(nPage == -1) @@ -4290,17 +4073,16 @@ public: BOOL RemovePage(int nPageIndex) { BOOL bRet = TRUE; - if(m_hWnd != NULL) + if(this->m_hWnd != NULL) TBase::RemovePage(nPageIndex); else // sheet not created yet, use internal data bRet = m_arrPages.RemoveAt(nPageIndex); return bRet; } -#if (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) void SetHeader(LPCTSTR szbmHeader) { - ATLASSERT(m_hWnd == NULL); // can't do this after it's created + ATLASSERT(this->m_hWnd == NULL); // can't do this after it's created m_psh.dwFlags &= ~PSH_WIZARD; m_psh.dwFlags |= (PSH_HEADER | PSH_WIZARD97); @@ -4309,7 +4091,7 @@ public: void SetHeader(HBITMAP hbmHeader) { - ATLASSERT(m_hWnd == NULL); // can't do this after it's created + ATLASSERT(this->m_hWnd == NULL); // can't do this after it's created m_psh.dwFlags &= ~PSH_WIZARD; m_psh.dwFlags |= (PSH_HEADER | PSH_USEHBMHEADER | PSH_WIZARD97); @@ -4318,13 +4100,13 @@ public: void SetWatermark(LPCTSTR szbmWatermark, HPALETTE hplWatermark = NULL) { - ATLASSERT(m_hWnd == NULL); // can't do this after it's created + ATLASSERT(this->m_hWnd == NULL); // can't do this after it's created m_psh.dwFlags &= ~PSH_WIZARD; m_psh.dwFlags |= PSH_WATERMARK | PSH_WIZARD97; m_psh.pszbmWatermark = szbmWatermark; - if (hplWatermark != NULL) + if(hplWatermark != NULL) { m_psh.dwFlags |= PSH_USEHPLWATERMARK; m_psh.hplWatermark = hplWatermark; @@ -4333,13 +4115,13 @@ public: void SetWatermark(HBITMAP hbmWatermark, HPALETTE hplWatermark = NULL) { - ATLASSERT(m_hWnd == NULL); // can't do this after it's created + ATLASSERT(this->m_hWnd == NULL); // can't do this after it's created m_psh.dwFlags &= ~PSH_WIZARD; m_psh.dwFlags |= (PSH_WATERMARK | PSH_USEHBMWATERMARK | PSH_WIZARD97); m_psh.hbmWatermark = hbmWatermark; - if (hplWatermark != NULL) + if(hplWatermark != NULL) { m_psh.dwFlags |= PSH_USEHPLWATERMARK; m_psh.hplWatermark = hplWatermark; @@ -4348,13 +4130,12 @@ public: void StretchWatermark(bool bStretchWatermark) { - ATLASSERT(m_hWnd == NULL); // can't do this after it's created - if (bStretchWatermark) + ATLASSERT(this->m_hWnd == NULL); // can't do this after it's created + if(bStretchWatermark) m_psh.dwFlags |= PSH_STRETCHWATERMARK; else m_psh.dwFlags &= ~PSH_STRETCHWATERMARK; } -#endif // (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) // Message map and handlers BEGIN_MSG_MAP(CPropertySheetImpl) @@ -4364,30 +4145,23 @@ public: LRESULT OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) { - LRESULT lRet = DefWindowProc(uMsg, wParam, lParam); - if(HIWORD(wParam) == BN_CLICKED && (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) && - ((m_psh.dwFlags & PSH_MODELESS) != 0) && (GetActivePage() == NULL)) - DestroyWindow(); + LRESULT lRet = this->DefWindowProc(uMsg, wParam, lParam); + if((HIWORD(wParam) == BN_CLICKED) && ((LOWORD(wParam) == IDOK) || (LOWORD(wParam) == IDCANCEL)) && + ((m_psh.dwFlags & PSH_MODELESS) != 0) && (this->GetActivePage() == NULL)) + this->DestroyWindow(); return lRet; } LRESULT OnSysCommand(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) { if(((m_psh.dwFlags & PSH_MODELESS) == PSH_MODELESS) && ((wParam & 0xFFF0) == SC_CLOSE)) - SendMessage(WM_CLOSE); + this->SendMessage(WM_CLOSE); else bHandled = FALSE; return 0; } }; -#if defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) // PPC static pointers -template < class T, class TBase > -LPCWSTR CPropertySheetImpl::m_pszTitle = NULL; -template < class T, class TBase> -LPCWSTR CPropertySheetImpl::m_pszLink = NULL; -#endif // defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) - // for non-customized sheets class CPropertySheet : public CPropertySheetImpl { @@ -4482,6 +4256,19 @@ public: /////////////////////////////////////////////////////////////////////////////// // CPropertyPageImpl - implements a property page +#if defined(_WTL_FORCE_OLD_PAGE_NOTIFY_HANDLERS) && defined(_WTL_NEW_PAGE_NOTIFY_HANDLERS) + #error _WTL_FORCE_OLD_PAGE_NOTIFY_HANDLERS and _WTL_NEW_PAGE_NOTIFY_HANDLERS cannot be both defined +#endif + +#if !defined(_WTL_FORCE_OLD_PAGE_NOTIFY_HANDLERS) && !defined(_WTL_NEW_PAGE_NOTIFY_HANDLERS) + #define _WTL_NEW_PAGE_NOTIFY_HANDLERS +#endif + +// NOTE: _WTL_NEW_PAGE_NOTIFY_HANDLERS is now defined by default. +// It enables use of new notification handlers that +// return direct values without any restrictions. +// Define _WTL_FORCE_OLD_PAGE_NOTIFY_HANDLERS to use old handlers. + template class ATL_NO_VTABLE CPropertyPageImpl : public ATL::CDialogImplBaseT< TBase > { @@ -4511,7 +4298,7 @@ public: // Callback function and overrideables static UINT CALLBACK PropPageCallback(HWND hWnd, UINT uMsg, LPPROPSHEETPAGE ppsp) { - hWnd; // avoid level 4 warning + (void)hWnd; // avoid level 4 warning ATLASSERT(hWnd == NULL); T* pT = (T*)ppsp->lParam; UINT uRet = 0; @@ -4525,11 +4312,9 @@ public: uRet = pT->OnPageCreate() ? 1 : 0; } break; -#if (_WIN32_IE >= 0x0500) case PSPCB_ADDREF: pT->OnPageAddRef(); break; -#endif // (_WIN32_IE >= 0x0500) case PSPCB_RELEASE: pT->OnPageRelease(); break; @@ -4545,11 +4330,9 @@ public: return true; // true - allow page to be created, false - prevent creation } -#if (_WIN32_IE >= 0x0500) void OnPageAddRef() { } -#endif // (_WIN32_IE >= 0x0500) void OnPageRelease() { @@ -4568,21 +4351,19 @@ public: m_psp.dwFlags |= PSP_USETITLE; } -#if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) void SetHeaderTitle(LPCTSTR lpstrHeaderTitle) { - ATLASSERT(m_hWnd == NULL); // can't do this after it's created + ATLASSERT(this->m_hWnd == NULL); // can't do this after it's created m_psp.dwFlags |= PSP_USEHEADERTITLE; m_psp.pszHeaderTitle = lpstrHeaderTitle; } void SetHeaderSubTitle(LPCTSTR lpstrHeaderSubTitle) { - ATLASSERT(m_hWnd == NULL); // can't do this after it's created + ATLASSERT(this->m_hWnd == NULL); // can't do this after it's created m_psp.dwFlags |= PSP_USEHEADERSUBTITLE; m_psp.pszHeaderSubTitle = lpstrHeaderSubTitle; } -#endif // (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) // Operations void EnableHelp() @@ -4595,25 +4376,17 @@ public: MESSAGE_HANDLER(WM_NOTIFY, OnNotify) END_MSG_MAP() - // NOTE: Define _WTL_NEW_PAGE_NOTIFY_HANDLERS to use new notification - // handlers that return direct values without any restrictions LRESULT OnNotify(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled) { -#ifndef _WIN32_WCE - // This notification is sometimes received on Windows CE after the window is already destroyed - ATLASSERT(::IsWindow(m_hWnd)); -#endif + ATLASSERT(::IsWindow(this->m_hWnd)); NMHDR* pNMHDR = (NMHDR*)lParam; // don't handle messages not from the page/sheet itself - if(pNMHDR->hwndFrom != m_hWnd && pNMHDR->hwndFrom != ::GetParent(m_hWnd)) + if((pNMHDR->hwndFrom != this->m_hWnd) && (pNMHDR->hwndFrom != ::GetParent(this->m_hWnd))) { bHandled = FALSE; return 1; } -#ifdef _WIN32_WCE - ATLASSERT(::IsWindow(m_hWnd)); -#endif T* pT = static_cast(this); LRESULT lResult = 0; @@ -4647,14 +4420,10 @@ public: case PSN_HELP: pT->OnHelp(); break; -#ifndef _WIN32_WCE -#if (_WIN32_IE >= 0x0400) case PSN_GETOBJECT: if(!pT->OnGetObject((LPNMOBJECTNOTIFY)lParam)) bHandled = FALSE; break; -#endif // (_WIN32_IE >= 0x0400) -#if (_WIN32_IE >= 0x0500) case PSN_TRANSLATEACCELERATOR: { LPPSHNOTIFY lpPSHNotify = (LPPSHNOTIFY)lParam; @@ -4667,8 +4436,6 @@ public: lResult = (LRESULT)pT->OnQueryInitialFocus((HWND)lpPSHNotify->lParam); } break; -#endif // (_WIN32_IE >= 0x0500) -#endif // !_WIN32_WCE #else // !_WTL_NEW_PAGE_NOTIFY_HANDLERS case PSN_SETACTIVE: @@ -4698,14 +4465,10 @@ public: case PSN_HELP: pT->OnHelp(); break; -#ifndef _WIN32_WCE -#if (_WIN32_IE >= 0x0400) case PSN_GETOBJECT: if(!pT->OnGetObject((LPNMOBJECTNOTIFY)lParam)) bHandled = FALSE; break; -#endif // (_WIN32_IE >= 0x0400) -#if (_WIN32_IE >= 0x0500) case PSN_TRANSLATEACCELERATOR: { LPPSHNOTIFY lpPSHNotify = (LPPSHNOTIFY)lParam; @@ -4718,8 +4481,6 @@ public: lResult = (LRESULT)pT->OnQueryInitialFocus((HWND)lpPSHNotify->lParam); } break; -#endif // (_WIN32_IE >= 0x0500) -#endif // !_WIN32_WCE #endif // !_WTL_NEW_PAGE_NOTIFY_HANDLERS default: @@ -4730,8 +4491,6 @@ public: } // Overridables - // NOTE: Define _WTL_NEW_PAGE_NOTIFY_HANDLERS to use new notification - // handlers that return direct values without any restrictions #ifdef _WTL_NEW_PAGE_NOTIFY_HANDLERS int OnSetActive() { @@ -4795,15 +4554,11 @@ public: { } -#ifndef _WIN32_WCE -#if (_WIN32_IE >= 0x0400) BOOL OnGetObject(LPNMOBJECTNOTIFY /*lpObjectNotify*/) { return FALSE; // not processed } -#endif // (_WIN32_IE >= 0x0400) -#if (_WIN32_IE >= 0x0500) int OnTranslateAccelerator(LPMSG /*lpMsg*/) { // PSNRET_NOERROR - message not handled @@ -4817,8 +4572,6 @@ public: // HWND = set focus to HWND return NULL; } -#endif // (_WIN32_IE >= 0x0500) -#endif // !_WIN32_WCE #else // !_WTL_NEW_PAGE_NOTIFY_HANDLERS BOOL OnSetActive() @@ -4870,15 +4623,11 @@ public: { } -#ifndef _WIN32_WCE -#if (_WIN32_IE >= 0x0400) BOOL OnGetObject(LPNMOBJECTNOTIFY /*lpObjectNotify*/) { return FALSE; // not processed } -#endif // (_WIN32_IE >= 0x0400) -#if (_WIN32_IE >= 0x0500) BOOL OnTranslateAccelerator(LPMSG /*lpMsg*/) { return FALSE; // not translated @@ -4888,8 +4637,6 @@ public: { return NULL; // default } -#endif // (_WIN32_IE >= 0x0500) -#endif // !_WIN32_WCE #endif // !_WTL_NEW_PAGE_NOTIFY_HANDLERS }; @@ -4929,7 +4676,7 @@ public: m_hInitData(NULL), m_hDlgRes(NULL), m_hDlgResSplit(NULL) { T* pT = static_cast(this); - pT; // avoid level 4 warning + (void)pT; // avoid level 4 warning // initialize ActiveX hosting and modify dialog template ATL::AtlAxWinInit(); @@ -4957,8 +4704,8 @@ public: // set up property page to use in-memory dialog template if(lpDialogTemplate != NULL) { - m_psp.dwFlags |= PSP_DLGINDIRECT; - m_psp.pResource = lpDialogTemplate; + this->m_psp.dwFlags |= PSP_DLGINDIRECT; + this->m_psp.pResource = lpDialogTemplate; } else { @@ -4993,25 +4740,24 @@ public: // call this one to handle keyboard message for ActiveX controls BOOL PreTranslateMessage(LPMSG pMsg) { - if ((pMsg->message < WM_KEYFIRST || pMsg->message > WM_KEYLAST) && - (pMsg->message < WM_MOUSEFIRST || pMsg->message > WM_MOUSELAST)) + if (((pMsg->message < WM_KEYFIRST) || (pMsg->message > WM_KEYLAST)) && + ((pMsg->message < WM_MOUSEFIRST) || (pMsg->message > WM_MOUSELAST))) return FALSE; // find a direct child of the dialog from the window that has focus HWND hWndCtl = ::GetFocus(); - if (IsChild(hWndCtl) && ::GetParent(hWndCtl) != m_hWnd) + if (this->IsChild(hWndCtl) && (::GetParent(hWndCtl) != this->m_hWnd)) { do { hWndCtl = ::GetParent(hWndCtl); } - while (::GetParent(hWndCtl) != m_hWnd); + while (::GetParent(hWndCtl) != this->m_hWnd); } // give controls a chance to translate this message return (BOOL)::SendMessage(hWndCtl, WM_FORWARDMSG, 0, (LPARAM)pMsg); } // Overridables -#if (_WIN32_IE >= 0x0500) // new default implementation for ActiveX hosting pages #ifdef _WTL_NEW_PAGE_NOTIFY_HANDLERS int OnTranslateAccelerator(LPMSG lpMsg) @@ -5026,10 +4772,7 @@ public: return pT->PreTranslateMessage(lpMsg); } #endif // !_WTL_NEW_PAGE_NOTIFY_HANDLERS -#endif // (_WIN32_IE >= 0x0500) -// Support for new stuff in ATL7 -#if (_ATL_VER >= 0x0700) int GetIDD() { return( static_cast(this)->IDD ); @@ -5086,7 +4829,7 @@ public: // Get first control on the dialog DLGITEMTEMPLATE* pItem = ATL::_DialogSplitHelper::FindFirstDlgItem(pDlg); - HWND hWndPrev = GetWindow(GW_CHILD); + HWND hWndPrev = this->GetWindow(GW_CHILD); // Create all ActiveX cotnrols in the dialog template and place them in the correct tab order (z-order) for (WORD nItem = 0; nItem < nItems; nItem++) @@ -5104,7 +4847,7 @@ public: { BYTE* pBytes = (BYTE*) GlobalLock(h); BYTE* pSource = pData; - SecureHelper::memcpy_x(pBytes, dwLen, pSource, dwLen); + ATL::Checked::memcpy_s(pBytes, dwLen, pSource, dwLen); GlobalUnlock(h); CreateStreamOnHGlobal(h, TRUE, &spStream); } @@ -5126,17 +4869,17 @@ public: (LPWSTR)(((ATL::_DialogSplitHelper::DLGITEMTEMPLATEEX*)pItem) + 1) : (LPWSTR)(pItem + 1); // Get control rect. - RECT rect = { 0 }; + RECT rect = {}; rect.left = bDialogEx ? ((ATL::_DialogSplitHelper::DLGITEMTEMPLATEEX*)pItem)->x : pItem->x; rect.top = bDialogEx ? ((ATL::_DialogSplitHelper::DLGITEMTEMPLATEEX*)pItem)->y : pItem->y; rect.right = rect.left + (bDialogEx ? ((ATL::_DialogSplitHelper::DLGITEMTEMPLATEEX*)pItem)->cx : pItem->cx); rect.bottom = rect.top + (bDialogEx ? ((ATL::_DialogSplitHelper::DLGITEMTEMPLATEEX*)pItem)->cy : pItem->cy); // Convert from dialog units to screen units - MapDialogRect(&rect); + this->MapDialogRect(&rect); // Create AxWindow with a NULL caption. - wnd.Create(m_hWnd, + wnd.Create(this->m_hWnd, &rect, NULL, (bDialogEx ? @@ -5152,11 +4895,9 @@ public: if (wnd != NULL) { -#ifndef _WIN32_WCE // Set the Help ID if (bDialogEx && ((ATL::_DialogSplitHelper::DLGITEMTEMPLATEEX*)pItem)->helpID != 0) wnd.SetWindowContextHelpId(((ATL::_DialogSplitHelper::DLGITEMTEMPLATEEX*)pItem)->helpID); -#endif // !_WIN32_WCE // Try to create the ActiveX control. hr = wnd.CreateControlLic(pszClassName, spStream, NULL, bstrLicKey); if (FAILED(hr)) @@ -5193,7 +4934,7 @@ public: // Event handling support HRESULT AdviseSinkMap(bool bAdvise) { - if(!bAdvise && m_hWnd == NULL) + if(!bAdvise && (this->m_hWnd == NULL)) { // window is gone, controls are already unadvised ATLTRACE2(atlTraceUI, 0, _T("CAxPropertyPageImpl::AdviseSinkMap called after the window was destroyed\n")); @@ -5219,7 +4960,7 @@ public: LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) { // initialize controls in dialog with DLGINIT resource section - ExecuteDlgInit(static_cast(this)->IDD); + this->ExecuteDlgInit(static_cast(this)->IDD); AdviseSinkMap(true); bHandled = FALSE; return 1; @@ -5231,7 +4972,6 @@ public: bHandled = FALSE; return 1; } -#endif // (_ATL_VER >= 0x0700) }; // for non-customized pages @@ -5244,14 +4984,9 @@ public: CAxPropertyPage(ATL::_U_STRINGorID title = (LPCTSTR)NULL) : CAxPropertyPageImpl(title) { } -#if (_WIN32_IE >= 0x0500) || (_ATL_VER >= 0x0700) - // not empty so we handle accelerators/create controls BEGIN_MSG_MAP(CAxPropertyPage) CHAIN_MSG_MAP(CAxPropertyPageImpl >) END_MSG_MAP() -#else // !((_WIN32_IE >= 0x0500) || (_ATL_VER >= 0x0700)) - DECLARE_EMPTY_MSG_MAP() -#endif // !((_WIN32_IE >= 0x0500) || (_ATL_VER >= 0x0700)) }; #endif // _ATL_NO_HOSTING @@ -5260,8 +4995,6 @@ public: /////////////////////////////////////////////////////////////////////////////// // Wizard97 Support -#if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) - // Sample wizard dialog resources: // // IDD_WIZ97_INTERIOR_BLANK DIALOG 0, 0, 317, 143 @@ -5425,11 +5158,11 @@ public: baseClass(title, uStartPage, hWndParent), m_bReceivedFirstSizeMessage(false) { - m_psh.dwFlags &= ~(PSH_NOCONTEXTHELP); - m_psh.dwFlags &= ~(PSH_WIZARD | PSH_WIZARD_LITE); + this->m_psh.dwFlags &= ~(PSH_NOCONTEXTHELP); + this->m_psh.dwFlags &= ~(PSH_WIZARD | PSH_WIZARD_LITE); - m_psh.dwFlags |= (PSH_HASHELP | PSH_WIZARDCONTEXTHELP); - m_psh.dwFlags |= PSH_WIZARD97; + this->m_psh.dwFlags |= (PSH_HASHELP | PSH_WIZARDCONTEXTHELP); + this->m_psh.dwFlags |= PSH_WIZARD97; baseClass::SetHeader(headerBitmap.m_lpstr); baseClass::SetWatermark(watermarkBitmap.m_lpstr); @@ -5455,8 +5188,8 @@ public: CFontHandle fontThisDialog = this->GetFont(); CClientDC dcScreen(NULL); - LOGFONT titleLogFont = {0}; - LOGFONT bulletLogFont = {0}; + LOGFONT titleLogFont = {}; + LOGFONT bulletLogFont = {}; fontThisDialog.GetLogFont(&titleLogFont); fontThisDialog.GetLogFont(&bulletLogFont); @@ -5464,7 +5197,7 @@ public: // as Verdana Bold, 12pt. titleLogFont.lfCharSet = DEFAULT_CHARSET; titleLogFont.lfWeight = FW_BOLD; - SecureHelper::strcpy_x(titleLogFont.lfFaceName, _countof(titleLogFont.lfFaceName), _T("Verdana Bold")); + ATL::Checked::tcscpy_s(titleLogFont.lfFaceName, _countof(titleLogFont.lfFaceName), _T("Verdana Bold")); INT titleFontPointSize = 12; titleLogFont.lfHeight = -::MulDiv(titleFontPointSize, dcScreen.GetDeviceCaps(LOGPIXELSY), 72); m_fontExteriorPageTitle.CreateFontIndirect(&titleLogFont); @@ -5473,7 +5206,7 @@ public: // static text of "h" in the Marlett font. bulletLogFont.lfCharSet = DEFAULT_CHARSET; bulletLogFont.lfWeight = FW_NORMAL; - SecureHelper::strcpy_x(bulletLogFont.lfFaceName, _countof(bulletLogFont.lfFaceName), _T("Marlett")); + ATL::Checked::tcscpy_s(bulletLogFont.lfFaceName, _countof(bulletLogFont.lfFaceName), _T("Marlett")); INT bulletFontSize = 8; bulletLogFont.lfHeight = -::MulDiv(bulletFontSize, dcScreen.GetDeviceCaps(LOGPIXELSY), 72); m_fontBullet.CreateFontIndirect(&bulletLogFont); @@ -5618,8 +5351,8 @@ public: // Constructors CWizard97ExteriorPageImpl(ATL::_U_STRINGorID title = (LPCTSTR)NULL) : baseClass(title) { - m_psp.dwFlags |= PSP_HASHELP; - m_psp.dwFlags |= PSP_HIDEHEADER; + this->m_psp.dwFlags |= PSP_HASHELP; + this->m_psp.dwFlags |= PSP_HIDEHEADER; } // Message Handling @@ -5644,9 +5377,9 @@ public: // Constructors CWizard97InteriorPageImpl(ATL::_U_STRINGorID title = (LPCTSTR)NULL) : baseClass(title) { - m_psp.dwFlags |= PSP_HASHELP; - m_psp.dwFlags &= ~PSP_HIDEHEADER; - m_psp.dwFlags |= PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE; + this->m_psp.dwFlags |= PSP_HASHELP; + this->m_psp.dwFlags &= ~PSP_HIDEHEADER; + this->m_psp.dwFlags |= PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE; // Be sure to have the derived class define this in the constructor. // We'll default it to something obvious in case its forgotten. @@ -5660,13 +5393,11 @@ public: END_MSG_MAP() }; -#endif // (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) - /////////////////////////////////////////////////////////////////////////////// // Aero Wizard support -#if (_WIN32_WINNT >= 0x0600) && !defined(_WIN32_WCE) +#if (_WIN32_WINNT >= 0x0600) /////////////////////////////////////////////////////////////////////////////// // CAeroWizardFrameWindow - client side for an Aero Wizard frame window @@ -5722,26 +5453,26 @@ public: CAeroWizardFrameImpl(ATL::_U_STRINGorID title = (LPCTSTR)NULL, UINT uStartPage = 0, HWND hWndParent = NULL) : CPropertySheetImpl(title, uStartPage, hWndParent) { - m_psh.dwFlags |= PSH_WIZARD | PSH_AEROWIZARD; + this->m_psh.dwFlags |= PSH_WIZARD | PSH_AEROWIZARD; } // Operations void EnableResizing() { - ATLASSERT(m_hWnd == NULL); // can't do this after it's created - m_psh.dwFlags |= PSH_RESIZABLE; + ATLASSERT(this->m_hWnd == NULL); // can't do this after it's created + this->m_psh.dwFlags |= PSH_RESIZABLE; } void UseHeaderBitmap() { - ATLASSERT(m_hWnd == NULL); // can't do this after it's created - m_psh.dwFlags |= PSH_HEADERBITMAP; + ATLASSERT(this->m_hWnd == NULL); // can't do this after it's created + this->m_psh.dwFlags |= PSH_HEADERBITMAP; } void SetNoMargin() { - ATLASSERT(m_hWnd == NULL); // can't do this after it's created - m_psh.dwFlags |= PSH_NOMARGIN; + ATLASSERT(this->m_hWnd == NULL); // can't do this after it's created + this->m_psh.dwFlags |= PSH_NOMARGIN; } // Override to prevent use @@ -5880,25 +5611,20 @@ public: CAeroWizardAxPage(ATL::_U_STRINGorID title = (LPCTSTR)NULL) : CAeroWizardAxPageImpl(title) { } -#if (_WIN32_IE >= 0x0500) || (_ATL_VER >= 0x0700) - // not empty so we handle accelerators/create controls BEGIN_MSG_MAP(CAeroWizardAxPage) CHAIN_MSG_MAP(CAeroWizardAxPageImpl >) END_MSG_MAP() -#else // !((_WIN32_IE >= 0x0500) || (_ATL_VER >= 0x0700)) - DECLARE_EMPTY_MSG_MAP() -#endif // !((_WIN32_IE >= 0x0500) || (_ATL_VER >= 0x0700)) }; #endif // _ATL_NO_HOSTING -#endif // (_WIN32_WINNT >= 0x0600) && !defined(_WIN32_WCE) +#endif // (_WIN32_WINNT >= 0x0600) /////////////////////////////////////////////////////////////////////////////// // TaskDialog support -#if ((_WIN32_WINNT >= 0x0600) || defined(_WTL_TASKDIALOG)) && !defined(_WIN32_WCE) +#if (_WIN32_WINNT >= 0x0600) || defined(_WTL_TASKDIALOG) /////////////////////////////////////////////////////////////////////////////// // AtlTaskDialog - support for TaskDialog() function @@ -6267,7 +5993,7 @@ public: static HRESULT CALLBACK TaskDialogCallback(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LONG_PTR lpRefData) { T* pT = (T*)lpRefData; - ATLASSERT(pT->m_hWnd == NULL || pT->m_hWnd == hWnd); + ATLASSERT((pT->m_hWnd == NULL) || (pT->m_hWnd == hWnd)); BOOL bRet = FALSE; switch(uMsg) @@ -6500,8 +6226,8 @@ public: } }; -#endif // ((_WIN32_WINNT >= 0x0600) || defined(_WTL_TASKDIALOG)) && !defined(_WIN32_WCE) +#endif // (_WIN32_WINNT >= 0x0600) || defined(_WTL_TASKDIALOG) -}; // namespace WTL +} // namespace WTL #endif // __ATLDLGS_H__ diff --git a/WrlSDK/SampleCode/PluginWinExe/WTL/atldwm.h b/WrlSDK/SampleCode/PluginWinExe/WTL/atldwm.h index 52b67c658f33a0e2d35a1d30e861f3a0d556f22c..f78d30fc87ecacbd1037ddbe54a8188258b678ff 100644 --- a/WrlSDK/SampleCode/PluginWinExe/WTL/atldwm.h +++ b/WrlSDK/SampleCode/PluginWinExe/WTL/atldwm.h @@ -1,4 +1,4 @@ -// Windows Template Library - WTL version 9.10 +// Windows Template Library - WTL version 10.0 // Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. // // This file is a part of the Windows Template Library. @@ -11,10 +11,6 @@ #pragma once -#ifdef _WIN32_WCE - #error atldwm.h is not supported on Windows CE -#endif - #ifndef __ATLAPP_H__ #error atldwm.h requires atlapp.h to be included first #endif @@ -37,10 +33,7 @@ // Delay load is NOT AUTOMATIC for VC++ 7, you have to link to delayimp.lib, // and add dwmapi.dll in the Linker.Input.Delay Loaded DLLs section of the // project properties. -#if (_MSC_VER < 1300) && !defined(_WTL_NO_DWMAPI_DELAYLOAD) - #pragma comment(lib, "delayimp.lib") - #pragma comment(linker, "/delayload:dwmapi.dll") -#endif // (_MSC_VER < 1300) && !defined(_WTL_NO_DWMAPI_DELAYLOAD) + /////////////////////////////////////////////////////////////////////////////// // Classes in this file: @@ -155,7 +148,7 @@ class CDwmImpl : public TBase public: HRESULT DwmEnableBlurBehindWindow(const DWM_BLURBEHIND* pBB) { - if(!IsDwmSupported()) + if(!this->IsDwmSupported()) return E_NOTIMPL; T* pT = static_cast(this); @@ -165,7 +158,7 @@ public: HRESULT DwmExtendFrameIntoClientArea(const MARGINS* pMargins) { - if(!IsDwmSupported()) + if(!this->IsDwmSupported()) return E_NOTIMPL; T* pT = static_cast(this); @@ -181,7 +174,7 @@ public: HRESULT DwmGetCompositionTimingInfo(DWM_TIMING_INFO* pTimingInfo) { - if(!IsDwmSupported()) + if(!this->IsDwmSupported()) return E_NOTIMPL; T* pT = static_cast(this); @@ -191,7 +184,7 @@ public: HRESULT DwmGetWindowAttribute(DWORD dwAttribute, PVOID pvAttribute, DWORD cbAttribute) { - if(!IsDwmSupported()) + if(!this->IsDwmSupported()) return E_NOTIMPL; T* pT = static_cast(this); @@ -201,7 +194,7 @@ public: HRESULT DwmModifyPreviousDxFrameDuration(INT cRefreshes, BOOL fRelative) { - if(!IsDwmSupported()) + if(!this->IsDwmSupported()) return E_NOTIMPL; T* pT = static_cast(this); @@ -211,7 +204,7 @@ public: HRESULT DwmSetDxFrameDuration(INT cRefreshes) { - if(!IsDwmSupported()) + if(!this->IsDwmSupported()) return E_NOTIMPL; T* pT = static_cast(this); @@ -221,7 +214,7 @@ public: HRESULT DwmSetPresentParameters(DWM_PRESENT_PARAMETERS* pPresentParams) { - if(!IsDwmSupported()) + if(!this->IsDwmSupported()) return E_NOTIMPL; T* pT = static_cast(this); @@ -231,7 +224,7 @@ public: HRESULT DwmSetWindowAttribute(DWORD dwAttribute, LPCVOID pvAttribute, DWORD cbAttribute) { - if(!IsDwmSupported()) + if(!this->IsDwmSupported()) return E_NOTIMPL; T* pT = static_cast(this); @@ -241,7 +234,7 @@ public: HRESULT DwmAttachMilContent() { - if(!IsDwmSupported()) + if(!this->IsDwmSupported()) return E_NOTIMPL; T* pT = static_cast(this); @@ -251,7 +244,7 @@ public: HRESULT DwmDetachMilContent() { - if(!IsDwmSupported()) + if(!this->IsDwmSupported()) return E_NOTIMPL; T* pT = static_cast(this); @@ -269,7 +262,7 @@ public: CDwmWindowT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } }; @@ -306,7 +299,7 @@ public: void Attach(HTHUMBNAIL hThumbnailNew) { - if(t_bManaged && m_hThumbnail != NULL && m_hThumbnail != hThumbnailNew) + if(t_bManaged && (m_hThumbnail != NULL) && (m_hThumbnail != hThumbnailNew)) Unregister(); m_hThumbnail = hThumbnailNew; } @@ -324,7 +317,7 @@ public: ATLASSERT(::IsWindow(hwndSource)); ATLASSERT(m_hThumbnail==NULL); - if(!IsDwmSupported()) + if(!this->IsDwmSupported()) return E_NOTIMPL; return ::DwmRegisterThumbnail(hwndDestination, hwndSource, &m_hThumbnail); @@ -332,7 +325,7 @@ public: HRESULT Unregister() { - if(!IsDwmSupported()) + if(!this->IsDwmSupported()) return E_NOTIMPL; if(m_hThumbnail == NULL) return S_FALSE; @@ -350,7 +343,7 @@ public: HRESULT UpdateProperties(const DWM_THUMBNAIL_PROPERTIES* ptnProperties) { - if(!IsDwmSupported()) + if(!this->IsDwmSupported()) return E_NOTIMPL; ATLASSERT(m_hThumbnail != NULL); @@ -360,7 +353,7 @@ public: // Attributes HRESULT QuerySourceSize(PSIZE pSize) { - if(!IsDwmSupported()) + if(!this->IsDwmSupported()) return E_NOTIMPL; ATLASSERT(m_hThumbnail != NULL); @@ -389,7 +382,7 @@ public: CAeroControlImpl() { - m_PaintParams.dwFlags = BPPF_ERASE; + this->m_PaintParams.dwFlags = BPPF_ERASE; } static LPCWSTR GetThemeName() @@ -421,8 +414,8 @@ public: LRESULT OnActivate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) { - if(IsThemingSupported()) - Invalidate(FALSE); + if(this->IsThemingSupported()) + this->Invalidate(FALSE); bHandled = FALSE; return 0; @@ -431,7 +424,7 @@ public: // Operations BOOL SubclassWindow(HWND hWnd) { - ATLASSERT(m_hWnd == NULL); + ATLASSERT(this->m_hWnd == NULL); ATLASSERT(::IsWindow(hWnd)); BOOL bRet = _windowClass::SubclassWindow(hWnd); if(bRet) @@ -446,7 +439,7 @@ public: // Implementation LRESULT DefWindowProc() { - const ATL::_ATL_MSG* pMsg = m_pCurrentMsg; + const ATL::_ATL_MSG* pMsg = this->m_pCurrentMsg; LRESULT lRes = 0; if(pMsg != NULL) lRes = DefWindowProc(pMsg->message, pMsg->wParam, pMsg->lParam); @@ -468,12 +461,12 @@ public: { T* pT = static_cast(this); HDC hDCPaint = NULL; - RECT rcClient = { 0 }; - GetClientRect(&rcClient); - m_BufferedPaint.Begin(hDC, &rcClient, m_dwFormat, &m_PaintParams, &hDCPaint); + RECT rcClient = {}; + this->GetClientRect(&rcClient); + this->m_BufferedPaint.Begin(hDC, &rcClient, this->m_dwFormat, &this->m_PaintParams, &hDCPaint); ATLASSERT(hDCPaint != NULL); pT->DoAeroPaint(hDCPaint, rcClient, rcPaint); - m_BufferedPaint.End(); + this->m_BufferedPaint.End(); } void DoPaint(HDC /*hdc*/, RECT& /*rcClient*/) @@ -485,21 +478,21 @@ public: void Init() { T* pT = static_cast(this); - pT; // avoid level 4 warning - SetThemeClassList(pT->GetThemeName()); - if(m_lpstrThemeClassList != NULL) - OpenThemeData(); + (void)pT; // avoid level 4 warning + this->SetThemeClassList(pT->GetThemeName()); + if(this->m_lpstrThemeClassList != NULL) + this->OpenThemeData(); } void DoAeroPaint(HDC hDC, RECT& /*rcClient*/, RECT& rcPaint) { DefWindowProc(WM_PAINT, (WPARAM) hDC, 0L); - m_BufferedPaint.MakeOpaque(&rcPaint); + this->m_BufferedPaint.MakeOpaque(&rcPaint); } }; #endif // __ATLTHEME_H__ -}; // namespace WTL +} // namespace WTL #endif // __ATLDWM_H__ diff --git a/WrlSDK/SampleCode/PluginWinExe/WTL/atlfind.h b/WrlSDK/SampleCode/PluginWinExe/WTL/atlfind.h index 25bd3e412edbbee88aea926b8eda865ca869947c..9b8c3291d0a37bf05cee8f2755c5e3039f152527 100644 --- a/WrlSDK/SampleCode/PluginWinExe/WTL/atlfind.h +++ b/WrlSDK/SampleCode/PluginWinExe/WTL/atlfind.h @@ -1,4 +1,4 @@ -// Windows Template Library - WTL version 9.10 +// Windows Template Library - WTL version 10.0 // Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. // // This file is a part of the Windows Template Library. @@ -11,10 +11,6 @@ #pragma once -#ifdef _WIN32_WCE - #error atlfind.h is not supported on Windows CE -#endif - #ifndef __ATLCTRLS_H__ #error atlfind.h requires atlctrls.h to be included first #endif @@ -23,8 +19,8 @@ #error atlfind.h requires atldlgs.h to be included first #endif -#if !((defined(__ATLMISC_H__) && defined(_WTL_USE_CSTRING)) || defined(__ATLSTR_H__)) - #error atlfind.h requires CString (either from ATL's atlstr.h or WTL's atlmisc.h with _WTL_USE_CSTRING) +#ifndef __ATLSTR_H__ + #error atlfind.h requires CString #endif @@ -50,13 +46,6 @@ protected: // Typedefs typedef CEditFindReplaceImplBase thisClass; -// Data members - TFindReplaceDialog* m_pFindReplaceDialog; - _CSTRING_NS::CString m_sFindNext, m_sReplaceWith; - BOOL m_bFindOnly, m_bFirstSearch, m_bMatchCase, m_bWholeWord, m_bFindDown; - LONG m_nInitialSearchPos; - HCURSOR m_hOldCursor; - // Enumerations enum TranslationTextItem { @@ -67,6 +56,13 @@ protected: }; public: +// Data members + TFindReplaceDialog* m_pFindReplaceDialog; + ATL::CString m_sFindNext, m_sReplaceWith; + BOOL m_bFindOnly, m_bFirstSearch, m_bMatchCase, m_bWholeWord, m_bFindDown; + LONG m_nInitialSearchPos; + HCURSOR m_hOldCursor; + // Constructors CEditFindReplaceImplBase() : m_pFindReplaceDialog(NULL), @@ -83,25 +79,12 @@ public: // Message Handlers BEGIN_MSG_MAP(thisClass) ALT_MSG_MAP(1) - MESSAGE_HANDLER(WM_DESTROY, OnDestroy) MESSAGE_HANDLER(TFindReplaceDialog::GetFindReplaceMsg(), OnFindReplaceCmd) COMMAND_ID_HANDLER(ID_EDIT_FIND, OnEditFind) COMMAND_ID_HANDLER(ID_EDIT_REPEAT, OnEditRepeat) COMMAND_ID_HANDLER(ID_EDIT_REPLACE, OnEditReplace) END_MSG_MAP() - LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) - { - if(m_pFindReplaceDialog != NULL) - { - m_pFindReplaceDialog->SendMessage(WM_CLOSE); - ATLASSERT(m_pFindReplaceDialog == NULL); - } - - bHandled = FALSE; - return 0; - } - LRESULT OnFindReplaceCmd(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/) { T* pT = static_cast(this); @@ -204,7 +187,8 @@ public: { // You can override all of this in a derived class - TFindReplaceDialog* findReplaceDialog = new TFindReplaceDialog(); + TFindReplaceDialog* findReplaceDialog = NULL; + ATLTRY(findReplaceDialog = new TFindReplaceDialog()); if(findReplaceDialog == NULL) { ::MessageBeep(MB_ICONHAND); @@ -238,27 +222,27 @@ public: // (CEdit::GetSel uses int&, and CRichEditCtrlT::GetSel uses LONG&) ::SendMessage(pT->m_hWnd, EM_GETSEL, (WPARAM)&nStartChar, (LPARAM)&nEndChar); POINT point = pT->PosFromChar(nStartChar); - ::ClientToScreen(pT->GetParent(), &point); - CRect rect; + pT->ClientToScreen(&point); + RECT rect = {}; ::GetWindowRect(hWndDialog, &rect); - if(rect.PtInRect(point)) + if(::PtInRect(&rect, point) != FALSE) { - if(point.y > rect.Height()) + if(point.y > (rect.bottom - rect.top)) { - rect.OffsetRect(0, point.y - rect.bottom - 20); + ::OffsetRect(&rect, 0, point.y - rect.bottom - 20); } else { int nVertExt = GetSystemMetrics(SM_CYSCREEN); - if(point.y + rect.Height() < nVertExt) - rect.OffsetRect(0, 40 + point.y - rect.top); + if((point.y + (rect.bottom - rect.top)) < nVertExt) + ::OffsetRect(&rect, 0, 40 + point.y - rect.top); } - ::MoveWindow(hWndDialog, rect.left, rect.top, rect.Width(), rect.Height(), TRUE); + ::MoveWindow(hWndDialog, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, TRUE); } } - DWORD GetFindReplaceDialogFlags(void) const + DWORD GetFindReplaceDialogFlags() const { DWORD dwFlags = 0; if(m_bFindDown) @@ -292,12 +276,12 @@ public: ATLASSERT(m_pFindReplaceDialog == NULL); - _CSTRING_NS::CString findNext; + ATL::CString findNext; pT->GetSelText(findNext); // if selection is empty or spans multiple lines use old find text if(findNext.IsEmpty() || (findNext.FindOneOf(_T("\n\r")) != -1)) findNext = m_sFindNext; - _CSTRING_NS::CString replaceWith = m_sReplaceWith; + ATL::CString replaceWith = m_sReplaceWith; DWORD dwFlags = pT->GetFindReplaceDialogFlags(); m_pFindReplaceDialog = pT->CreateFindReplaceDialog(bFindOnly, @@ -321,11 +305,11 @@ public: return FALSE; // length is the same, check contents - _CSTRING_NS::CString selectedText; + ATL::CString selectedText; pT->GetSelText(selectedText); - return (bMatchCase && selectedText.Compare(lpszCompare) == 0) || - (!bMatchCase && selectedText.CompareNoCase(lpszCompare) == 0); + return (bMatchCase && (selectedText.Compare(lpszCompare) == 0)) || + (!bMatchCase && (selectedText.CompareNoCase(lpszCompare) == 0)); } void TextNotFound(LPCTSTR lpszFind) @@ -335,9 +319,9 @@ public: pT->OnTextNotFound(lpszFind); } - _CSTRING_NS::CString GetTranslationText(enum TranslationTextItem eItem) const + ATL::CString GetTranslationText(enum TranslationTextItem eItem) const { - _CSTRING_NS::CString text; + ATL::CString text; switch(eItem) { case eText_OnReplaceAllMessage: @@ -441,11 +425,11 @@ public: ::SetCursor(m_hOldCursor); - _CSTRING_NS::CString message = pT->GetTranslationText(eText_OnReplaceAllMessage); + ATL::CString message = pT->GetTranslationText(eText_OnReplaceAllMessage); if(message.GetLength() > 0) { - _CSTRING_NS::CString formattedMessage; - formattedMessage.Format(message, replaceCount, m_sFindNext, m_sReplaceWith); + ATL::CString formattedMessage; + formattedMessage.Format(message, replaceCount, (LPCTSTR)m_sFindNext, (LPCTSTR)m_sReplaceWith); if(m_pFindReplaceDialog != NULL) { m_pFindReplaceDialog->MessageBox(formattedMessage, @@ -464,10 +448,10 @@ public: void OnTextNotFound(LPCTSTR lpszFind) { T* pT = static_cast(this); - _CSTRING_NS::CString message = pT->GetTranslationText(eText_OnTextNotFoundMessage); + ATL::CString message = pT->GetTranslationText(eText_OnTextNotFoundMessage); if(message.GetLength() > 0) { - _CSTRING_NS::CString formattedMessage; + ATL::CString formattedMessage; formattedMessage.Format(message, lpszFind); if(m_pFindReplaceDialog != NULL) { @@ -518,29 +502,7 @@ protected: typedef CEditFindReplaceImpl thisClass; typedef CEditFindReplaceImplBase baseClass; -// Data members - LPTSTR m_pShadowBuffer; // Special shadow buffer only used in some cases. - UINT m_nShadowSize; - int m_bShadowBufferNeeded; // TRUE, FALSE, < 0 => Need to check - public: -// Constructors - CEditFindReplaceImpl() : - m_pShadowBuffer(NULL), - m_nShadowSize(0), - m_bShadowBufferNeeded(-1) - { - } - - virtual ~CEditFindReplaceImpl() - { - if(m_pShadowBuffer != NULL) - { - delete [] m_pShadowBuffer; - m_pShadowBuffer = NULL; - } - } - // Message Handlers BEGIN_MSG_MAP(thisClass) ALT_MSG_MAP(1) @@ -575,7 +537,7 @@ public: bool isDBCS = false; #ifdef _MBCS - CPINFO info = { 0 }; + CPINFO info = {}; ::GetCPInfo(::GetOEMCP(), &info); isDBCS = (info.MaxCharSize > 1); #endif @@ -650,9 +612,9 @@ public: while(lpsz <= lpszStop) { #ifndef _UNICODE - if(!bMatchCase || (*lpsz == *lpszFind && (!::IsDBCSLeadByte(*lpsz) || lpsz[1] == lpszFind[1]))) + if(!bMatchCase || ((*lpsz == *lpszFind) && (!::IsDBCSLeadByte(*lpsz) || (lpsz[1] == lpszFind[1])))) #else - if(!bMatchCase || (*lpsz == *lpszFind && lpsz[1] == lpszFind[1])) + if(!bMatchCase || ((*lpsz == *lpszFind) && (lpsz[1] == lpszFind[1]))) #endif { LPTSTR lpch = (LPTSTR)(lpsz + nLenFind); @@ -723,32 +685,18 @@ public: const T* pT = static_cast(this); ATLASSERT(pT->m_hWnd != NULL); - BOOL useShadowBuffer = pT->UseShadowBuffer(); - if(useShadowBuffer) - { - if((m_pShadowBuffer == NULL) || pT->GetModify()) - { - ATLASSERT((m_pShadowBuffer != NULL) || (m_nShadowSize == 0)); - UINT nSize = pT->GetWindowTextLength() + 1; - if(nSize > m_nShadowSize) - { - // need more room for shadow buffer - T* pThisNoConst = const_cast(pT); - delete[] m_pShadowBuffer; - pThisNoConst->m_pShadowBuffer = NULL; - pThisNoConst->m_nShadowSize = 0; - pThisNoConst->m_pShadowBuffer = new TCHAR[nSize]; - pThisNoConst->m_nShadowSize = nSize; - } - - // update the shadow buffer with GetWindowText - ATLASSERT(m_nShadowSize >= nSize); - ATLASSERT(m_pShadowBuffer != NULL); - pT->GetWindowText(m_pShadowBuffer, nSize); - } - - return m_pShadowBuffer; +#ifndef _UNICODE + // If common controls version 6 is in use (such as via theming), then EM_GETHANDLE + // will always return a UNICODE string. You're really not supposed to superclass + // or subclass common controls with an ANSI windows procedure. + DWORD dwMajor = 0, dwMinor = 0; + HRESULT hRet = ATL::AtlGetCommCtrlVersion(&dwMajor, &dwMinor); + if(SUCCEEDED(hRet) && (dwMajor >= 6)) + { + ATLTRACE2(atlTraceUI, 0, _T("AtlFind Warning: You have compiled for MBCS/ANSI but are using common controls version 6 or later which are always Unicode.\r\n")); + ATLASSERT(FALSE); } +#endif // !_UNICODE HLOCAL hLocal = pT->GetHandle(); ATLASSERT(hLocal != NULL); @@ -763,13 +711,9 @@ public: const T* pT = static_cast(this); ATLASSERT(pT->m_hWnd != NULL); - BOOL useShadowBuffer = pT->UseShadowBuffer(); - if(!useShadowBuffer) - { - HLOCAL hLocal = pT->GetHandle(); - ATLASSERT(hLocal != NULL); - ::LocalUnlock(hLocal); - } + HLOCAL hLocal = pT->GetHandle(); + ATLASSERT(hLocal != NULL); + ::LocalUnlock(hLocal); } UINT GetBufferLength() const @@ -790,12 +734,12 @@ public: { LPCTSTR lpsz = lpszText + nIndex; LPCTSTR lpszStop = lpszText + nLen; - while(lpsz < lpszStop && *lpsz != _T('\r')) + while((lpsz < lpszStop) && (*lpsz != _T('\r'))) ++lpsz; return LONG(lpsz - lpszText); } - LONG GetSelText(_CSTRING_NS::CString& strText) const + LONG GetSelText(ATL::CString& strText) const { const T* pT = static_cast(this); @@ -804,78 +748,12 @@ public: ATLASSERT((UINT)nEndChar <= pT->GetBufferLength()); LPCTSTR lpszText = pT->LockBuffer(); LONG nLen = pT->EndOfLine(lpszText, nEndChar, nStartChar) - nStartChar; - SecureHelper::memcpy_x(strText.GetBuffer(nLen), nLen * sizeof(TCHAR), lpszText + nStartChar, nLen * sizeof(TCHAR)); + ATL::Checked::memcpy_s(strText.GetBuffer(nLen), nLen * sizeof(TCHAR), lpszText + nStartChar, nLen * sizeof(TCHAR)); strText.ReleaseBuffer(nLen); pT->UnlockBuffer(); return nLen; } - - BOOL UseShadowBuffer(void) const - { - const T* pT = static_cast(this); - - if(pT->m_bShadowBufferNeeded < 0) - { - T* pThisNoConst = const_cast(pT); - -#ifdef _versionhelpers_H_INCLUDED_ - OSVERSIONINFOEX ovi = { sizeof(OSVERSIONINFOEX) }; - ovi.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS; - DWORDLONG const dwlConditionMask = ::VerSetConditionMask(0, VER_PLATFORMID, VER_EQUAL); - bool bWin9x = (::VerifyVersionInfo(&ovi, VER_PLATFORMID, dwlConditionMask) != FALSE); -#else // !_versionhelpers_H_INCLUDED_ - OSVERSIONINFO ovi = { sizeof(OSVERSIONINFO) }; - ::GetVersionEx(&ovi); - - bool bWin9x = (ovi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS); -#endif // _versionhelpers_H_INCLUDED_ - if(bWin9x) - { - // Windows 95, 98, ME - // Under Win9x, it is necessary to maintain a shadow buffer. - // It is only updated when the control contents have been changed. - pThisNoConst->m_bShadowBufferNeeded = TRUE; - } - else - { - // Windows NT, 2000, XP, etc. - pThisNoConst->m_bShadowBufferNeeded = FALSE; - -#ifndef _UNICODE - // On Windows XP (or later), if common controls version 6 is in use - // (such as via theming), then EM_GETHANDLE will always return a UNICODE string. - // If theming is enabled and Common Controls version 6 is in use, - // you're really not suppose to superclass or subclass common controls - // with an ANSI windows procedure (so its best to only theme if you use UNICODE). - // Using a shadow buffer uses GetWindowText instead, so it solves - // this problem for us (although it makes it a little less efficient). - -#ifdef _versionhelpers_H_INCLUDED_ - if(::IsWindowsXPOrGreater()) -#else // !_versionhelpers_H_INCLUDED_ - if ((ovi.dwMajorVersion == 5 && ovi.dwMinorVersion >= 1) || (ovi.dwMajorVersion > 5)) -#endif // _versionhelpers_H_INCLUDED_ - { - DWORD dwMajor = 0, dwMinor = 0; - HRESULT hRet = ATL::AtlGetCommCtrlVersion(&dwMajor, &dwMinor); - if(SUCCEEDED(hRet)) - { - if(dwMajor >= 6) - { - pThisNoConst->m_bShadowBufferNeeded = TRUE; - - ATLTRACE2(atlTraceUI, 0, _T("Warning: You have compiled for MBCS/ANSI but are using common controls version 6 or later (likely through a manifest file).\r\n")); - ATLTRACE2(atlTraceUI, 0, _T("If you use common controls version 6 or later, you should only do so for UNICODE builds.\r\n")); - } - } - } -#endif // !_UNICODE - } - } - - return (pT->m_bShadowBufferNeeded != FALSE); - } }; @@ -915,24 +793,19 @@ public: T* pT = static_cast(this); ATLASSERT(lpszFind != NULL); - FINDTEXTEX ft = { 0 }; + FINDTEXTEX ft = {}; pT->GetSel(ft.chrg); - if(m_bFirstSearch) + if(this->m_bFirstSearch) { if(bFindDown) - m_nInitialSearchPos = ft.chrg.cpMin; + this->m_nInitialSearchPos = ft.chrg.cpMin; else - m_nInitialSearchPos = ft.chrg.cpMax; - m_bFirstSearch = FALSE; + this->m_nInitialSearchPos = ft.chrg.cpMax; + this->m_bFirstSearch = FALSE; } -#if (_RICHEDIT_VER >= 0x0200) ft.lpstrText = (LPTSTR)lpszFind; -#else // !(_RICHEDIT_VER >= 0x0200) - USES_CONVERSION; - ft.lpstrText = T2A((LPTSTR)lpszFind); -#endif // !(_RICHEDIT_VER >= 0x0200) if(ft.chrg.cpMin != ft.chrg.cpMax) // i.e. there is a selection { @@ -950,11 +823,11 @@ public: DWORD dwFlags = bMatchCase ? FR_MATCHCASE : 0; dwFlags |= bWholeWord ? FR_WHOLEWORD : 0; - ft.chrg.cpMax = pT->GetTextLength() + m_nInitialSearchPos; + ft.chrg.cpMax = pT->GetTextLength() + this->m_nInitialSearchPos; if(bFindDown) { - if(m_nInitialSearchPos >= 0) + if(this->m_nInitialSearchPos >= 0) ft.chrg.cpMax = pT->GetTextLength(); dwFlags |= FR_DOWN; @@ -962,7 +835,7 @@ public: } else { - if(m_nInitialSearchPos >= 0) + if(this->m_nInitialSearchPos >= 0) ft.chrg.cpMax = 0; dwFlags &= ~FR_DOWN; @@ -974,21 +847,21 @@ public: { bRet = TRUE; // we found the text } - else if(m_nInitialSearchPos > 0) + else if(this->m_nInitialSearchPos > 0) { // if the original starting point was not the beginning // of the buffer and we haven't already been here if(bFindDown) { ft.chrg.cpMin = 0; - ft.chrg.cpMax = m_nInitialSearchPos; + ft.chrg.cpMax = this->m_nInitialSearchPos; } else { ft.chrg.cpMin = pT->GetTextLength(); - ft.chrg.cpMax = m_nInitialSearchPos; + ft.chrg.cpMax = this->m_nInitialSearchPos; } - m_nInitialSearchPos = m_nInitialSearchPos - pT->GetTextLength(); + this->m_nInitialSearchPos = this->m_nInitialSearchPos - pT->GetTextLength(); bRet = (pT->FindAndSelect(dwFlags, ft) != -1) ? TRUE : FALSE; } @@ -1007,6 +880,6 @@ public: } }; -}; // namespace WTL +} // namespace WTL #endif // __ATLFIND_H__ diff --git a/WrlSDK/SampleCode/PluginWinExe/WTL/atlframe.h b/WrlSDK/SampleCode/PluginWinExe/WTL/atlframe.h index e8dc66b7db9d3ce7cf0a84e316ab176aa1d501a6..604c1ab6b111dd6240b79c1bdb320299d941146c 100644 --- a/WrlSDK/SampleCode/PluginWinExe/WTL/atlframe.h +++ b/WrlSDK/SampleCode/PluginWinExe/WTL/atlframe.h @@ -1,4 +1,4 @@ -// Windows Template Library - WTL version 9.10 +// Windows Template Library - WTL version 10.0 // Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. // // This file is a part of the Windows Template Library. @@ -33,6 +33,7 @@ // CDynamicUpdateUI // CAutoUpdateUI // CDialogResize +// CDynamicDialogLayout // CDoubleBufferImpl // CDoubleBufferWindowImpl // @@ -49,13 +50,8 @@ namespace WTL class CFrameWndClassInfo { public: -#ifndef _WIN32_WCE enum { cchAutoName = 5 + sizeof(void*) * 2 }; // sizeof(void*) * 2 is the number of digits %p outputs WNDCLASSEX m_wc; -#else // CE specific - enum { cchAutoName = MAX_PATH }; // MAX_PATH because this can be set in the wizard generated CMainFrame::ActivatePreviousInstance to a user defined string. - WNDCLASS m_wc; -#endif // !_WIN32_WCE LPCTSTR m_lpszOrigName; WNDPROC pWndProc; LPCTSTR m_lpszCursorID; @@ -64,7 +60,6 @@ public: TCHAR m_szAutoName[cchAutoName]; UINT m_uCommonResourceID; -#ifndef _WIN32_WCE ATOM Register(WNDPROC* pProc) { if (m_atom == 0) @@ -112,11 +107,7 @@ public: m_wc.style &= ~CS_GLOBALCLASS; // we don't register global classes if (m_wc.lpszClassName == NULL) { -#if (_WIN32_WINNT >= 0x0500) || defined(_WIN64) - SecureHelper::wsprintf_x(m_szAutoName, cchAutoName, _T("ATL:%p"), &m_wc); -#else // !((_WIN32_WINNT >= 0x0500) || defined(_WIN64)) - SecureHelper::wsprintf_x(m_szAutoName, cchAutoName, _T("ATL:%8.8X"), (DWORD_PTR)&m_wc); -#endif // !((_WIN32_WINNT >= 0x0500) || defined(_WIN64)) + _stprintf_s(m_szAutoName, cchAutoName, _T("ATL:%p"), &m_wc); m_wc.lpszClassName = m_szAutoName; } @@ -149,95 +140,12 @@ public: return m_atom; } -#else // CE specific - ATOM Register(WNDPROC* pProc) - { - if (m_atom == 0) - { - CWindowCreateCriticalSectionLock lock; - if(FAILED(lock.Lock())) - { - ATLTRACE2(atlTraceUI, 0, _T("ERROR : Unable to lock critical section in CFrameWndClassInfo::Register.\n")); - ATLASSERT(FALSE); - return 0; - } - - if(m_atom == 0) - { - HINSTANCE hInst = ModuleHelper::GetModuleInstance(); - - if (m_lpszOrigName != NULL) - { - ATLASSERT(pProc != NULL); - LPCTSTR lpsz = m_wc.lpszClassName; - WNDPROC proc = m_wc.lpfnWndProc; - - WNDCLASS wc = { 0 }; - // try process local class first - if(!::GetClassInfo(ModuleHelper::GetModuleInstance(), m_lpszOrigName, &wc)) - { - // try global class - if(!::GetClassInfo(NULL, m_lpszOrigName, &wc)) - { - lock.Unlock(); - return 0; - } - } - m_wc = wc; - pWndProc = m_wc.lpfnWndProc; - m_wc.lpszClassName = lpsz; - m_wc.lpfnWndProc = proc; - } - else - { -#if defined(GWES_CURSOR) || defined(GWES_MCURSOR) - m_wc.hCursor = ::LoadCursor(m_bSystemCursor ? NULL : hInst, m_lpszCursorID); -#else // !(defined(GWES_CURSOR) || defined(GWES_MCURSOR)) - m_wc.hCursor = NULL; -#endif // !(defined(GWES_CURSOR) || defined(GWES_MCURSOR)) - } - - m_wc.hInstance = hInst; - m_wc.style &= ~CS_GLOBALCLASS; // we don't register global classes - if (m_wc.lpszClassName == NULL) - { - wsprintf(m_szAutoName, _T("ATL:%8.8X"), (DWORD_PTR)&m_wc); - m_wc.lpszClassName = m_szAutoName; - } - - WNDCLASS wcTemp = m_wc; - m_atom = (ATOM)::GetClassInfo(m_wc.hInstance, m_wc.lpszClassName, &wcTemp); - if (m_atom == 0) - { - if(m_uCommonResourceID != 0) // use it if not zero - m_wc.hIcon = (HICON)::LoadImage(ModuleHelper::GetResourceInstance(), - MAKEINTRESOURCE(m_uCommonResourceID), IMAGE_ICON, - ::GetSystemMetrics(SM_CXICON), ::GetSystemMetrics(SM_CYICON), LR_DEFAULTCOLOR); - m_atom = ::RegisterClass(&m_wc); - } - } - - lock.Unlock(); - } - - if (m_lpszOrigName != NULL) - { - ATLASSERT(pProc != NULL); - ATLASSERT(pWndProc != NULL); - *pProc = pWndProc; - } - - return m_atom; - } -#endif // _WIN32_WCE }; /////////////////////////////////////////////////////////////////////////////// // Macros for declaring frame window WNDCLASS -#ifndef _WIN32_WCE - #define DECLARE_FRAME_WND_CLASS(WndClassName, uCommonResourceID) \ static WTL::CFrameWndClassInfo& GetWndClassInfo() \ { \ @@ -274,54 +182,51 @@ static WTL::CFrameWndClassInfo& GetWndClassInfo() \ return wc; \ } -#else // CE specific - -#define DECLARE_FRAME_WND_CLASS(WndClassName, uCommonResourceID) \ +// These are for templated classes +#define DECLARE_FRAME_WND_CLASS2(WndClassName, EnclosingClass, uCommonResourceID) \ static WTL::CFrameWndClassInfo& GetWndClassInfo() \ { \ static WTL::CFrameWndClassInfo wc = \ { \ - { 0, StartWindowProc, \ - 0, 0, NULL, NULL, NULL, (HBRUSH)(COLOR_WINDOW + 1), NULL, WndClassName }, \ + { sizeof(WNDCLASSEX), 0, EnclosingClass::StartWindowProc, \ + 0, 0, NULL, NULL, NULL, (HBRUSH)(COLOR_WINDOW + 1), NULL, WndClassName, NULL }, \ NULL, NULL, IDC_ARROW, TRUE, 0, _T(""), uCommonResourceID \ }; \ return wc; \ } -#define DECLARE_FRAME_WND_CLASS_EX(WndClassName, uCommonResourceID, style, bkgnd) \ +#define DECLARE_FRAME_WND_CLASS_EX2(WndClassName, EnclosingClass, uCommonResourceID, style, bkgnd) \ static WTL::CFrameWndClassInfo& GetWndClassInfo() \ { \ static WTL::CFrameWndClassInfo wc = \ { \ - { style, StartWindowProc, \ - 0, 0, NULL, NULL, NULL, (HBRUSH)(bkgnd + 1), NULL, WndClassName }, \ + { sizeof(WNDCLASSEX), style, EnclosingClass::StartWindowProc, \ + 0, 0, NULL, NULL, NULL, (HBRUSH)(bkgnd + 1), NULL, WndClassName, NULL }, \ NULL, NULL, IDC_ARROW, TRUE, 0, _T(""), uCommonResourceID \ }; \ return wc; \ } -#define DECLARE_FRAME_WND_SUPERCLASS(WndClassName, OrigWndClassName, uCommonResourceID) \ +#define DECLARE_FRAME_WND_SUPERCLASS2(WndClassName, EnclosingClass, OrigWndClassName, uCommonResourceID) \ static WTL::CFrameWndClassInfo& GetWndClassInfo() \ { \ static WTL::CFrameWndClassInfo wc = \ { \ - { NULL, StartWindowProc, \ - 0, 0, NULL, NULL, NULL, NULL, NULL, WndClassName }, \ - OrigWndClassName, NULL, IDC_ARROW, TRUE, 0, _T(""), uCommonResourceID \ + { sizeof(WNDCLASSEX), 0, EnclosingClass::StartWindowProc, \ + 0, 0, NULL, NULL, NULL, NULL, NULL, WndClassName, NULL }, \ + OrigWndClassName, NULL, NULL, TRUE, 0, _T(""), uCommonResourceID \ }; \ return wc; \ } -#endif // !_WIN32_WCE - /////////////////////////////////////////////////////////////////////////////// // CFrameWindowImpl // Client window command chaining macro (only for frame windows) #define CHAIN_CLIENT_COMMANDS() \ - if(uMsg == WM_COMMAND && m_hWndClient != NULL) \ - ::SendMessage(m_hWndClient, uMsg, wParam, lParam); + if((uMsg == WM_COMMAND) && (this->m_hWndClient != NULL)) \ + ::SendMessage(this->m_hWndClient, uMsg, wParam, lParam); // standard toolbar styles #define ATL_SIMPLE_TOOLBAR_STYLE \ @@ -330,24 +235,14 @@ static WTL::CFrameWndClassInfo& GetWndClassInfo() \ #define ATL_SIMPLE_TOOLBAR_PANE_STYLE \ (WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | CCS_NODIVIDER | CCS_NORESIZE | CCS_NOPARENTALIGN | TBSTYLE_TOOLTIPS | TBSTYLE_FLAT) // standard rebar styles -#if (_WIN32_IE >= 0x0400) #define ATL_SIMPLE_REBAR_STYLE \ (WS_CHILD | WS_VISIBLE | WS_BORDER | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | RBS_VARHEIGHT | RBS_BANDBORDERS | RBS_AUTOSIZE) -#else - #define ATL_SIMPLE_REBAR_STYLE \ - (WS_CHILD | WS_VISIBLE | WS_BORDER | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | RBS_VARHEIGHT | RBS_BANDBORDERS) -#endif // !(_WIN32_IE >= 0x0400) // rebar without borders -#if (_WIN32_IE >= 0x0400) #define ATL_SIMPLE_REBAR_NOBORDER_STYLE \ (WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | RBS_VARHEIGHT | RBS_BANDBORDERS | RBS_AUTOSIZE | CCS_NODIVIDER) -#else - #define ATL_SIMPLE_REBAR_NOBORDER_STYLE \ - (WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | RBS_VARHEIGHT | RBS_BANDBORDERS | CCS_NODIVIDER) -#endif // !(_WIN32_IE >= 0x0400) // command bar support -#if !defined(__ATLCTRLW_H__) && !defined(_WIN32_WCE) +#if !defined(__ATLCTRLW_H__) #define CBRM_GETCMDBAR (WM_USER + 301) // returns command bar HWND #define CBRM_GETMENU (WM_USER + 302) // returns loaded or attached menu @@ -365,33 +260,28 @@ struct _AtlFrameWnd_CmdBarPopupMenu #define CBRPOPUPMENU _AtlFrameWnd_CmdBarPopupMenu -#endif // !defined(__ATLCTRLW_H__) && !defined(_WIN32_WCE) +#endif // !defined(__ATLCTRLW_H__) template class ATL_NO_VTABLE CFrameWindowImplBase : public ATL::CWindowImplBaseT< TBase, TWinTraits > { public: - DECLARE_FRAME_WND_CLASS(NULL, 0) + typedef CFrameWindowImplBase _thisClass; + DECLARE_FRAME_WND_CLASS2(NULL, _thisClass, 0) -#if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) struct _ChevronMenuInfo { HMENU hMenu; LPNMREBARCHEVRON lpnm; bool bCmdBar; }; -#endif // (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) // Data members HWND m_hWndToolBar; HWND m_hWndStatusBar; HWND m_hWndClient; -#ifdef _WIN32_WCE - HWND m_hWndCECommandBar; -#endif // _WIN32_WCE - HACCEL m_hAccel; // Constructor @@ -399,33 +289,28 @@ public: m_hWndToolBar(NULL), m_hWndStatusBar(NULL), m_hWndClient(NULL), -#ifdef _WIN32_WCE - m_hWndCECommandBar(NULL), -#endif // _WIN32_WCE m_hAccel(NULL) { } // Methods HWND Create(HWND hWndParent, ATL::_U_RECT rect, LPCTSTR szWindowName, DWORD dwStyle, DWORD dwExStyle, ATL::_U_MENUorID MenuOrID, ATOM atom, LPVOID lpCreateParam) { - ATLASSERT(m_hWnd == NULL); + ATLASSERT(this->m_hWnd == NULL); -#if (_ATL_VER >= 0x0800) // Allocate the thunk structure here, where we can fail gracefully. - BOOL bRet = m_thunk.Init(NULL, NULL); + BOOL bRet = this->m_thunk.Init(NULL, NULL); if(bRet == FALSE) { ::SetLastError(ERROR_OUTOFMEMORY); return NULL; } -#endif // (_ATL_VER >= 0x0800) if(atom == 0) return NULL; - ModuleHelper::AddCreateWndData(&m_thunk.cd, this); + ModuleHelper::AddCreateWndData(&this->m_thunk.cd, this); - if(MenuOrID.m_hMenu == NULL && (dwStyle & WS_CHILD)) + if((MenuOrID.m_hMenu == NULL) && (dwStyle & WS_CHILD)) MenuOrID.m_hMenu = (HMENU)(UINT_PTR)this; if(rect.m_lpRect == NULL) rect.m_lpRect = &TBase::rcDefault; @@ -435,7 +320,7 @@ public: rect.m_lpRect->bottom - rect.m_lpRect->top, hWndParent, MenuOrID.m_hMenu, ModuleHelper::GetModuleInstance(), lpCreateParam); - ATLASSERT(hWnd == NULL || m_hWnd == hWnd); + ATLASSERT((hWnd == NULL) || (this->m_hWnd == hWnd)); return hWnd; } @@ -459,7 +344,7 @@ public: WORD* pItems = pData->items(); int nItems = pData->wItemCount + (bInitialSeparator ? 1 : 0); - CTempBuffer buff; + ATL::CTempBuffer buff; TBBUTTON* pTBBtn = buff.Allocate(nItems); ATLASSERT(pTBBtn != NULL); if(pTBBtn == NULL) @@ -501,19 +386,12 @@ public: } } -#ifndef _WIN32_WCE HWND hWnd = ::CreateWindowEx(0, TOOLBARCLASSNAME, NULL, dwStyle, 0, 0, 100, 100, hWndParent, (HMENU)LongToHandle(nID), ModuleHelper::GetModuleInstance(), NULL); if(hWnd == NULL) { ATLASSERT(FALSE); return NULL; } -#else // CE specific - dwStyle; - nID; - // The toolbar must go onto the existing CommandBar or MenuBar - HWND hWnd = hWndParent; -#endif // _WIN32_WCE ::SendMessage(hWnd, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0L); @@ -521,11 +399,10 @@ public: CFontHandle font = (HFONT)::SendMessage(hWnd, WM_GETFONT, 0, 0L); if(font.IsNull()) font = (HFONT)::GetStockObject(SYSTEM_FONT); - LOGFONT lf = { 0 }; + LOGFONT lf = {}; font.GetLogFont(lf); WORD cyFontHeight = (WORD)abs(lf.lfHeight); -#ifndef _WIN32_WCE WORD bitsPerPixel = AtlGetBitmapResourceBitsPerPixel(nResourceID); if(bitsPerPixel > 4) { @@ -540,9 +417,8 @@ public: ::SendMessage(hWnd, TB_SETIMAGELIST, 0, (LPARAM)hImageList); } else -#endif // !_WIN32_WCE { - TBADDBITMAP tbab = { 0 }; + TBADDBITMAP tbab = {}; tbab.hInst = hInst; tbab.nID = nResourceID; ::SendMessage(hWnd, TB_ADDBITMAP, nBmp, (LPARAM)&tbab); @@ -556,11 +432,10 @@ public: return hWnd; } -#ifndef _WIN32_WCE static HWND CreateSimpleReBarCtrl(HWND hWndParent, DWORD dwStyle = ATL_SIMPLE_REBAR_STYLE, UINT nID = ATL_IDW_TOOLBAR) { // Ensure style combinations for proper rebar painting - if(dwStyle & CCS_NODIVIDER && dwStyle & WS_BORDER) + if(dwStyle & CCS_NODIVIDER && (dwStyle & WS_BORDER)) dwStyle &= ~WS_BORDER; else if(!(dwStyle & WS_BORDER) && !(dwStyle & CCS_NODIVIDER)) dwStyle |= CCS_NODIVIDER; @@ -588,7 +463,7 @@ public: BOOL CreateSimpleReBar(DWORD dwStyle = ATL_SIMPLE_REBAR_STYLE, UINT nID = ATL_IDW_TOOLBAR) { ATLASSERT(!::IsWindow(m_hWndToolBar)); - m_hWndToolBar = CreateSimpleReBarCtrl(m_hWnd, dwStyle, nID); + m_hWndToolBar = CreateSimpleReBarCtrl(this->m_hWnd, dwStyle, nID); return (m_hWndToolBar != NULL); } @@ -598,7 +473,7 @@ public: #ifdef _DEBUG // block - check if this is really a rebar { - TCHAR lpszClassName[sizeof(REBARCLASSNAME)] = { 0 }; + TCHAR lpszClassName[sizeof(REBARCLASSNAME)] = {}; ::GetClassName(hWndReBar, lpszClassName, sizeof(REBARCLASSNAME)); ATLASSERT(lstrcmp(lpszClassName, REBARCLASSNAME) == 0); } @@ -610,18 +485,12 @@ public: // Set band info structure REBARBANDINFO rbBand = { RunTimeHelper::SizeOf_REBARBANDINFO() }; -#if (_WIN32_IE >= 0x0400) rbBand.fMask = RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_STYLE | RBBIM_ID | RBBIM_SIZE | RBBIM_IDEALSIZE; -#else - rbBand.fMask = RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_STYLE | RBBIM_ID | RBBIM_SIZE; -#endif // !(_WIN32_IE >= 0x0400) if(lpstrTitle != NULL) rbBand.fMask |= RBBIM_TEXT; rbBand.fStyle = RBBS_CHILDEDGE; -#if (_WIN32_IE >= 0x0500) if(nBtnCount > 0) // add chevron style for toolbar with buttons rbBand.fStyle |= RBBS_USECHEVRON; -#endif // (_WIN32_IE >= 0x0500) if(bNewRow) rbBand.fStyle |= RBBS_BREAK; @@ -633,7 +502,7 @@ public: // Calculate the size of the band BOOL bRet = FALSE; - RECT rcTmp = { 0 }; + RECT rcTmp = {}; if(nBtnCount > 0) { bRet = (BOOL)::SendMessage(hWndBand, TB_GETITEMRECT, nBtnCount - 1, (LPARAM)&rcTmp); @@ -664,9 +533,7 @@ public: rbBand.cyMinChild = rcTmp.bottom - rcTmp.top; } -#if (_WIN32_IE >= 0x0400) rbBand.cxIdeal = rbBand.cx; -#endif // (_WIN32_IE >= 0x0400) // Add the band LRESULT lRes = ::SendMessage(hWndReBar, RB_INSERTBAND, (WPARAM)-1, (LPARAM)&rbBand); @@ -676,10 +543,8 @@ public: return FALSE; } -#if (_WIN32_IE >= 0x0501) DWORD dwExStyle = (DWORD)::SendMessage(hWndBand, TB_GETEXTENDEDSTYLE, 0, 0L); ::SendMessage(hWndBand, TB_SETEXTENDEDSTYLE, 0, dwExStyle | TBSTYLE_EX_HIDECLIPPEDBUTTONS); -#endif // (_WIN32_IE >= 0x0501) return TRUE; } @@ -691,7 +556,6 @@ public: return AddSimpleReBarBandCtrl(m_hWndToolBar, hWndBand, 0, lpstrTitle, bNewRow, cxWidth, bFullWidthAlways); } -#if (_WIN32_IE >= 0x0400) void SizeSimpleReBarBands() { ATLASSERT(::IsWindow(m_hWndToolBar)); // must be an existing rebar @@ -704,105 +568,33 @@ public: rbBand.fMask = RBBIM_SIZE; BOOL bRet = (BOOL)::SendMessage(m_hWndToolBar, RB_GETBANDINFO, i, (LPARAM)&rbBand); ATLASSERT(bRet); - RECT rect = { 0 }; + RECT rect = {}; ::SendMessage(m_hWndToolBar, RB_GETBANDBORDERS, i, (LPARAM)&rect); rbBand.cx += rect.left + rect.right; bRet = (BOOL)::SendMessage(m_hWndToolBar, RB_SETBANDINFO, i, (LPARAM)&rbBand); ATLASSERT(bRet); } } -#endif // (_WIN32_IE >= 0x0400) -#endif // _WIN32_WCE -#ifndef _WIN32_WCE BOOL CreateSimpleStatusBar(LPCTSTR lpstrText, DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | SBARS_SIZEGRIP, UINT nID = ATL_IDW_STATUS_BAR) -#else // CE specific - BOOL CreateSimpleStatusBar(LPCTSTR lpstrText, DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, UINT nID = ATL_IDW_STATUS_BAR) -#endif // _WIN32_WCE { ATLASSERT(!::IsWindow(m_hWndStatusBar)); - m_hWndStatusBar = ::CreateStatusWindow(dwStyle, lpstrText, m_hWnd, nID); + m_hWndStatusBar = ::CreateStatusWindow(dwStyle, lpstrText, this->m_hWnd, nID); return (m_hWndStatusBar != NULL); } -#ifndef _WIN32_WCE BOOL CreateSimpleStatusBar(UINT nTextID = ATL_IDS_IDLEMESSAGE, DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | SBARS_SIZEGRIP, UINT nID = ATL_IDW_STATUS_BAR) -#else // CE specific - BOOL CreateSimpleStatusBar(UINT nTextID = ATL_IDS_IDLEMESSAGE, DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, UINT nID = ATL_IDW_STATUS_BAR) -#endif // _WIN32_WCE { const int cchMax = 128; // max text length is 127 for status bars (+1 for null) - TCHAR szText[cchMax] = { 0 }; + TCHAR szText[cchMax] = {}; ::LoadString(ModuleHelper::GetResourceInstance(), nTextID, szText, cchMax); return CreateSimpleStatusBar(szText, dwStyle, nID); } -#ifdef _WIN32_WCE - BOOL CreateSimpleCECommandBar(LPTSTR pszMenu = NULL, WORD iButton = 0, DWORD dwFlags = 0, int nCmdBarID = 1) - { - ATLASSERT(m_hWndCECommandBar == NULL); - ATLASSERT(m_hWndToolBar == NULL); - - m_hWndCECommandBar = ::CommandBar_Create(ModuleHelper::GetModuleInstance(), m_hWnd, nCmdBarID); - if(m_hWndCECommandBar == NULL) - return FALSE; - - m_hWndToolBar = m_hWndCECommandBar; - - BOOL bRet = TRUE; - - if(pszMenu != NULL) - bRet &= ::CommandBar_InsertMenubarEx(m_hWndCECommandBar, IS_INTRESOURCE(pszMenu) ? ModuleHelper::GetResourceInstance() : NULL, pszMenu, iButton); - - bRet &= ::CommandBar_AddAdornments(m_hWndCECommandBar, dwFlags, 0); - - return bRet; - } - -#if defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) - BOOL CreateSimpleCEMenuBar(UINT nToolBarId = ATL_IDW_MENU_BAR, DWORD dwFlags = 0, int nBmpId = 0, int cBmpImages = 0) - { - ATLASSERT(m_hWndCECommandBar == NULL); - - SHMENUBARINFO mbi = { 0 }; - mbi.cbSize = sizeof(mbi); - mbi.hwndParent = m_hWnd; - mbi.dwFlags = dwFlags; - mbi.nToolBarId = nToolBarId; - mbi.hInstRes = ModuleHelper::GetResourceInstance(); - mbi.nBmpId = nBmpId; - mbi.cBmpImages = cBmpImages; - mbi.hwndMB = NULL; // This gets set by SHCreateMenuBar - - BOOL bRet = ::SHCreateMenuBar(&mbi); - if(bRet != FALSE) - { - m_hWndCECommandBar = mbi.hwndMB; - SizeToMenuBar(); - } - - return bRet; - } - - void SizeToMenuBar() // for menu bar only - { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT(::IsWindow(m_hWndCECommandBar)); - - RECT rect = { 0 }; - GetWindowRect(&rect); - RECT rectMB = { 0 }; - ::GetWindowRect(m_hWndCECommandBar, &rectMB); - int cy = ::IsWindowVisible(m_hWndCECommandBar) ? rectMB.top - rect.top : rectMB.bottom - rect.top; - SetWindowPos(NULL, 0, 0, rect.right - rect.left, cy, SWP_NOZORDER | SWP_NOMOVE); - } -#endif // defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) -#endif // _WIN32_WCE - void UpdateLayout(BOOL bResizeBars = TRUE) { - RECT rect = { 0 }; - GetClientRect(&rect); + RECT rect = {}; + this->GetClientRect(&rect); // position bars and offset their dimensions UpdateBarsPosition(rect, bResizeBars); @@ -817,24 +609,24 @@ public: void UpdateBarsPosition(RECT& rect, BOOL bResizeBars = TRUE) { // resize toolbar - if(m_hWndToolBar != NULL && ((DWORD)::GetWindowLong(m_hWndToolBar, GWL_STYLE) & WS_VISIBLE)) + if((m_hWndToolBar != NULL) && ((DWORD)::GetWindowLong(m_hWndToolBar, GWL_STYLE) & WS_VISIBLE)) { if(bResizeBars != FALSE) { ::SendMessage(m_hWndToolBar, WM_SIZE, 0, 0); ::InvalidateRect(m_hWndToolBar, NULL, TRUE); } - RECT rectTB = { 0 }; + RECT rectTB = {}; ::GetWindowRect(m_hWndToolBar, &rectTB); rect.top += rectTB.bottom - rectTB.top; } // resize status bar - if(m_hWndStatusBar != NULL && ((DWORD)::GetWindowLong(m_hWndStatusBar, GWL_STYLE) & WS_VISIBLE)) + if((m_hWndStatusBar != NULL) && ((DWORD)::GetWindowLong(m_hWndStatusBar, GWL_STYLE) & WS_VISIBLE)) { if(bResizeBars != FALSE) ::SendMessage(m_hWndStatusBar, WM_SIZE, 0, 0); - RECT rectSB = { 0 }; + RECT rectSB = {}; ::GetWindowRect(m_hWndStatusBar, &rectSB); rect.bottom -= rectSB.bottom - rectSB.top; } @@ -842,22 +634,18 @@ public: BOOL PreTranslateMessage(MSG* pMsg) { - if(m_hAccel != NULL && ::TranslateAccelerator(m_hWnd, m_hAccel, pMsg)) + if((m_hAccel != NULL) && ::TranslateAccelerator(this->m_hWnd, m_hAccel, pMsg)) return TRUE; return FALSE; } BEGIN_MSG_MAP(CFrameWindowImplBase) MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackground) -#ifndef _WIN32_WCE MESSAGE_HANDLER(WM_MENUSELECT, OnMenuSelect) -#endif // !_WIN32_WCE MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus) MESSAGE_HANDLER(WM_DESTROY, OnDestroy) -#ifndef _WIN32_WCE NOTIFY_CODE_HANDLER(TTN_GETDISPINFOA, OnToolTipTextA) NOTIFY_CODE_HANDLER(TTN_GETDISPINFOW, OnToolTipTextW) -#endif // !_WIN32_WCE END_MSG_MAP() LRESULT OnEraseBackground(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) @@ -869,7 +657,6 @@ public: return 0; } -#ifndef _WIN32_WCE LRESULT OnMenuSelect(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { bHandled = FALSE; @@ -878,23 +665,23 @@ public: return 1; WORD wFlags = HIWORD(wParam); - if(wFlags == 0xFFFF && lParam == NULL) // menu closing + if((wFlags == 0xFFFF) && (lParam == NULL)) // menu closing { ::SendMessage(m_hWndStatusBar, SB_SIMPLE, FALSE, 0L); } else { const int cchBuff = 256; - TCHAR szBuff[cchBuff] = { 0 }; + TCHAR szBuff[cchBuff] = {}; if(!(wFlags & MF_POPUP)) { WORD wID = LOWORD(wParam); // check for special cases - if(wID >= 0xF000 && wID < 0xF1F0) // system menu IDs + if((wID >= 0xF000) && (wID < 0xF1F0)) // system menu IDs wID = (WORD)(((wID - 0xF000) >> 4) + ATL_IDS_SCFIRST); - else if(wID >= ID_FILE_MRU_FIRST && wID <= ID_FILE_MRU_LAST) // MRU items + else if((wID >= ID_FILE_MRU_FIRST) && (wID <= ID_FILE_MRU_LAST)) // MRU items wID = ATL_IDS_MRU_FILE; - else if(wID >= ATL_IDM_FIRST_MDICHILD && wID <= ATL_IDM_LAST_MDICHILD) // MDI child windows + else if((wID >= ATL_IDM_FIRST_MDICHILD) && (wID <= ATL_IDM_LAST_MDICHILD)) // MDI child windows wID = ATL_IDS_MDICHILD; int nRet = ::LoadString(ModuleHelper::GetResourceInstance(), wID, szBuff, cchBuff); @@ -913,7 +700,6 @@ public: return 1; } -#endif // !_WIN32_WCE LRESULT OnSetFocus(UINT, WPARAM, LPARAM, BOOL& bHandled) { @@ -926,34 +712,31 @@ public: LRESULT OnDestroy(UINT, WPARAM, LPARAM, BOOL& bHandled) { - if((GetStyle() & (WS_CHILD | WS_POPUP)) == 0) + if((this->GetStyle() & (WS_CHILD | WS_POPUP)) == 0) ::PostQuitMessage(1); bHandled = FALSE; return 1; } -#ifndef _WIN32_WCE LRESULT OnToolTipTextA(int idCtrl, LPNMHDR pnmh, BOOL& /*bHandled*/) { LPNMTTDISPINFOA pDispInfo = (LPNMTTDISPINFOA)pnmh; if((idCtrl != 0) && !(pDispInfo->uFlags & TTF_IDISHWND)) { const int cchBuff = 256; - char szBuff[cchBuff] = { 0 }; + char szBuff[cchBuff] = {}; int nRet = ::LoadStringA(ModuleHelper::GetResourceInstance(), idCtrl, szBuff, cchBuff); for(int i = 0; i < nRet; i++) { if(szBuff[i] == '\n') { - SecureHelper::strncpyA_x(pDispInfo->szText, _countof(pDispInfo->szText), &szBuff[i + 1], _TRUNCATE); + ATL::Checked::strncpy_s(pDispInfo->szText, _countof(pDispInfo->szText), &szBuff[i + 1], _TRUNCATE); break; } } -#if (_WIN32_IE >= 0x0300) if(nRet > 0) // string was loaded, save it pDispInfo->uFlags |= TTF_DI_SETITEM; -#endif // (_WIN32_IE >= 0x0300) } return 0; @@ -965,28 +748,24 @@ public: if((idCtrl != 0) && !(pDispInfo->uFlags & TTF_IDISHWND)) { const int cchBuff = 256; - wchar_t szBuff[cchBuff] = { 0 }; + wchar_t szBuff[cchBuff] = {}; int nRet = ::LoadStringW(ModuleHelper::GetResourceInstance(), idCtrl, szBuff, cchBuff); for(int i = 0; i < nRet; i++) { if(szBuff[i] == L'\n') { - SecureHelper::strncpyW_x(pDispInfo->szText, _countof(pDispInfo->szText), &szBuff[i + 1], _TRUNCATE); + ATL::Checked::wcsncpy_s(pDispInfo->szText, _countof(pDispInfo->szText), &szBuff[i + 1], _TRUNCATE); break; } } -#if (_WIN32_IE >= 0x0300) if(nRet > 0) // string was loaded, save it pDispInfo->uFlags |= TTF_DI_SETITEM; -#endif // (_WIN32_IE >= 0x0300) } return 0; } -#endif // !_WIN32_WCE // Implementation - chevron menu support -#if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) bool PrepareChevronMenu(_ChevronMenuInfo& cmi) { // get rebar and toolbar @@ -1009,18 +788,18 @@ public: CMenuHandle menu; bRet = menu.CreatePopupMenu(); ATLASSERT(bRet); - RECT rcClient = { 0 }; + RECT rcClient = {}; bRet = wnd.GetClientRect(&rcClient); ATLASSERT(bRet); for(int i = 0; i < nCount; i++) { - TBBUTTON tbb = { 0 }; + TBBUTTON tbb = {}; bRet = (BOOL)wnd.SendMessage(TB_GETBUTTON, i, (LPARAM)&tbb); ATLASSERT(bRet); // skip hidden buttons if((tbb.fsState & TBSTATE_HIDDEN) != 0) continue; - RECT rcButton = { 0 }; + RECT rcButton = {}; bRet = (BOOL)wnd.SendMessage(TB_GETITEMRECT, i, (LPARAM)&rcButton); ATLASSERT(bRet); bool bEnabled = ((tbb.fsState & TBSTATE_ENABLED) != 0); @@ -1034,7 +813,7 @@ public: else if(cmi.bCmdBar) { const int cchBuff = 200; - TCHAR szBuff[cchBuff] = { 0 }; + TCHAR szBuff[cchBuff] = {}; CMenuItemInfo mii; mii.fMask = MIIM_TYPE | MIIM_SUBMENU; mii.dwTypeData = szBuff; @@ -1050,9 +829,9 @@ public: { // get button's text const int cchBuff = 200; - TCHAR szBuff[cchBuff] = { 0 }; + TCHAR szBuff[cchBuff] = {}; LPCTSTR lpstrText = szBuff; - TBBUTTONINFO tbbi = { 0 }; + TBBUTTONINFO tbbi = {}; tbbi.cbSize = sizeof(TBBUTTONINFO); tbbi.dwMask = TBIF_TEXT; tbbi.pszText = szBuff; @@ -1090,9 +869,6 @@ public: void DisplayChevronMenu(_ChevronMenuInfo& cmi) { -#ifndef TPM_VERPOSANIMATION - const UINT TPM_VERPOSANIMATION = 0x1000L; // Menu animation flag -#endif // convert chevron rect to screen coordinates ATL::CWindow wndFrom = cmi.lpnm->hdr.hwndFrom; POINT pt = { cmi.lpnm->rc.left, cmi.lpnm->rc.bottom }; @@ -1100,12 +876,12 @@ public: RECT rc = cmi.lpnm->rc; wndFrom.MapWindowPoints(NULL, &rc); // set up flags and rect - UINT uMenuFlags = TPM_LEFTBUTTON | TPM_VERTICAL | TPM_LEFTALIGN | TPM_TOPALIGN | (!AtlIsOldWindows() ? TPM_VERPOSANIMATION : 0); - TPMPARAMS TPMParams = { 0 }; + UINT uMenuFlags = TPM_LEFTBUTTON | TPM_VERTICAL | TPM_LEFTALIGN | TPM_TOPALIGN | TPM_VERPOSANIMATION; + TPMPARAMS TPMParams = {}; TPMParams.cbSize = sizeof(TPMPARAMS); TPMParams.rcExclude = rc; // check if this window has a command bar - HWND hWndCmdBar = (HWND)::SendMessage(m_hWnd, CBRM_GETCMDBAR, 0, 0L); + HWND hWndCmdBar = (HWND)::SendMessage(this->m_hWnd, CBRM_GETCMDBAR, 0, 0L); if(::IsWindow(hWndCmdBar)) { CBRPOPUPMENU CBRPopupMenu = { sizeof(CBRPOPUPMENU), cmi.hMenu, uMenuFlags, pt.x, pt.y, &TPMParams }; @@ -1114,7 +890,7 @@ public: else { CMenuHandle menu = cmi.hMenu; - menu.TrackPopupMenuEx(uMenuFlags, pt.x, pt.y, m_hWnd, &TPMParams); + menu.TrackPopupMenuEx(uMenuFlags, pt.x, pt.y, this->m_hWnd, &TPMParams); } } @@ -1134,11 +910,10 @@ public: RECT rc = cmi.lpnm->rc; wndFrom.MapWindowPoints(NULL, &rc); // eat next message if click is on the same button - MSG msg = { 0 }; - if(::PeekMessage(&msg, m_hWnd, WM_LBUTTONDOWN, WM_LBUTTONDOWN, PM_NOREMOVE) && ::PtInRect(&rc, msg.pt)) - ::PeekMessage(&msg, m_hWnd, WM_LBUTTONDOWN, WM_LBUTTONDOWN, PM_REMOVE); + MSG msg = {}; + if(::PeekMessage(&msg, this->m_hWnd, WM_LBUTTONDOWN, WM_LBUTTONDOWN, PM_NOREMOVE) && ::PtInRect(&rc, msg.pt)) + ::PeekMessage(&msg, this->m_hWnd, WM_LBUTTONDOWN, WM_LBUTTONDOWN, PM_REMOVE); } -#endif // (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) }; @@ -1150,7 +925,7 @@ public: DWORD dwStyle = 0, DWORD dwExStyle = 0, HMENU hMenu = NULL, LPVOID lpCreateParam = NULL) { - ATOM atom = T::GetWndClassInfo().Register(&m_pfnSuperWindowProc); + ATOM atom = T::GetWndClassInfo().Register(&this->m_pfnSuperWindowProc); dwStyle = T::GetWndStyle(dwStyle); dwExStyle = T::GetWndExStyle(dwExStyle); @@ -1164,24 +939,15 @@ public: HWND CreateEx(HWND hWndParent = NULL, ATL::_U_RECT rect = NULL, DWORD dwStyle = 0, DWORD dwExStyle = 0, LPVOID lpCreateParam = NULL) { const int cchName = 256; - TCHAR szWindowName[cchName] = { 0 }; -#ifndef _WIN32_WCE + TCHAR szWindowName[cchName] = {}; ::LoadString(ModuleHelper::GetResourceInstance(), T::GetWndClassInfo().m_uCommonResourceID, szWindowName, cchName); HMENU hMenu = ::LoadMenu(ModuleHelper::GetResourceInstance(), MAKEINTRESOURCE(T::GetWndClassInfo().m_uCommonResourceID)); -#else // CE specific - ::LoadString(ModuleHelper::GetResourceInstance(), T::GetWndClassInfo().m_uCommonResourceID, szWindowName, cchName); - - // This always needs to be NULL for Windows CE. - // Frame Window menus have to go onto the CommandBar. - // Use CreateSimpleCECommandBar - HMENU hMenu = NULL; -#endif // _WIN32_WCE T* pT = static_cast(this); HWND hWnd = pT->Create(hWndParent, rect, szWindowName, dwStyle, dwExStyle, hMenu, lpCreateParam); if(hWnd != NULL) - m_hAccel = ::LoadAccelerators(ModuleHelper::GetResourceInstance(), MAKEINTRESOURCE(T::GetWndClassInfo().m_uCommonResourceID)); + this->m_hAccel = ::LoadAccelerators(ModuleHelper::GetResourceInstance(), MAKEINTRESOURCE(T::GetWndClassInfo().m_uCommonResourceID)); return hWnd; } @@ -1190,26 +956,10 @@ public: { if(nResourceID == 0) nResourceID = T::GetWndClassInfo().m_uCommonResourceID; -#ifndef _WIN32_WCE - ATLASSERT(!::IsWindow(m_hWndToolBar)); - m_hWndToolBar = T::CreateSimpleToolBarCtrl(m_hWnd, nResourceID, TRUE, dwStyle, nID); - return (m_hWndToolBar != NULL); -#else // CE specific - HWND hWnd= T::CreateSimpleToolBarCtrl(m_hWndCECommandBar, nResourceID, TRUE, dwStyle, nID); - return (hWnd != NULL); -#endif // _WIN32_WCE - } - -#ifdef _WIN32_WCE - // CE specific variant that returns the handle of the toolbar - HWND CreateSimpleCEToolBar(UINT nResourceID = 0, DWORD dwStyle = ATL_SIMPLE_TOOLBAR_STYLE, UINT nID = ATL_IDW_TOOLBAR) - { - if(nResourceID == 0) - nResourceID = T::GetWndClassInfo().m_uCommonResourceID; - - return T::CreateSimpleToolBarCtrl(m_hWndCECommandBar, nResourceID, TRUE, dwStyle, nID); + ATLASSERT(!::IsWindow(this->m_hWndToolBar)); + this->m_hWndToolBar = T::CreateSimpleToolBarCtrl(this->m_hWnd, nResourceID, TRUE, dwStyle, nID); + return (this->m_hWndToolBar != NULL); } -#endif // _WIN32_WCE // message map and handlers typedef CFrameWindowImplBase< TBase, TWinTraits > _baseClass; @@ -1217,12 +967,8 @@ public: BEGIN_MSG_MAP(CFrameWindowImpl) MESSAGE_HANDLER(WM_SIZE, OnSize) #ifndef _ATL_NO_REBAR_SUPPORT -#if (_WIN32_IE >= 0x0400) NOTIFY_CODE_HANDLER(RBN_AUTOSIZE, OnReBarAutoSize) -#endif // (_WIN32_IE >= 0x0400) -#if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) NOTIFY_CODE_HANDLER(RBN_CHEVRONPUSHED, OnChevronPushed) -#endif // (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) #endif // !_ATL_NO_REBAR_SUPPORT CHAIN_MSG_MAP(_baseClass) END_MSG_MAP() @@ -1239,20 +985,17 @@ public: } #ifndef _ATL_NO_REBAR_SUPPORT -#if (_WIN32_IE >= 0x0400) LRESULT OnReBarAutoSize(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/) { T* pT = static_cast(this); pT->UpdateLayout(FALSE); return 0; } -#endif // (_WIN32_IE >= 0x0400) -#if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) LRESULT OnChevronPushed(int /*idCtrl*/, LPNMHDR pnmh, BOOL& bHandled) { T* pT = static_cast(this); - _ChevronMenuInfo cmi = { NULL, (LPNMREBARCHEVRON)pnmh, false }; + typename CFrameWindowImplBase< TBase, TWinTraits >::_ChevronMenuInfo cmi = { NULL, (LPNMREBARCHEVRON)pnmh, false }; if(!pT->PrepareChevronMenu(cmi)) { bHandled = FALSE; @@ -1264,7 +1007,6 @@ public: pT->CleanupChevronMenu(cmi); return 0; } -#endif // (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) #endif // !_ATL_NO_REBAR_SUPPORT }; @@ -1272,24 +1014,18 @@ public: /////////////////////////////////////////////////////////////////////////////// // AtlCreateSimpleToolBar - helper for creating simple toolbars -#ifndef _WIN32_WCE - inline HWND AtlCreateSimpleToolBar(HWND hWndParent, UINT nResourceID, BOOL bInitialSeparator = FALSE, DWORD dwStyle = ATL_SIMPLE_TOOLBAR_STYLE, UINT nID = ATL_IDW_TOOLBAR) { return CFrameWindowImplBase<>::CreateSimpleToolBarCtrl(hWndParent, nResourceID, bInitialSeparator, dwStyle, nID); } -#endif // !_WIN32_WCE - /////////////////////////////////////////////////////////////////////////////// // CMDIWindow -#ifndef _WIN32_WCE - #ifndef _WTL_MDIWINDOWMENU_TEXT -#define _WTL_MDIWINDOWMENU_TEXT _T("&Window") + #define _WTL_MDIWINDOWMENU_TEXT _T("&Window") #endif class CMDIWindow : public ATL::CWindow @@ -1326,7 +1062,7 @@ public: void MDINext(HWND hWndChild, BOOL bPrevious = FALSE) { ATLASSERT(::IsWindow(m_hWndMDIClient)); - ATLASSERT(hWndChild == NULL || ::IsWindow(hWndChild)); + ATLASSERT((hWndChild == NULL) || ::IsWindow(hWndChild)); ::SendMessage(m_hWndMDIClient, WM_MDINEXT, (WPARAM)hWndChild, (LPARAM)bPrevious); } @@ -1390,7 +1126,7 @@ public: int nLen = ::GetMenuString(hMenu, nCount - 2, NULL, 0, MF_BYPOSITION); if(nLen == 0) return NULL; - CTempBuffer buff; + ATL::CTempBuffer buff; LPTSTR lpszText = buff.Allocate(nLen + 1); if(lpszText == NULL) return NULL; @@ -1415,19 +1151,15 @@ public: } }; -#endif // !_WIN32_WCE - /////////////////////////////////////////////////////////////////////////////// // CMDIFrameWindowImpl -#ifndef _WIN32_WCE - // MDI child command chaining macro (only for MDI frame windows) #define CHAIN_MDI_CHILD_COMMANDS() \ if(uMsg == WM_COMMAND) \ { \ - HWND hWndChild = MDIGetActive(); \ + HWND hWndChild = this->MDIGetActive(); \ if(hWndChild != NULL) \ ::SendMessage(hWndChild, uMsg, wParam, lParam); \ } @@ -1440,8 +1172,8 @@ public: DWORD dwStyle = 0, DWORD dwExStyle = 0, HMENU hMenu = NULL, LPVOID lpCreateParam = NULL) { - m_hMenu = hMenu; - ATOM atom = T::GetWndClassInfo().Register(&m_pfnSuperWindowProc); + this->m_hMenu = hMenu; + ATOM atom = T::GetWndClassInfo().Register(&this->m_pfnSuperWindowProc); dwStyle = T::GetWndStyle(dwStyle); dwExStyle = T::GetWndExStyle(dwExStyle); @@ -1455,7 +1187,7 @@ public: HWND CreateEx(HWND hWndParent = NULL, ATL::_U_RECT rect = NULL, DWORD dwStyle = 0, DWORD dwExStyle = 0, LPVOID lpCreateParam = NULL) { const int cchName = 256; - TCHAR szWindowName[cchName] = { 0 }; + TCHAR szWindowName[cchName] = {}; ::LoadString(ModuleHelper::GetResourceInstance(), T::GetWndClassInfo().m_uCommonResourceID, szWindowName, cchName); HMENU hMenu = ::LoadMenu(ModuleHelper::GetResourceInstance(), MAKEINTRESOURCE(T::GetWndClassInfo().m_uCommonResourceID)); @@ -1463,18 +1195,18 @@ public: HWND hWnd = pT->Create(hWndParent, rect, szWindowName, dwStyle, dwExStyle, hMenu, lpCreateParam); if(hWnd != NULL) - m_hAccel = ::LoadAccelerators(ModuleHelper::GetResourceInstance(), MAKEINTRESOURCE(T::GetWndClassInfo().m_uCommonResourceID)); + this->m_hAccel = ::LoadAccelerators(ModuleHelper::GetResourceInstance(), MAKEINTRESOURCE(T::GetWndClassInfo().m_uCommonResourceID)); return hWnd; } BOOL CreateSimpleToolBar(UINT nResourceID = 0, DWORD dwStyle = ATL_SIMPLE_TOOLBAR_STYLE, UINT nID = ATL_IDW_TOOLBAR) { - ATLASSERT(!::IsWindow(m_hWndToolBar)); + ATLASSERT(!::IsWindow(this->m_hWndToolBar)); if(nResourceID == 0) nResourceID = T::GetWndClassInfo().m_uCommonResourceID; - m_hWndToolBar = T::CreateSimpleToolBarCtrl(m_hWnd, nResourceID, TRUE, dwStyle, nID); - return (m_hWndToolBar != NULL); + this->m_hWndToolBar = T::CreateSimpleToolBarCtrl(this->m_hWnd, nResourceID, TRUE, dwStyle, nID); + return (this->m_hWndToolBar != NULL); } virtual WNDPROC GetWindowProc() @@ -1486,13 +1218,8 @@ public: { CMDIFrameWindowImpl< T, TBase, TWinTraits >* pThis = (CMDIFrameWindowImpl< T, TBase, TWinTraits >*)hWnd; // set a ptr to this message and save the old value -#if (_ATL_VER >= 0x0700) ATL::_ATL_MSG msg(pThis->m_hWnd, uMsg, wParam, lParam); const ATL::_ATL_MSG* pOldMsg = pThis->m_pCurrentMsg; -#else // !(_ATL_VER >= 0x0700) - MSG msg = { pThis->m_hWnd, uMsg, wParam, lParam, 0, { 0, 0 } }; - const MSG* pOldMsg = pThis->m_pCurrentMsg; -#endif // !(_ATL_VER >= 0x0700) pThis->m_pCurrentMsg = &msg; // pass to the message map to process LRESULT lRes = 0; @@ -1512,38 +1239,28 @@ public: // unsubclass, if needed LONG_PTR pfnWndProc = ::GetWindowLongPtr(pThis->m_hWnd, GWLP_WNDPROC); lRes = pThis->DefWindowProc(uMsg, wParam, lParam); - if(pThis->m_pfnSuperWindowProc != ::DefWindowProc && ::GetWindowLongPtr(pThis->m_hWnd, GWLP_WNDPROC) == pfnWndProc) + if((pThis->m_pfnSuperWindowProc != ::DefWindowProc) && (::GetWindowLongPtr(pThis->m_hWnd, GWLP_WNDPROC) == pfnWndProc)) ::SetWindowLongPtr(pThis->m_hWnd, GWLP_WNDPROC, (LONG_PTR)pThis->m_pfnSuperWindowProc); -#if (_ATL_VER >= 0x0700) // mark window as destryed - pThis->m_dwState |= WINSTATE_DESTROYED; -#else // !(_ATL_VER >= 0x0700) - // clear out window handle - HWND hWnd = pThis->m_hWnd; - pThis->m_hWnd = NULL; - // clean up after window is destroyed - pThis->OnFinalMessage(hWnd); -#endif // !(_ATL_VER >= 0x0700) + pThis->m_dwState |= ATL::CWindowImplRoot< TBase >::WINSTATE_DESTROYED; } } -#if (_ATL_VER >= 0x0700) - if(pThis->m_dwState & WINSTATE_DESTROYED && pThis->m_pCurrentMsg == NULL) + if((pThis->m_dwState & ATL::CWindowImplRoot< TBase >::WINSTATE_DESTROYED) && (pThis->m_pCurrentMsg == NULL)) { // clear out window handle HWND hWndThis = pThis->m_hWnd; pThis->m_hWnd = NULL; - pThis->m_dwState &= ~WINSTATE_DESTROYED; + pThis->m_dwState &= ~ATL::CWindowImplRoot< TBase >::WINSTATE_DESTROYED; // clean up after window is destroyed pThis->OnFinalMessage(hWndThis); } -#endif // (_ATL_VER >= 0x0700) return lRes; } // Overriden to call DefWindowProc which uses DefFrameProc LRESULT DefWindowProc() { - const MSG* pMsg = m_pCurrentMsg; + const ATL::_ATL_MSG* pMsg = this->m_pCurrentMsg; LRESULT lRes = 0; if (pMsg != NULL) lRes = DefWindowProc(pMsg->message, pMsg->wParam, pMsg->lParam); @@ -1552,14 +1269,14 @@ public: LRESULT DefWindowProc(UINT uMsg, WPARAM wParam, LPARAM lParam) { - return ::DefFrameProc(m_hWnd, m_hWndMDIClient, uMsg, wParam, lParam); + return ::DefFrameProc(this->m_hWnd, this->m_hWndMDIClient, uMsg, wParam, lParam); } BOOL PreTranslateMessage(MSG* pMsg) { if(CFrameWindowImplBase::PreTranslateMessage(pMsg)) return TRUE; - return ::TranslateMDISysAccel(m_hWndMDIClient, pMsg); + return ::TranslateMDISysAccel(this->m_hWndMDIClient, pMsg); } HWND CreateMDIClient(HMENU hWindowMenu = NULL, UINT nID = ATL_IDW_CLIENT, UINT nFirstChildID = ATL_IDM_FIRST_MDICHILD) @@ -1567,40 +1284,40 @@ public: DWORD dwStyle = WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | MDIS_ALLCHILDSTYLES; DWORD dwExStyle = WS_EX_CLIENTEDGE; - CLIENTCREATESTRUCT ccs = { 0 }; + CLIENTCREATESTRUCT ccs = {}; ccs.hWindowMenu = hWindowMenu; ccs.idFirstChild = nFirstChildID; - if((GetStyle() & (WS_HSCROLL | WS_VSCROLL)) != 0) + if((this->GetStyle() & (WS_HSCROLL | WS_VSCROLL)) != 0) { // parent MDI frame's scroll styles move to the MDICLIENT - dwStyle |= (GetStyle() & (WS_HSCROLL | WS_VSCROLL)); + dwStyle |= (this->GetStyle() & (WS_HSCROLL | WS_VSCROLL)); // fast way to turn off the scrollbar bits (without a resize) - ModifyStyle(WS_HSCROLL | WS_VSCROLL, 0, SWP_NOREDRAW | SWP_FRAMECHANGED); + this->ModifyStyle(WS_HSCROLL | WS_VSCROLL, 0, SWP_NOREDRAW | SWP_FRAMECHANGED); } // Create MDICLIENT window - m_hWndClient = ::CreateWindowEx(dwExStyle, _T("MDIClient"), NULL, - dwStyle, 0, 0, 1, 1, m_hWnd, (HMENU)LongToHandle(nID), + this->m_hWndClient = ::CreateWindowEx(dwExStyle, _T("MDIClient"), NULL, + dwStyle, 0, 0, 1, 1, this->m_hWnd, (HMENU)LongToHandle(nID), ModuleHelper::GetModuleInstance(), (LPVOID)&ccs); - if (m_hWndClient == NULL) + if (this->m_hWndClient == NULL) { ATLTRACE2(atlTraceUI, 0, _T("MDI Frame failed to create MDICLIENT.\n")); return NULL; } // Move it to the top of z-order - ::BringWindowToTop(m_hWndClient); + ::BringWindowToTop(this->m_hWndClient); // set as MDI client window - m_hWndMDIClient = m_hWndClient; + this->m_hWndMDIClient = this->m_hWndClient; // update to proper size T* pT = static_cast(this); pT->UpdateLayout(); - return m_hWndClient; + return this->m_hWndClient; } typedef CFrameWindowImplBase _baseClass; @@ -1610,12 +1327,8 @@ public: MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus) MESSAGE_HANDLER(WM_MDISETMENU, OnMDISetMenu) #ifndef _ATL_NO_REBAR_SUPPORT -#if (_WIN32_IE >= 0x0400) NOTIFY_CODE_HANDLER(RBN_AUTOSIZE, OnReBarAutoSize) -#endif // (_WIN32_IE >= 0x0400) -#if (_WIN32_IE >= 0x0500) NOTIFY_CODE_HANDLER(RBN_CHEVRONPUSHED, OnChevronPushed) -#endif // (_WIN32_IE >= 0x0500) #endif // !_ATL_NO_REBAR_SUPPORT CHAIN_MSG_MAP(_baseClass) END_MSG_MAP() @@ -1639,25 +1352,22 @@ public: LRESULT OnMDISetMenu(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { - SetMDIFrameMenu(); + this->SetMDIFrameMenu(); return 0; } #ifndef _ATL_NO_REBAR_SUPPORT -#if (_WIN32_IE >= 0x0400) LRESULT OnReBarAutoSize(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/) { T* pT = static_cast(this); pT->UpdateLayout(FALSE); return 0; } -#endif // (_WIN32_IE >= 0x0400) -#if (_WIN32_IE >= 0x0500) LRESULT OnChevronPushed(int /*idCtrl*/, LPNMHDR pnmh, BOOL& bHandled) { T* pT = static_cast(this); - _ChevronMenuInfo cmi = { NULL, (LPNMREBARCHEVRON)pnmh, false }; + typename CFrameWindowImplBase::_ChevronMenuInfo cmi = { NULL, (LPNMREBARCHEVRON)pnmh, false }; if(!pT->PrepareChevronMenu(cmi)) { bHandled = FALSE; @@ -1669,18 +1379,13 @@ public: pT->CleanupChevronMenu(cmi); return 0; } -#endif // (_WIN32_IE >= 0x0500) #endif // !_ATL_NO_REBAR_SUPPORT }; -#endif // !_WIN32_WCE - /////////////////////////////////////////////////////////////////////////////// // CMDIChildWindowImpl -#ifndef _WIN32_WCE - template class ATL_NO_VTABLE CMDIChildWindowImpl : public CFrameWindowImplBase { @@ -1689,18 +1394,18 @@ public: DWORD dwStyle = 0, DWORD dwExStyle = 0, UINT nMenuID = 0, LPVOID lpCreateParam = NULL) { - ATOM atom = T::GetWndClassInfo().Register(&m_pfnSuperWindowProc); + ATOM atom = T::GetWndClassInfo().Register(&this->m_pfnSuperWindowProc); if(nMenuID != 0) - m_hMenu = ::LoadMenu(ModuleHelper::GetResourceInstance(), MAKEINTRESOURCE(nMenuID)); + this->m_hMenu = ::LoadMenu(ModuleHelper::GetResourceInstance(), MAKEINTRESOURCE(nMenuID)); dwStyle = T::GetWndStyle(dwStyle); dwExStyle = T::GetWndExStyle(dwExStyle); dwExStyle |= WS_EX_MDICHILD; // force this one - m_pfnSuperWindowProc = ::DefMDIChildProc; - m_hWndMDIClient = hWndParent; - ATLASSERT(::IsWindow(m_hWndMDIClient)); + this->m_pfnSuperWindowProc = ::DefMDIChildProc; + this->m_hWndMDIClient = hWndParent; + ATLASSERT(::IsWindow(this->m_hWndMDIClient)); if(rect.m_lpRect == NULL) rect.m_lpRect = &TBase::rcDefault; @@ -1718,12 +1423,12 @@ public: { // Maximize and redraw everything if(hWnd != NULL) - MDIMaximize(hWnd); + this->MDIMaximize(hWnd); wndParent.SetRedraw(TRUE); wndParent.RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_ALLCHILDREN); - ::SetFocus(GetMDIFrame()); // focus will be set back to this window + ::SetFocus(this->GetMDIFrame()); // focus will be set back to this window } - else if(hWnd != NULL && ::IsWindowVisible(m_hWnd) && !::IsChild(hWnd, ::GetFocus())) + else if((hWnd != NULL) && ::IsWindowVisible(this->m_hWnd) && !::IsChild(hWnd, ::GetFocus())) { ::SetFocus(hWnd); } @@ -1734,7 +1439,7 @@ public: HWND CreateEx(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR lpcstrWindowName = NULL, DWORD dwStyle = 0, DWORD dwExStyle = 0, LPVOID lpCreateParam = NULL) { const int cchName = 256; - TCHAR szWindowName[cchName] = { 0 }; + TCHAR szWindowName[cchName] = {}; if(lpcstrWindowName == NULL) { ::LoadString(ModuleHelper::GetResourceInstance(), T::GetWndClassInfo().m_uCommonResourceID, szWindowName, cchName); @@ -1745,31 +1450,31 @@ public: HWND hWnd = pT->Create(hWndParent, rect, lpcstrWindowName, dwStyle, dwExStyle, T::GetWndClassInfo().m_uCommonResourceID, lpCreateParam); if(hWnd != NULL) - m_hAccel = ::LoadAccelerators(ModuleHelper::GetResourceInstance(), MAKEINTRESOURCE(T::GetWndClassInfo().m_uCommonResourceID)); + this->m_hAccel = ::LoadAccelerators(ModuleHelper::GetResourceInstance(), MAKEINTRESOURCE(T::GetWndClassInfo().m_uCommonResourceID)); return hWnd; } BOOL CreateSimpleToolBar(UINT nResourceID = 0, DWORD dwStyle = ATL_SIMPLE_TOOLBAR_STYLE, UINT nID = ATL_IDW_TOOLBAR) { - ATLASSERT(!::IsWindow(m_hWndToolBar)); + ATLASSERT(!::IsWindow(this->m_hWndToolBar)); if(nResourceID == 0) nResourceID = T::GetWndClassInfo().m_uCommonResourceID; - m_hWndToolBar = T::CreateSimpleToolBarCtrl(m_hWnd, nResourceID, TRUE, dwStyle, nID); - return (m_hWndToolBar != NULL); + this->m_hWndToolBar = T::CreateSimpleToolBarCtrl(this->m_hWnd, nResourceID, TRUE, dwStyle, nID); + return (this->m_hWndToolBar != NULL); } BOOL UpdateClientEdge(LPRECT lpRect = NULL) { // only adjust for active MDI child window - HWND hWndChild = MDIGetActive(); - if(hWndChild != NULL && hWndChild != m_hWnd) + HWND hWndChild = this->MDIGetActive(); + if((hWndChild != NULL) && (hWndChild != this->m_hWnd)) return FALSE; // need to adjust the client edge style as max/restore happens - DWORD dwStyle = ::GetWindowLong(m_hWndMDIClient, GWL_EXSTYLE); + DWORD dwStyle = ::GetWindowLong(this->m_hWndMDIClient, GWL_EXSTYLE); DWORD dwNewStyle = dwStyle; - if(hWndChild != NULL && ((GetExStyle() & WS_EX_CLIENTEDGE) == 0) && ((GetStyle() & WS_MAXIMIZE) != 0)) + if((hWndChild != NULL) && ((this->GetExStyle() & WS_EX_CLIENTEDGE) == 0) && ((this->GetStyle() & WS_MAXIMIZE) != 0)) dwNewStyle &= ~(WS_EX_CLIENTEDGE); else dwNewStyle |= WS_EX_CLIENTEDGE; @@ -1777,17 +1482,17 @@ public: if(dwStyle != dwNewStyle) { // SetWindowPos will not move invalid bits - ::RedrawWindow(m_hWndMDIClient, NULL, NULL, + ::RedrawWindow(this->m_hWndMDIClient, NULL, NULL, RDW_INVALIDATE | RDW_ALLCHILDREN); // remove/add WS_EX_CLIENTEDGE to MDI client area - ::SetWindowLong(m_hWndMDIClient, GWL_EXSTYLE, dwNewStyle); - ::SetWindowPos(m_hWndMDIClient, NULL, 0, 0, 0, 0, + ::SetWindowLong(this->m_hWndMDIClient, GWL_EXSTYLE, dwNewStyle); + ::SetWindowPos(this->m_hWndMDIClient, NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOCOPYBITS); // return new client area if (lpRect != NULL) - ::GetClientRect(m_hWndMDIClient, lpRect); + ::GetClientRect(this->m_hWndMDIClient, lpRect); return TRUE; } @@ -1804,19 +1509,15 @@ public: MESSAGE_HANDLER(WM_MDIACTIVATE, OnMDIActivate) MESSAGE_HANDLER(WM_DESTROY, OnDestroy) #ifndef _ATL_NO_REBAR_SUPPORT -#if (_WIN32_IE >= 0x0400) NOTIFY_CODE_HANDLER(RBN_AUTOSIZE, OnReBarAutoSize) -#endif // (_WIN32_IE >= 0x0400) -#if (_WIN32_IE >= 0x0500) NOTIFY_CODE_HANDLER(RBN_CHEVRONPUSHED, OnChevronPushed) -#endif // (_WIN32_IE >= 0x0500) #endif // !_ATL_NO_REBAR_SUPPORT CHAIN_MSG_MAP(_baseClass) END_MSG_MAP() LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) { - DefWindowProc(uMsg, wParam, lParam); // needed for MDI children + this->DefWindowProc(uMsg, wParam, lParam); // needed for MDI children if(wParam != SIZE_MINIMIZED) { T* pT = static_cast(this); @@ -1832,10 +1533,10 @@ public: if(!(lpWndPos->flags & SWP_NOSIZE)) { - RECT rectClient = { 0 }; - if(UpdateClientEdge(&rectClient) && ((GetStyle() & WS_MAXIMIZE) != 0)) + RECT rectClient = {}; + if(UpdateClientEdge(&rectClient) && ((this->GetStyle() & WS_MAXIMIZE) != 0)) { - ::AdjustWindowRectEx(&rectClient, GetStyle(), FALSE, GetExStyle()); + ::AdjustWindowRectEx(&rectClient, this->GetStyle(), FALSE, this->GetExStyle()); lpWndPos->x = rectClient.left; lpWndPos->y = rectClient.top; lpWndPos->cx = rectClient.right - rectClient.left; @@ -1849,13 +1550,13 @@ public: LRESULT OnMouseActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) { - LRESULT lRes = DefWindowProc(uMsg, wParam, lParam); + LRESULT lRes = this->DefWindowProc(uMsg, wParam, lParam); // Activate this MDI window if needed - if(lRes == MA_ACTIVATE || lRes == MA_ACTIVATEANDEAT) + if((lRes == MA_ACTIVATE) || (lRes == MA_ACTIVATEANDEAT)) { - if(MDIGetActive() != m_hWnd) - MDIActivate(m_hWnd); + if(this->MDIGetActive() != this->m_hWnd) + this->MDIActivate(this->m_hWnd); } return lRes; @@ -1863,15 +1564,15 @@ public: LRESULT OnMenuSelect(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) { - return ::SendMessage(GetMDIFrame(), uMsg, wParam, lParam); + return ::SendMessage(this->GetMDIFrame(), uMsg, wParam, lParam); } LRESULT OnMDIActivate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled) { - if((HWND)lParam == m_hWnd && m_hMenu != NULL) - SetMDIFrameMenu(); + if(((HWND)lParam == this->m_hWnd) && (this->m_hMenu != NULL)) + this->SetMDIFrameMenu(); else if((HWND)lParam == NULL) - ::SendMessage(GetMDIFrame(), WM_MDISETMENU, 0, 0); + ::SendMessage(this->GetMDIFrame(), WM_MDISETMENU, 0, 0); bHandled = FALSE; return 1; @@ -1879,10 +1580,10 @@ public: LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) { - if(m_hMenu != NULL) + if(this->m_hMenu != NULL) { - ::DestroyMenu(m_hMenu); - m_hMenu = NULL; + ::DestroyMenu(this->m_hMenu); + this->m_hMenu = NULL; } UpdateClientEdge(); bHandled = FALSE; @@ -1890,20 +1591,17 @@ public: } #ifndef _ATL_NO_REBAR_SUPPORT -#if (_WIN32_IE >= 0x0400) LRESULT OnReBarAutoSize(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/) { T* pT = static_cast(this); pT->UpdateLayout(FALSE); return 0; } -#endif // (_WIN32_IE >= 0x0400) -#if (_WIN32_IE >= 0x0500) LRESULT OnChevronPushed(int /*idCtrl*/, LPNMHDR pnmh, BOOL& bHandled) { T* pT = static_cast(this); - _ChevronMenuInfo cmi = { NULL, (LPNMREBARCHEVRON)pnmh, false }; + typename CFrameWindowImplBase::_ChevronMenuInfo cmi = { NULL, (LPNMREBARCHEVRON)pnmh, false }; if(!pT->PrepareChevronMenu(cmi)) { bHandled = FALSE; @@ -1915,12 +1613,9 @@ public: pT->CleanupChevronMenu(cmi); return 0; } -#endif // (_WIN32_IE >= 0x0500) #endif // !_ATL_NO_REBAR_SUPPORT }; -#endif // !_WIN32_WCE - /////////////////////////////////////////////////////////////////////////////// // COwnerDraw - MI class for owner-draw support @@ -1929,19 +1624,6 @@ template class COwnerDraw { public: -#if (_ATL_VER < 0x0700) - BOOL m_bHandledOD; - - BOOL IsMsgHandled() const - { - return m_bHandledOD; - } - void SetMsgHandled(BOOL bHandled) - { - m_bHandledOD = bHandled; - } -#endif // (_ATL_VER < 0x0700) - // Message map and handlers BEGIN_MSG_MAP(COwnerDraw< T >) MESSAGE_HANDLER(WM_DRAWITEM, OnDrawItem) @@ -2005,7 +1687,7 @@ public: T* pT = static_cast(this); HWND hWnd = pT->GetDlgItem(lpMeasureItemStruct->CtlID); CClientDC dc(hWnd); - TEXTMETRIC tm = { 0 }; + TEXTMETRIC tm = {}; dc.GetTextMetrics(&tm); lpMeasureItemStruct->itemHeight = tm.tmHeight; @@ -2034,7 +1716,7 @@ public: #define BEGIN_UPDATE_UI_MAP(thisClass) \ static const CUpdateUIBase::_AtlUpdateUIMap* GetUpdateUIMap() \ { \ - static const _AtlUpdateUIMap theMap[] = \ + static const CUpdateUIBase::_AtlUpdateUIMap theMap[] = \ { #define UPDATE_ELEMENT(nID, wType) \ @@ -2080,7 +1762,7 @@ public: WORD m_wType; bool operator ==(const _AtlUpdateUIElement& e) const - { return (m_hWnd == e.m_hWnd && m_wType == e.m_wType); } + { return ((m_hWnd == e.m_hWnd) && (m_wType == e.m_wType)); } }; // map data @@ -2090,7 +1772,7 @@ public: WORD m_wType; bool operator ==(const _AtlUpdateUIMap& e) const - { return (m_nID == e.m_nID && m_wType == e.m_wType); } + { return ((m_nID == e.m_nID) && (m_wType == e.m_wType)); } }; // instance data @@ -2112,7 +1794,7 @@ public: }; bool operator ==(const _AtlUpdateUIData& e) const - { return (m_wState == e.m_wState && m_lpData == e.m_lpData); } + { return ((m_wState == e.m_wState) && (m_lpData == e.m_lpData)); } }; #pragma warning(pop) @@ -2131,7 +1813,7 @@ public: ~CUpdateUIBase() { - if(m_pUIMap != NULL && m_pUIData != NULL) + if((m_pUIMap != NULL) && (m_pUIData != NULL)) { const _AtlUpdateUIMap* pUIMap = m_pUIMap; _AtlUpdateUIData* pUIData = m_pUIData; @@ -2234,7 +1916,7 @@ public: LRESULT OnCommand(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) { bHandled = FALSE; - if(m_bBlockAccelerators && HIWORD(wParam) == 1) // accelerators only + if(m_bBlockAccelerators && (HIWORD(wParam) == 1)) // accelerators only { int nID = LOWORD(wParam); if((UIGetState(nID) & UPDUI_DISABLED) == UPDUI_DISABLED) @@ -2405,7 +2087,7 @@ public: if(pUIData->m_wState & pMap->m_wType) m_wDirtyType |= pMap->m_wType; } - else if(pMap->m_nID >= nIDFirst && pMap->m_nID <= nIDLast) + else if((pMap->m_nID >= nIDFirst) && (pMap->m_nID <= nIDLast)) { if(pUIData->m_wState & UPDUI_RADIO) { @@ -2436,7 +2118,7 @@ public: { if(nID == (int)pMap->m_nID) { - if(pUIData->m_lpstrText == NULL || lstrcmp(pUIData->m_lpstrText, lpstrText)) + if((pUIData->m_lpstrText == NULL) || (lstrcmp(pUIData->m_lpstrText, lpstrText) != 0)) { delete [] pUIData->m_lpstrText; pUIData->m_lpstrText = NULL; @@ -2447,7 +2129,7 @@ public: ATLTRACE2(atlTraceUI, 0, _T("UISetText - memory allocation failed\n")); break; } - SecureHelper::strcpy_x(pUIData->m_lpstrText, nStrLen + 1, lpstrText); + ATL::Checked::tcscpy_s(pUIData->m_lpstrText, nStrLen + 1, lpstrText); pUIData->m_wState |= (UPDUI_TEXT | pMap->m_wType); } @@ -2538,7 +2220,6 @@ public: } // methods for updating UI -#ifndef _WIN32_WCE BOOL UIUpdateMenuBar(BOOL bForceUpdate = FALSE, BOOL bMainMenu = FALSE) { if(!(m_wDirtyType & UPDUI_MENUBAR) && !bForceUpdate) @@ -2556,7 +2237,7 @@ public: if(m_UIElements[i].m_wType == UPDUI_MENUBAR) { HMENU hMenu = ::GetMenu(m_UIElements[i].m_hWnd); - if(hMenu != NULL && (pUIData->m_wState & UPDUI_MENUBAR) && (pMap->m_wType & UPDUI_MENUBAR)) + if((hMenu != NULL) && (pUIData->m_wState & UPDUI_MENUBAR) && (pMap->m_wType & UPDUI_MENUBAR)) UIUpdateMenuBarElement(pMap->m_nID, pUIData, hMenu); } if(bMainMenu) @@ -2576,7 +2257,6 @@ public: m_wDirtyType &= ~UPDUI_MENUBAR; return TRUE; } -#endif // !_WIN32_WCE BOOL UIUpdateToolBar(BOOL bForceUpdate = FALSE) { @@ -2680,19 +2360,16 @@ public: // internal element specific methods static void UIUpdateMenuBarElement(int nID, _AtlUpdateUIData* pUIData, HMENU hMenu) { -#ifndef _WIN32_WCE if((pUIData->m_wState & UPDUI_CLEARDEFAULT) != 0) { ::SetMenuDefaultItem(hMenu, (UINT)-1, 0); pUIData->m_wState &= ~UPDUI_CLEARDEFAULT; } -#endif // !_WIN32_WCE CMenuItemInfo mii; mii.fMask = MIIM_STATE; mii.wID = nID; -#ifndef _WIN32_WCE if((pUIData->m_wState & UPDUI_DISABLED) != 0) mii.fState |= MFS_DISABLED | MFS_GRAYED; else @@ -2705,23 +2382,6 @@ public: if((pUIData->m_wState & UPDUI_DEFAULT) != 0) mii.fState |= MFS_DEFAULT; -#else // CE specific - // ::SetMenuItemInfo() can't disable or check menu items - // on Windows CE, so we have to do that directly - UINT uEnable = MF_BYCOMMAND; - if((pUIData->m_wState & UPDUI_DISABLED) != 0) - uEnable |= MF_GRAYED; - else - uEnable |= MF_ENABLED; - ::EnableMenuItem(hMenu, nID, uEnable); - - UINT uCheck = MF_BYCOMMAND; - if((pUIData->m_wState & UPDUI_CHECKED) != 0) - uCheck |= MF_CHECKED; - else - uCheck |= MF_UNCHECKED; - ::CheckMenuItem(hMenu, nID, uCheck); -#endif // _WIN32_WCE if((pUIData->m_wState & UPDUI_TEXT) != 0) { @@ -2732,11 +2392,7 @@ public: { mii.fMask |= MIIM_TYPE; // MFT_BITMAP and MFT_SEPARATOR don't go together with MFT_STRING -#ifndef _WIN32_WCE mii.fType |= (miiNow.fType & ~(MFT_BITMAP | MFT_SEPARATOR)) | MFT_STRING; -#else // CE specific - mii.fType |= (miiNow.fType & ~(MFT_SEPARATOR)) | MFT_STRING; -#endif // _WIN32_WCE mii.dwTypeData = pUIData->m_lpstrText; } } @@ -2767,7 +2423,7 @@ public: ::EnableWindow(hChild, (pUIData->m_wState & UPDUI_DISABLED) ? FALSE : TRUE); // for check and radio, assume that window is a button int nCheck = BST_UNCHECKED; - if(pUIData->m_wState & UPDUI_CHECKED || pUIData->m_wState & UPDUI_RADIO) + if((pUIData->m_wState & UPDUI_CHECKED) || (pUIData->m_wState & UPDUI_RADIO)) nCheck = BST_CHECKED; else if(pUIData->m_wState & UPDUI_CHECKED2) nCheck = BST_INDETERMINATE; @@ -2795,7 +2451,7 @@ public: CUpdateUI() { T* pT = static_cast(this); - pT; + (void)pT; // avoid level 4 warning const _AtlUpdateUIMap* pMap = pT->GetUpdateUIMap(); m_pUIMap = pMap; ATLASSERT(m_pUIMap != NULL); @@ -2841,7 +2497,7 @@ public: CDynamicUpdateUI() { T* pT = static_cast(this); - pT; + (void)pT; // avoid level 4 warning const _AtlUpdateUIMap* pMap = pT->GetUpdateUIMap(); ATLASSERT(pMap != NULL); @@ -2975,10 +2631,10 @@ class CAutoUpdateUI : public CDynamicUpdateUI public: LPCTSTR UIGetText(int nID) { - for(int i = 0; i < m_arrUIMap.GetSize(); i++) + for(int i = 0; i < this->m_arrUIMap.GetSize(); i++) { - if(m_arrUIMap[i].m_nID == nID) - return m_arrUIData[i].m_lpstrText; + if(this->m_arrUIMap[i].m_nID == nID) + return this->m_arrUIData[i].m_lpstrText; } return NULL; @@ -2989,36 +2645,36 @@ public: bool UIAddElement(UINT nID) { // check for existing UI map element - for(int i = 0; i < m_arrUIMap.GetSize(); i++) + for(int i = 0; i < this->m_arrUIMap.GetSize(); i++) { - if(m_arrUIMap[i].m_nID == nID) + if(this->m_arrUIMap[i].m_nID == nID) { // set requested type - m_arrUIMap[i].m_wType |= t_wType; + this->m_arrUIMap[i].m_wType |= t_wType; return true; } } // Add element to UI map with requested type - return UIAddUpdateElement((WORD)nID, t_wType); + return this->UIAddUpdateElement((WORD)nID, t_wType); } template bool UIRemoveElement(UINT nID) { - for(int i = 0; i < m_arrUIMap.GetSize(); i++) + for(int i = 0; i < this->m_arrUIMap.GetSize(); i++) { - if(m_arrUIMap[i].m_nID == nID) // matching UI map element + if(this->m_arrUIMap[i].m_nID == nID) // matching UI map element { - WORD wType = m_arrUIMap[i].m_wType & ~t_wType; + WORD wType = this->m_arrUIMap[i].m_wType & ~t_wType; if (wType != 0) // has other types { - m_arrUIMap[i].m_wType = wType; // keep other types + this->m_arrUIMap[i].m_wType = wType; // keep other types return true; } else { - return UIRemoveUpdateElement((WORD)nID); + return this->UIRemoveUpdateElement((WORD)nID); } } } @@ -3029,9 +2685,6 @@ public: // Menu bool UIAddMenu(HMENU hMenu, bool bSetText = false) { -#if defined(_WIN32_WCE) && (_ATL_VER >= 0x0800) - using ATL::GetMenuString; -#endif ATLASSERT(::IsMenu(hMenu)); MENUITEMINFO mii = {sizeof(MENUITEMINFO), MIIM_TYPE | MIIM_ID | MIIM_SUBMENU}; @@ -3046,17 +2699,13 @@ public: else if (mii.wID != 0) { // Add element to UI map - UIAddElement(mii.wID); -#if !defined(_WIN32_WCE) || (_ATL_VER >= 0x0800) + UIAddElement::UPDUI_MENUPOPUP>(mii.wID); if (bSetText) { - TCHAR sText[64] = { 0 }; + TCHAR sText[64] = {}; if (GetMenuString(hMenu, uItem, sText, 64, MF_BYPOSITION)) - UISetText(mii.wID, sText); + this->UISetText(mii.wID, sText); } -#else - bSetText; -#endif // !defined(_WIN32_WCE) || (_ATL_VER >= 0x0800) } } @@ -3071,7 +2720,6 @@ public: } // ToolBar -#if !defined(_WIN32_WCE) || (defined(_AUTOUI_CE_TOOLBAR) && defined(TBIF_BYINDEX)) bool UIAddToolBar(HWND hWndToolBar) { ATLASSERT(::IsWindow(hWndToolBar)); @@ -3081,7 +2729,7 @@ public: for (int uItem = 0; ::SendMessage(hWndToolBar, TB_GETBUTTONINFO, uItem, (LPARAM)&tbbi) != -1; uItem++) { if (tbbi.fsStyle ^ BTNS_SEP) - UIAddElement(tbbi.idCommand); + UIAddElement::UPDUI_TOOLBAR>(tbbi.idCommand); } // Add embedded controls if any @@ -3090,7 +2738,6 @@ public: return (CUpdateUIBase::UIAddToolBar(hWndToolBar) != FALSE); } -#endif // !defined(_WIN32_WCE) || (defined(_AUTOUI_CE_TOOLBAR) && defined(TBIF_BYINDEX)) // Container bool UIAddChildWindowContainer(HWND hWnd) @@ -3102,7 +2749,7 @@ public: { int id = wCtl.GetDlgCtrlID(); if(id != 0) - UIAddElement(id); + UIAddElement::UPDUI_CHILDWINDOW>(id); } return (CUpdateUIBase::UIAddChildWindowContainer(hWnd) != FALSE); @@ -3111,26 +2758,26 @@ public: // StatusBar BOOL UIUpdateStatusBar(BOOL bForceUpdate = FALSE) { - if(!(m_wDirtyType & UPDUI_STATUSBAR) && !bForceUpdate) + if(!(this->m_wDirtyType & CDynamicUpdateUI::UPDUI_STATUSBAR) && !bForceUpdate) return TRUE; - for(int i = 0; i < m_arrUIMap.GetSize(); i++) + for(int i = 0; i < this->m_arrUIMap.GetSize(); i++) { - for(int e = 0; e < m_UIElements.GetSize(); e++) + for(int e = 0; e < this->m_UIElements.GetSize(); e++) { - if((m_UIElements[e].m_wType == UPDUI_STATUSBAR) && - (m_arrUIMap[i].m_wType & UPDUI_STATUSBAR) && - (m_arrUIData[i].m_wState & UPDUI_STATUSBAR)) + if((this->m_UIElements[e].m_wType == CDynamicUpdateUI::UPDUI_STATUSBAR) && + (this->m_arrUIMap[i].m_wType & CDynamicUpdateUI::UPDUI_STATUSBAR) && + (this->m_arrUIData[i].m_wState & CDynamicUpdateUI::UPDUI_STATUSBAR)) { - UIUpdateStatusBarElement(m_arrUIMap[i].m_nID, &m_arrUIData[i], m_UIElements[e].m_hWnd); - m_arrUIData[i].m_wState &= ~UPDUI_STATUSBAR; - if(m_arrUIData[i].m_wState & UPDUI_TEXT) - m_arrUIData[i].m_wState &= ~UPDUI_TEXT; + this->UIUpdateStatusBarElement(this->m_arrUIMap[i].m_nID, &this->m_arrUIData[i], this->m_UIElements[e].m_hWnd); + this->m_arrUIData[i].m_wState &= ~CDynamicUpdateUI::UPDUI_STATUSBAR; + if(this->m_arrUIData[i].m_wState & CDynamicUpdateUI::UPDUI_TEXT) + this->m_arrUIData[i].m_wState &= ~CDynamicUpdateUI::UPDUI_TEXT; } } } - m_wDirtyType &= ~UPDUI_STATUSBAR; + this->m_wDirtyType &= ~CDynamicUpdateUI::UPDUI_STATUSBAR; return TRUE; } @@ -3140,7 +2787,7 @@ public: // Add StatusBar panes for (int iPane = 0; iPane < nPanes; iPane++) - UIAddElement(ID_DEFAULT_PANE + iPane); + UIAddElement::UPDUI_STATUSBAR>(ID_DEFAULT_PANE + iPane); return (CUpdateUIBase::UIAddStatusBar(hWndStatusBar) != FALSE); } @@ -3168,10 +2815,16 @@ public: // on the position of the previous control in a group. // dialog resize map macros +struct _AtlDlgResizeMap +{ + int m_nCtlID; + DWORD m_dwResizeFlags; +}; + #define BEGIN_DLGRESIZE_MAP(thisClass) \ - static const _AtlDlgResizeMap* GetDlgResizeMap() \ + static const WTL::_AtlDlgResizeMap* GetDlgResizeMap() \ { \ - static const _AtlDlgResizeMap theMap[] = \ + static const WTL::_AtlDlgResizeMap theMap[] = \ { #define END_DLGRESIZE_MAP() \ @@ -3211,12 +2864,6 @@ public: _DLSZ_GRIPPER = 0x00004000 }; - struct _AtlDlgResizeMap - { - int m_nCtlID; - DWORD m_dwResizeFlags; - }; - struct _AtlDlgResizeData { int m_nCtlID; @@ -3230,14 +2877,14 @@ public: void SetGroupCount(int nCount) { - ATLASSERT(nCount > 0 && nCount < 256); + ATLASSERT((nCount > 0) && (nCount < 256)); DWORD dwCount = (DWORD)MAKELONG(0, MAKEWORD(nCount, 0)); m_dwResizeFlags &= 0xFF00FFFF; m_dwResizeFlags |= dwCount; } bool operator ==(const _AtlDlgResizeData& r) const - { return (m_nCtlID == r.m_nCtlID && m_dwResizeFlags == r.m_dwResizeFlags); } + { return ((m_nCtlID == r.m_nCtlID) && (m_dwResizeFlags == r.m_dwResizeFlags)); } }; ATL::CSimpleArray<_AtlDlgResizeData> m_arrData; @@ -3273,7 +2920,6 @@ public: if((dwStyle & dwForceStyle) != dwForceStyle) pT->ModifyStyle(0, dwForceStyle); -#ifndef _WIN32_WCE // Adding this style removes an empty icon that dialogs with WS_THICKFRAME have. // Setting icon to NULL is required when XP themes are active. // Note: This will not prevent adding an icon for the dialog using SetIcon() @@ -3283,13 +2929,12 @@ public: if(pT->GetIcon(FALSE) == NULL) pT->SetIcon(NULL, FALSE); } -#endif // Cleanup in case of multiple initialization // block: first check for the gripper control, destroy it if needed { ATL::CWindow wndGripper = pT->GetDlgItem(ATL_IDW_STATUS_BAR); - if(wndGripper.IsWindow() && m_arrData.GetSize() > 0 && (m_arrData[0].m_dwResizeFlags & _DLSZ_GRIPPER) != 0) + if(wndGripper.IsWindow() && (m_arrData.GetSize() > 0) && (m_arrData[0].m_dwResizeFlags & _DLSZ_GRIPPER) != 0) wndGripper.DestroyWindow(); } // clear out everything else @@ -3300,27 +2945,26 @@ public: m_ptMinTrackSize.y = -1; // Get initial dialog client size - RECT rectDlg = { 0 }; + RECT rectDlg = {}; pT->GetClientRect(&rectDlg); m_sizeDialog.cx = rectDlg.right; m_sizeDialog.cy = rectDlg.bottom; -#ifndef _WIN32_WCE // Create gripper if requested m_bGripper = false; if(bAddGripper) { // shouldn't exist already - ATLASSERT(!::IsWindow(pT->GetDlgItem(ATL_IDW_STATUS_BAR))); - if(!::IsWindow(pT->GetDlgItem(ATL_IDW_STATUS_BAR))) + ATLASSERT(!pT->GetDlgItem(ATL_IDW_STATUS_BAR).IsWindow()); + if(!pT->GetDlgItem(ATL_IDW_STATUS_BAR).IsWindow()) { ATL::CWindow wndGripper; - wndGripper.Create(_T("SCROLLBAR"), pT->m_hWnd, rectDlg, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | SBS_SIZEBOX | SBS_SIZEGRIP | SBS_SIZEBOXBOTTOMRIGHTALIGN, 0, ATL_IDW_STATUS_BAR); + wndGripper.Create(_T("SCROLLBAR"), pT->m_hWnd, rectDlg, NULL, WS_CHILD | WS_VISIBLE | WS_GROUP | WS_CLIPSIBLINGS | SBS_SIZEBOX | SBS_SIZEGRIP | SBS_SIZEBOXBOTTOMRIGHTALIGN, 0, ATL_IDW_STATUS_BAR); ATLASSERT(wndGripper.IsWindow()); if(wndGripper.IsWindow()) { m_bGripper = true; - RECT rectCtl = { 0 }; + RECT rectCtl = {}; wndGripper.GetWindowRect(&rectCtl); ::MapWindowPoints(NULL, pT->m_hWnd, (LPPOINT)&rectCtl, 2); _AtlDlgResizeData data = { ATL_IDW_STATUS_BAR, DLSZ_MOVE_X | DLSZ_MOVE_Y | DLSZ_REPAINT | _DLSZ_GRIPPER, { rectCtl.left, rectCtl.top, rectCtl.right, rectCtl.bottom } }; @@ -3328,23 +2972,20 @@ public: } } } -#else // CE specific - bAddGripper; // avoid level 4 warning -#endif // _WIN32_WCE // Get min track position if requested if(bUseMinTrackSize) { if((dwStyle & WS_CHILD) != 0) { - RECT rect = { 0 }; + RECT rect = {}; pT->GetClientRect(&rect); m_ptMinTrackSize.x = rect.right - rect.left; m_ptMinTrackSize.y = rect.bottom - rect.top; } else { - RECT rect = { 0 }; + RECT rect = {}; pT->GetWindowRect(&rect); m_ptMinTrackSize.x = rect.right - rect.left; m_ptMinTrackSize.y = rect.bottom - rect.top; @@ -3355,7 +2996,7 @@ public: const _AtlDlgResizeMap* pMap = pT->GetDlgResizeMap(); ATLASSERT(pMap != NULL); int nGroupStart = -1; - for(int nCount = 1; !(pMap->m_nCtlID == -1 && pMap->m_dwResizeFlags == 0); nCount++, pMap++) + for(int nCount = 1; !((pMap->m_nCtlID == -1) && (pMap->m_dwResizeFlags == 0)); nCount++, pMap++) { if(pMap->m_nCtlID == -1) { @@ -3385,11 +3026,11 @@ public: ATL::CWindow ctl = pT->GetDlgItem(pMap->m_nCtlID); ATLASSERT(ctl.IsWindow()); - RECT rectCtl = { 0 }; + RECT rectCtl = {}; ctl.GetWindowRect(&rectCtl); ::MapWindowPoints(NULL, pT->m_hWnd, (LPPOINT)&rectCtl, 2); - DWORD dwGroupFlag = (nGroupStart != -1 && m_arrData.GetSize() == nGroupStart) ? _DLSZ_BEGIN_GROUP : 0; + DWORD dwGroupFlag = ((nGroupStart != -1) && (m_arrData.GetSize() == nGroupStart)) ? _DLSZ_BEGIN_GROUP : 0; _AtlDlgResizeData data = { pMap->m_nCtlID, pMap->m_dwResizeFlags | dwGroupFlag, { rectCtl.left, rectCtl.top, rectCtl.right, rectCtl.bottom } }; m_arrData.Add(data); } @@ -3403,7 +3044,7 @@ public: ATLASSERT(::IsWindow(pT->m_hWnd)); // Restrict minimum size if requested - if(((pT->GetStyle() & WS_CHILD) != 0) && m_ptMinTrackSize.x != -1 && m_ptMinTrackSize.y != -1) + if(((pT->GetStyle() & WS_CHILD) != 0) && (m_ptMinTrackSize.x != -1) && (m_ptMinTrackSize.y != -1)) { if(cxWidth < m_ptMinTrackSize.x) cxWidth = m_ptMinTrackSize.x; @@ -3420,7 +3061,7 @@ public: if((m_arrData[i].m_dwResizeFlags & _DLSZ_BEGIN_GROUP) != 0) // start of a group { int nGroupCount = m_arrData[i].GetGroupCount(); - ATLASSERT(nGroupCount > 0 && i + nGroupCount - 1 < m_arrData.GetSize()); + ATLASSERT((nGroupCount > 0) && ((i + nGroupCount - 1) < m_arrData.GetSize())); RECT rectGroup = m_arrData[i].m_rect; int j = 1; @@ -3444,7 +3085,7 @@ public: } else // one control entry { - RECT rectGroup = { 0 }; + RECT rectGroup = {}; pT->DlgResize_PositionControl(cxWidth, cyHeight, rectGroup, m_arrData[i], false); } } @@ -3458,15 +3099,12 @@ public: // Message map and handlers BEGIN_MSG_MAP(CDialogResize) MESSAGE_HANDLER(WM_SIZE, OnSize) -#ifndef _WIN32_WCE MESSAGE_HANDLER(WM_GETMINMAXINFO, OnGetMinMaxInfo) -#endif // _WIN32_WCE END_MSG_MAP() LRESULT OnSize(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) { T* pT = static_cast(this); -#ifndef _WIN32_WCE if(m_bGripper) { ATL::CWindow wndGripper = pT->GetDlgItem(ATL_IDW_STATUS_BAR); @@ -3475,7 +3113,6 @@ public: else if(wParam == SIZE_RESTORED) wndGripper.ShowWindow(SW_SHOW); } -#endif // _WIN32_WCE if(wParam != SIZE_MINIMIZED) { ATLASSERT(::IsWindow(pT->m_hWnd)); @@ -3484,17 +3121,15 @@ public: return 0; } -#ifndef _WIN32_WCE LRESULT OnGetMinMaxInfo(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/) { - if(m_ptMinTrackSize.x != -1 && m_ptMinTrackSize.y != -1) + if((m_ptMinTrackSize.x != -1) && (m_ptMinTrackSize.y != -1)) { LPMINMAXINFO lpMMI = (LPMINMAXINFO)lParam; lpMMI->ptMinTrackSize = m_ptMinTrackSize; } return 0; } -#endif // _WIN32_WCE // Implementation bool DlgResize_PositionControl(int cxWidth, int cyHeight, RECT& rectGroup, _AtlDlgResizeData& data, bool bGroup, @@ -3503,7 +3138,7 @@ public: T* pT = static_cast(this); ATLASSERT(::IsWindow(pT->m_hWnd)); ATL::CWindow ctl; - RECT rectCtl = { 0 }; + RECT rectCtl = {}; ctl = pT->GetDlgItem(data.m_nCtlID); if(!ctl.GetWindowRect(&rectCtl)) @@ -3530,7 +3165,7 @@ public: if(pDataPrev != NULL) { ATL::CWindow ctlPrev = pT->GetDlgItem(pDataPrev->m_nCtlID); - RECT rcPrev = { 0 }; + RECT rcPrev = {}; ctlPrev.GetWindowRect(&rcPrev); ::MapWindowPoints(NULL, pT->m_hWnd, (LPPOINT)&rcPrev, 2); int dxAdjust = (rectCtl.left - rcPrev.right) - (data.m_rect.left - pDataPrev->m_rect.right); @@ -3562,7 +3197,7 @@ public: if(pDataPrev != NULL) { ATL::CWindow ctlPrev = pT->GetDlgItem(pDataPrev->m_nCtlID); - RECT rcPrev = { 0 }; + RECT rcPrev = {}; ctlPrev.GetWindowRect(&rcPrev); ::MapWindowPoints(NULL, pT->m_hWnd, (LPPOINT)&rcPrev, 2); int dxAdjust = (rectCtl.top - rcPrev.bottom) - (data.m_rect.top - pDataPrev->m_rect.bottom); @@ -3618,6 +3253,254 @@ public: }; +/////////////////////////////////////////////////////////////////////////////// +// CDynamicDialogLayout - support for dialog dynamic layout resource info +// (AFX_DIALOG_LAYOUT) in VS2015 and higher + +#if (_MSC_VER >= 1900) + +template +class CDynamicDialogLayout +{ +public: +// Data declarations + struct _AtlDynamicLayoutData + { + HWND m_hWnd; + char m_nMoveRatioX; + char m_nMoveRatioY; + char m_nSizeRatioX; + char m_nSizeRatioY; + RECT m_rcInit; + }; + +// Data members + ATL::CSimpleArray<_AtlDynamicLayoutData> m_arrLayoutData; + SIZE m_szParentInit; + POINT m_ptMinTrackSize; + bool m_bGripper; + +// Constructor + CDynamicDialogLayout() : m_bGripper(false) + { + m_szParentInit.cx = 0; + m_szParentInit.cy = 0; + m_ptMinTrackSize.x = -1; + m_ptMinTrackSize.y = -1; + } + +// Methods + void InitDynamicLayout(bool bAddGripper = true, bool bMinTrackSize = true) + { + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + + // Cleanup in case of multiple initialization + // block: first check for the gripper control, destroy it if needed + { + ATL::CWindow wndGripper = pT->GetDlgItem(ATL_IDW_STATUS_BAR); + if(wndGripper.IsWindow() != FALSE) + wndGripper.DestroyWindow(); + } + // clear out everything else + m_arrLayoutData.RemoveAll(); + m_ptMinTrackSize.x = -1; + m_ptMinTrackSize.y = -1; + m_szParentInit.cx = 0; + m_szParentInit.cy = 0; + m_bGripper = false; + + CResource rcLayout; + if(rcLayout.Load(_T("AFX_DIALOG_LAYOUT"), pT->IDD)) + { + int nCount = rcLayout.GetSize() / sizeof(WORD); + if(nCount > 1) + { + RECT rcParent = {}; + pT->GetWindowRect(&rcParent); + m_szParentInit.cx = rcParent.right - rcParent.left; + m_szParentInit.cy = rcParent.bottom - rcParent.top; + + WORD* pnData = (WORD*)rcLayout.Lock(); + WORD wVersion = *pnData; // AFX_DIALOG_LAYOUT version + ATLASSERT(wVersion == 0); + if(wVersion == 0) + { + pnData++; // skip version + ATL::CWindow wndChild = pT->GetWindow(GW_CHILD); + for(int i = 0; (i < nCount) && (wndChild.m_hWnd != NULL); i += 4) + { + char nMoveRatioX = _GetDataPct(pnData[i]); + char nMoveRatioY = _GetDataPct(pnData[i + 1]); + char nSizeRatioX = _GetDataPct(pnData[i + 2]); + char nSizeRatioY = _GetDataPct(pnData[i + 3]); + + bool bValid = ((nMoveRatioX != -1) && (nMoveRatioY != -1) && (nSizeRatioX != -1) && (nSizeRatioY != -1)); + bool bAction = ((nMoveRatioX != 0) || (nMoveRatioY != 0) || (nSizeRatioX != 0) || (nSizeRatioY != 0)); + if(bValid && bAction) + { + _AtlDynamicLayoutData LayoutData = { wndChild.m_hWnd, nMoveRatioX, nMoveRatioY, nSizeRatioX, nSizeRatioY }; + wndChild.GetWindowRect(&LayoutData.m_rcInit); + pT->ScreenToClient(&LayoutData.m_rcInit); + m_arrLayoutData.Add(LayoutData); + } + + wndChild = wndChild.GetWindow(GW_HWNDNEXT); + } + } + + rcLayout.Release(); + } + } + + if(bAddGripper) + { + RECT rcDialog = {}; + pT->GetClientRect(&rcDialog); + + ATL::CWindow wndGripper = pT->GetDlgItem(ATL_IDW_STATUS_BAR); + if(wndGripper.m_hWnd != NULL) + wndGripper.DestroyWindow(); + + wndGripper.Create(_T("SCROLLBAR"), pT->m_hWnd, rcDialog, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | SBS_SIZEBOX | SBS_SIZEGRIP | SBS_SIZEBOXBOTTOMRIGHTALIGN, 0, ATL_IDW_STATUS_BAR); + ATLASSERT(wndGripper.m_hWnd != NULL); + if(wndGripper.m_hWnd != NULL) + { + m_bGripper = true; + _AtlDynamicLayoutData LayoutData = { wndGripper.m_hWnd, 100, 100, 0, 0 }; + wndGripper.GetWindowRect(&LayoutData.m_rcInit); + pT->ScreenToClient(&LayoutData.m_rcInit); + m_arrLayoutData.Add(LayoutData); + } + } + + if(bMinTrackSize) + { + RECT rcMinTrack = {}; + if((pT->GetStyle() & WS_CHILD) != 0) + pT->GetClientRect(&rcMinTrack); + else + pT->GetWindowRect(&rcMinTrack); + + m_ptMinTrackSize.x = rcMinTrack.right - rcMinTrack.left; + m_ptMinTrackSize.y = rcMinTrack.bottom - rcMinTrack.top; + } + } + + void UpdateDynamicLayout() + { + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + + int nCount = m_arrLayoutData.GetSize(); + if(nCount == 0) + return; + + RECT rcParent = {}; + pT->GetWindowRect(&rcParent); + + int nDeltaWidth = rcParent.right - rcParent.left - m_szParentInit.cx; + int nDeltaHeight = rcParent.bottom - rcParent.top - m_szParentInit.cy; + + HDWP hDwp = ::BeginDeferWindowPos(nCount); + + for(int i = 0; i < nCount; i++) + { + _AtlDynamicLayoutData& LayoutData = m_arrLayoutData[i]; + + ATLASSERT(::IsWindow(LayoutData.m_hWnd) != FALSE); + + int nID = ::GetDlgCtrlID(LayoutData.m_hWnd); + UINT nFlags = (SWP_NOMOVE | SWP_NOSIZE); + RECT rcItem = LayoutData.m_rcInit; + + if(((nID == ATL_IDW_STATUS_BAR) || (nDeltaWidth >= 0)) && (LayoutData.m_nMoveRatioX != 0)) + { + rcItem.left += ::MulDiv(nDeltaWidth, LayoutData.m_nMoveRatioX, 100); + rcItem.right += ::MulDiv(nDeltaWidth, LayoutData.m_nMoveRatioX, 100); + nFlags &= ~SWP_NOMOVE; + } + + if(((nID == ATL_IDW_STATUS_BAR) || (nDeltaHeight >= 0)) && (LayoutData.m_nMoveRatioY != 0)) + { + rcItem.top += ::MulDiv(nDeltaHeight, LayoutData.m_nMoveRatioY, 100); + rcItem.bottom += ::MulDiv(nDeltaHeight, LayoutData.m_nMoveRatioY, 100); + nFlags &= ~SWP_NOMOVE; + } + + if((nDeltaWidth >= 0) && (LayoutData.m_nSizeRatioX != 0)) + { + rcItem.right += ::MulDiv(nDeltaWidth, LayoutData.m_nSizeRatioX, 100); + nFlags &= ~SWP_NOSIZE; + } + + if((nDeltaHeight >= 0) && (LayoutData.m_nSizeRatioY != 0)) + { + rcItem.bottom += ::MulDiv(nDeltaHeight, LayoutData.m_nSizeRatioY, 100); + nFlags &= ~SWP_NOSIZE; + } + + if(nFlags != (SWP_NOMOVE | SWP_NOSIZE)) + ::DeferWindowPos(hDwp, LayoutData.m_hWnd, NULL, rcItem.left, rcItem.top, rcItem.right - rcItem.left, rcItem.bottom - rcItem.top, nFlags | SWP_NOZORDER | SWP_NOREPOSITION | SWP_NOACTIVATE | SWP_NOCOPYBITS); + } + + ::EndDeferWindowPos(hDwp); + } + +// Message map and handlers + BEGIN_MSG_MAP(CDynamicDialogLayout) + MESSAGE_HANDLER(WM_SIZE, OnSize) + MESSAGE_HANDLER(WM_GETMINMAXINFO, OnGetMinMaxInfo) + END_MSG_MAP() + + LRESULT OnSize(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + T* pT = static_cast(this); + + if(m_bGripper) + { + ATL::CWindow wndGripper = pT->GetDlgItem(ATL_IDW_STATUS_BAR); + if(wndGripper.m_hWnd != NULL) + { + if(wParam == SIZE_MAXIMIZED) + wndGripper.ShowWindow(SW_HIDE); + else if(wParam == SIZE_RESTORED) + wndGripper.ShowWindow(SW_SHOW); + } + } + + if(wParam != SIZE_MINIMIZED) + pT->UpdateDynamicLayout(); + + return 0; + } + + LRESULT OnGetMinMaxInfo(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/) + { + if((m_ptMinTrackSize.x != -1) && (m_ptMinTrackSize.y != -1)) + { + LPMINMAXINFO lpMMI = (LPMINMAXINFO)lParam; + lpMMI->ptMinTrackSize = m_ptMinTrackSize; + } + + return 0; + } + +// Implementation + char _GetDataPct(WORD wResData) + { + ATLASSERT((wResData >= 0) && (wResData <= 100)); + char nPct = (char)LOBYTE(wResData); + if((nPct < 0) || (nPct > 100)) + nPct = -1; + + return nPct; + } +}; + +#endif // (_MSC_VER >= 1900) + + /////////////////////////////////////////////////////////////////////////////// // CDoubleBufferImpl - Provides double-buffer painting support to any window @@ -3636,9 +3519,7 @@ public: BEGIN_MSG_MAP(CDoubleBufferImpl) MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackground) MESSAGE_HANDLER(WM_PAINT, OnPaint) -#ifndef _WIN32_WCE MESSAGE_HANDLER(WM_PRINTCLIENT, OnPaint) -#endif // !_WIN32_WCE END_MSG_MAP() LRESULT OnEraseBackground(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) @@ -3653,7 +3534,7 @@ public: if(wParam != NULL) { - RECT rect = { 0 }; + RECT rect = {}; pT->GetClientRect(&rect); CMemoryDC dcMem((HDC)wParam, rect); pT->DoPaint(dcMem.m_hDC); @@ -3684,13 +3565,13 @@ public: // command bar support -#if !defined(__ATLCTRLW_H__) && !defined(_WIN32_WCE) +#if !defined(__ATLCTRLW_H__) #undef CBRM_GETMENU #undef CBRM_TRACKPOPUPMENU #undef CBRM_GETCMDBAR #undef CBRPOPUPMENU -#endif // !defined(__ATLCTRLW_H__) && !defined(_WIN32_WCE) +#endif // !defined(__ATLCTRLW_H__) -}; // namespace WTL +} // namespace WTL #endif // __ATLFRAME_H__ diff --git a/WrlSDK/SampleCode/PluginWinExe/WTL/atlgdi.h b/WrlSDK/SampleCode/PluginWinExe/WTL/atlgdi.h index 946e8de6530df0eb9355f3de2a13c691e412f34a..14e151899b3dd3354bd1a7ffe919b576dfea7ca5 100644 --- a/WrlSDK/SampleCode/PluginWinExe/WTL/atlgdi.h +++ b/WrlSDK/SampleCode/PluginWinExe/WTL/atlgdi.h @@ -1,4 +1,4 @@ -// Windows Template Library - WTL version 9.10 +// Windows Template Library - WTL version 10.0 // Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. // // This file is a part of the Windows Template Library. @@ -28,10 +28,8 @@ #endif // _INC_WINDOWSX // required libraries -#if !defined(_ATL_NO_MSIMG) && !defined(_WIN32_WCE) - #pragma comment(lib, "msimg32.lib") -#endif -#if !defined(_ATL_NO_OPENGL) && !defined(_WIN32_WCE) +#pragma comment(lib, "msimg32.lib") +#if !defined(_ATL_NO_OPENGL) #pragma comment(lib, "opengl32.lib") #endif @@ -54,19 +52,6 @@ // CEnhMetaFileInfo // CEnhMetaFileT // CEnhMetaFileDC -// -// Global functions: -// AtlGetBitmapResourceInfo() -// AtlGetBitmapResourceBitsPerPixel() -// AtlIsAlphaBitmapResource() -// AtlIsDib16() -// AtlGetDibColorTableSize() -// AtlGetDibNumColors(), -// AtlGetDibBitmap() -// AtlCopyBitmap() -// AtlCreatePackedDib16() -// AtlSetClipboardDib16() -// AtlGetClipboardDib() namespace WTL @@ -127,7 +112,7 @@ public: ~CPenT() { - if(t_bManaged && m_hPen != NULL) + if(t_bManaged && (m_hPen != NULL)) DeleteObject(); } @@ -139,7 +124,7 @@ public: void Attach(HPEN hPen) { - if(t_bManaged && m_hPen != NULL && m_hPen != hPen) + if(t_bManaged && (m_hPen != NULL) && (m_hPen != hPen)) ::DeleteObject(m_hPen); m_hPen = hPen; } @@ -163,14 +148,12 @@ public: return m_hPen; } -#ifndef _WIN32_WCE HPEN CreatePen(int nPenStyle, int nWidth, const LOGBRUSH* pLogBrush, int nStyleCount = 0, const DWORD* lpStyle = NULL) { ATLASSERT(m_hPen == NULL); m_hPen = ::ExtCreatePen(nPenStyle, nWidth, pLogBrush, nStyleCount, lpStyle); return m_hPen; } -#endif // !_WIN32_WCE HPEN CreatePenIndirect(LPLOGPEN lpLogPen) { @@ -201,7 +184,6 @@ public: return (::GetObject(m_hPen, sizeof(LOGPEN), &LogPen) == sizeof(LOGPEN)); } -#ifndef _WIN32_WCE int GetExtLogPen(EXTLOGPEN* pLogPen, int nSize = sizeof(EXTLOGPEN)) const { ATLASSERT(m_hPen != NULL); @@ -214,7 +196,6 @@ public: int nRet = ::GetObject(m_hPen, nSize, &ExtLogPen); return ((nRet > 0) && (nRet <= nSize)); } -#endif // !_WIN32_WCE }; typedef CPenT CPenHandle; @@ -237,7 +218,7 @@ public: ~CBrushT() { - if(t_bManaged && m_hBrush != NULL) + if(t_bManaged && (m_hBrush != NULL)) DeleteObject(); } @@ -249,7 +230,7 @@ public: void Attach(HBRUSH hBrush) { - if(t_bManaged && m_hBrush != NULL && m_hBrush != hBrush) + if(t_bManaged && (m_hBrush != NULL) && (m_hBrush != hBrush)) ::DeleteObject(m_hBrush); m_hBrush = hBrush; } @@ -273,27 +254,19 @@ public: return m_hBrush; } -#ifndef _WIN32_WCE HBRUSH CreateHatchBrush(int nIndex, COLORREF crColor) { ATLASSERT(m_hBrush == NULL); m_hBrush = ::CreateHatchBrush(nIndex, crColor); return m_hBrush; } -#endif // !_WIN32_WCE -#if !defined(_WIN32_WCE) || (_ATL_VER >= 0x0800) HBRUSH CreateBrushIndirect(const LOGBRUSH* lpLogBrush) { ATLASSERT(m_hBrush == NULL); -#ifndef _WIN32_WCE m_hBrush = ::CreateBrushIndirect(lpLogBrush); -#else // CE specific - m_hBrush = ATL::CreateBrushIndirect(lpLogBrush); -#endif // _WIN32_WCE return m_hBrush; } -#endif // !defined(_WIN32_WCE) || (_ATL_VER >= 0x0800) HBRUSH CreatePatternBrush(HBITMAP hBitmap) { @@ -426,17 +399,12 @@ public: LONG GetDeciPointHeight(HDC hDC = NULL) const { HDC hDC1 = (hDC != NULL) ? hDC : ::GetDC(NULL); -#ifndef _WIN32_WCE POINT ptOrg = { 0, 0 }; ::DPtoLP(hDC1, &ptOrg, 1); POINT pt = { 0, 0 }; pt.y = abs(lfHeight) + ptOrg.y; - ::LPtoDP(hDC1, &pt,1); + ::LPtoDP(hDC1, &pt, 1); LONG nDeciPoint = ::MulDiv(pt.y, 720, ::GetDeviceCaps(hDC1, LOGPIXELSY)); // 72 points/inch, 10 decipoints/point -#else // CE specific - // DP and LP are always the same on CE - LONG nDeciPoint = ::MulDiv(abs(lfHeight), 720, ::GetDeviceCaps(hDC1, LOGPIXELSY)); // 72 points/inch, 10 decipoints/point -#endif // _WIN32_WCE if(hDC == NULL) ::ReleaseDC(NULL, hDC1); @@ -446,22 +414,16 @@ public: void SetHeightFromDeciPoint(LONG nDeciPtHeight, HDC hDC = NULL) { HDC hDC1 = (hDC != NULL) ? hDC : ::GetDC(NULL); -#ifndef _WIN32_WCE POINT pt = { 0, 0 }; pt.y = ::MulDiv(::GetDeviceCaps(hDC1, LOGPIXELSY), nDeciPtHeight, 720); // 72 points/inch, 10 decipoints/point ::DPtoLP(hDC1, &pt, 1); POINT ptOrg = { 0, 0 }; ::DPtoLP(hDC1, &ptOrg, 1); lfHeight = -abs(pt.y - ptOrg.y); -#else // CE specific - // DP and LP are always the same on CE - lfHeight = -abs(::MulDiv(::GetDeviceCaps(hDC1, LOGPIXELSY), nDeciPtHeight, 720)); // 72 points/inch, 10 decipoints/point -#endif // _WIN32_WCE if(hDC == NULL) ::ReleaseDC(NULL, hDC1); } -#ifndef _WIN32_WCE void SetCaptionFont() { NONCLIENTMETRICS ncm = { RunTimeHelper::SizeOf_NONCLIENTMETRICS() }; @@ -489,7 +451,6 @@ public: ATLVERIFY(::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(ncm), &ncm, 0)); Copy(&ncm.lfMessageFont); } -#endif // !_WIN32_WCE void Copy(const LOGFONT* pLogFont) { @@ -518,20 +479,20 @@ public: bool operator ==(const LOGFONT& logfont) const { - return(logfont.lfHeight == lfHeight && - logfont.lfWidth == lfWidth && - logfont.lfEscapement == lfEscapement && - logfont.lfOrientation == lfOrientation && - logfont.lfWeight == lfWeight && - logfont.lfItalic == lfItalic && - logfont.lfUnderline == lfUnderline && - logfont.lfStrikeOut == lfStrikeOut && - logfont.lfCharSet == lfCharSet && - logfont.lfOutPrecision == lfOutPrecision && - logfont.lfClipPrecision == lfClipPrecision && - logfont.lfQuality == lfQuality && - logfont.lfPitchAndFamily == lfPitchAndFamily && - lstrcmp(logfont.lfFaceName, lfFaceName) == 0); + return((logfont.lfHeight == lfHeight) && + (logfont.lfWidth == lfWidth) && + (logfont.lfEscapement == lfEscapement) && + (logfont.lfOrientation == lfOrientation) && + (logfont.lfWeight == lfWeight) && + (logfont.lfItalic == lfItalic) && + (logfont.lfUnderline == lfUnderline) && + (logfont.lfStrikeOut == lfStrikeOut) && + (logfont.lfCharSet == lfCharSet) && + (logfont.lfOutPrecision == lfOutPrecision) && + (logfont.lfClipPrecision == lfClipPrecision) && + (logfont.lfQuality == lfQuality) && + (logfont.lfPitchAndFamily == lfPitchAndFamily) && + (lstrcmp(logfont.lfFaceName, lfFaceName) == 0)); } }; @@ -549,7 +510,7 @@ public: ~CFontT() { - if(t_bManaged && m_hFont != NULL) + if(t_bManaged && (m_hFont != NULL)) DeleteObject(); } @@ -561,7 +522,7 @@ public: void Attach(HFONT hFont) { - if(t_bManaged && m_hFont != NULL && m_hFont != hFont) + if(t_bManaged && (m_hFont != NULL) && (m_hFont != hFont)) ::DeleteObject(m_hFont); m_hFont = hFont; } @@ -585,16 +546,13 @@ public: return m_hFont; } -#if !defined(_WIN32_WCE) && (_WIN32_WINNT >= 0x0500) HFONT CreateFontIndirectEx(CONST ENUMLOGFONTEXDV* penumlfex) { ATLASSERT(m_hFont == NULL); m_hFont = ::CreateFontIndirectEx(penumlfex); return m_hFont; } -#endif // !defined(_WIN32_WCE) && (_WIN32_WINNT >= 0x0500) -#if !defined(_WIN32_WCE) || (_ATL_VER >= 0x0800) HFONT CreateFont(int nHeight, int nWidth, int nEscapement, int nOrientation, int nWeight, BYTE bItalic, BYTE bUnderline, BYTE cStrikeOut, BYTE nCharSet, BYTE nOutPrecision, @@ -602,27 +560,19 @@ public: LPCTSTR lpszFacename) { ATLASSERT(m_hFont == NULL); -#ifndef _WIN32_WCE m_hFont = ::CreateFont(nHeight, nWidth, nEscapement, nOrientation, nWeight, bItalic, bUnderline, cStrikeOut, nCharSet, nOutPrecision, nClipPrecision, nQuality, nPitchAndFamily, lpszFacename); -#else // CE specific - m_hFont = ATL::CreateFont(nHeight, nWidth, nEscapement, - nOrientation, nWeight, bItalic, bUnderline, cStrikeOut, - nCharSet, nOutPrecision, nClipPrecision, nQuality, - nPitchAndFamily, lpszFacename); -#endif // _WIN32_WCE return m_hFont; } -#endif // !defined(_WIN32_WCE) || (_ATL_VER >= 0x0800) HFONT CreatePointFont(int nPointSize, LPCTSTR lpszFaceName, HDC hDC = NULL, bool bBold = false, bool bItalic = false) { - LOGFONT logFont = { 0 }; + LOGFONT logFont = {}; logFont.lfCharSet = DEFAULT_CHARSET; logFont.lfHeight = nPointSize; - SecureHelper::strncpy_x(logFont.lfFaceName, _countof(logFont.lfFaceName), lpszFaceName, _TRUNCATE); + ATL::Checked::tcsncpy_s(logFont.lfFaceName, _countof(logFont.lfFaceName), lpszFaceName, _TRUNCATE); if(bBold) logFont.lfWeight = FW_BOLD; @@ -638,17 +588,12 @@ public: // convert nPointSize to logical units based on hDC LOGFONT logFont = *lpLogFont; -#ifndef _WIN32_WCE POINT pt = { 0, 0 }; pt.y = ::MulDiv(::GetDeviceCaps(hDC1, LOGPIXELSY), logFont.lfHeight, 720); // 72 points/inch, 10 decipoints/point ::DPtoLP(hDC1, &pt, 1); POINT ptOrg = { 0, 0 }; ::DPtoLP(hDC1, &ptOrg, 1); logFont.lfHeight = -abs(pt.y - ptOrg.y); -#else // CE specific - // DP and LP are always the same on CE - logFont.lfHeight = -abs(::MulDiv(::GetDeviceCaps(hDC1, LOGPIXELSY), logFont.lfHeight, 720)); // 72 points/inch, 10 decipoints/point -#endif // _WIN32_WCE if(hDC == NULL) ::ReleaseDC(NULL, hDC1); @@ -699,7 +644,7 @@ public: ~CBitmapT() { - if(t_bManaged && m_hBitmap != NULL) + if(t_bManaged && (m_hBitmap != NULL)) DeleteObject(); } @@ -711,7 +656,7 @@ public: void Attach(HBITMAP hBitmap) { - if(t_bManaged && m_hBitmap != NULL&& m_hBitmap != hBitmap) + if(t_bManaged && (m_hBitmap != NULL) && (m_hBitmap != hBitmap)) ::DeleteObject(m_hBitmap); m_hBitmap = hBitmap; } @@ -742,14 +687,12 @@ public: return m_hBitmap; } -#ifndef _WIN32_WCE HBITMAP LoadMappedBitmap(UINT nIDBitmap, UINT nFlags = 0, LPCOLORMAP lpColorMap = NULL, int nMapSize = 0) { ATLASSERT(m_hBitmap == NULL); m_hBitmap = ::CreateMappedBitmap(ModuleHelper::GetResourceInstance(), nIDBitmap, (WORD)nFlags, lpColorMap, nMapSize); return m_hBitmap; } -#endif // !_WIN32_WCE HBITMAP CreateBitmap(int nWidth, int nHeight, UINT nPlanes, UINT nBitsPerPixel, const void* lpBits) { @@ -758,14 +701,12 @@ public: return m_hBitmap; } -#ifndef _WIN32_WCE HBITMAP CreateBitmapIndirect(LPBITMAP lpBitmap) { ATLASSERT(m_hBitmap == NULL); m_hBitmap = ::CreateBitmapIndirect(lpBitmap); return m_hBitmap; } -#endif // !_WIN32_WCE HBITMAP CreateCompatibleBitmap(HDC hDC, int nWidth, int nHeight) { @@ -774,14 +715,12 @@ public: return m_hBitmap; } -#ifndef _WIN32_WCE HBITMAP CreateDiscardableBitmap(HDC hDC, int nWidth, int nHeight) { ATLASSERT(m_hBitmap == NULL); m_hBitmap = ::CreateDiscardableBitmap(hDC, nWidth, nHeight); return m_hBitmap; } -#endif // !_WIN32_WCE BOOL DeleteObject() { @@ -808,7 +747,7 @@ public: bool GetSize(SIZE& size) const { ATLASSERT(m_hBitmap != NULL); - BITMAP bm = { 0 }; + BITMAP bm = {}; if(!GetBitmap(&bm)) return false; size.cx = bm.bmWidth; @@ -816,23 +755,18 @@ public: return true; } -#ifndef _WIN32_WCE DWORD GetBitmapBits(DWORD dwCount, LPVOID lpBits) const { ATLASSERT(m_hBitmap != NULL); return ::GetBitmapBits(m_hBitmap, dwCount, lpBits); } -#endif // !_WIN32_WCE -#if !defined(_WIN32_WCE) || (_WIN32_WCE >= 410) DWORD SetBitmapBits(DWORD dwCount, const void* lpBits) { ATLASSERT(m_hBitmap != NULL); return ::SetBitmapBits(m_hBitmap, dwCount, lpBits); } -#endif // !defined(_WIN32_WCE) || (_WIN32_WCE >= 410) -#ifndef _WIN32_WCE BOOL GetBitmapDimension(LPSIZE lpSize) const { ATLASSERT(m_hBitmap != NULL); @@ -852,7 +786,6 @@ public: m_hBitmap = ::CreateDIBitmap(hDC, lpbmih, dwInit, lpbInit, lpbmi, uColorUse); return m_hBitmap; } -#endif // !_WIN32_WCE HBITMAP CreateDIBSection(HDC hDC, CONST BITMAPINFO* lpbmi, UINT uColorUse, VOID** ppvBits, HANDLE hSection, DWORD dwOffset) { @@ -861,7 +794,6 @@ public: return m_hBitmap; } -#ifndef _WIN32_WCE int GetDIBits(HDC hDC, UINT uStartScan, UINT cScanLines, LPVOID lpvBits, LPBITMAPINFO lpbmi, UINT uColorUse) const { ATLASSERT(m_hBitmap != NULL); @@ -873,7 +805,6 @@ public: ATLASSERT(m_hBitmap != NULL); return ::SetDIBits(hDC, m_hBitmap, uStartScan, cScanLines, lpvBits, lpbmi, uColorUse); } -#endif // !_WIN32_WCE }; typedef CBitmapT CBitmapHandle; @@ -896,7 +827,7 @@ public: ~CPaletteT() { - if(t_bManaged && m_hPalette != NULL) + if(t_bManaged && (m_hPalette != NULL)) DeleteObject(); } @@ -908,7 +839,7 @@ public: void Attach(HPALETTE hPalette) { - if(t_bManaged && m_hPalette != NULL && m_hPalette != hPalette) + if(t_bManaged && (m_hPalette != NULL) && (m_hPalette != hPalette)) ::DeleteObject(m_hPalette); m_hPalette = hPalette; } @@ -932,7 +863,6 @@ public: return m_hPalette; } -#ifndef _WIN32_WCE HPALETTE CreateHalftonePalette(HDC hDC) { ATLASSERT(m_hPalette == NULL); @@ -940,7 +870,6 @@ public: m_hPalette = ::CreateHalftonePalette(hDC); return m_hPalette; } -#endif // !_WIN32_WCE BOOL DeleteObject() { @@ -973,7 +902,6 @@ public: } // Operations -#ifndef _WIN32_WCE void AnimatePalette(UINT nStartIndex, UINT nNumEntries, LPPALETTEENTRY lpPaletteColors) { ATLASSERT(m_hPalette != NULL); @@ -985,7 +913,6 @@ public: ATLASSERT(m_hPalette != NULL); return ::ResizePalette(m_hPalette, nNumEntries); } -#endif // !_WIN32_WCE UINT GetNearestPaletteIndex(COLORREF crColor) const { @@ -1014,7 +941,7 @@ public: ~CRgnT() { - if(t_bManaged && m_hRgn != NULL) + if(t_bManaged && (m_hRgn != NULL)) DeleteObject(); } @@ -1026,7 +953,7 @@ public: void Attach(HRGN hRgn) { - if(t_bManaged && m_hRgn != NULL && m_hRgn != hRgn) + if(t_bManaged && (m_hRgn != NULL) && (m_hRgn != hRgn)) ::DeleteObject(m_hRgn); m_hRgn = hRgn; } @@ -1057,7 +984,6 @@ public: return m_hRgn; } -#ifndef _WIN32_WCE HRGN CreateEllipticRgn(int x1, int y1, int x2, int y2) { ATLASSERT(m_hRgn == NULL); @@ -1072,14 +998,14 @@ public: return m_hRgn; } - HRGN CreatePolygonRgn(LPPOINT lpPoints, int nCount, int nMode) + HRGN CreatePolygonRgn(const POINT* lpPoints, int nCount, int nMode) { ATLASSERT(m_hRgn == NULL); m_hRgn = ::CreatePolygonRgn(lpPoints, nCount, nMode); return m_hRgn; } - HRGN CreatePolyPolygonRgn(LPPOINT lpPoints, LPINT lpPolyCounts, int nCount, int nPolyFillMode) + HRGN CreatePolyPolygonRgn(const POINT* lpPoints, const INT* lpPolyCounts, int nCount, int nPolyFillMode) { ATLASSERT(m_hRgn == NULL); m_hRgn = ::CreatePolyPolygonRgn(lpPoints, lpPolyCounts, nCount, nPolyFillMode); @@ -1107,7 +1033,6 @@ public: m_hRgn = ::ExtCreateRegion(lpXForm, nCount, pRgnData); return m_hRgn; } -#endif // !_WIN32_WCE BOOL DeleteObject() { @@ -1205,6 +1130,11 @@ typedef CRgnT CRgn; /////////////////////////////////////////////////////////////////////////////// // CDC - The device context class +template +class CDCT; +typedef CDCT CDCHandle; +typedef CDCT CDC; + template class CDCT { @@ -1219,7 +1149,7 @@ public: ~CDCT() { - if(t_bManaged && m_hDC != NULL) + if(t_bManaged && (m_hDC != NULL)) ::DeleteDC(Detach()); } @@ -1231,7 +1161,7 @@ public: void Attach(HDC hDC) { - if(t_bManaged && m_hDC != NULL && m_hDC != hDC) + if(t_bManaged && (m_hDC != NULL) && (m_hDC != hDC)) ::DeleteDC(m_hDC); m_hDC = hDC; } @@ -1248,13 +1178,11 @@ public: bool IsNull() const { return (m_hDC == NULL); } // Operations -#ifndef _WIN32_WCE HWND WindowFromDC() const { ATLASSERT(m_hDC != NULL); return ::WindowFromDC(m_hDC); } -#endif // !_WIN32_WCE CPenHandle GetCurrentPen() const { @@ -1329,7 +1257,6 @@ public: return ::GetDeviceCaps(m_hDC, nIndex); } -#ifndef _WIN32_WCE UINT SetBoundsRect(LPCRECT lpRectBounds, UINT flags) { ATLASSERT(m_hDC != NULL); @@ -1354,7 +1281,6 @@ public: ATLASSERT(m_hDC != NULL); return ::GetBrushOrgEx(m_hDC, lpPoint); } -#endif // !_WIN32_WCE BOOL SetBrushOrg(int x, int y, LPPOINT lpPoint = NULL) { @@ -1368,7 +1294,6 @@ public: return ::SetBrushOrgEx(m_hDC, point.x, point.y, lpPointRet); } -#ifndef _WIN32_WCE int EnumObjects(int nObjectType, int (CALLBACK* lpfn)(LPVOID, LPARAM), LPARAM lpData) { ATLASSERT(m_hDC != NULL); @@ -1378,45 +1303,40 @@ public: return ::EnumObjects(m_hDC, nObjectType, (GOBJENUMPROC)lpfn, (LPVOID)lpData); #endif } -#endif // !_WIN32_WCE // Type-safe selection helpers HPEN SelectPen(HPEN hPen) { ATLASSERT(m_hDC != NULL); -#ifndef _WIN32_WCE - ATLASSERT(hPen == NULL || ::GetObjectType(hPen) == OBJ_PEN || ::GetObjectType(hPen) == OBJ_EXTPEN); -#else // CE specific - ATLASSERT(hPen == NULL || ::GetObjectType(hPen) == OBJ_PEN); -#endif // _WIN32_WCE + ATLASSERT((hPen == NULL) || (::GetObjectType(hPen) == OBJ_PEN) || (::GetObjectType(hPen) == OBJ_EXTPEN)); return (HPEN)::SelectObject(m_hDC, hPen); } HBRUSH SelectBrush(HBRUSH hBrush) { ATLASSERT(m_hDC != NULL); - ATLASSERT(hBrush == NULL || ::GetObjectType(hBrush) == OBJ_BRUSH); + ATLASSERT((hBrush == NULL) || (::GetObjectType(hBrush) == OBJ_BRUSH)); return (HBRUSH)::SelectObject(m_hDC, hBrush); } HFONT SelectFont(HFONT hFont) { ATLASSERT(m_hDC != NULL); - ATLASSERT(hFont == NULL || ::GetObjectType(hFont) == OBJ_FONT); + ATLASSERT((hFont == NULL) || (::GetObjectType(hFont) == OBJ_FONT)); return (HFONT)::SelectObject(m_hDC, hFont); } HBITMAP SelectBitmap(HBITMAP hBitmap) { ATLASSERT(m_hDC != NULL); - ATLASSERT(hBitmap == NULL || ::GetObjectType(hBitmap) == OBJ_BITMAP); + ATLASSERT((hBitmap == NULL) || (::GetObjectType(hBitmap) == OBJ_BITMAP)); return (HBITMAP)::SelectObject(m_hDC, hBitmap); } int SelectRgn(HRGN hRgn) // special return for regions { ATLASSERT(m_hDC != NULL); - ATLASSERT(hRgn == NULL || ::GetObjectType(hRgn) == OBJ_REGION); + ATLASSERT((hRgn == NULL) || (::GetObjectType(hRgn) == OBJ_REGION)); return PtrToInt(::SelectObject(m_hDC, hRgn)); } @@ -1424,31 +1344,19 @@ public: HPEN SelectStockPen(int nPen) { ATLASSERT(m_hDC != NULL); -#if (_WIN32_WINNT >= 0x0500) - ATLASSERT(nPen == WHITE_PEN || nPen == BLACK_PEN || nPen == NULL_PEN || nPen == DC_PEN); -#else - ATLASSERT(nPen == WHITE_PEN || nPen == BLACK_PEN || nPen == NULL_PEN); -#endif // !(_WIN32_WINNT >= 0x0500) + ATLASSERT((nPen == WHITE_PEN) || (nPen == BLACK_PEN) || (nPen == NULL_PEN) || (nPen == DC_PEN)); return SelectPen((HPEN)::GetStockObject(nPen)); } HBRUSH SelectStockBrush(int nBrush) { -#if (_WIN32_WINNT >= 0x0500) - ATLASSERT((nBrush >= WHITE_BRUSH && nBrush <= HOLLOW_BRUSH) || nBrush == DC_BRUSH); -#else - ATLASSERT(nBrush >= WHITE_BRUSH && nBrush <= HOLLOW_BRUSH); -#endif // !(_WIN32_WINNT >= 0x0500) + ATLASSERT(((nBrush >= WHITE_BRUSH) && (nBrush <= HOLLOW_BRUSH)) || (nBrush == DC_BRUSH)); return SelectBrush((HBRUSH)::GetStockObject(nBrush)); } HFONT SelectStockFont(int nFont) { -#ifndef _WIN32_WCE - ATLASSERT((nFont >= OEM_FIXED_FONT && nFont <= SYSTEM_FIXED_FONT) || nFont == DEFAULT_GUI_FONT); -#else // CE specific - ATLASSERT(nFont == SYSTEM_FONT); -#endif // _WIN32_WCE + ATLASSERT(((nFont >= OEM_FIXED_FONT) && (nFont <= SYSTEM_FIXED_FONT)) || (nFont == DEFAULT_GUI_FONT)); return SelectFont((HFONT)::GetStockObject(nFont)); } @@ -1478,13 +1386,11 @@ public: return ::RealizePalette(m_hDC); } -#ifndef _WIN32_WCE void UpdateColors() { ATLASSERT(m_hDC != NULL); ::UpdateColors(m_hDC); } -#endif // !_WIN32_WCE // Drawing-Attribute Functions COLORREF GetBkColor() const @@ -1499,7 +1405,6 @@ public: return ::GetBkMode(m_hDC); } -#ifndef _WIN32_WCE int GetPolyFillMode() const { ATLASSERT(m_hDC != NULL); @@ -1517,7 +1422,6 @@ public: ATLASSERT(m_hDC != NULL); return ::GetStretchBltMode(m_hDC); } -#endif // !_WIN32_WCE COLORREF GetTextColor() const { @@ -1537,13 +1441,11 @@ public: return ::SetBkMode(m_hDC, nBkMode); } -#ifndef _WIN32_WCE int SetPolyFillMode(int nPolyFillMode) { ATLASSERT(m_hDC != NULL); return ::SetPolyFillMode(m_hDC, nPolyFillMode); } -#endif // !_WIN32_WCE int SetROP2(int nDrawMode) { @@ -1551,13 +1453,11 @@ public: return ::SetROP2(m_hDC, nDrawMode); } -#ifndef _WIN32_WCE int SetStretchBltMode(int nStretchMode) { ATLASSERT(m_hDC != NULL); return ::SetStretchBltMode(m_hDC, nStretchMode); } -#endif // !_WIN32_WCE COLORREF SetTextColor(COLORREF crColor) { @@ -1565,7 +1465,6 @@ public: return ::SetTextColor(m_hDC, crColor); } -#ifndef _WIN32_WCE BOOL GetColorAdjustment(LPCOLORADJUSTMENT lpColorAdjust) const { ATLASSERT(m_hDC != NULL); @@ -1596,7 +1495,6 @@ public: ATLASSERT(m_hDC != NULL); return ::SetMapMode(m_hDC, nMapMode); } -#endif // !_WIN32_WCE // Viewport Origin BOOL SetViewportOrg(int x, int y, LPPOINT lpPoint = NULL) @@ -1611,7 +1509,6 @@ public: return SetViewportOrg(point.x, point.y, lpPointRet); } -#ifndef _WIN32_WCE BOOL OffsetViewportOrg(int nWidth, int nHeight, LPPOINT lpPoint = NULL) { ATLASSERT(m_hDC != NULL); @@ -1642,10 +1539,8 @@ public: ATLASSERT(m_hDC != NULL); return ::ScaleViewportExtEx(m_hDC, xNum, xDenom, yNum, yDenom, lpSize); } -#endif // !_WIN32_WCE // Window Origin -#ifndef _WIN32_WCE BOOL GetWindowOrg(LPPOINT lpPoint) const { ATLASSERT(m_hDC != NULL); @@ -1710,10 +1605,10 @@ public: BOOL DPtoLP(LPSIZE lpSize) const { - SIZE sizeWinExt = { 0, 0 }; + SIZE sizeWinExt = {}; if(!GetWindowExt(&sizeWinExt)) return FALSE; - SIZE sizeVpExt = { 0, 0 }; + SIZE sizeVpExt = {}; if(!GetViewportExt(&sizeVpExt)) return FALSE; lpSize->cx = ::MulDiv(lpSize->cx, abs(sizeWinExt.cx), abs(sizeVpExt.cx)); @@ -1735,10 +1630,10 @@ public: BOOL LPtoDP(LPSIZE lpSize) const { - SIZE sizeWinExt = { 0, 0 }; + SIZE sizeWinExt = {}; if(!GetWindowExt(&sizeWinExt)) return FALSE; - SIZE sizeVpExt = { 0, 0 }; + SIZE sizeVpExt = {}; if(!GetViewportExt(&sizeVpExt)) return FALSE; lpSize->cx = ::MulDiv(lpSize->cx, abs(sizeVpExt.cx), abs(sizeWinExt.cx)); @@ -1749,62 +1644,61 @@ public: // Special Coordinate Functions (useful for dealing with metafiles and OLE) #define HIMETRIC_INCH 2540 // HIMETRIC units per inch - void DPtoHIMETRIC(LPSIZE lpSize) const + void DPtoHIMETRIC(LPSIZE lpSize) { ATLASSERT(m_hDC != NULL); - int nMapMode; - if((nMapMode = GetMapMode()) < MM_ISOTROPIC && nMapMode != MM_TEXT) + int nMapMode = GetMapMode(); + if((nMapMode < MM_ISOTROPIC) && (nMapMode != MM_TEXT)) { // when using a constrained map mode, map against physical inch - ((CDCHandle*)this)->SetMapMode(MM_HIMETRIC); + SetMapMode(MM_HIMETRIC); DPtoLP(lpSize); - ((CDCHandle*)this)->SetMapMode(nMapMode); + SetMapMode(nMapMode); } else { // map against logical inch for non-constrained mapping modes int cxPerInch = GetDeviceCaps(LOGPIXELSX); int cyPerInch = GetDeviceCaps(LOGPIXELSY); - ATLASSERT(cxPerInch != 0 && cyPerInch != 0); + ATLASSERT((cxPerInch != 0) && (cyPerInch != 0)); lpSize->cx = ::MulDiv(lpSize->cx, HIMETRIC_INCH, cxPerInch); lpSize->cy = ::MulDiv(lpSize->cy, HIMETRIC_INCH, cyPerInch); } } - void HIMETRICtoDP(LPSIZE lpSize) const + void HIMETRICtoDP(LPSIZE lpSize) { ATLASSERT(m_hDC != NULL); - int nMapMode; - if((nMapMode = GetMapMode()) < MM_ISOTROPIC && nMapMode != MM_TEXT) + int nMapMode = GetMapMode(); + if((nMapMode < MM_ISOTROPIC) && (nMapMode != MM_TEXT)) { // when using a constrained map mode, map against physical inch - ((CDCHandle*)this)->SetMapMode(MM_HIMETRIC); + SetMapMode(MM_HIMETRIC); LPtoDP(lpSize); - ((CDCHandle*)this)->SetMapMode(nMapMode); + SetMapMode(nMapMode); } else { // map against logical inch for non-constrained mapping modes int cxPerInch = GetDeviceCaps(LOGPIXELSX); int cyPerInch = GetDeviceCaps(LOGPIXELSY); - ATLASSERT(cxPerInch != 0 && cyPerInch != 0); + ATLASSERT((cxPerInch != 0) && (cyPerInch != 0)); lpSize->cx = ::MulDiv(lpSize->cx, cxPerInch, HIMETRIC_INCH); lpSize->cy = ::MulDiv(lpSize->cy, cyPerInch, HIMETRIC_INCH); } } - void LPtoHIMETRIC(LPSIZE lpSize) const + void LPtoHIMETRIC(LPSIZE lpSize) { LPtoDP(lpSize); DPtoHIMETRIC(lpSize); } - void HIMETRICtoLP(LPSIZE lpSize) const + void HIMETRICtoLP(LPSIZE lpSize) { HIMETRICtoDP(lpSize); DPtoLP(lpSize); } -#endif // !_WIN32_WCE // Region Functions BOOL FillRgn(HRGN hRgn, HBRUSH hBrush) @@ -1813,7 +1707,6 @@ public: return ::FillRgn(m_hDC, hRgn, hBrush); } -#ifndef _WIN32_WCE BOOL FrameRgn(HRGN hRgn, HBRUSH hBrush, int nWidth, int nHeight) { ATLASSERT(m_hDC != NULL); @@ -1831,7 +1724,6 @@ public: ATLASSERT(m_hDC != NULL); return ::PaintRgn(m_hDC, hRgn); } -#endif // !_WIN32_WCE // Clipping Functions int GetClipBox(LPRECT lpRect) const @@ -1853,7 +1745,6 @@ public: return nRet; } -#ifndef _WIN32_WCE BOOL PtVisible(int x, int y) const { ATLASSERT(m_hDC != NULL); @@ -1865,7 +1756,6 @@ public: ATLASSERT(m_hDC != NULL); return ::PtVisible(m_hDC, point.x, point.y); } -#endif // !_WIN32_WCE BOOL RectVisible(LPCRECT lpRect) const { @@ -1891,13 +1781,11 @@ public: return ::ExcludeClipRect(m_hDC, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom); } -#ifndef _WIN32_WCE int ExcludeUpdateRgn(HWND hWnd) { ATLASSERT(m_hDC != NULL); return ::ExcludeUpdateRgn(m_hDC, hWnd); } -#endif // !_WIN32_WCE int IntersectClipRect(int x1, int y1, int x2, int y2) { @@ -1911,7 +1799,6 @@ public: return ::IntersectClipRect(m_hDC, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom); } -#ifndef _WIN32_WCE int OffsetClipRgn(int x, int y) { ATLASSERT(m_hDC != NULL); @@ -1929,10 +1816,8 @@ public: ATLASSERT(m_hDC != NULL); return ::ExtSelectClipRgn(m_hDC, hRgn, nMode); } -#endif // !_WIN32_WCE // Line-Output Functions -#if !defined(_WIN32_WCE) || (_WIN32_WCE >= 400) BOOL GetCurrentPosition(LPPOINT lpPoint) const { ATLASSERT(m_hDC != NULL); @@ -1962,9 +1847,7 @@ public: ATLASSERT(m_hDC != NULL); return LineTo(point.x, point.y); } -#endif // !defined(_WIN32_WCE) || (_WIN32_WCE >= 400) -#ifndef _WIN32_WCE BOOL Arc(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) { ATLASSERT(m_hDC != NULL); @@ -1978,7 +1861,6 @@ public: lpRect->right, lpRect->bottom, ptStart.x, ptStart.y, ptEnd.x, ptEnd.y); } -#endif // !_WIN32_WCE BOOL Polyline(const POINT* lpPoints, int nCount) { @@ -1986,7 +1868,6 @@ public: return ::Polyline(m_hDC, lpPoints, nCount); } -#ifndef _WIN32_WCE BOOL AngleArc(int x, int y, int nRadius, float fStartAngle, float fSweepAngle) { ATLASSERT(m_hDC != NULL); @@ -2048,7 +1929,6 @@ public: ATLASSERT(m_hDC != NULL); return ::PolyBezierTo(m_hDC, lpPoints, nCount); } -#endif // !_WIN32_WCE // Simple Drawing Functions BOOL FillRect(LPCRECT lpRect, HBRUSH hBrush) @@ -2060,47 +1940,31 @@ public: BOOL FillRect(LPCRECT lpRect, int nColorIndex) { ATLASSERT(m_hDC != NULL); -#ifndef _WIN32_WCE return ::FillRect(m_hDC, lpRect, (HBRUSH)LongToPtr(nColorIndex + 1)); -#else // CE specific - return ::FillRect(m_hDC, lpRect, ::GetSysColorBrush(nColorIndex)); -#endif // _WIN32_WCE } -#ifndef _WIN32_WCE BOOL FrameRect(LPCRECT lpRect, HBRUSH hBrush) { ATLASSERT(m_hDC != NULL); return ::FrameRect(m_hDC, lpRect, hBrush); } -#endif // !_WIN32_WCE -#if !defined(_WIN32_WCE) || (_WIN32_WCE >= 420) BOOL InvertRect(LPCRECT lpRect) { ATLASSERT(m_hDC != NULL); return ::InvertRect(m_hDC, lpRect); } -#endif // !defined(_WIN32_WCE) || (_WIN32_WCE >= 420) BOOL DrawIcon(int x, int y, HICON hIcon) { ATLASSERT(m_hDC != NULL); -#ifndef _WIN32_WCE return ::DrawIcon(m_hDC, x, y, hIcon); -#else // CE specific - return ::DrawIconEx(m_hDC, x, y, hIcon, 0, 0, 0, NULL, DI_NORMAL); -#endif // _WIN32_WCE } BOOL DrawIcon(POINT point, HICON hIcon) { ATLASSERT(m_hDC != NULL); -#ifndef _WIN32_WCE return ::DrawIcon(m_hDC, point.x, point.y, hIcon); -#else // CE specific - return ::DrawIconEx(m_hDC, point.x, point.y, hIcon, 0, 0, 0, NULL, DI_NORMAL); -#endif // _WIN32_WCE } BOOL DrawIconEx(int x, int y, HICON hIcon, int cxWidth, int cyWidth, UINT uStepIfAniCur = 0, HBRUSH hbrFlickerFreeDraw = NULL, UINT uFlags = DI_NORMAL) @@ -2115,7 +1979,6 @@ public: return ::DrawIconEx(m_hDC, point.x, point.y, hIcon, size.cx, size.cy, uStepIfAniCur, hbrFlickerFreeDraw, uFlags); } -#ifndef _WIN32_WCE BOOL DrawState(POINT pt, SIZE size, HBITMAP hBitmap, UINT nFlags, HBRUSH hBrush = NULL) { ATLASSERT(m_hDC != NULL); @@ -2139,10 +2002,8 @@ public: ATLASSERT(m_hDC != NULL); return ::DrawState(m_hDC, hBrush, lpDrawProc, lData, 0, pt.x, pt.y, size.cx, size.cy, nFlags | DST_COMPLEX); } -#endif // !_WIN32_WCE // Ellipse and Polygon Functions -#ifndef _WIN32_WCE BOOL Chord(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) { ATLASSERT(m_hDC != NULL); @@ -2154,7 +2015,6 @@ public: ATLASSERT(m_hDC != NULL); return ::Chord(m_hDC, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom, ptStart.x, ptStart.y, ptEnd.x, ptEnd.y); } -#endif // !_WIN32_WCE void DrawFocusRect(LPCRECT lpRect) { @@ -2174,7 +2034,6 @@ public: return ::Ellipse(m_hDC, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom); } -#ifndef _WIN32_WCE BOOL Pie(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) { ATLASSERT(m_hDC != NULL); @@ -2186,7 +2045,6 @@ public: ATLASSERT(m_hDC != NULL); return ::Pie(m_hDC, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom, ptStart.x, ptStart.y, ptEnd.x, ptEnd.y); } -#endif // !_WIN32_WCE BOOL Polygon(const POINT* lpPoints, int nCount) { @@ -2194,13 +2052,11 @@ public: return ::Polygon(m_hDC, lpPoints, nCount); } -#ifndef _WIN32_WCE BOOL PolyPolygon(const POINT* lpPoints, const INT* lpPolyCounts, int nCount) { ATLASSERT(m_hDC != NULL); return ::PolyPolygon(m_hDC, lpPoints, lpPolyCounts, nCount); } -#endif // !_WIN32_WCE BOOL Rectangle(int x1, int y1, int x2, int y2) { @@ -2270,7 +2126,6 @@ public: return ::SetPixel(m_hDC, point.x, point.y, crColor); } -#ifndef _WIN32_WCE BOOL FloodFill(int x, int y, COLORREF crColor) { ATLASSERT(m_hDC != NULL); @@ -2282,7 +2137,6 @@ public: ATLASSERT(m_hDC != NULL); return ::ExtFloodFill(m_hDC, x, y, crColor, nFillType); } -#endif // !_WIN32_WCE BOOL MaskBlt(int x, int y, int nWidth, int nHeight, HDC hSrcDC, int xSrc, int ySrc, HBITMAP hMaskBitmap, int xMask, int yMask, DWORD dwRop) { @@ -2290,7 +2144,6 @@ public: return ::MaskBlt(m_hDC, x, y, nWidth, nHeight, hSrcDC, xSrc, ySrc, hMaskBitmap, xMask, yMask, dwRop); } -#ifndef _WIN32_WCE BOOL PlgBlt(LPPOINT lpPoint, HDC hSrcDC, int xSrc, int ySrc, int nWidth, int nHeight, HBITMAP hMaskBitmap, int xMask, int yMask) { ATLASSERT(m_hDC != NULL); @@ -2308,24 +2161,13 @@ public: ATLASSERT(m_hDC != NULL); return ::SetPixelV(m_hDC, point.x, point.y, crColor); } -#endif // !_WIN32_WCE -#if !defined(_ATL_NO_MSIMG) || defined(_WIN32_WCE) -#ifndef _WIN32_WCE BOOL TransparentBlt(int x, int y, int nWidth, int nHeight, HDC hSrcDC, int xSrc, int ySrc, int nSrcWidth, int nSrcHeight, UINT crTransparent) { ATLASSERT(m_hDC != NULL); return ::TransparentBlt(m_hDC, x, y, nWidth, nHeight, hSrcDC, xSrc, ySrc, nSrcWidth, nSrcHeight, crTransparent); } -#else // CE specific - BOOL TransparentImage(int x, int y, int nWidth, int nHeight, HDC hSrcDC, int xSrc, int ySrc, int nSrcWidth, int nSrcHeight, UINT crTransparent) - { - ATLASSERT(m_hDC != NULL); - return ::TransparentImage(m_hDC, x, y, nWidth, nHeight, hSrcDC, xSrc, ySrc, nSrcWidth, nSrcHeight, crTransparent); - } -#endif // _WIN32_WCE -#if (!defined(_WIN32_WCE) || (_WIN32_WCE >= 420)) BOOL GradientFill(const PTRIVERTEX pVertices, DWORD nVertices, void* pMeshElements, DWORD nMeshElements, DWORD dwMode) { ATLASSERT(m_hDC != NULL); @@ -2356,16 +2198,12 @@ public: return ::GradientFill(m_hDC, arrTvx, 2, &gr, 1, bHorizontal ? GRADIENT_FILL_RECT_H : GRADIENT_FILL_RECT_V); } -#endif // !defined(_WIN32_WCE) || (_WIN32_WCE >= 420) -#if !defined(_WIN32_WCE) || (_WIN32_WCE > 0x500) BOOL AlphaBlend(int x, int y, int nWidth, int nHeight, HDC hSrcDC, int xSrc, int ySrc, int nSrcWidth, int nSrcHeight, BLENDFUNCTION bf) { ATLASSERT(m_hDC != NULL); return ::AlphaBlend(m_hDC, x, y, nWidth, nHeight, hSrcDC, xSrc, ySrc, nSrcWidth, nSrcHeight, bf); } -#endif // !defined(_WIN32_WCE) || (_WIN32_WCE > 0x500) -#endif // !defined(_ATL_NO_MSIMG) || defined(_WIN32_WCE) // Extra bitmap functions // Helper function for painting a disabled toolbar or menu bitmap @@ -2376,17 +2214,17 @@ public: HBRUSH hBrush3DEffect = ::GetSysColorBrush(COLOR_3DHILIGHT), HBRUSH hBrushDisabledImage = ::GetSysColorBrush(COLOR_3DSHADOW)) { - ATLASSERT(m_hDC != NULL || hBitmap != NULL); - ATLASSERT(nWidth > 0 && nHeight > 0); + ATLASSERT((m_hDC != NULL) || (hBitmap != NULL)); + ATLASSERT((nWidth > 0) && (nHeight > 0)); // Create a generic DC for all BitBlts - CDCHandle dc = (hSrcDC != NULL) ? hSrcDC : ::CreateCompatibleDC(m_hDC); + CDCT dc = (hSrcDC != NULL) ? hSrcDC : ::CreateCompatibleDC(m_hDC); ATLASSERT(dc.m_hDC != NULL); if(dc.m_hDC == NULL) return FALSE; // Create a DC for the monochrome DIB section - CDC dcBW = ::CreateCompatibleDC(m_hDC); + CDCT dcBW = ::CreateCompatibleDC(m_hDC); ATLASSERT(dcBW.m_hDC != NULL); if(dcBW.m_hDC == NULL) { @@ -2426,8 +2264,8 @@ public: // Block: Dark gray removal: we want (128, 128, 128) pixels to become black and not white { - CDC dcTemp1 = ::CreateCompatibleDC(m_hDC); - CDC dcTemp2 = ::CreateCompatibleDC(m_hDC); + CDCT dcTemp1 = ::CreateCompatibleDC(m_hDC); + CDCT dcTemp2 = ::CreateCompatibleDC(m_hDC); CBitmap bmpTemp1; bmpTemp1.CreateCompatibleBitmap(dc, nWidth, nHeight); CBitmap bmpTemp2; @@ -2480,7 +2318,6 @@ public: } // Text Functions -#ifndef _WIN32_WCE BOOL TextOut(int x, int y, LPCTSTR lpszString, int nCount = -1) { ATLASSERT(m_hDC != NULL); @@ -2488,17 +2325,16 @@ public: nCount = lstrlen(lpszString); return ::TextOut(m_hDC, x, y, lpszString, nCount); } -#endif // !_WIN32_WCE - BOOL ExtTextOut(int x, int y, UINT nOptions, LPCRECT lpRect, LPCTSTR lpszString, UINT nCount = -1, LPINT lpDxWidths = NULL) + BOOL ExtTextOut(int x, int y, UINT nOptions, LPCRECT lpRect, LPCTSTR lpszString, int nCount = -1, LPINT lpDxWidths = NULL) { ATLASSERT(m_hDC != NULL); if(nCount == -1) nCount = lstrlen(lpszString); - return ::ExtTextOut(m_hDC, x, y, nOptions, lpRect, lpszString, nCount, lpDxWidths); + ATLASSERT((nCount >= 0) && (nCount <= 8192)); + return ::ExtTextOut(m_hDC, x, y, nOptions, lpRect, lpszString, (UINT)nCount, lpDxWidths); } -#ifndef _WIN32_WCE SIZE TabbedTextOut(int x, int y, LPCTSTR lpszString, int nCount = -1, int nTabPositions = 0, LPINT lpnTabStopPositions = NULL, int nTabOrigin = 0) { ATLASSERT(m_hDC != NULL); @@ -2508,14 +2344,11 @@ public: SIZE size = { GET_X_LPARAM(lRes), GET_Y_LPARAM(lRes) }; return size; } -#endif // !_WIN32_WCE int DrawText(LPCTSTR lpstrText, int cchText, LPRECT lpRect, UINT uFormat) { ATLASSERT(m_hDC != NULL); -#ifndef _WIN32_WCE ATLASSERT((uFormat & DT_MODIFYSTRING) == 0); -#endif // !_WIN32_WCE return ::DrawText(m_hDC, lpstrText, cchText, lpRect, uFormat); } @@ -2525,36 +2358,19 @@ public: return ::DrawText(m_hDC, lpstrText, cchText, lpRect, uFormat); } -#ifndef _WIN32_WCE int DrawTextEx(LPTSTR lpstrText, int cchText, LPRECT lpRect, UINT uFormat, LPDRAWTEXTPARAMS lpDTParams = NULL) { ATLASSERT(m_hDC != NULL); return ::DrawTextEx(m_hDC, lpstrText, cchText, lpRect, uFormat, lpDTParams); } -#endif // !_WIN32_WCE -#if (_WIN32_WINNT >= 0x0501) + // Note - ::DrawShadowText() is present only if comctl32.dll version 6 is loaded int DrawShadowText(LPCWSTR lpstrText, int cchText, LPRECT lpRect, DWORD dwFlags, COLORREF clrText, COLORREF clrShadow, int xOffset, int yOffset) { ATLASSERT(m_hDC != NULL); - // This function is present only if comctl32.dll version 6 is loaded; - // we use LoadLibrary/GetProcAddress to allow apps compiled with - // _WIN32_WINNT >= 0x0501 to run on older Windows/CommCtrl - int nRet = 0; - HMODULE hCommCtrlDLL = ::LoadLibrary(_T("comctl32.dll")); - ATLASSERT(hCommCtrlDLL != NULL); - if(hCommCtrlDLL != NULL) - { - typedef int (WINAPI *PFN_DrawShadowText)(HDC hDC, LPCWSTR lpstrText, UINT cchText, LPRECT lpRect, DWORD dwFlags, COLORREF clrText, COLORREF clrShadow, int xOffset, int yOffset); - PFN_DrawShadowText pfnDrawShadowText = (PFN_DrawShadowText)::GetProcAddress(hCommCtrlDLL, "DrawShadowText"); - ATLASSERT(pfnDrawShadowText != NULL); // this function requires CommCtrl6 - if(pfnDrawShadowText != NULL) - nRet = pfnDrawShadowText(m_hDC, lpstrText, cchText, lpRect, dwFlags, clrText, clrShadow, xOffset, yOffset); - ::FreeLibrary(hCommCtrlDLL); - } - return nRet; + ATLASSERT(lpRect != NULL); + return ::DrawShadowText(m_hDC, lpstrText, cchText, lpRect, dwFlags, clrText, clrShadow, xOffset, yOffset); } -#endif // (_WIN32_WINNT >= 0x0501) BOOL GetTextExtent(LPCTSTR lpszString, int nCount, LPSIZE lpSize) const { @@ -2570,7 +2386,6 @@ public: return ::GetTextExtentExPoint(m_hDC, lpszString, cchString, nMaxExtent, lpnFit, alpDx, lpSize); } -#ifndef _WIN32_WCE DWORD GetTabbedTextExtent(LPCTSTR lpszString, int nCount = -1, int nTabPositions = 0, LPINT lpnTabStopPositions = NULL) const { ATLASSERT(m_hDC != NULL); @@ -2584,9 +2399,7 @@ public: ATLASSERT(m_hDC != NULL); return ::GrayString(m_hDC, hBrush, (GRAYSTRINGPROC)lpfnOutput, lpData, nCount, x, y, nWidth, nHeight); } -#endif // !_WIN32_WCE -#if !defined(_WIN32_WCE) || (_WIN32_WCE >= 400) UINT GetTextAlign() const { ATLASSERT(m_hDC != NULL); @@ -2598,7 +2411,6 @@ public: ATLASSERT(m_hDC != NULL); return ::SetTextAlign(m_hDC, nFlags); } -#endif // !defined(_WIN32_WCE) || (_WIN32_WCE >= 400) int GetTextFace(LPTSTR lpszFacename, int nCount) const { @@ -2612,7 +2424,6 @@ public: return ::GetTextFace(m_hDC, 0, NULL); } -#ifndef _ATL_NO_COM #ifdef _OLEAUTO_H_ BOOL GetTextFace(BSTR& bstrFace) const { @@ -2624,7 +2435,7 @@ public: if(nLen == 0) return FALSE; - CTempBuffer buff; + ATL::CTempBuffer buff; LPTSTR lpszText = buff.Allocate(nLen); if(lpszText == NULL) return FALSE; @@ -2636,10 +2447,9 @@ public: return (bstrFace != NULL) ? TRUE : FALSE; } #endif -#endif // !_ATL_NO_COM -#if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) - int GetTextFace(_CSTRING_NS::CString& strFace) const +#ifdef __ATLSTR_H__ + int GetTextFace(ATL::CString& strFace) const { ATLASSERT(m_hDC != NULL); @@ -2654,7 +2464,7 @@ public: strFace.ReleaseBuffer(); return nRet; } -#endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) +#endif // __ATLSTR_H__ BOOL GetTextMetrics(LPTEXTMETRIC lpMetrics) const { @@ -2662,7 +2472,6 @@ public: return ::GetTextMetrics(m_hDC, lpMetrics); } -#ifndef _WIN32_WCE int SetTextJustification(int nBreakExtra, int nBreakCount) { ATLASSERT(m_hDC != NULL); @@ -2680,7 +2489,6 @@ public: ATLASSERT(m_hDC != NULL); return ::SetTextCharacterExtra(m_hDC, nCharExtra); } -#endif // !_WIN32_WCE // Advanced Drawing BOOL DrawEdge(LPRECT lpRect, UINT nEdge, UINT nFlags) @@ -2703,7 +2511,6 @@ public: } // Font Functions -#ifndef _WIN32_WCE BOOL GetCharWidth(UINT nFirstChar, UINT nLastChar, LPINT lpBuffer) const { ATLASSERT(m_hDC != NULL); @@ -2770,16 +2577,13 @@ public: ATLASSERT(m_hDC != NULL); return ::GetCharWidthFloat(m_hDC, nFirstChar, nLastChar, lpFloatBuffer); } -#endif // !_WIN32_WCE // Printer/Device Escape Functions -#ifndef _WIN32_WCE int Escape(int nEscape, int nCount, LPCSTR lpszInData, LPVOID lpOutData) { ATLASSERT(m_hDC != NULL); return ::Escape(m_hDC, nEscape, nCount, lpszInData, lpOutData); } -#endif // !_WIN32_WCE int Escape(int nEscape, int nInputSize, LPCSTR lpszInputData, int nOutputSize, LPSTR lpszOutputData) @@ -2788,19 +2592,16 @@ public: return ::ExtEscape(m_hDC, nEscape, nInputSize, lpszInputData, nOutputSize, lpszOutputData); } -#ifndef _WIN32_WCE int DrawEscape(int nEscape, int nInputSize, LPCSTR lpszInputData) { ATLASSERT(m_hDC != NULL); return ::DrawEscape(m_hDC, nEscape, nInputSize, lpszInputData); } -#endif // !_WIN32_WCE // Escape helpers -#if !defined(_WIN32_WCE) || ((_WIN32_WCE >= 200) && defined(StartDoc)) int StartDoc(LPCTSTR lpszDocName) // old Win3.0 version { - DOCINFO di = { 0 }; + DOCINFO di = {}; di.cbSize = sizeof(DOCINFO); di.lpszDocName = lpszDocName; return StartDoc(&di); @@ -2841,10 +2642,8 @@ public: ATLASSERT(m_hDC != NULL); return ::EndDoc(m_hDC); } -#endif // !defined(_WIN32_WCE) || ((_WIN32_WCE >= 200) && defined(StartDoc)) // MetaFile Functions -#ifndef _WIN32_WCE BOOL PlayMetaFile(HMETAFILE hMF) { ATLASSERT(m_hDC != NULL); @@ -2873,7 +2672,7 @@ public: // Special handling for metafile playback static int CALLBACK EnumMetaFileProc(HDC hDC, HANDLETABLE* pHandleTable, METARECORD* pMetaRec, int nHandles, LPARAM lParam) { - CDCHandle* pDC = (CDCHandle*)lParam; + CDCT* pDC = (CDCT*)lParam; switch (pMetaRec->rdFunction) { @@ -2957,10 +2756,8 @@ public: return 1; } -#endif // !_WIN32_WCE // Path Functions -#ifndef _WIN32_WCE BOOL AbortPath() { ATLASSERT(m_hDC != NULL); @@ -3038,13 +2835,12 @@ public: ATLASSERT(m_hDC != NULL); return ::SelectClipPath(m_hDC, nMode); } -#endif // !_WIN32_WCE // Misc Helper Functions static CBrushHandle PASCAL GetHalftoneBrush() { HBRUSH halftoneBrush = NULL; - WORD grayPattern[8] = { 0 }; + WORD grayPattern[8] = {}; for(int i = 0; i < 8; i++) grayPattern[i] = (WORD)(0x5555 << (i & 1)); HBITMAP grayBitmap = CreateBitmap(8, 8, 1, 1, &grayPattern); @@ -3097,7 +2893,7 @@ public: rgnUpdate.CombineRgn(rgnLast, rgnNew, RGN_XOR); } } - if(hBrush != hBrushLast && lpRectLast != NULL) + if((hBrush != hBrushLast) && (lpRectLast != NULL)) { // brushes are different -- erase old region first SelectClipRgn(rgnLast); @@ -3156,15 +2952,12 @@ public: } // DIB support -#if !defined(_WIN32_WCE) || (_WIN32_WCE >= 410) int SetDIBitsToDevice(int x, int y, DWORD dwWidth, DWORD dwHeight, int xSrc, int ySrc, UINT uStartScan, UINT cScanLines, CONST VOID* lpvBits, CONST BITMAPINFO* lpbmi, UINT uColorUse) { ATLASSERT(m_hDC != NULL); return ::SetDIBitsToDevice(m_hDC, x, y, dwWidth, dwHeight, xSrc, ySrc, uStartScan, cScanLines, lpvBits, lpbmi, uColorUse); } -#endif // !defined(_WIN32_WCE) || (_WIN32_WCE >= 410) -#if !defined(_WIN32_WCE) || (_WIN32_WCE >= 400) int StretchDIBits(int x, int y, int nWidth, int nHeight, int xSrc, int ySrc, int nSrcWidth, int nSrcHeight, CONST VOID* lpvBits, CONST BITMAPINFO* lpbmi, UINT uColorUse, DWORD dwRop) { ATLASSERT(m_hDC != NULL); @@ -3182,10 +2975,9 @@ public: ATLASSERT(m_hDC != NULL); return ::SetDIBColorTable(m_hDC, uStartIndex, cEntries, pColors); } -#endif // !defined(_WIN32_WCE) || (_WIN32_WCE >= 400) // OpenGL support -#if !defined(_ATL_NO_OPENGL) && !defined(_WIN32_WCE) +#if !defined(_ATL_NO_OPENGL) int ChoosePixelFormat(CONST PIXELFORMATDESCRIPTOR* ppfd) { ATLASSERT(m_hDC != NULL); @@ -3275,10 +3067,8 @@ public: ATLASSERT(m_hDC != NULL); return ::wglSwapLayerBuffers(m_hDC, uPlanes); } -#endif // !defined(_ATL_NO_OPENGL) && !defined(_WIN32_WCE) +#endif // !defined(_ATL_NO_OPENGL) -// New for Windows 2000 only -#if (_WIN32_WINNT >= 0x0500) COLORREF GetDCPenColor() const { ATLASSERT(m_hDC != NULL); @@ -3303,13 +3093,11 @@ public: return ::SetDCBrushColor(m_hDC, clr); } -#ifndef _WIN32_WCE DWORD GetFontUnicodeRanges(LPGLYPHSET lpgs) const { ATLASSERT(m_hDC != NULL); return ::GetFontUnicodeRanges(m_hDC, lpgs); } -#endif // !_WIN32_WCE DWORD GetGlyphIndices(LPCTSTR lpstr, int cch, LPWORD pgi, DWORD dwFlags) const { @@ -3340,21 +3128,14 @@ public: ATLASSERT(m_hDC != NULL); return ::GetCharABCWidthsI(m_hDC, giFirst, cgi, pgi, lpabc); } -#endif // (_WIN32_WINNT >= 0x0500) -// New for Windows 2000 and Windows 98 -#if (WINVER >= 0x0500) && !defined(_WIN32_WCE) BOOL ColorCorrectPalette(HPALETTE hPalette, DWORD dwFirstEntry, DWORD dwNumOfEntries) { ATLASSERT(m_hDC != NULL); return ::ColorCorrectPalette(m_hDC, hPalette, dwFirstEntry, dwNumOfEntries); } -#endif // (WINVER >= 0x0500) && !defined(_WIN32_WCE) }; -typedef CDCT CDCHandle; -typedef CDCT CDC; - /////////////////////////////////////////////////////////////////////////////// // CDC Helpers @@ -3392,7 +3173,7 @@ public: // Constructor/destructor CClientDC(HWND hWnd) { - ATLASSERT(hWnd == NULL || ::IsWindow(hWnd)); + ATLASSERT((hWnd == NULL) || ::IsWindow(hWnd)); m_hWnd = hWnd; m_hDC = ::GetDC(hWnd); } @@ -3413,7 +3194,7 @@ public: // Constructor/destructor CWindowDC(HWND hWnd) { - ATLASSERT(hWnd == NULL || ::IsWindow(hWnd)); + ATLASSERT((hWnd == NULL) || ::IsWindow(hWnd)); m_hWnd = hWnd; m_hDC = ::GetWindowDC(hWnd); } @@ -3457,8 +3238,6 @@ public: /////////////////////////////////////////////////////////////////////////////// // Enhanced metafile support -#ifndef _WIN32_WCE - class CEnhMetaFileInfo { public: @@ -3470,8 +3249,11 @@ public: PIXELFORMATDESCRIPTOR m_pfd; // Constructor/destructor - CEnhMetaFileInfo(HENHMETAFILE hEMF) : m_pBits(NULL), m_pDesc(NULL), m_hEMF(hEMF) - { } + CEnhMetaFileInfo(HENHMETAFILE hEMF) : m_hEMF(hEMF), m_pBits(NULL), m_pDesc(NULL) + { + memset(&m_header, 0, sizeof(m_header)); + memset(&m_pfd, 0, sizeof(m_pfd)); + } ~CEnhMetaFileInfo() { @@ -3538,7 +3320,7 @@ public: ~CEnhMetaFileT() { - if(t_bManaged && m_hEMF != NULL) + if(t_bManaged && (m_hEMF != NULL)) DeleteObject(); } @@ -3551,7 +3333,7 @@ public: void Attach(HENHMETAFILE hEMF) { - if(t_bManaged && m_hEMF != NULL && m_hEMF != hEMF) + if(t_bManaged && (m_hEMF != NULL) && (m_hEMF != hEMF)) DeleteObject(); m_hEMF = hEMF; } @@ -3658,232 +3440,6 @@ public: } }; -#endif // !_WIN32_WCE - - -/////////////////////////////////////////////////////////////////////////////// -// WinCE compatible clipboard CF_DIB format support functions - -#ifndef _WTL_NO_DIB16 - -#define DIBINFO16_BITFIELDS { 31744, 992, 31 } - -// DIBINFO16 - To avoid color table problems in WinCE we only create this type of Dib -struct DIBINFO16 // a BITMAPINFO with 2 additional color bitfields -{ - BITMAPINFOHEADER bmiHeader; - RGBQUAD bmiColors[3]; - - DIBINFO16(SIZE size) - { - BITMAPINFOHEADER bmih = { sizeof(BITMAPINFOHEADER), size.cx, size.cy, - 1, 16, BI_BITFIELDS, (DWORD)(2 * size.cx * size.cy), 0, 0, 3 }; - DWORD dw[3] = DIBINFO16_BITFIELDS ; - - bmiHeader = bmih; - SecureHelper::memcpy_x(bmiColors, sizeof(bmiColors), dw, 3 * sizeof(DWORD)); - } -}; - - -// AtlxxxDibxxx minimal packed DIB implementation and helpers to copy and paste CF_DIB - -inline bool AtlIsDib16(LPBITMAPINFOHEADER pbmih) -{ - return (pbmih->biBitCount == 16) && (pbmih->biCompression == BI_BITFIELDS); -} - -inline int AtlGetDibColorTableSize(LPBITMAPINFOHEADER pbmih) -{ - switch (pbmih->biBitCount) - { - case 2: - case 4: - case 8: - return pbmih->biClrUsed ? pbmih->biClrUsed : 1 << pbmih->biBitCount; - case 24: - break; - case 16: - case 32: - return pbmih->biCompression == BI_BITFIELDS ? 3 : 0; - default: - ATLASSERT(FALSE); // should never come here - } - - return 0; -} - -inline int AtlGetDibNumColors(LPBITMAPINFOHEADER pbmih) -{ - switch (pbmih->biBitCount) - { - case 2: - case 4: - case 8: - if (pbmih->biClrUsed) - return pbmih->biClrUsed; - else - break; - case 16: - if (pbmih->biCompression == BI_BITFIELDS ) - return 1 << 15; - else - break; - case 24: - break; - case 32: - if (pbmih->biCompression == BI_BITFIELDS ) - return 1 << 24; - else - break; - default: - ATLASSERT(FALSE); - } - - return 1 << pbmih->biBitCount; -} - -inline HBITMAP AtlGetDibBitmap(LPBITMAPINFO pbmi) -{ - CDC dc(NULL); - void* pBits = NULL; - - LPBYTE pDibBits = (LPBYTE)pbmi + sizeof(BITMAPINFOHEADER) + AtlGetDibColorTableSize(&pbmi->bmiHeader) * sizeof(RGBQUAD); - HBITMAP hbm = CreateDIBSection(dc, pbmi, DIB_RGB_COLORS, &pBits, NULL, NULL); - if (hbm != NULL) - { - int cbBits = pbmi->bmiHeader.biWidth * pbmi->bmiHeader.biHeight * pbmi->bmiHeader.biBitCount / 8; - SecureHelper::memcpy_x(pBits, cbBits, pDibBits, pbmi->bmiHeader.biSizeImage); - } - - return hbm; -} - -inline HBITMAP AtlCopyBitmap(HBITMAP hbm, SIZE sizeDst, bool bAsBitmap = false) -{ - CDC hdcSrc = CreateCompatibleDC(NULL); - CDC hdcDst = CreateCompatibleDC(NULL); - - CBitmapHandle hbmOld = NULL, hbmOld2 = NULL, bmSrc = hbm; - - CBitmap bmNew = NULL; - - SIZE sizeSrc = { 0 }; - bmSrc.GetSize(sizeSrc); - - hbmOld = hdcSrc.SelectBitmap(bmSrc); - - if (bAsBitmap) - { - bmNew.CreateCompatibleBitmap(hdcSrc, sizeDst.cx, sizeDst.cy); - } - else - { - DIBINFO16 dib16(sizeDst); - LPVOID pBits = NULL; - bmNew = CreateDIBSection(hdcDst, (const BITMAPINFO*)&dib16, DIB_RGB_COLORS, &pBits, NULL, NULL); - } - - ATLASSERT(!bmNew.IsNull()); - - hbmOld2 = hdcDst.SelectBitmap(bmNew); - BOOL bOK = FALSE; - - if ((sizeDst.cx == sizeSrc.cx) && (sizeDst.cy == sizeSrc.cy)) - bOK = hdcDst.BitBlt(0, 0, sizeDst.cx, sizeDst.cy, hdcSrc, 0, 0, SRCCOPY); - else - bOK = hdcDst.StretchBlt(0, 0, sizeDst.cx, sizeDst.cy, hdcSrc, 0, 0, sizeSrc.cx, sizeSrc.cy, SRCCOPY); - - hdcSrc.SelectBitmap(hbmOld); - hdcDst.SelectBitmap(hbmOld2); - - if (bOK == FALSE) - bmNew.DeleteObject(); - - return bmNew.Detach(); -} - -inline HLOCAL AtlCreatePackedDib16(HBITMAP hbm, SIZE size) -{ - DIBSECTION ds = { 0 }; - LPBYTE pDib = NULL; - bool bCopied = false; - - bool bOK = GetObject(hbm, sizeof(ds), &ds) == sizeof(ds); - if ((bOK == FALSE) || (ds.dsBm.bmBits == NULL) || (AtlIsDib16(&ds.dsBmih) == FALSE) || - (ds.dsBmih.biWidth != size.cx ) || (ds.dsBmih.biHeight != size.cy )) - { - if ((hbm = AtlCopyBitmap(hbm, size)) != NULL) - { - bCopied = true; - bOK = GetObject(hbm, sizeof(ds), &ds) == sizeof(ds); - } - else - { - bOK = FALSE; - } - } - - if((bOK != FALSE) && (AtlIsDib16(&ds.dsBmih) != FALSE) && (ds.dsBm.bmBits != NULL)) - { - pDib = (LPBYTE)LocalAlloc(LMEM_ZEROINIT, sizeof(DIBINFO16) + ds.dsBmih.biSizeImage); - if (pDib != NULL) - { - SecureHelper::memcpy_x(pDib, sizeof(DIBINFO16) + ds.dsBmih.biSizeImage, &ds.dsBmih, sizeof(DIBINFO16)); - SecureHelper::memcpy_x(pDib + sizeof(DIBINFO16), ds.dsBmih.biSizeImage, ds.dsBm.bmBits, ds.dsBmih.biSizeImage); - } - } - - if (bCopied == true) - DeleteObject(hbm); - - return (HLOCAL)pDib; -} - -inline bool AtlSetClipboardDib16(HBITMAP hbm, SIZE size, HWND hWnd) -{ - ATLASSERT(::IsWindow(hWnd)); - BOOL bOK = OpenClipboard(hWnd); - if (bOK != FALSE) - { - bOK = EmptyClipboard(); - if (bOK != FALSE) - { - HLOCAL hDib = AtlCreatePackedDib16(hbm, size); - if (hDib != NULL) - { - bOK = SetClipboardData(CF_DIB, hDib) != NULL; - if (bOK == FALSE) - LocalFree(hDib); - } - else - { - bOK = FALSE; - } - } - CloseClipboard(); - } - - return (bOK != FALSE); -} - -inline HBITMAP AtlGetClipboardDib(HWND hWnd) -{ - ATLASSERT(::IsWindow(hWnd) != FALSE); - HBITMAP hbm = NULL; - if (OpenClipboard(hWnd) != FALSE) - { - LPBITMAPINFO pbmi = (LPBITMAPINFO)GetClipboardData(CF_DIB); - if (pbmi != NULL) - hbm = AtlGetDibBitmap(pbmi); - CloseClipboard(); - } - - return hbm; -} - -#endif // _WTL_NO_DIB16 - -}; // namespace WTL +} // namespace WTL #endif // __ATLGDI_H__ diff --git a/WrlSDK/SampleCode/PluginWinExe/WTL/atlmisc.h b/WrlSDK/SampleCode/PluginWinExe/WTL/atlmisc.h index ea4bb4da563a9f4e73667fd88b73aa40156d2dd7..af94875b1f12550dbb762b2d83b3eee9a4554a8e 100644 --- a/WrlSDK/SampleCode/PluginWinExe/WTL/atlmisc.h +++ b/WrlSDK/SampleCode/PluginWinExe/WTL/atlmisc.h @@ -1,4 +1,4 @@ -// Windows Template Library - WTL version 9.10 +// Windows Template Library - WTL version 10.0 // Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. // // This file is a part of the Windows Template Library. @@ -15,2800 +15,68 @@ #error atlmisc.h requires atlapp.h to be included first #endif +#ifndef _WTL_NO_COMPATIBILITY_INCLUDES + #include + #include +#endif // _WTL_NO_COMPATIBILITY_INCLUDES -#ifdef _ATL_TMP_NO_CSTRING - #define _WTL_NO_CSTRING -#endif - -#if defined(_WTL_USE_CSTRING) && defined(_WTL_NO_CSTRING) - #error Conflicting options - both _WTL_USE_CSTRING and _WTL_NO_CSTRING are defined -#endif // defined(_WTL_USE_CSTRING) && defined(_WTL_NO_CSTRING) - -#if !defined(_WTL_USE_CSTRING) && !defined(_WTL_NO_CSTRING) - #define _WTL_USE_CSTRING -#endif // !defined(_WTL_USE_CSTRING) && !defined(_WTL_NO_CSTRING) - -#ifndef _WTL_NO_CSTRING - #if defined(_ATL_USE_CSTRING_FLOAT) && defined(_ATL_MIN_CRT) - #error Cannot use CString floating point formatting with _ATL_MIN_CRT defined - #endif // defined(_ATL_USE_CSTRING_FLOAT) && defined(_ATL_MIN_CRT) -#endif // !_WTL_NO_CSTRING - - -/////////////////////////////////////////////////////////////////////////////// -// Classes in this file: -// -// CSize -// CPoint -// CRect -// CString -// -// CRecentDocumentListBase -// CRecentDocumentList -// CFindFile -// -// Global functions: -// AtlGetStockPen() -// AtlGetStockBrush() -// AtlGetStockFont() -// AtlGetStockPalette() -// -// AtlCompactPath() - - -namespace WTL -{ - -#ifndef _WTL_NO_WTYPES - -// forward declarations -class CSize; -class CPoint; -class CRect; - -/////////////////////////////////////////////////////////////////////////////// -// CSize - Wrapper for Windows SIZE structure. - -class CSize : public SIZE -{ -public: -// Constructors - CSize() - { - cx = 0; - cy = 0; - } - - CSize(int initCX, int initCY) - { - cx = initCX; - cy = initCY; - } - - CSize(SIZE initSize) - { - *(SIZE*)this = initSize; - } - - CSize(POINT initPt) - { - *(POINT*)this = initPt; - } - - CSize(DWORD dwSize) - { - cx = (short)LOWORD(dwSize); - cy = (short)HIWORD(dwSize); - } - -// Operations - BOOL operator ==(SIZE size) const - { - return (cx == size.cx && cy == size.cy); - } - - BOOL operator !=(SIZE size) const - { - return (cx != size.cx || cy != size.cy); - } - - void operator +=(SIZE size) - { - cx += size.cx; - cy += size.cy; - } - - void operator -=(SIZE size) - { - cx -= size.cx; - cy -= size.cy; - } - - void SetSize(int CX, int CY) - { - cx = CX; - cy = CY; - } - -// Operators returning CSize values - CSize operator +(SIZE size) const - { - return CSize(cx + size.cx, cy + size.cy); - } - - CSize operator -(SIZE size) const - { - return CSize(cx - size.cx, cy - size.cy); - } - - CSize operator -() const - { - return CSize(-cx, -cy); - } - -// Operators returning CPoint values - CPoint operator +(POINT point) const; - CPoint operator -(POINT point) const; - -// Operators returning CRect values - CRect operator +(const RECT* lpRect) const; - CRect operator -(const RECT* lpRect) const; -}; - - -/////////////////////////////////////////////////////////////////////////////// -// CPoint - Wrapper for Windows POINT structure. - -class CPoint : public POINT -{ -public: -// Constructors - CPoint() - { - x = 0; - y = 0; - } - - CPoint(int initX, int initY) - { - x = initX; - y = initY; - } - - CPoint(POINT initPt) - { - *(POINT*)this = initPt; - } - - CPoint(SIZE initSize) - { - *(SIZE*)this = initSize; - } - - CPoint(DWORD dwPoint) - { - x = (short)LOWORD(dwPoint); - y = (short)HIWORD(dwPoint); - } - -// Operations - void Offset(int xOffset, int yOffset) - { - x += xOffset; - y += yOffset; - } - - void Offset(POINT point) - { - x += point.x; - y += point.y; - } - - void Offset(SIZE size) - { - x += size.cx; - y += size.cy; - } - - BOOL operator ==(POINT point) const - { - return (x == point.x && y == point.y); - } - - BOOL operator !=(POINT point) const - { - return (x != point.x || y != point.y); - } - - void operator +=(SIZE size) - { - x += size.cx; - y += size.cy; - } - - void operator -=(SIZE size) - { - x -= size.cx; - y -= size.cy; - } - - void operator +=(POINT point) - { - x += point.x; - y += point.y; - } - - void operator -=(POINT point) - { - x -= point.x; - y -= point.y; - } - - void SetPoint(int X, int Y) - { - x = X; - y = Y; - } - -// Operators returning CPoint values - CPoint operator +(SIZE size) const - { - return CPoint(x + size.cx, y + size.cy); - } - - CPoint operator -(SIZE size) const - { - return CPoint(x - size.cx, y - size.cy); - } - - CPoint operator -() const - { - return CPoint(-x, -y); - } - - CPoint operator +(POINT point) const - { - return CPoint(x + point.x, y + point.y); - } - -// Operators returning CSize values - CSize operator -(POINT point) const - { - return CSize(x - point.x, y - point.y); - } - -// Operators returning CRect values - CRect operator +(const RECT* lpRect) const; - CRect operator -(const RECT* lpRect) const; -}; - - -/////////////////////////////////////////////////////////////////////////////// -// CRect - Wrapper for Windows RECT structure. - -class CRect : public RECT -{ -public: -// Constructors - CRect() - { - left = 0; - top = 0; - right = 0; - bottom = 0; - } - - CRect(int l, int t, int r, int b) - { - left = l; - top = t; - right = r; - bottom = b; - } - - CRect(const RECT& srcRect) - { - ::CopyRect(this, &srcRect); - } - - CRect(LPCRECT lpSrcRect) - { - ::CopyRect(this, lpSrcRect); - } - - CRect(POINT point, SIZE size) - { - right = (left = point.x) + size.cx; - bottom = (top = point.y) + size.cy; - } - - CRect(POINT topLeft, POINT bottomRight) - { - left = topLeft.x; - top = topLeft.y; - right = bottomRight.x; - bottom = bottomRight.y; - } - -// Attributes (in addition to RECT members) - int Width() const - { - return right - left; - } - - int Height() const - { - return bottom - top; - } - - CSize Size() const - { - return CSize(right - left, bottom - top); - } - - CPoint& TopLeft() - { - return *((CPoint*)this); - } - - CPoint& BottomRight() - { - return *((CPoint*)this + 1); - } - - const CPoint& TopLeft() const - { - return *((CPoint*)this); - } - - const CPoint& BottomRight() const - { - return *((CPoint*)this + 1); - } - - CPoint CenterPoint() const - { - return CPoint((left + right) / 2, (top + bottom) / 2); - } - - // convert between CRect and LPRECT/LPCRECT (no need for &) - operator LPRECT() - { - return this; - } - - operator LPCRECT() const - { - return this; - } - - BOOL IsRectEmpty() const - { - return ::IsRectEmpty(this); - } - - BOOL IsRectNull() const - { - return (left == 0 && right == 0 && top == 0 && bottom == 0); - } - - BOOL PtInRect(POINT point) const - { - return ::PtInRect(this, point); - } - -// Operations - void SetRect(int x1, int y1, int x2, int y2) - { - ::SetRect(this, x1, y1, x2, y2); - } - - void SetRect(POINT topLeft, POINT bottomRight) - { - ::SetRect(this, topLeft.x, topLeft.y, bottomRight.x, bottomRight.y); - } - - void SetRectEmpty() - { - ::SetRectEmpty(this); - } - - void CopyRect(LPCRECT lpSrcRect) - { - ::CopyRect(this, lpSrcRect); - } - - BOOL EqualRect(LPCRECT lpRect) const - { - return ::EqualRect(this, lpRect); - } - - void InflateRect(int x, int y) - { - ::InflateRect(this, x, y); - } - - void InflateRect(SIZE size) - { - ::InflateRect(this, size.cx, size.cy); - } - - void InflateRect(LPCRECT lpRect) - { - left -= lpRect->left; - top -= lpRect->top; - right += lpRect->right; - bottom += lpRect->bottom; - } - - void InflateRect(int l, int t, int r, int b) - { - left -= l; - top -= t; - right += r; - bottom += b; - } - - void DeflateRect(int x, int y) - { - ::InflateRect(this, -x, -y); - } - - void DeflateRect(SIZE size) - { - ::InflateRect(this, -size.cx, -size.cy); - } - - void DeflateRect(LPCRECT lpRect) - { - left += lpRect->left; - top += lpRect->top; - right -= lpRect->right; - bottom -= lpRect->bottom; - } - - void DeflateRect(int l, int t, int r, int b) - { - left += l; - top += t; - right -= r; - bottom -= b; - } - - void OffsetRect(int x, int y) - { - ::OffsetRect(this, x, y); - } - void OffsetRect(SIZE size) - { - ::OffsetRect(this, size.cx, size.cy); - } - - void OffsetRect(POINT point) - { - ::OffsetRect(this, point.x, point.y); - } - - void NormalizeRect() - { - int nTemp; - if (left > right) - { - nTemp = left; - left = right; - right = nTemp; - } - if (top > bottom) - { - nTemp = top; - top = bottom; - bottom = nTemp; - } - } - - // absolute position of rectangle - void MoveToY(int y) - { - bottom = Height() + y; - top = y; - } - - void MoveToX(int x) - { - right = Width() + x; - left = x; - } - - void MoveToXY(int x, int y) - { - MoveToX(x); - MoveToY(y); - } - - void MoveToXY(POINT pt) - { - MoveToX(pt.x); - MoveToY(pt.y); - } - - // operations that fill '*this' with result - BOOL IntersectRect(LPCRECT lpRect1, LPCRECT lpRect2) - { - return ::IntersectRect(this, lpRect1, lpRect2); - } - - BOOL UnionRect(LPCRECT lpRect1, LPCRECT lpRect2) - { - return ::UnionRect(this, lpRect1, lpRect2); - } - - BOOL SubtractRect(LPCRECT lpRectSrc1, LPCRECT lpRectSrc2) - { - return ::SubtractRect(this, lpRectSrc1, lpRectSrc2); - } - -// Additional Operations - void operator =(const RECT& srcRect) - { - ::CopyRect(this, &srcRect); - } - - BOOL operator ==(const RECT& rect) const - { - return ::EqualRect(this, &rect); - } - - BOOL operator !=(const RECT& rect) const - { - return !::EqualRect(this, &rect); - } - - void operator +=(POINT point) - { - ::OffsetRect(this, point.x, point.y); - } - - void operator +=(SIZE size) - { - ::OffsetRect(this, size.cx, size.cy); - } - - void operator +=(LPCRECT lpRect) - { - InflateRect(lpRect); - } - - void operator -=(POINT point) - { - ::OffsetRect(this, -point.x, -point.y); - } - - void operator -=(SIZE size) - { - ::OffsetRect(this, -size.cx, -size.cy); - } - - void operator -=(LPCRECT lpRect) - { - DeflateRect(lpRect); - } - - void operator &=(const RECT& rect) - { - ::IntersectRect(this, this, &rect); - } - - void operator |=(const RECT& rect) - { - ::UnionRect(this, this, &rect); - } - -// Operators returning CRect values - CRect operator +(POINT pt) const - { - CRect rect(*this); - ::OffsetRect(&rect, pt.x, pt.y); - return rect; - } - - CRect operator -(POINT pt) const - { - CRect rect(*this); - ::OffsetRect(&rect, -pt.x, -pt.y); - return rect; - } - - CRect operator +(LPCRECT lpRect) const - { - CRect rect(this); - rect.InflateRect(lpRect); - return rect; - } - - CRect operator +(SIZE size) const - { - CRect rect(*this); - ::OffsetRect(&rect, size.cx, size.cy); - return rect; - } - - CRect operator -(SIZE size) const - { - CRect rect(*this); - ::OffsetRect(&rect, -size.cx, -size.cy); - return rect; - } - - CRect operator -(LPCRECT lpRect) const - { - CRect rect(this); - rect.DeflateRect(lpRect); - return rect; - } - - CRect operator &(const RECT& rect2) const - { - CRect rect; - ::IntersectRect(&rect, this, &rect2); - return rect; - } - - CRect operator |(const RECT& rect2) const - { - CRect rect; - ::UnionRect(&rect, this, &rect2); - return rect; - } - - CRect MulDiv(int nMultiplier, int nDivisor) const - { - return CRect( - ::MulDiv(left, nMultiplier, nDivisor), - ::MulDiv(top, nMultiplier, nDivisor), - ::MulDiv(right, nMultiplier, nDivisor), - ::MulDiv(bottom, nMultiplier, nDivisor)); - } -}; - - -// CSize implementation - -inline CPoint CSize::operator +(POINT point) const -{ return CPoint(cx + point.x, cy + point.y); } - -inline CPoint CSize::operator -(POINT point) const -{ return CPoint(cx - point.x, cy - point.y); } - -inline CRect CSize::operator +(const RECT* lpRect) const -{ return CRect(lpRect) + *this; } - -inline CRect CSize::operator -(const RECT* lpRect) const -{ return CRect(lpRect) - *this; } - - -// CPoint implementation - -inline CRect CPoint::operator +(const RECT* lpRect) const -{ return CRect(lpRect) + *this; } - -inline CRect CPoint::operator -(const RECT* lpRect) const -{ return CRect(lpRect) - *this; } - -#endif // !_WTL_NO_WTYPES - - -// WTL::CSize or ATL::CSize scalar operators - -#if !defined(_WTL_NO_SIZE_SCALAR) && (!defined(_WTL_NO_WTYPES) || defined(__ATLTYPES_H__)) - -template -inline CSize operator *(SIZE s, Num n) -{ - return CSize((int)(s.cx * n), (int)(s.cy * n)); -}; - -template -inline void operator *=(SIZE & s, Num n) -{ - s = s * n; -}; - -template -inline CSize operator /(SIZE s, Num n) -{ - return CSize((int)(s.cx / n), (int)(s.cy / n)); -}; - -template -inline void operator /=(SIZE & s, Num n) -{ - s = s / n; -}; - -#endif // !defined(_WTL_NO_SIZE_SCALAR) && (!defined(_WTL_NO_WTYPES) || defined(__ATLTYPES_H__)) - - -/////////////////////////////////////////////////////////////////////////////// -// CString - String class - -#ifndef _WTL_NO_CSTRING - -struct CStringData -{ - long nRefs; // reference count - int nDataLength; - int nAllocLength; - // TCHAR data[nAllocLength] - - TCHAR* data() - { return (TCHAR*)(this + 1); } -}; - -// Globals - -// For an empty string, m_pchData will point here -// (note: avoids special case of checking for NULL m_pchData) -// empty string data (and locked) -_declspec(selectany) int rgInitData[] = { -1, 0, 0, 0 }; -_declspec(selectany) CStringData* _atltmpDataNil = (CStringData*)&rgInitData; -_declspec(selectany) LPCTSTR _atltmpPchNil = (LPCTSTR)(((BYTE*)&rgInitData) + sizeof(CStringData)); - - -class CString -{ -public: -// Constructors - CString() - { - Init(); - } - - CString(const CString& stringSrc) - { - ATLASSERT(stringSrc.GetData()->nRefs != 0); - if (stringSrc.GetData()->nRefs >= 0) - { - ATLASSERT(stringSrc.GetData() != _atltmpDataNil); - m_pchData = stringSrc.m_pchData; - InterlockedIncrement(&GetData()->nRefs); - } - else - { - Init(); - *this = stringSrc.m_pchData; - } - } - - CString(TCHAR ch, int nRepeat = 1) - { - ATLASSERT(!_istlead(ch)); // can't create a lead byte string - Init(); - if (nRepeat >= 1) - { - if(AllocBuffer(nRepeat)) - { -#ifdef _UNICODE - for (int i = 0; i < nRepeat; i++) - m_pchData[i] = ch; -#else - memset(m_pchData, ch, nRepeat); -#endif - } - } - } - - CString(LPCTSTR lpsz) - { - Init(); - if (lpsz != NULL && HIWORD(lpsz) == NULL) - { - UINT nID = LOWORD((DWORD_PTR)lpsz); - if (!LoadString(nID)) - ATLTRACE2(atlTraceUI, 0, _T("Warning: implicit LoadString(%u) in CString failed\n"), nID); - } - else - { - int nLen = SafeStrlen(lpsz); - if (nLen != 0) - { - if(AllocBuffer(nLen)) - SecureHelper::memcpy_x(m_pchData, (nLen + 1) * sizeof(TCHAR), lpsz, nLen * sizeof(TCHAR)); - } - } - } - -#ifdef _UNICODE - CString(LPCSTR lpsz) - { - Init(); -#if defined(_WIN32_WCE) && (_ATL_VER >= 0x0800) - int nSrcLen = (lpsz != NULL) ? ATL::lstrlenA(lpsz) : 0; -#else - int nSrcLen = (lpsz != NULL) ? lstrlenA(lpsz) : 0; -#endif - if (nSrcLen != 0) - { - if(AllocBuffer(nSrcLen)) - { - _mbstowcsz(m_pchData, lpsz, nSrcLen + 1); - ReleaseBuffer(); - } - } - } -#else // !_UNICODE - CString(LPCWSTR lpsz) - { - Init(); - int nSrcLen = (lpsz != NULL) ? (int)wcslen(lpsz) : 0; - if (nSrcLen != 0) - { - if(AllocBuffer(nSrcLen * 2)) - { - _wcstombsz(m_pchData, lpsz, (nSrcLen * 2) + 1); - ReleaseBuffer(); - } - } - } -#endif // !_UNICODE - - CString(LPCTSTR lpch, int nLength) - { - Init(); - if (nLength != 0) - { - if(AllocBuffer(nLength)) - SecureHelper::memcpy_x(m_pchData, (nLength + 1) * sizeof(TCHAR), lpch, nLength * sizeof(TCHAR)); - } - } - -#ifdef _UNICODE - CString(LPCSTR lpsz, int nLength) - { - Init(); - if (nLength != 0) - { - if(AllocBuffer(nLength)) - { - int n = ::MultiByteToWideChar(CP_ACP, 0, lpsz, nLength, m_pchData, nLength + 1); - ReleaseBuffer((n >= 0) ? n : -1); - } - } - } -#else // !_UNICODE - CString(LPCWSTR lpsz, int nLength) - { - Init(); - if (nLength != 0) - { - if(((nLength * 2) > nLength) && AllocBuffer(nLength * 2)) - { - int n = ::WideCharToMultiByte(CP_ACP, 0, lpsz, nLength, m_pchData, (nLength * 2) + 1, NULL, NULL); - ReleaseBuffer((n >= 0) ? n : -1); - } - } - } -#endif // !_UNICODE - - CString(const unsigned char* lpsz) - { - Init(); - *this = (LPCSTR)lpsz; - } - -// Attributes & Operations - int GetLength() const // as an array of characters - { - return GetData()->nDataLength; - } - - BOOL IsEmpty() const - { - return GetData()->nDataLength == 0; - } - - void Empty() // free up the data - { - if (GetData()->nDataLength == 0) - return; - - if (GetData()->nRefs >= 0) - Release(); - else - *this = _T(""); - - ATLASSERT(GetData()->nDataLength == 0); - ATLASSERT(GetData()->nRefs < 0 || GetData()->nAllocLength == 0); - } - - TCHAR GetAt(int nIndex) const // 0 based - { - ATLASSERT(nIndex >= 0); - ATLASSERT(nIndex < GetData()->nDataLength); - return m_pchData[nIndex]; - } - - TCHAR operator [](int nIndex) const // same as GetAt - { - // same as GetAt - ATLASSERT(nIndex >= 0); - ATLASSERT(nIndex < GetData()->nDataLength); - return m_pchData[nIndex]; - } - - void SetAt(int nIndex, TCHAR ch) - { - ATLASSERT(nIndex >= 0); - ATLASSERT(nIndex < GetData()->nDataLength); - - CopyBeforeWrite(); - m_pchData[nIndex] = ch; - } - - operator LPCTSTR() const // as a C string - { - return m_pchData; - } - - // overloaded assignment - CString& operator =(const CString& stringSrc) - { - if (m_pchData != stringSrc.m_pchData) - { - if ((GetData()->nRefs < 0 && GetData() != _atltmpDataNil) || stringSrc.GetData()->nRefs < 0) - { - // actual copy necessary since one of the strings is locked - AssignCopy(stringSrc.GetData()->nDataLength, stringSrc.m_pchData); - } - else - { - // can just copy references around - Release(); - ATLASSERT(stringSrc.GetData() != _atltmpDataNil); - m_pchData = stringSrc.m_pchData; - InterlockedIncrement(&GetData()->nRefs); - } - } - return *this; - } - - CString& operator =(TCHAR ch) - { - ATLASSERT(!_istlead(ch)); // can't set single lead byte - AssignCopy(1, &ch); - return *this; - } - -#ifdef _UNICODE - CString& operator =(char ch) - { - *this = (TCHAR)ch; - return *this; - } -#endif - - CString& operator =(LPCTSTR lpsz) - { - ATLASSERT(lpsz == NULL || _IsValidString(lpsz)); - AssignCopy(SafeStrlen(lpsz), lpsz); - return *this; - } - -#ifdef _UNICODE - CString& operator =(LPCSTR lpsz) - { -#if defined(_WIN32_WCE) && (_ATL_VER >= 0x0800) - int nSrcLen = (lpsz != NULL) ? ATL::lstrlenA(lpsz) : 0; -#else - int nSrcLen = (lpsz != NULL) ? lstrlenA(lpsz) : 0; -#endif - if(AllocBeforeWrite(nSrcLen)) - { - _mbstowcsz(m_pchData, lpsz, nSrcLen + 1); - ReleaseBuffer(); - } - return *this; - } -#else // !_UNICODE - CString& operator =(LPCWSTR lpsz) - { - int nSrcLen = (lpsz != NULL) ? (int)wcslen(lpsz) : 0; - if(AllocBeforeWrite(nSrcLen * 2)) - { - _wcstombsz(m_pchData, lpsz, (nSrcLen * 2) + 1); - ReleaseBuffer(); - } - return *this; - } -#endif // !_UNICODE - - CString& operator =(const unsigned char* lpsz) - { - *this = (LPCSTR)lpsz; - return *this; - } - - // string concatenation - CString& operator +=(const CString& string) - { - ConcatInPlace(string.GetData()->nDataLength, string.m_pchData); - return *this; - } - - CString& operator +=(TCHAR ch) - { - ConcatInPlace(1, &ch); - return *this; - } - -#ifdef _UNICODE - CString& operator +=(char ch) - { - *this += (TCHAR)ch; - return *this; - } -#endif - - CString& operator +=(LPCTSTR lpsz) - { - ATLASSERT(lpsz == NULL || _IsValidString(lpsz)); - ConcatInPlace(SafeStrlen(lpsz), lpsz); - return *this; - } - - friend CString __stdcall operator +(const CString& string1, const CString& string2); - friend CString __stdcall operator +(const CString& string, TCHAR ch); - friend CString __stdcall operator +(TCHAR ch, const CString& string); -#ifdef _UNICODE - friend CString __stdcall operator +(const CString& string, char ch); - friend CString __stdcall operator +(char ch, const CString& string); -#endif - friend CString __stdcall operator +(const CString& string, LPCTSTR lpsz); - friend CString __stdcall operator +(LPCTSTR lpsz, const CString& string); - - // string comparison - int Compare(LPCTSTR lpsz) const // straight character (MBCS/Unicode aware) - { - return _cstrcmp(m_pchData, lpsz); - } - - int CompareNoCase(LPCTSTR lpsz) const // ignore case (MBCS/Unicode aware) - { - return _cstrcmpi(m_pchData, lpsz); - } - -#ifndef _WIN32_WCE - // CString::Collate is often slower than Compare but is MBSC/Unicode - // aware as well as locale-sensitive with respect to sort order. - int Collate(LPCTSTR lpsz) const // NLS aware - { - return _cstrcoll(m_pchData, lpsz); - } - - int CollateNoCase(LPCTSTR lpsz) const // ignore case - { - return _cstrcolli(m_pchData, lpsz); - } -#endif // !_WIN32_WCE - - // simple sub-string extraction - CString Mid(int nFirst, int nCount) const - { - // out-of-bounds requests return sensible things - if (nFirst < 0) - nFirst = 0; - if (nCount < 0) - nCount = 0; - - if (nFirst + nCount > GetData()->nDataLength) - nCount = GetData()->nDataLength - nFirst; - if (nFirst > GetData()->nDataLength) - nCount = 0; - - CString dest; - AllocCopy(dest, nCount, nFirst, 0); - return dest; - } - - CString Mid(int nFirst) const - { - return Mid(nFirst, GetData()->nDataLength - nFirst); - } - - CString Left(int nCount) const - { - if (nCount < 0) - nCount = 0; - else if (nCount > GetData()->nDataLength) - nCount = GetData()->nDataLength; - - CString dest; - AllocCopy(dest, nCount, 0, 0); - return dest; - } - - CString Right(int nCount) const - { - if (nCount < 0) - nCount = 0; - else if (nCount > GetData()->nDataLength) - nCount = GetData()->nDataLength; - - CString dest; - AllocCopy(dest, nCount, GetData()->nDataLength-nCount, 0); - return dest; - } - - CString SpanIncluding(LPCTSTR lpszCharSet) const // strspn equivalent - { - ATLASSERT(_IsValidString(lpszCharSet)); - return Left(_cstrspn(m_pchData, lpszCharSet)); - } - - CString SpanExcluding(LPCTSTR lpszCharSet) const // strcspn equivalent - { - ATLASSERT(_IsValidString(lpszCharSet)); - return Left(_cstrcspn(m_pchData, lpszCharSet)); - } - - // upper/lower/reverse conversion - void MakeUpper() - { - CopyBeforeWrite(); - CharUpper(m_pchData); - } - - void MakeLower() - { - CopyBeforeWrite(); - CharLower(m_pchData); - } - - void MakeReverse() - { - CopyBeforeWrite(); - _cstrrev(m_pchData); - } - - // trimming whitespace (either side) - void TrimRight() - { - CopyBeforeWrite(); - - // find beginning of trailing spaces by starting at beginning (DBCS aware) - LPTSTR lpsz = m_pchData; - LPTSTR lpszLast = NULL; - while (*lpsz != _T('\0')) - { - if (_cstrisspace(*lpsz)) - { - if (lpszLast == NULL) - lpszLast = lpsz; - } - else - { - lpszLast = NULL; - } - lpsz = ::CharNext(lpsz); - } - - if (lpszLast != NULL) - { - // truncate at trailing space start - *lpszLast = _T('\0'); - GetData()->nDataLength = (int)(DWORD_PTR)(lpszLast - m_pchData); - } - } - - void TrimLeft() - { - CopyBeforeWrite(); - - // find first non-space character - LPCTSTR lpsz = m_pchData; - while (_cstrisspace(*lpsz)) - lpsz = ::CharNext(lpsz); - - // fix up data and length - int nDataLength = GetData()->nDataLength - (int)(DWORD_PTR)(lpsz - m_pchData); - SecureHelper::memmove_x(m_pchData, (GetData()->nAllocLength + 1) * sizeof(TCHAR), lpsz, (nDataLength + 1) * sizeof(TCHAR)); - GetData()->nDataLength = nDataLength; - } - - // remove continuous occurrences of chTarget starting from right - void TrimRight(TCHAR chTarget) - { - // find beginning of trailing matches - // by starting at beginning (DBCS aware) - - CopyBeforeWrite(); - LPTSTR lpsz = m_pchData; - LPTSTR lpszLast = NULL; - - while (*lpsz != _T('\0')) - { - if (*lpsz == chTarget) - { - if (lpszLast == NULL) - lpszLast = lpsz; - } - else - lpszLast = NULL; - lpsz = ::CharNext(lpsz); - } - - if (lpszLast != NULL) - { - // truncate at left-most matching character - *lpszLast = _T('\0'); - GetData()->nDataLength = (int)(DWORD_PTR)(lpszLast - m_pchData); - } - } - - // remove continuous occcurrences of characters in passed string, starting from right - void TrimRight(LPCTSTR lpszTargetList) - { - // find beginning of trailing matches by starting at beginning (DBCS aware) - - CopyBeforeWrite(); - LPTSTR lpsz = m_pchData; - LPTSTR lpszLast = NULL; - - while (*lpsz != _T('\0')) - { - TCHAR* pNext = ::CharNext(lpsz); - if(pNext > lpsz + 1) - { - if (_cstrchr_db(lpszTargetList, *lpsz, *(lpsz + 1)) != NULL) - { - if (lpszLast == NULL) - lpszLast = lpsz; - } - else - { - lpszLast = NULL; - } - } - else - { - if (_cstrchr(lpszTargetList, *lpsz) != NULL) - { - if (lpszLast == NULL) - lpszLast = lpsz; - } - else - { - lpszLast = NULL; - } - } - - lpsz = pNext; - } - - if (lpszLast != NULL) - { - // truncate at left-most matching character - *lpszLast = _T('\0'); - GetData()->nDataLength = (int)(DWORD_PTR)(lpszLast - m_pchData); - } - } - - // remove continuous occurrences of chTarget starting from left - void TrimLeft(TCHAR chTarget) - { - // find first non-matching character - - CopyBeforeWrite(); - LPCTSTR lpsz = m_pchData; - - while (chTarget == *lpsz) - lpsz = ::CharNext(lpsz); - - if (lpsz != m_pchData) - { - // fix up data and length - int nDataLength = GetData()->nDataLength - (int)(DWORD_PTR)(lpsz - m_pchData); - SecureHelper::memmove_x(m_pchData, (GetData()->nAllocLength + 1) * sizeof(TCHAR), lpsz, (nDataLength + 1) * sizeof(TCHAR)); - GetData()->nDataLength = nDataLength; - } - } - - // remove continuous occcurrences of characters in passed string, starting from left - void TrimLeft(LPCTSTR lpszTargets) - { - // if we're not trimming anything, we're not doing any work - if (SafeStrlen(lpszTargets) == 0) - return; - - CopyBeforeWrite(); - LPCTSTR lpsz = m_pchData; - - while (*lpsz != _T('\0')) - { - TCHAR* pNext = ::CharNext(lpsz); - if(pNext > lpsz + 1) - { - if (_cstrchr_db(lpszTargets, *lpsz, *(lpsz + 1)) == NULL) - break; - } - else - { - if (_cstrchr(lpszTargets, *lpsz) == NULL) - break; - } - lpsz = pNext; - } - - if (lpsz != m_pchData) - { - // fix up data and length - int nDataLength = GetData()->nDataLength - (int)(DWORD_PTR)(lpsz - m_pchData); - SecureHelper::memmove_x(m_pchData, (GetData()->nAllocLength + 1) * sizeof(TCHAR), lpsz, (nDataLength + 1) * sizeof(TCHAR)); - GetData()->nDataLength = nDataLength; - } - } - - // advanced manipulation - // replace occurrences of chOld with chNew - int Replace(TCHAR chOld, TCHAR chNew) - { - int nCount = 0; - - // short-circuit the nop case - if (chOld != chNew) - { - // otherwise modify each character that matches in the string - CopyBeforeWrite(); - LPTSTR psz = m_pchData; - LPTSTR pszEnd = psz + GetData()->nDataLength; - while (psz < pszEnd) - { - // replace instances of the specified character only - if (*psz == chOld) - { - *psz = chNew; - nCount++; - } - psz = ::CharNext(psz); - } - } - return nCount; - } - - // replace occurrences of substring lpszOld with lpszNew; - // empty lpszNew removes instances of lpszOld - int Replace(LPCTSTR lpszOld, LPCTSTR lpszNew) - { - // can't have empty or NULL lpszOld - - int nSourceLen = SafeStrlen(lpszOld); - if (nSourceLen == 0) - return 0; - int nReplacementLen = SafeStrlen(lpszNew); - - // loop once to figure out the size of the result string - int nCount = 0; - LPTSTR lpszStart = m_pchData; - LPTSTR lpszEnd = m_pchData + GetData()->nDataLength; - LPTSTR lpszTarget = NULL; - while (lpszStart < lpszEnd) - { - while ((lpszTarget = (TCHAR*)_cstrstr(lpszStart, lpszOld)) != NULL) - { - nCount++; - lpszStart = lpszTarget + nSourceLen; - } - lpszStart += lstrlen(lpszStart) + 1; - } - - // if any changes were made, make them - if (nCount > 0) - { - CopyBeforeWrite(); - - // if the buffer is too small, just allocate a new buffer (slow but sure) - int nOldLength = GetData()->nDataLength; - int nNewLength = nOldLength + (nReplacementLen - nSourceLen) * nCount; - if (GetData()->nAllocLength < nNewLength || GetData()->nRefs > 1) - { - CStringData* pOldData = GetData(); - LPTSTR pstr = m_pchData; - if(!AllocBuffer(nNewLength)) - return -1; - SecureHelper::memcpy_x(m_pchData, (nNewLength + 1) * sizeof(TCHAR), pstr, pOldData->nDataLength * sizeof(TCHAR)); - CString::Release(pOldData); - } - // else, we just do it in-place - lpszStart = m_pchData; - lpszEnd = m_pchData + GetData()->nDataLength; - - // loop again to actually do the work - while (lpszStart < lpszEnd) - { - while ((lpszTarget = (TCHAR*)_cstrstr(lpszStart, lpszOld)) != NULL) - { - int nBalance = nOldLength - ((int)(DWORD_PTR)(lpszTarget - m_pchData) + nSourceLen); - int cchBuffLen = GetData()->nAllocLength - (int)(DWORD_PTR)(lpszTarget - m_pchData); - SecureHelper::memmove_x(lpszTarget + nReplacementLen, (cchBuffLen - nReplacementLen + 1) * sizeof(TCHAR), lpszTarget + nSourceLen, nBalance * sizeof(TCHAR)); - SecureHelper::memcpy_x(lpszTarget, (cchBuffLen + 1) * sizeof(TCHAR), lpszNew, nReplacementLen * sizeof(TCHAR)); - lpszStart = lpszTarget + nReplacementLen; - lpszStart[nBalance] = _T('\0'); - nOldLength += (nReplacementLen - nSourceLen); - } - lpszStart += lstrlen(lpszStart) + 1; - } - ATLASSERT(m_pchData[nNewLength] == _T('\0')); - GetData()->nDataLength = nNewLength; - } - - return nCount; - } - - // remove occurrences of chRemove - int Remove(TCHAR chRemove) - { - CopyBeforeWrite(); - - LPTSTR pstrSource = m_pchData; - LPTSTR pstrDest = m_pchData; - LPTSTR pstrEnd = m_pchData + GetData()->nDataLength; - - while (pstrSource < pstrEnd) - { - if (*pstrSource != chRemove) - { - *pstrDest = *pstrSource; - pstrDest = ::CharNext(pstrDest); - } - pstrSource = ::CharNext(pstrSource); - } - *pstrDest = _T('\0'); - int nCount = (int)(DWORD_PTR)(pstrSource - pstrDest); - GetData()->nDataLength -= nCount; - - return nCount; - } - - // insert character at zero-based index; concatenates if index is past end of string - int Insert(int nIndex, TCHAR ch) - { - CopyBeforeWrite(); - - if (nIndex < 0) - nIndex = 0; - - int nNewLength = GetData()->nDataLength; - if (nIndex > nNewLength) - nIndex = nNewLength; - nNewLength++; - - if (GetData()->nAllocLength < nNewLength) - { - CStringData* pOldData = GetData(); - LPTSTR pstr = m_pchData; - if(!AllocBuffer(nNewLength)) - return -1; - SecureHelper::memcpy_x(m_pchData, (nNewLength + 1) * sizeof(TCHAR), pstr, (pOldData->nDataLength + 1) * sizeof(TCHAR)); - CString::Release(pOldData); - } - - // move existing bytes down - SecureHelper::memmove_x(m_pchData + nIndex + 1, (GetData()->nAllocLength - nIndex) * sizeof(TCHAR), m_pchData + nIndex, (nNewLength - nIndex) * sizeof(TCHAR)); - m_pchData[nIndex] = ch; - GetData()->nDataLength = nNewLength; - - return nNewLength; - } - - // insert substring at zero-based index; concatenates if index is past end of string - int Insert(int nIndex, LPCTSTR pstr) - { - if (nIndex < 0) - nIndex = 0; - - int nInsertLength = SafeStrlen(pstr); - int nNewLength = GetData()->nDataLength; - if (nInsertLength > 0) - { - CopyBeforeWrite(); - if (nIndex > nNewLength) - nIndex = nNewLength; - nNewLength += nInsertLength; - - if (GetData()->nAllocLength < nNewLength) - { - CStringData* pOldData = GetData(); - LPTSTR pstrTmp = m_pchData; - if(!AllocBuffer(nNewLength)) - return -1; - SecureHelper::memcpy_x(m_pchData, (nNewLength + 1) * sizeof(TCHAR), pstrTmp, (pOldData->nDataLength + 1) * sizeof(TCHAR)); - CString::Release(pOldData); - } - - // move existing bytes down - SecureHelper::memmove_x(m_pchData + nIndex + nInsertLength, (GetData()->nAllocLength + 1 - nIndex - nInsertLength) * sizeof(TCHAR), m_pchData + nIndex, (nNewLength - nIndex - nInsertLength + 1) * sizeof(TCHAR)); - SecureHelper::memcpy_x(m_pchData + nIndex, (GetData()->nAllocLength + 1 - nIndex) * sizeof(TCHAR), pstr, nInsertLength * sizeof(TCHAR)); - GetData()->nDataLength = nNewLength; - } - - return nNewLength; - } - - // delete nCount characters starting at zero-based index - int Delete(int nIndex, int nCount = 1) - { - if (nIndex < 0) - nIndex = 0; - int nLength = GetData()->nDataLength; - if (nCount > 0 && nIndex < nLength) - { - if((nIndex + nCount) > nLength) - nCount = nLength - nIndex; - CopyBeforeWrite(); - int nBytesToCopy = nLength - (nIndex + nCount) + 1; - - SecureHelper::memmove_x(m_pchData + nIndex, (GetData()->nAllocLength + 1 - nIndex) * sizeof(TCHAR), m_pchData + nIndex + nCount, nBytesToCopy * sizeof(TCHAR)); - nLength -= nCount; - GetData()->nDataLength = nLength; - } - - return nLength; - } - - // searching (return starting index, or -1 if not found) - // look for a single character match - int Find(TCHAR ch) const // like "C" strchr - { - return Find(ch, 0); - } - - int ReverseFind(TCHAR ch) const - { - // find last single character - LPCTSTR lpsz = _cstrrchr(m_pchData, (_TUCHAR)ch); - - // return -1 if not found, distance from beginning otherwise - return (lpsz == NULL) ? -1 : (int)(lpsz - m_pchData); - } - - int Find(TCHAR ch, int nStart) const // starting at index - { - int nLength = GetData()->nDataLength; - if (nStart < 0 || nStart >= nLength) - return -1; - - // find first single character - LPCTSTR lpsz = _cstrchr(m_pchData + nStart, (_TUCHAR)ch); - - // return -1 if not found and index otherwise - return (lpsz == NULL) ? -1 : (int)(lpsz - m_pchData); - } - - int FindOneOf(LPCTSTR lpszCharSet) const - { - ATLASSERT(_IsValidString(lpszCharSet)); - LPCTSTR lpsz = _cstrpbrk(m_pchData, lpszCharSet); - return (lpsz == NULL) ? -1 : (int)(lpsz - m_pchData); - } - - // look for a specific sub-string - // find a sub-string (like strstr) - int Find(LPCTSTR lpszSub) const // like "C" strstr - { - return Find(lpszSub, 0); - } - - int Find(LPCTSTR lpszSub, int nStart) const // starting at index - { - ATLASSERT(_IsValidString(lpszSub)); - - int nLength = GetData()->nDataLength; - if (nStart < 0 || nStart > nLength) - return -1; - - // find first matching substring - LPCTSTR lpsz = _cstrstr(m_pchData + nStart, lpszSub); - - // return -1 for not found, distance from beginning otherwise - return (lpsz == NULL) ? -1 : (int)(lpsz - m_pchData); - } - - // Concatentation for non strings - CString& Append(int n) - { - const int cchBuff = 12; - TCHAR szBuffer[cchBuff] = { 0 }; - SecureHelper::wsprintf_x(szBuffer, cchBuff, _T("%d"), n); - ConcatInPlace(SafeStrlen(szBuffer), szBuffer); - return *this; - } - - // simple formatting - // formatting (using wsprintf style formatting) - BOOL __cdecl Format(LPCTSTR lpszFormat, ...) - { - ATLASSERT(_IsValidString(lpszFormat)); - - va_list argList; - va_start(argList, lpszFormat); - BOOL bRet = FormatV(lpszFormat, argList); - va_end(argList); - return bRet; - } - - BOOL __cdecl Format(UINT nFormatID, ...) - { - CString strFormat; - BOOL bRet = strFormat.LoadString(nFormatID); - ATLASSERT(bRet != 0); - - va_list argList; - va_start(argList, nFormatID); - bRet = FormatV(strFormat, argList); - va_end(argList); - return bRet; - } - - BOOL FormatV(LPCTSTR lpszFormat, va_list argList) - { - ATLASSERT(_IsValidString(lpszFormat)); - - enum _FormatModifiers - { - FORCE_ANSI = 0x10000, - FORCE_UNICODE = 0x20000, - FORCE_INT64 = 0x40000 - }; - - va_list argListSave = argList; - - // make a guess at the maximum length of the resulting string - int nMaxLen = 0; - for (LPCTSTR lpsz = lpszFormat; *lpsz != _T('\0'); lpsz = ::CharNext(lpsz)) - { - // handle '%' character, but watch out for '%%' - if (*lpsz != _T('%') || *(lpsz = ::CharNext(lpsz)) == _T('%')) - { - nMaxLen += (int)(::CharNext(lpsz) - lpsz); - continue; - } - - int nItemLen = 0; - - // handle '%' character with format - int nWidth = 0; - for (; *lpsz != _T('\0'); lpsz = ::CharNext(lpsz)) - { - // check for valid flags - if (*lpsz == _T('#')) - nMaxLen += 2; // for '0x' - else if (*lpsz == _T('*')) - nWidth = va_arg(argList, int); - else if (*lpsz == _T('-') || *lpsz == _T('+') || *lpsz == _T('0') || *lpsz == _T(' ')) - ; - else // hit non-flag character - break; - } - // get width and skip it - if (nWidth == 0) - { - // width indicated by - nWidth = _cstrtoi(lpsz); - for (; *lpsz != _T('\0') && _cstrisdigit(*lpsz); lpsz = ::CharNext(lpsz)) - ; - } - ATLASSERT(nWidth >= 0); - - int nPrecision = 0; - if (*lpsz == _T('.')) - { - // skip past '.' separator (width.precision) - lpsz = ::CharNext(lpsz); - - // get precision and skip it - if (*lpsz == _T('*')) - { - nPrecision = va_arg(argList, int); - lpsz = ::CharNext(lpsz); - } - else - { - nPrecision = _cstrtoi(lpsz); - for (; *lpsz != _T('\0') && _cstrisdigit(*lpsz); lpsz = ::CharNext(lpsz)) - ; - } - ATLASSERT(nPrecision >= 0); - } - - // should be on type modifier or specifier - int nModifier = 0; - if(lpsz[0] == _T('I')) - { - if((lpsz[1] == _T('6')) && (lpsz[2] == _T('4'))) - { - lpsz += 3; - nModifier = FORCE_INT64; - } - else if((lpsz[1] == _T('3')) && (lpsz[2] == _T('2'))) - { - lpsz += 3; - } - else - { - lpsz++; - if(sizeof(size_t) == 8) - nModifier = FORCE_INT64; - } - } - else - { - switch (*lpsz) - { - // modifiers that affect size - case _T('h'): - nModifier = FORCE_ANSI; - lpsz = ::CharNext(lpsz); - break; - case _T('l'): - nModifier = FORCE_UNICODE; - lpsz = ::CharNext(lpsz); - break; - - // modifiers that do not affect size - case _T('F'): - case _T('N'): - case _T('L'): - lpsz = ::CharNext(lpsz); - break; - } - } - - // now should be on specifier - switch (*lpsz | nModifier) - { - // single characters - case _T('c'): - case _T('C'): - nItemLen = 2; - va_arg(argList, TCHAR); - break; - case _T('c') | FORCE_ANSI: - case _T('C') | FORCE_ANSI: - nItemLen = 2; - va_arg(argList, char); - break; - case _T('c') | FORCE_UNICODE: - case _T('C') | FORCE_UNICODE: - nItemLen = 2; - va_arg(argList, WCHAR); - break; - - // strings - case _T('s'): - { - LPCTSTR pstrNextArg = va_arg(argList, LPCTSTR); - if (pstrNextArg == NULL) - { - nItemLen = 6; // "(null)" - } - else - { - nItemLen = lstrlen(pstrNextArg); - nItemLen = __max(1, nItemLen); - } - break; - } - - case _T('S'): - { -#ifndef _UNICODE - LPWSTR pstrNextArg = va_arg(argList, LPWSTR); - if (pstrNextArg == NULL) - { - nItemLen = 6; // "(null)" - } - else - { - nItemLen = (int)wcslen(pstrNextArg); - nItemLen = __max(1, nItemLen); - } -#else // _UNICODE - LPCSTR pstrNextArg = va_arg(argList, LPCSTR); - if (pstrNextArg == NULL) - { - nItemLen = 6; // "(null)" - } - else - { -#if defined(_WIN32_WCE) && (_ATL_VER >= 0x0800) - nItemLen = ATL::lstrlenA(pstrNextArg); -#else - nItemLen = lstrlenA(pstrNextArg); -#endif - nItemLen = __max(1, nItemLen); - } -#endif // _UNICODE - break; - } - - case _T('s') | FORCE_ANSI: - case _T('S') | FORCE_ANSI: - { - LPCSTR pstrNextArg = va_arg(argList, LPCSTR); - if (pstrNextArg == NULL) - { - nItemLen = 6; // "(null)" - } - else - { -#if defined(_WIN32_WCE) && (_ATL_VER >= 0x0800) - nItemLen = ATL::lstrlenA(pstrNextArg); -#else - nItemLen = lstrlenA(pstrNextArg); -#endif - nItemLen = __max(1, nItemLen); - } - break; - } - - case _T('s') | FORCE_UNICODE: - case _T('S') | FORCE_UNICODE: - { - LPWSTR pstrNextArg = va_arg(argList, LPWSTR); - if (pstrNextArg == NULL) - { - nItemLen = 6; // "(null)" - } - else - { - nItemLen = (int)wcslen(pstrNextArg); - nItemLen = __max(1, nItemLen); - } - break; - } - } - - // adjust nItemLen for strings - if (nItemLen != 0) - { - nItemLen = __max(nItemLen, nWidth); - if (nPrecision != 0) - nItemLen = __min(nItemLen, nPrecision); - } - else - { - switch (*lpsz) - { - // integers - case _T('d'): - case _T('i'): - case _T('u'): - case _T('x'): - case _T('X'): - case _T('o'): - if (nModifier & FORCE_INT64) - va_arg(argList, __int64); - else - va_arg(argList, int); - nItemLen = 32; - nItemLen = __max(nItemLen, nWidth + nPrecision); - break; - -#ifndef _ATL_USE_CSTRING_FLOAT - case _T('e'): - case _T('E'): - case _T('f'): - case _T('g'): - case _T('G'): - ATLASSERT(!"Floating point (%%e, %%E, %%f, %%g, and %%G) is not supported by the WTL::CString class."); -#ifndef _DEBUG - ::OutputDebugString(_T("Floating point (%%e, %%f, %%g, and %%G) is not supported by the WTL::CString class.")); -#ifndef _WIN32_WCE - ::DebugBreak(); -#else // CE specific - DebugBreak(); -#endif // _WIN32_WCE -#endif // !_DEBUG - break; -#else // _ATL_USE_CSTRING_FLOAT - case _T('e'): - case _T('E'): - case _T('g'): - case _T('G'): - va_arg(argList, double); - nItemLen = 128; - nItemLen = __max(nItemLen, nWidth + nPrecision); - break; - case _T('f'): - { - double f = va_arg(argList, double); - // 312 == strlen("-1+(309 zeroes).") - // 309 zeroes == max precision of a double - // 6 == adjustment in case precision is not specified, - // which means that the precision defaults to 6 - int cchLen = __max(nWidth, 312 + nPrecision + 6); - CTempBuffer buff; - LPTSTR pszTemp = buff.Allocate(cchLen); - if(pszTemp != NULL) - { - SecureHelper::sprintf_x(pszTemp, cchLen, _T("%*.*f"), nWidth, nPrecision + 6, f); - nItemLen = (int)_tcslen(pszTemp); - } - else - { - nItemLen = cchLen; - } - } - break; -#endif // _ATL_USE_CSTRING_FLOAT - - case _T('p'): - va_arg(argList, void*); - nItemLen = 32; - nItemLen = __max(nItemLen, nWidth + nPrecision); - break; - - // no output - case _T('n'): - va_arg(argList, int*); - break; - - default: - ATLASSERT(FALSE); // unknown formatting option - } - } - - // adjust nMaxLen for output nItemLen - nMaxLen += nItemLen; - } - - if(GetBuffer(nMaxLen) == NULL) - return FALSE; -#ifndef _ATL_USE_CSTRING_FLOAT - int nRet = SecureHelper::wvsprintf_x(m_pchData, GetAllocLength() + 1, lpszFormat, argListSave); -#else // _ATL_USE_CSTRING_FLOAT - int nRet = SecureHelper::vsprintf_x(m_pchData, GetAllocLength() + 1, lpszFormat, argListSave); -#endif // _ATL_USE_CSTRING_FLOAT - nRet; // ref - ATLASSERT(nRet <= GetAllocLength()); - ReleaseBuffer(); - - va_end(argListSave); - return TRUE; - } - - // formatting for localization (uses FormatMessage API) - // formatting (using FormatMessage style formatting) - BOOL __cdecl FormatMessage(LPCTSTR lpszFormat, ...) - { - // format message into temporary buffer lpszTemp - va_list argList; - va_start(argList, lpszFormat); - LPTSTR lpszTemp = NULL; - BOOL bRet = TRUE; - - if ((::FormatMessage(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ALLOCATE_BUFFER, - lpszFormat, 0, 0, (LPTSTR)&lpszTemp, 0, &argList) == 0) || (lpszTemp == NULL)) - bRet = FALSE; - - // assign lpszTemp into the resulting string and free the temporary - *this = lpszTemp; - LocalFree(lpszTemp); - va_end(argList); - return bRet; - } - - BOOL __cdecl FormatMessage(UINT nFormatID, ...) - { - // get format string from string table - CString strFormat; - BOOL bRetTmp = strFormat.LoadString(nFormatID); - bRetTmp; // ref - ATLASSERT(bRetTmp != 0); - - // format message into temporary buffer lpszTemp - va_list argList; - va_start(argList, nFormatID); - LPTSTR lpszTemp = NULL; - BOOL bRet = TRUE; - - if ((::FormatMessage(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ALLOCATE_BUFFER, - strFormat, 0, 0, (LPTSTR)&lpszTemp, 0, &argList) == 0) || (lpszTemp == NULL)) - bRet = FALSE; - - // assign lpszTemp into the resulting string and free lpszTemp - *this = lpszTemp; - LocalFree(lpszTemp); - va_end(argList); - return bRet; - } - - // Windows support - BOOL LoadString(UINT nID) // load from string resource (255 chars max.) - { -#ifdef _UNICODE - const int CHAR_FUDGE = 1; // one TCHAR unused is good enough -#else - const int CHAR_FUDGE = 2; // two BYTES unused for case of DBC last char -#endif - - // try fixed buffer first (to avoid wasting space in the heap) - TCHAR szTemp[256] = { 0 }; - int nCount = sizeof(szTemp) / sizeof(szTemp[0]); - int nLen = _LoadString(nID, szTemp, nCount); - if (nCount - nLen > CHAR_FUDGE) - { - *this = szTemp; - return (nLen > 0); - } - - // try buffer size of 512, then larger size until entire string is retrieved - int nSize = 256; - do - { - nSize += 256; - LPTSTR lpstr = GetBuffer(nSize - 1); - if(lpstr == NULL) - { - nLen = 0; - break; - } - nLen = _LoadString(nID, lpstr, nSize); - } while (nSize - nLen <= CHAR_FUDGE); - ReleaseBuffer(); - - return (nLen > 0); - } - -#ifndef _UNICODE - // ANSI <-> OEM support (convert string in place) - void AnsiToOem() - { - CopyBeforeWrite(); - ::AnsiToOem(m_pchData, m_pchData); - } - - void OemToAnsi() - { - CopyBeforeWrite(); - ::OemToAnsi(m_pchData, m_pchData); - } -#endif - -#ifndef _ATL_NO_COM - // OLE BSTR support (use for OLE automation) - BSTR AllocSysString() const - { -#if defined(_UNICODE) || defined(OLE2ANSI) - BSTR bstr = ::SysAllocStringLen(m_pchData, GetData()->nDataLength); -#else - int nLen = MultiByteToWideChar(CP_ACP, 0, m_pchData, - GetData()->nDataLength, NULL, NULL); - BSTR bstr = ::SysAllocStringLen(NULL, nLen); - if(bstr != NULL) - MultiByteToWideChar(CP_ACP, 0, m_pchData, GetData()->nDataLength, bstr, nLen); -#endif - return bstr; - } - - BSTR SetSysString(BSTR* pbstr) const - { -#if defined(_UNICODE) || defined(OLE2ANSI) - ::SysReAllocStringLen(pbstr, m_pchData, GetData()->nDataLength); -#else - int nLen = MultiByteToWideChar(CP_ACP, 0, m_pchData, - GetData()->nDataLength, NULL, NULL); - if(::SysReAllocStringLen(pbstr, NULL, nLen)) - MultiByteToWideChar(CP_ACP, 0, m_pchData, GetData()->nDataLength, *pbstr, nLen); -#endif - ATLASSERT(*pbstr != NULL); - return *pbstr; - } -#endif // !_ATL_NO_COM - - // Access to string implementation buffer as "C" character array - LPTSTR GetBuffer(int nMinBufLength) - { - ATLASSERT(nMinBufLength >= 0); - - if (GetData()->nRefs > 1 || nMinBufLength > GetData()->nAllocLength) - { - // we have to grow the buffer - CStringData* pOldData = GetData(); - int nOldLen = GetData()->nDataLength; // AllocBuffer will tromp it - if (nMinBufLength < nOldLen) - nMinBufLength = nOldLen; - - if(!AllocBuffer(nMinBufLength)) - return NULL; - - SecureHelper::memcpy_x(m_pchData, (nMinBufLength + 1) * sizeof(TCHAR), pOldData->data(), (nOldLen + 1) * sizeof(TCHAR)); - GetData()->nDataLength = nOldLen; - CString::Release(pOldData); - } - ATLASSERT(GetData()->nRefs <= 1); - - // return a pointer to the character storage for this string - ATLASSERT(m_pchData != NULL); - return m_pchData; - } - - void ReleaseBuffer(int nNewLength = -1) - { - CopyBeforeWrite(); // just in case GetBuffer was not called - - if (nNewLength == -1) - nNewLength = lstrlen(m_pchData); // zero terminated - - ATLASSERT(nNewLength <= GetData()->nAllocLength); - GetData()->nDataLength = nNewLength; - m_pchData[nNewLength] = _T('\0'); - } - - LPTSTR GetBufferSetLength(int nNewLength) - { - ATLASSERT(nNewLength >= 0); - - if(GetBuffer(nNewLength) == NULL) - return NULL; - - GetData()->nDataLength = nNewLength; - m_pchData[nNewLength] = _T('\0'); - return m_pchData; - } - - void FreeExtra() - { - ATLASSERT(GetData()->nDataLength <= GetData()->nAllocLength); - if (GetData()->nDataLength != GetData()->nAllocLength) - { - CStringData* pOldData = GetData(); - if(AllocBuffer(GetData()->nDataLength)) - { - SecureHelper::memcpy_x(m_pchData, (GetData()->nAllocLength + 1) * sizeof(TCHAR), pOldData->data(), pOldData->nDataLength * sizeof(TCHAR)); - ATLASSERT(m_pchData[GetData()->nDataLength] == _T('\0')); - CString::Release(pOldData); - } - } - ATLASSERT(GetData() != NULL); - } - - // Use LockBuffer/UnlockBuffer to turn refcounting off - LPTSTR LockBuffer() - { - LPTSTR lpsz = GetBuffer(0); - if(lpsz != NULL) - GetData()->nRefs = -1; - return lpsz; - } - - void UnlockBuffer() - { - ATLASSERT(GetData()->nRefs == -1); - if (GetData() != _atltmpDataNil) - GetData()->nRefs = 1; - } - -// Implementation -public: - ~CString() // free any attached data - { - if (GetData() != _atltmpDataNil) - { - if (InterlockedDecrement(&GetData()->nRefs) <= 0) - delete[] (BYTE*)GetData(); - } - } - - int GetAllocLength() const - { - return GetData()->nAllocLength; - } - - static BOOL __stdcall _IsValidString(LPCTSTR lpsz, int /*nLength*/ = -1) - { - return (lpsz != NULL) ? TRUE : FALSE; - } - -protected: - LPTSTR m_pchData; // pointer to ref counted string data - - // implementation helpers - CStringData* GetData() const - { - ATLASSERT(m_pchData != NULL); - return ((CStringData*)m_pchData) - 1; - } - - void Init() - { - m_pchData = _GetEmptyString().m_pchData; - } - - BOOL AllocCopy(CString& dest, int nCopyLen, int nCopyIndex, int nExtraLen) const - { - // will clone the data attached to this string - // allocating 'nExtraLen' characters - // Places results in uninitialized string 'dest' - // Will copy the part or all of original data to start of new string - - BOOL bRet = FALSE; - int nNewLen = nCopyLen + nExtraLen; - if (nNewLen == 0) - { - dest.Init(); - bRet = TRUE; - } - else if(nNewLen >= nCopyLen) - { - if(dest.AllocBuffer(nNewLen)) - { - SecureHelper::memcpy_x(dest.m_pchData, (nNewLen + 1) * sizeof(TCHAR), m_pchData + nCopyIndex, nCopyLen * sizeof(TCHAR)); - bRet = TRUE; - } - } - - return bRet; - } - - // always allocate one extra character for '\0' termination - // assumes [optimistically] that data length will equal allocation length - BOOL AllocBuffer(int nLen) - { - ATLASSERT(nLen >= 0); - ATLASSERT(nLen <= INT_MAX - 1); // max size (enough room for 1 extra) - - if (nLen == 0) - { - Init(); - } - else - { - CStringData* pData = NULL; - ATLTRY(pData = (CStringData*)new BYTE[sizeof(CStringData) + (nLen + 1) * sizeof(TCHAR)]); - if(pData == NULL) - return FALSE; - - pData->nRefs = 1; - pData->data()[nLen] = _T('\0'); - pData->nDataLength = nLen; - pData->nAllocLength = nLen; - m_pchData = pData->data(); - } - - return TRUE; - } - - // Assignment operators - // All assign a new value to the string - // (a) first see if the buffer is big enough - // (b) if enough room, copy on top of old buffer, set size and type - // (c) otherwise free old string data, and create a new one - // - // All routines return the new string (but as a 'const CString&' so that - // assigning it again will cause a copy, eg: s1 = s2 = "hi there". - // - void AssignCopy(int nSrcLen, LPCTSTR lpszSrcData) - { - if(AllocBeforeWrite(nSrcLen)) - { - SecureHelper::memcpy_x(m_pchData, (nSrcLen + 1) * sizeof(TCHAR), lpszSrcData, nSrcLen * sizeof(TCHAR)); - GetData()->nDataLength = nSrcLen; - m_pchData[nSrcLen] = _T('\0'); - } - } - - // Concatenation - // NOTE: "operator +" is done as friend functions for simplicity - // There are three variants: - // CString + CString - // and for ? = TCHAR, LPCTSTR - // CString + ? - // ? + CString - BOOL ConcatCopy(int nSrc1Len, LPCTSTR lpszSrc1Data, int nSrc2Len, LPCTSTR lpszSrc2Data) - { - // -- master concatenation routine - // Concatenate two sources - // -- assume that 'this' is a new CString object - - BOOL bRet = TRUE; - int nNewLen = nSrc1Len + nSrc2Len; - if(nNewLen < nSrc1Len || nNewLen < nSrc2Len) - { - bRet = FALSE; - } - else if(nNewLen != 0) - { - bRet = AllocBuffer(nNewLen); - if (bRet) - { - SecureHelper::memcpy_x(m_pchData, (nNewLen + 1) * sizeof(TCHAR), lpszSrc1Data, nSrc1Len * sizeof(TCHAR)); - SecureHelper::memcpy_x(m_pchData + nSrc1Len, (nNewLen + 1 - nSrc1Len) * sizeof(TCHAR), lpszSrc2Data, nSrc2Len * sizeof(TCHAR)); - } - } - return bRet; - } - - void ConcatInPlace(int nSrcLen, LPCTSTR lpszSrcData) - { - // -- the main routine for += operators - - // concatenating an empty string is a no-op! - if (nSrcLen == 0) - return; - - // if the buffer is too small, or we have a width mis-match, just - // allocate a new buffer (slow but sure) - if (GetData()->nRefs > 1 || GetData()->nDataLength + nSrcLen > GetData()->nAllocLength) - { - // we have to grow the buffer, use the ConcatCopy routine - CStringData* pOldData = GetData(); - if (ConcatCopy(GetData()->nDataLength, m_pchData, nSrcLen, lpszSrcData)) - { - ATLASSERT(pOldData != NULL); - CString::Release(pOldData); - } - } - else - { - // fast concatenation when buffer big enough - SecureHelper::memcpy_x(m_pchData + GetData()->nDataLength, (GetData()->nAllocLength + 1) * sizeof(TCHAR), lpszSrcData, nSrcLen * sizeof(TCHAR)); - GetData()->nDataLength += nSrcLen; - ATLASSERT(GetData()->nDataLength <= GetData()->nAllocLength); - m_pchData[GetData()->nDataLength] = _T('\0'); - } - } - - void CopyBeforeWrite() - { - if (GetData()->nRefs > 1) - { - CStringData* pData = GetData(); - Release(); - if(AllocBuffer(pData->nDataLength)) - SecureHelper::memcpy_x(m_pchData, (GetData()->nAllocLength + 1) * sizeof(TCHAR), pData->data(), (pData->nDataLength + 1) * sizeof(TCHAR)); - } - ATLASSERT(GetData()->nRefs <= 1); - } - - BOOL AllocBeforeWrite(int nLen) - { - BOOL bRet = TRUE; - if (GetData()->nRefs > 1 || nLen > GetData()->nAllocLength) - { - Release(); - bRet = AllocBuffer(nLen); - } - ATLASSERT(GetData()->nRefs <= 1); - return bRet; - } - - void Release() - { - if (GetData() != _atltmpDataNil) - { - ATLASSERT(GetData()->nRefs != 0); - if (InterlockedDecrement(&GetData()->nRefs) <= 0) - delete[] (BYTE*)GetData(); - Init(); - } - } - - static void PASCAL Release(CStringData* pData) - { - if (pData != _atltmpDataNil) - { - ATLASSERT(pData->nRefs != 0); - if (InterlockedDecrement(&pData->nRefs) <= 0) - delete[] (BYTE*)pData; - } - } - - static int PASCAL SafeStrlen(LPCTSTR lpsz) - { - return (lpsz == NULL) ? 0 : lstrlen(lpsz); - } - - static int __stdcall _LoadString(UINT nID, LPTSTR lpszBuf, UINT nMaxBuf) - { -#ifdef _DEBUG - // LoadString without annoying warning from the Debug kernel if the - // segment containing the string is not present - if (::FindResource(ModuleHelper::GetResourceInstance(), MAKEINTRESOURCE((nID >> 4) + 1), RT_STRING) == NULL) - { - lpszBuf[0] = _T('\0'); - return 0; // not found - } -#endif // _DEBUG - - int nLen = ::LoadString(ModuleHelper::GetResourceInstance(), nID, lpszBuf, nMaxBuf); - if (nLen == 0) - lpszBuf[0] = _T('\0'); - - return nLen; - } - - static const CString& __stdcall _GetEmptyString() - { - return *(CString*)&_atltmpPchNil; - } - -// CString conversion helpers - static int __cdecl _wcstombsz(char* mbstr, const wchar_t* wcstr, size_t count) - { - if (count == 0 && mbstr != NULL) - return 0; - - int result = ::WideCharToMultiByte(CP_ACP, 0, wcstr, -1, mbstr, (int)count, NULL, NULL); - ATLASSERT(mbstr == NULL || result <= (int)count); - if ((mbstr != NULL) && (result > 0)) - mbstr[result - 1] = 0; - return result; - } - - static int __cdecl _mbstowcsz(wchar_t* wcstr, const char* mbstr, size_t count) - { - if (count == 0 && wcstr != NULL) - return 0; - - int result = ::MultiByteToWideChar(CP_ACP, 0, mbstr, -1, wcstr, (int)count); - ATLASSERT(wcstr == NULL || result <= (int)count); - if ((wcstr != NULL) && (result > 0)) - wcstr[result - 1] = 0; - return result; - } - -// Helpers to avoid CRT startup code -#ifdef _ATL_MIN_CRT - static const TCHAR* _cstrchr(const TCHAR* p, TCHAR ch) - { - // strchr for '\0' should succeed - while (*p != 0) - { - if (*p == ch) - break; - p = ::CharNext(p); - } - return (*p == ch) ? p : NULL; - } - - static TCHAR* _cstrrev(TCHAR* pStr) - { - // optimize NULL, zero-length, and single-char case - if ((pStr == NULL) || (pStr[0] == _T('\0')) || (pStr[1] == _T('\0'))) - return pStr; - - TCHAR* p = pStr; - - while (*p != 0) - { - TCHAR* pNext = ::CharNext(p); - if(pNext > p + 1) - { - char p1 = *(char*)p; - *(char*)p = *(char*)(p + 1); - *(char*)(p + 1) = p1; - } - p = pNext; - } - - p--; - TCHAR* q = pStr; - - while (q < p) - { - TCHAR t = *q; - *q = *p; - *p = t; - q++; - p--; - } - return pStr; - } - - static const TCHAR* _cstrstr(const TCHAR* pStr, const TCHAR* pCharSet) - { - int nLen = lstrlen(pCharSet); - if (nLen == 0) - return (TCHAR*)pStr; - - const TCHAR* pRet = NULL; - const TCHAR* pCur = pStr; - while((pCur = _cstrchr(pCur, *pCharSet)) != NULL) - { - if(memcmp(pCur, pCharSet, nLen * sizeof(TCHAR)) == 0) - { - pRet = pCur; - break; - } - pCur = ::CharNext(pCur); - } - return pRet; - } - - static int _cstrspn(const TCHAR* pStr, const TCHAR* pCharSet) - { - int nRet = 0; - const TCHAR* p = pStr; - while (*p != 0) - { - const TCHAR* pNext = ::CharNext(p); - if(pNext > p + 1) - { - if(_cstrchr_db(pCharSet, *p, *(p + 1)) == NULL) - break; - nRet += 2; - } - else - { - if(_cstrchr(pCharSet, *p) == NULL) - break; - nRet++; - } - p = pNext; - } - return nRet; - } - - static int _cstrcspn(const TCHAR* pStr, const TCHAR* pCharSet) - { - int nRet = 0; - TCHAR* p = (TCHAR*)pStr; - while (*p != 0) - { - TCHAR* pNext = ::CharNext(p); - if(pNext > p + 1) - { - if(_cstrchr_db(pCharSet, *p, *(p + 1)) != NULL) - break; - nRet += 2; - } - else - { - if(_cstrchr(pCharSet, *p) != NULL) - break; - nRet++; - } - p = pNext; - } - return nRet; - } - - static const TCHAR* _cstrpbrk(const TCHAR* p, const TCHAR* lpszCharSet) - { - int n = _cstrcspn(p, lpszCharSet); - return (p[n] != 0) ? &p[n] : NULL; - } - - static int _cstrcmp(const TCHAR* pstrOne, const TCHAR* pstrOther) - { - return lstrcmp(pstrOne, pstrOther); - } - - static int _cstrcmpi(const TCHAR* pstrOne, const TCHAR* pstrOther) - { - return lstrcmpi(pstrOne, pstrOther); - } - - static int _cstrcoll(const TCHAR* pstrOne, const TCHAR* pstrOther) - { - int nRet = CompareString(GetThreadLocale(), 0, pstrOne, -1, pstrOther, -1); - ATLASSERT(nRet != 0); - return nRet - 2; // convert to strcmp convention - } - - static int _cstrcolli(const TCHAR* pstrOne, const TCHAR* pstrOther) - { - int nRet = CompareString(GetThreadLocale(), NORM_IGNORECASE, pstrOne, -1, pstrOther, -1); - ATLASSERT(nRet != 0); - return nRet - 2; // convert to strcmp convention - } -#else // !_ATL_MIN_CRT - static const TCHAR* _cstrchr(const TCHAR* p, TCHAR ch) - { - return _tcschr(p, ch); - } - - static TCHAR* _cstrrev(TCHAR* pStr) - { - return _tcsrev(pStr); - } - - static const TCHAR* _cstrstr(const TCHAR* pStr, const TCHAR* pCharSet) - { - return _tcsstr(pStr, pCharSet); - } - - static int _cstrspn(const TCHAR* pStr, const TCHAR* pCharSet) - { - return (int)_tcsspn(pStr, pCharSet); - } - - static int _cstrcspn(const TCHAR* pStr, const TCHAR* pCharSet) - { - return (int)_tcscspn(pStr, pCharSet); - } - - static const TCHAR* _cstrpbrk(const TCHAR* p, const TCHAR* lpszCharSet) - { - return _tcspbrk(p, lpszCharSet); - } - - static int _cstrcmp(const TCHAR* pstrOne, const TCHAR* pstrOther) - { - return _tcscmp(pstrOne, pstrOther); - } - - static int _cstrcmpi(const TCHAR* pstrOne, const TCHAR* pstrOther) - { - return _tcsicmp(pstrOne, pstrOther); - } - -#ifndef _WIN32_WCE - static int _cstrcoll(const TCHAR* pstrOne, const TCHAR* pstrOther) - { - return _tcscoll(pstrOne, pstrOther); - } - - static int _cstrcolli(const TCHAR* pstrOne, const TCHAR* pstrOther) - { - return _tcsicoll(pstrOne, pstrOther); - } -#endif // !_WIN32_WCE -#endif // !_ATL_MIN_CRT - - static const TCHAR* _cstrrchr(const TCHAR* p, TCHAR ch) - { - return MinCrtHelper::_strrchr(p, ch); - } - - static int _cstrisdigit(TCHAR ch) - { - return MinCrtHelper::_isdigit(ch); - } - - static int _cstrisspace(TCHAR ch) - { - return MinCrtHelper::_isspace(ch); - } - - static int _cstrtoi(const TCHAR* nptr) - { - return MinCrtHelper::_atoi(nptr); - } - - static const TCHAR* _cstrchr_db(const TCHAR* p, TCHAR ch1, TCHAR ch2) - { - const TCHAR* lpsz = NULL; - while (*p != 0) - { - if (*p == ch1 && *(p + 1) == ch2) - { - lpsz = p; - break; - } - p = ::CharNext(p); - } - return lpsz; - } -}; - - -// Compare helpers - -inline bool __stdcall operator ==(const CString& s1, const CString& s2) -{ return s1.Compare(s2) == 0; } - -inline bool __stdcall operator ==(const CString& s1, LPCTSTR s2) -{ return s1.Compare(s2) == 0; } - -inline bool __stdcall operator ==(LPCTSTR s1, const CString& s2) -{ return s2.Compare(s1) == 0; } - -inline bool __stdcall operator !=(const CString& s1, const CString& s2) -{ return s1.Compare(s2) != 0; } - -inline bool __stdcall operator !=(const CString& s1, LPCTSTR s2) -{ return s1.Compare(s2) != 0; } - -inline bool __stdcall operator !=(LPCTSTR s1, const CString& s2) -{ return s2.Compare(s1) != 0; } - -inline bool __stdcall operator <(const CString& s1, const CString& s2) -{ return s1.Compare(s2) < 0; } - -inline bool __stdcall operator <(const CString& s1, LPCTSTR s2) -{ return s1.Compare(s2) < 0; } - -inline bool __stdcall operator <(LPCTSTR s1, const CString& s2) -{ return s2.Compare(s1) > 0; } - -inline bool __stdcall operator >(const CString& s1, const CString& s2) -{ return s1.Compare(s2) > 0; } - -inline bool __stdcall operator >(const CString& s1, LPCTSTR s2) -{ return s1.Compare(s2) > 0; } - -inline bool __stdcall operator >(LPCTSTR s1, const CString& s2) -{ return s2.Compare(s1) < 0; } - -inline bool __stdcall operator <=(const CString& s1, const CString& s2) -{ return s1.Compare(s2) <= 0; } - -inline bool __stdcall operator <=(const CString& s1, LPCTSTR s2) -{ return s1.Compare(s2) <= 0; } - -inline bool __stdcall operator <=(LPCTSTR s1, const CString& s2) -{ return s2.Compare(s1) >= 0; } - -inline bool __stdcall operator >=(const CString& s1, const CString& s2) -{ return s1.Compare(s2) >= 0; } - -inline bool __stdcall operator >=(const CString& s1, LPCTSTR s2) -{ return s1.Compare(s2) >= 0; } - -inline bool __stdcall operator >=(LPCTSTR s1, const CString& s2) -{ return s2.Compare(s1) <= 0; } +/////////////////////////////////////////////////////////////////////////////// +// Classes in this file: +// +// CRecentDocumentListBase +// CRecentDocumentList +// CFindFile +// CRegProperty +// CRegPropertyImpl +// +// Global functions: +// AtlGetStockPen() +// AtlGetStockBrush() +// AtlGetStockFont() +// AtlGetStockPalette() +// +// AtlCompactPath() -// CString "operator +" functions -inline CString __stdcall operator +(const CString& string1, const CString& string2) +namespace WTL { - CString s; - s.ConcatCopy(string1.GetData()->nDataLength, string1.m_pchData, string2.GetData()->nDataLength, string2.m_pchData); - return s; -} -inline CString __stdcall operator +(const CString& string, TCHAR ch) -{ - CString s; - s.ConcatCopy(string.GetData()->nDataLength, string.m_pchData, 1, &ch); - return s; -} +/////////////////////////////////////////////////////////////////////////////// +// CSize scalar operators -inline CString __stdcall operator +(TCHAR ch, const CString& string) -{ - CString s; - s.ConcatCopy(1, &ch, string.GetData()->nDataLength, string.m_pchData); - return s; -} +#if !defined(_WTL_NO_SIZE_SCALAR) && defined(__ATLTYPES_H__) -#ifdef _UNICODE -inline CString __stdcall operator +(const CString& string, char ch) +template +inline CSize operator *(SIZE s, Num n) { - return string + (TCHAR)ch; -} + return CSize((int)(s.cx * n), (int)(s.cy * n)); +}; -inline CString __stdcall operator +(char ch, const CString& string) +template +inline void operator *=(SIZE & s, Num n) { - return (TCHAR)ch + string; -} -#endif // _UNICODE + s = s * n; +}; -inline CString __stdcall operator +(const CString& string, LPCTSTR lpsz) +template +inline CSize operator /(SIZE s, Num n) { - ATLASSERT(lpsz == NULL || CString::_IsValidString(lpsz)); - CString s; - s.ConcatCopy(string.GetData()->nDataLength, string.m_pchData, CString::SafeStrlen(lpsz), lpsz); - return s; -} + return CSize((int)(s.cx / n), (int)(s.cy / n)); +}; -inline CString __stdcall operator +(LPCTSTR lpsz, const CString& string) +template +inline void operator /=(SIZE & s, Num n) { - ATLASSERT(lpsz == NULL || CString::_IsValidString(lpsz)); - CString s; - s.ConcatCopy(CString::SafeStrlen(lpsz), lpsz, string.GetData()->nDataLength, string.m_pchData); - return s; -} + s = s / n; +}; -#endif // !_WTL_NO_CSTRING +#endif // !defined(_WTL_NO_SIZE_SCALAR) && defined(__ATLTYPES_H__) /////////////////////////////////////////////////////////////////////////////// // CRecentDocumentList - MRU List Support -#ifndef _WIN32_WCE - #ifndef _WTL_MRUEMPTY_TEXT #define _WTL_MRUEMPTY_TEXT _T("(empty)") #endif @@ -2847,8 +115,10 @@ public: int m_cchMaxItemLen; // Constructor - CRecentDocumentListBase() : m_hMenu(NULL), m_nMaxEntries(4), m_cchMaxItemLen(-1) + CRecentDocumentListBase() : m_nMaxEntries(4), m_hMenu(NULL), m_cchMaxItemLen(-1) { + m_szNoEntries[0] = 0; + // These ASSERTs verify values of the template arguments ATLASSERT(t_cchItemLen > m_cchMaxItemLen_Min); ATLASSERT(m_nMaxEntries_Max > m_nMaxEntries_Min); @@ -2862,13 +132,13 @@ public: void SetMenuHandle(HMENU hMenu) { - ATLASSERT(hMenu == NULL || ::IsMenu(hMenu)); + ATLASSERT((hMenu == NULL) || ::IsMenu(hMenu)); m_hMenu = hMenu; - if(m_hMenu == NULL || (::GetMenuString(m_hMenu, t_nFirstID, m_szNoEntries, t_cchItemLen, MF_BYCOMMAND) == 0)) + if((m_hMenu == NULL) || (::GetMenuString(m_hMenu, t_nFirstID, m_szNoEntries, t_cchItemLen, MF_BYCOMMAND) == 0)) { T* pT = static_cast(this); - pT; // avoid level 4 warning - SecureHelper::strncpy_x(m_szNoEntries, _countof(m_szNoEntries), pT->GetMRUEmptyText(), _TRUNCATE); + (void)pT; // avoid level 4 warning + ATL::Checked::tcsncpy_s(m_szNoEntries, _countof(m_szNoEntries), pT->GetMRUEmptyText(), _TRUNCATE); } } @@ -2879,7 +149,7 @@ public: void SetMaxEntries(int nMaxEntries) { - ATLASSERT(nMaxEntries >= m_nMaxEntries_Min && nMaxEntries <= m_nMaxEntries_Max); + ATLASSERT((nMaxEntries >= m_nMaxEntries_Min) && (nMaxEntries <= m_nMaxEntries_Max)); if(nMaxEntries < m_nMaxEntries_Min) nMaxEntries = m_nMaxEntries_Min; else if(nMaxEntries > m_nMaxEntries_Max) @@ -2894,7 +164,7 @@ public: void SetMaxItemLength(int cchMaxLen) { - ATLASSERT((cchMaxLen >= m_cchMaxItemLen_Min && cchMaxLen <= m_cchMaxItemLen_Max) || cchMaxLen == -1); + ATLASSERT(((cchMaxLen >= m_cchMaxItemLen_Min) && (cchMaxLen <= m_cchMaxItemLen_Max)) || (cchMaxLen == -1)); if(cchMaxLen != -1) { if(cchMaxLen < m_cchMaxItemLen_Min) @@ -2911,8 +181,8 @@ public: BOOL AddToList(LPCTSTR lpstrDocName) { _DocEntry de; - errno_t nRet = SecureHelper::strncpy_x(de.szDocName, _countof(de.szDocName), lpstrDocName, _TRUNCATE); - if(nRet != 0 && nRet != STRUNCATE) + errno_t nRet = ATL::Checked::tcsncpy_s(de.szDocName, _countof(de.szDocName), lpstrDocName, _TRUNCATE); + if((nRet != 0) && (nRet != STRUNCATE)) return FALSE; for(int i = 0; i < m_arrDocs.GetSize(); i++) @@ -2938,9 +208,7 @@ public: // This function is deprecated because it is not safe. // Use the version below that accepts the buffer length. -#if (_MSC_VER >= 1300) __declspec(deprecated) -#endif BOOL GetFromList(int /*nItemID*/, LPTSTR /*lpstrDocName*/) { ATLASSERT(FALSE); @@ -2950,25 +218,25 @@ public: BOOL GetFromList(int nItemID, LPTSTR lpstrDocName, int cchLength) { int nIndex = m_arrDocs.GetSize() - (nItemID - t_nFirstID) - 1; - if(nIndex < 0 || nIndex >= m_arrDocs.GetSize()) + if((nIndex < 0) || (nIndex >= m_arrDocs.GetSize())) return FALSE; if(lstrlen(m_arrDocs[nIndex].szDocName) >= cchLength) return FALSE; - SecureHelper::strcpy_x(lpstrDocName, cchLength, m_arrDocs[nIndex].szDocName); + ATL::Checked::tcscpy_s(lpstrDocName, cchLength, m_arrDocs[nIndex].szDocName); return TRUE; } -#if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) - BOOL GetFromList(int nItemID, _CSTRING_NS::CString& strDocName) +#ifdef __ATLSTR_H__ + BOOL GetFromList(int nItemID, ATL::CString& strDocName) { int nIndex = m_arrDocs.GetSize() - (nItemID - t_nFirstID) - 1; - if(nIndex < 0 || nIndex >= m_arrDocs.GetSize()) + if((nIndex < 0) || (nIndex >= m_arrDocs.GetSize())) return FALSE; strDocName = m_arrDocs[nIndex].szDocName; return TRUE; } -#endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) +#endif // __ATLSTR_H__ BOOL RemoveFromList(int nItemID) { @@ -2985,7 +253,7 @@ public: BOOL MoveToTop(int nItemID) { int nIndex = m_arrDocs.GetSize() - (nItemID - t_nFirstID) - 1; - if(nIndex < 0 || nIndex >= m_arrDocs.GetSize()) + if((nIndex < 0) || (nIndex >= m_arrDocs.GetSize())) return FALSE; _DocEntry de; de = m_arrDocs[nIndex]; @@ -3002,8 +270,8 @@ public: BOOL ReadFromRegistry(LPCTSTR lpstrRegKey) { T* pT = static_cast(this); - CRegKeyEx rkParent; - CRegKeyEx rk; + ATL::CRegKey rkParent; + ATL::CRegKey rk; LONG lRet = rkParent.Open(HKEY_CURRENT_USER, lpstrRegKey); if(lRet != ERROR_SUCCESS) @@ -3020,18 +288,18 @@ public: m_arrDocs.RemoveAll(); - TCHAR szRetString[t_cchItemLen] = { 0 }; + TCHAR szRetString[t_cchItemLen] = {}; _DocEntry de; for(int nItem = m_nMaxEntries; nItem > 0; nItem--) { - TCHAR szBuff[m_cchItemNameLen] = { 0 }; - SecureHelper::wsprintf_x(szBuff, m_cchItemNameLen, pT->GetRegItemName(), nItem); + TCHAR szBuff[m_cchItemNameLen] = {}; + _stprintf_s(szBuff, m_cchItemNameLen, pT->GetRegItemName(), nItem); ULONG ulCount = t_cchItemLen; lRet = rk.QueryStringValue(szBuff, szRetString, &ulCount); if(lRet == ERROR_SUCCESS) { - SecureHelper::strcpy_x(de.szDocName, _countof(de.szDocName), szRetString); + ATL::Checked::tcscpy_s(de.szDocName, _countof(de.szDocName), szRetString); m_arrDocs.Add(de); } } @@ -3045,9 +313,9 @@ public: BOOL WriteToRegistry(LPCTSTR lpstrRegKey) { T* pT = static_cast(this); - pT; // avoid level 4 warning - CRegKeyEx rkParent; - CRegKeyEx rk; + (void)pT; // avoid level 4 warning + ATL::CRegKey rkParent; + ATL::CRegKey rk; LONG lRet = rkParent.Create(HKEY_CURRENT_USER, lpstrRegKey); if(lRet != ERROR_SUCCESS) @@ -3063,9 +331,9 @@ public: int nItem; for(nItem = m_arrDocs.GetSize(); nItem > 0; nItem--) { - TCHAR szBuff[m_cchItemNameLen] = { 0 }; - SecureHelper::wsprintf_x(szBuff, m_cchItemNameLen, pT->GetRegItemName(), nItem); - TCHAR szDocName[t_cchItemLen] = { 0 }; + TCHAR szBuff[m_cchItemNameLen] = {}; + _stprintf_s(szBuff, m_cchItemNameLen, pT->GetRegItemName(), nItem); + TCHAR szDocName[t_cchItemLen] = {}; GetFromList(t_nFirstID + nItem - 1, szDocName, t_cchItemLen); lRet = rk.SetStringValue(szBuff, szDocName); ATLASSERT(lRet == ERROR_SUCCESS); @@ -3074,8 +342,8 @@ public: // delete unused keys for(nItem = m_arrDocs.GetSize() + 1; nItem <= m_nMaxEntries_Max; nItem++) { - TCHAR szBuff[m_cchItemNameLen] = { 0 }; - SecureHelper::wsprintf_x(szBuff, m_cchItemNameLen, pT->GetRegItemName(), nItem); + TCHAR szBuff[m_cchItemNameLen] = {}; + _stprintf_s(szBuff, m_cchItemNameLen, pT->GetRegItemName(), nItem); rk.DeleteValue(szBuff); } @@ -3106,7 +374,7 @@ public: } } - ATLASSERT(nInsertPoint < nItems && "You need a menu item with an ID = t_nFirstID"); + ATLASSERT((nInsertPoint < nItems) && "You need a menu item with an ID = t_nFirstID"); for(int j = t_nFirstID; j < (t_nFirstID + m_nMaxEntries); j++) { @@ -3115,7 +383,7 @@ public: ::DeleteMenu(m_hMenu, j, MF_BYCOMMAND); } - TCHAR szItemText[t_cchItemLen + 6] = { 0 }; // add space for &, 2 digits, and a space + TCHAR szItemText[t_cchItemLen + 6] = {}; // add space for &, 2 digits, and a space int nSize = m_arrDocs.GetSize(); int nItem = 0; if(nSize > 0) @@ -3124,17 +392,17 @@ public: { if(m_cchMaxItemLen == -1) { - SecureHelper::wsprintf_x(szItemText, t_cchItemLen + 6, _T("&%i %s"), nItem + 1, m_arrDocs[nSize - 1 - nItem].szDocName); + _stprintf_s(szItemText, t_cchItemLen + 6, _T("&%i %s"), nItem + 1, m_arrDocs[nSize - 1 - nItem].szDocName); } else { - TCHAR szBuff[t_cchItemLen] = { 0 }; + TCHAR szBuff[t_cchItemLen] = {}; T* pT = static_cast(this); - pT; // avoid level 4 warning + (void)pT; // avoid level 4 warning bool bRet = pT->CompactDocumentName(szBuff, m_arrDocs[nSize - 1 - nItem].szDocName, m_cchMaxItemLen); - bRet; // avoid level 4 warning + (void)bRet; // avoid level 4 warning ATLASSERT(bRet); - SecureHelper::wsprintf_x(szItemText, t_cchItemLen + 6, _T("&%i %s"), nItem + 1, szBuff); + _stprintf_s(szItemText, t_cchItemLen + 6, _T("&%i %s"), nItem + 1, szBuff); } ::InsertMenu(m_hMenu, nInsertPoint + nItem, MF_BYPOSITION | MF_STRING, t_nFirstID + nItem, szItemText); @@ -3188,8 +456,6 @@ public: // nothing here }; -#endif // _WIN32_WCE - /////////////////////////////////////////////////////////////////////////////// // CFindFile - file search helper class @@ -3198,15 +464,17 @@ class CFindFile { public: // Data members - WIN32_FIND_DATA m_fd; - TCHAR m_lpszRoot[MAX_PATH]; - TCHAR m_chDirSeparator; HANDLE m_hFind; + WIN32_FIND_DATA m_fd; + LPTSTR m_lpszRoot; + const TCHAR m_chDirSeparator; BOOL m_bFound; // Constructor/destructor - CFindFile() : m_hFind(NULL), m_chDirSeparator(_T('\\')), m_bFound(FALSE) - { } + CFindFile() : m_hFind(NULL), m_lpszRoot(NULL), m_chDirSeparator(_T('\\')), m_bFound(FALSE) + { + memset(&m_fd, 0, sizeof(m_fd)); + } ~CFindFile() { @@ -3218,8 +486,7 @@ public: { ATLASSERT(m_hFind != NULL); - ULARGE_INTEGER nFileSize = { 0 }; - + ULARGE_INTEGER nFileSize = {}; if(m_bFound) { nFileSize.LowPart = m_fd.nFileSizeLow; @@ -3240,7 +507,7 @@ public: return FALSE; if(m_bFound) - SecureHelper::strcpy_x(lpstrFileName, cchLength, m_fd.cFileName); + ATL::Checked::tcscpy_s(lpstrFileName, cchLength, m_fd.cFileName); return m_bFound; } @@ -3250,70 +517,61 @@ public: ATLASSERT(m_hFind != NULL); int nLen = lstrlen(m_lpszRoot); -#ifndef _WIN32_WCE ATLASSERT(nLen > 0); if(nLen == 0) return FALSE; - bool bAddSep = (m_lpszRoot[nLen - 1] != _T('\\') && m_lpszRoot[nLen - 1] !=_T('/')); -#else // CE specific - // allow diskless devices (nLen == 0) - bool bAddSep = ((nLen == 0) || (m_lpszRoot[nLen - 1] != _T('\\') && m_lpszRoot[nLen - 1] !=_T('/'))); -#endif // _WIN32_WCE + bool bAddSep = (m_lpszRoot[nLen - 1] != m_chDirSeparator); if((lstrlen(m_lpszRoot) + (bAddSep ? 1 : 0)) >= cchLength) return FALSE; - SecureHelper::strcpy_x(lpstrFilePath, cchLength, m_lpszRoot); + ATL::Checked::tcscpy_s(lpstrFilePath, cchLength, m_lpszRoot); if(bAddSep) { TCHAR szSeparator[2] = { m_chDirSeparator, 0 }; - SecureHelper::strcat_x(lpstrFilePath, cchLength, szSeparator); + ATL::Checked::tcscat_s(lpstrFilePath, cchLength, szSeparator); } - SecureHelper::strcat_x(lpstrFilePath, cchLength, m_fd.cFileName); + ATL::Checked::tcscat_s(lpstrFilePath, cchLength, m_fd.cFileName); return TRUE; } -#ifndef _WIN32_WCE BOOL GetFileTitle(LPTSTR lpstrFileTitle, int cchLength) const { ATLASSERT(m_hFind != NULL); - TCHAR szBuff[MAX_PATH] = { 0 }; + TCHAR szBuff[MAX_PATH] = {}; if(!GetFileName(szBuff, MAX_PATH)) return FALSE; - if(lstrlen(szBuff) >= cchLength || cchLength < 1) + if(lstrlen(szBuff) >= cchLength) return FALSE; // find the last dot - LPTSTR pstrDot = MinCrtHelper::_strrchr(szBuff, _T('.')); + LPTSTR pstrDot = _tcsrchr(szBuff, _T('.')); if(pstrDot != NULL) *pstrDot = 0; - SecureHelper::strcpy_x(lpstrFileTitle, cchLength, szBuff); + ATL::Checked::tcscpy_s(lpstrFileTitle, cchLength, szBuff); return TRUE; } -#endif // !_WIN32_WCE BOOL GetFileURL(LPTSTR lpstrFileURL, int cchLength) const { ATLASSERT(m_hFind != NULL); - TCHAR szBuff[MAX_PATH] = { 0 }; - if(!GetFilePath(szBuff, MAX_PATH)) - return FALSE; LPCTSTR lpstrFileURLPrefix = _T("file://"); - if(lstrlen(szBuff) + lstrlen(lpstrFileURLPrefix) >= cchLength) + const int cchPrefix = lstrlen(lpstrFileURLPrefix); + if(cchPrefix >= cchLength) return FALSE; - SecureHelper::strcpy_x(lpstrFileURL, cchLength, lpstrFileURLPrefix); - SecureHelper::strcat_x(lpstrFileURL, cchLength, szBuff); - return TRUE; + ATL::Checked::tcscpy_s(lpstrFileURL, cchLength, lpstrFileURLPrefix); + + return GetFilePath(&lpstrFileURL[cchPrefix], cchLength - cchPrefix); } BOOL GetRoot(LPTSTR lpstrRoot, int cchLength) const @@ -3322,81 +580,74 @@ public: if(lstrlen(m_lpszRoot) >= cchLength) return FALSE; - SecureHelper::strcpy_x(lpstrRoot, cchLength, m_lpszRoot); + ATL::Checked::tcscpy_s(lpstrRoot, cchLength, m_lpszRoot); return TRUE; } -#if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) - _CSTRING_NS::CString GetFileName() const +#ifdef __ATLSTR_H__ + ATL::CString GetFileName() const { ATLASSERT(m_hFind != NULL); - _CSTRING_NS::CString ret; + ATL::CString ret; if(m_bFound) ret = m_fd.cFileName; return ret; } - _CSTRING_NS::CString GetFilePath() const + ATL::CString GetFilePath() const { ATLASSERT(m_hFind != NULL); - _CSTRING_NS::CString strResult = m_lpszRoot; + ATL::CString strResult = m_lpszRoot; int nLen = strResult.GetLength(); -#ifndef _WIN32_WCE ATLASSERT(nLen > 0); if(nLen == 0) return strResult; - if((strResult[nLen - 1] != _T('\\')) && (strResult[nLen - 1] != _T('/'))) -#else // CE specific - // allow diskless devices (nLen == 0) - if((nLen == 0) || ((strResult[nLen - 1] != _T('\\')) && (strResult[nLen - 1] != _T('/')))) -#endif // _WIN32_WCE + if(strResult[nLen - 1] != m_chDirSeparator) strResult += m_chDirSeparator; strResult += GetFileName(); return strResult; } -#ifndef _WIN32_WCE - _CSTRING_NS::CString GetFileTitle() const + ATL::CString GetFileTitle() const { ATLASSERT(m_hFind != NULL); - _CSTRING_NS::CString strResult; + ATL::CString strResult; GetFileTitle(strResult.GetBuffer(MAX_PATH), MAX_PATH); strResult.ReleaseBuffer(); return strResult; } -#endif // !_WIN32_WCE - _CSTRING_NS::CString GetFileURL() const + ATL::CString GetFileURL() const { ATLASSERT(m_hFind != NULL); - _CSTRING_NS::CString strResult("file://"); + ATL::CString strResult("file://"); strResult += GetFilePath(); return strResult; } - _CSTRING_NS::CString GetRoot() const + ATL::CString GetRoot() const { ATLASSERT(m_hFind != NULL); - _CSTRING_NS::CString str = m_lpszRoot; + ATL::CString str = m_lpszRoot; return str; } -#endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) +#endif // __ATLSTR_H__ BOOL GetLastWriteTime(FILETIME* pTimeStamp) const { ATLASSERT(m_hFind != NULL); ATLASSERT(pTimeStamp != NULL); - if(m_bFound && pTimeStamp != NULL) + if(m_bFound && (pTimeStamp != NULL)) { *pTimeStamp = m_fd.ftLastWriteTime; return TRUE; @@ -3410,7 +661,7 @@ public: ATLASSERT(m_hFind != NULL); ATLASSERT(pTimeStamp != NULL); - if(m_bFound && pTimeStamp != NULL) + if(m_bFound && (pTimeStamp != NULL)) { *pTimeStamp = m_fd.ftLastAccessTime; return TRUE; @@ -3423,7 +674,7 @@ public: { ATLASSERT(m_hFind != NULL); - if(m_bFound && pTimeStamp != NULL) + if(m_bFound && (pTimeStamp != NULL)) { *pTimeStamp = m_fd.ftCreationTime; return TRUE; @@ -3452,7 +703,7 @@ public: BOOL bResult = FALSE; if(m_bFound && IsDirectory()) { - if(m_fd.cFileName[0] == _T('.') && (m_fd.cFileName[1] == _T('\0') || (m_fd.cFileName[1] == _T('.') && m_fd.cFileName[2] == _T('\0')))) + if((m_fd.cFileName[0] == _T('.')) && ((m_fd.cFileName[1] == _T('\0')) || ((m_fd.cFileName[1] == _T('.')) && (m_fd.cFileName[2] == _T('\0'))))) bResult = TRUE; } @@ -3500,33 +751,41 @@ public: } // Operations - BOOL FindFile(LPCTSTR pstrName = NULL) + BOOL FindFile(LPCTSTR pstrName = NULL, bool bAutoLongPath = false) { Close(); if(pstrName == NULL) - { pstrName = _T("*.*"); + + if(bAutoLongPath && (lstrlen(pstrName) >= MAX_PATH)) + { + LPCTSTR lpstrPrefix = _T("\\\\?\\"); + int cchLongPath = lstrlen(lpstrPrefix) + lstrlen(pstrName) + 1; + ATL::CTempBuffer buff; + LPTSTR lpstrLongPath = buff.Allocate(cchLongPath); + if(lpstrLongPath != NULL) + { + ATL::Checked::tcscpy_s(lpstrLongPath, cchLongPath, lpstrPrefix); + ATL::Checked::tcscat_s(lpstrLongPath, cchLongPath, pstrName); + m_hFind = ::FindFirstFile(lpstrLongPath, &m_fd); + } } - else if(lstrlen(pstrName) >= MAX_PATH) + else { - ATLASSERT(FALSE); - return FALSE; + m_hFind = ::FindFirstFile(pstrName, &m_fd); } - SecureHelper::strcpy_x(m_fd.cFileName, _countof(m_fd.cFileName), pstrName); - - m_hFind = ::FindFirstFile(pstrName, &m_fd); - if(m_hFind == INVALID_HANDLE_VALUE) return FALSE; -#ifndef _WIN32_WCE - bool bFullPath = (::GetFullPathName(pstrName, MAX_PATH, m_lpszRoot, NULL) != 0); -#else // CE specific - errno_t nRet = SecureHelper::strncpy_x(m_lpszRoot, _countof(m_lpszRoot), pstrName, _TRUNCATE); - bool bFullPath = (nRet == 0 || nRet == STRUNCATE); -#endif // _WIN32_WCE + int cchRoot = ::GetFullPathName(pstrName, 0, NULL, NULL); + if(cchRoot > 0) + ATLTRY(m_lpszRoot = new TCHAR[cchRoot]); + if(m_lpszRoot == NULL) + return FALSE; + + bool bFullPath = (::GetFullPathName(pstrName, cchRoot, m_lpszRoot, NULL) != 0); // passed name isn't a valid path but was found by the API ATLASSERT(bFullPath); @@ -3538,24 +797,10 @@ public: } else { - // find the last forward or backward whack - LPTSTR pstrBack = MinCrtHelper::_strrchr(m_lpszRoot, _T('\\')); - LPTSTR pstrFront = MinCrtHelper::_strrchr(m_lpszRoot, _T('/')); - - if(pstrFront != NULL || pstrBack != NULL) - { - if(pstrFront == NULL) - pstrFront = m_lpszRoot; - if(pstrBack == NULL) - pstrBack = m_lpszRoot; - - // from the start to the last whack is the root - - if(pstrFront >= pstrBack) - *pstrFront = _T('\0'); - else - *pstrBack = _T('\0'); - } + // find the last separator + LPTSTR pstrSep = _tcsrchr(m_lpszRoot, m_chDirSeparator); + if(pstrSep != NULL) + *pstrSep = _T('\0'); } m_bFound = TRUE; @@ -3582,7 +827,10 @@ public: { m_bFound = FALSE; - if(m_hFind != NULL && m_hFind != INVALID_HANDLE_VALUE) + delete [] m_lpszRoot; + m_lpszRoot = NULL; + + if((m_hFind != NULL) && (m_hFind != INVALID_HANDLE_VALUE)) { ::FindClose(m_hFind); m_hFind = NULL; @@ -3591,36 +839,383 @@ public: }; +/////////////////////////////////////////////////////////////////////////////// +// CRegProperty and CRegPropertyImpl<> - properties stored in registry + +// How to use: Derive a class from CRegPropertyImpl, add data members +// for properties, and add REGPROP map to map properties to registry value names. +// You can then call Read() and Write() methods to read and write properties to/from registry. +// You can also use CRegProperty class directly, for one time read/write, or for custom stuff. + +#define REGPROP_CURRENTUSER 0x0000 +#define REGPROP_LOCALMACHINE 0x0001 +#define REGPROP_READONLY 0x0002 +#define REGPROP_WRITEONLY 0x0004 + +class CRegProperty +{ +public: +// Type declarations + struct BinaryProp + { + void* pBinary; + ULONG uSize; // buffer size in bytes, used size after read + + BinaryProp() : pBinary(NULL), uSize(0U) + { } + }; + + struct CharArrayProp + { + LPTSTR lpstrText; + ULONG uSize; // buffer size in chars + + CharArrayProp() : lpstrText(NULL), uSize(0U) + { } + }; + +// Data members + ATL::CRegKey m_regkey; + WORD m_wFlags; + +// Constructor + CRegProperty() : m_wFlags(REGPROP_CURRENTUSER) + { } + +// Registry key methods + LSTATUS OpenRegKey(LPCTSTR lpstrRegKey, bool bWrite) + { + ATLASSERT(m_regkey.m_hKey == NULL); + + HKEY hKey = ((m_wFlags & REGPROP_LOCALMACHINE) != 0) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; + REGSAM sam = KEY_READ | KEY_WRITE; + LSTATUS lRet = -1; + if(bWrite) + lRet = m_regkey.Create(hKey, lpstrRegKey, NULL, 0, ((m_wFlags & REGPROP_WRITEONLY) != 0) ? KEY_WRITE : sam); + else + lRet = m_regkey.Open(hKey, lpstrRegKey, ((m_wFlags & REGPROP_READONLY) != 0) ? KEY_READ : sam); + + return lRet; + } + + void CloseRegKey() + { + LSTATUS lRet = m_regkey.Close(); + (void)lRet; // avoid level 4 warning + ATLASSERT(lRet == ERROR_SUCCESS); + } + +// Flag methods + WORD GetFlags() const + { + return m_wFlags; + } + + WORD SetFlags(WORD wFlags, WORD wMask = 0) + { + WORD wPrevFlags = m_wFlags; + if(wMask == 0) + m_wFlags = wFlags; + else + m_wFlags = (m_wFlags & ~wMask) | (wFlags & wMask); + + return wPrevFlags; + } + +// Generic read/write methods + template + LSTATUS ReadProp(LPCTSTR lpstrRegValue, TProp& prop) + { + ATLASSERT(m_regkey.m_hKey != NULL); + + DWORD dwRet = 0; + LSTATUS lRet = m_regkey.QueryDWORDValue(lpstrRegValue, dwRet); + if(lRet == ERROR_SUCCESS) + prop = static_cast(dwRet); + + return lRet; + } + + template + LSTATUS WriteProp(LPCTSTR lpstrRegValue, TProp& prop) + { + ATLASSERT(m_regkey.m_hKey != NULL); + + return m_regkey.SetDWORDValue(lpstrRegValue, (DWORD)prop); + } + +// Specialization for bool + template <> + LSTATUS ReadProp(LPCTSTR lpstrRegValue, bool& bProp) + { + ATLASSERT(m_regkey.m_hKey != NULL); + + DWORD dwRet = 0; + LSTATUS lRet = m_regkey.QueryDWORDValue(lpstrRegValue, dwRet); + if(lRet == ERROR_SUCCESS) + bProp = (dwRet != 0); + + return lRet; + } + + template <> + LSTATUS WriteProp(LPCTSTR lpstrRegValue, bool& bProp) + { + ATLASSERT(m_regkey.m_hKey != NULL); + + return m_regkey.SetDWORDValue(lpstrRegValue, bProp ? 1 : 0); + } + +// Specialization for HFONT + template <> + LSTATUS ReadProp(LPCTSTR lpstrRegValue, HFONT& hFont) + { + ATLASSERT(m_regkey.m_hKey != NULL); + + LOGFONT lf = {}; + ULONG uSize = sizeof(lf); + LSTATUS lRet = m_regkey.QueryBinaryValue(lpstrRegValue, &lf, &uSize); + if(lRet == ERROR_SUCCESS) + { + if(hFont != NULL) + ::DeleteObject(hFont); + + hFont = ::CreateFontIndirect(&lf); + if(hFont == NULL) + lRet = ERROR_INVALID_DATA; + } + + return lRet; + } + + template <> + LSTATUS WriteProp(LPCTSTR lpstrRegValue, HFONT& hFont) + { + ATLASSERT(m_regkey.m_hKey != NULL); + + CLogFont lf(hFont); + return m_regkey.SetBinaryValue(lpstrRegValue, &lf, sizeof(lf)); + } + +// Specialization for BinaryProp + template <> + LSTATUS ReadProp(LPCTSTR lpstrRegValue, BinaryProp& binProp) + { + ATLASSERT(m_regkey.m_hKey != NULL); + + ULONG uSize = 0U; + LSTATUS lRet = m_regkey.QueryBinaryValue(lpstrRegValue, NULL, &uSize); + if(lRet == ERROR_SUCCESS) + { + if(uSize <= binProp.uSize) + lRet = m_regkey.QueryBinaryValue(lpstrRegValue, binProp.pBinary, &binProp.uSize); + else + lRet = ERROR_OUTOFMEMORY; + } + + return lRet; + } + + template <> + LSTATUS WriteProp(LPCTSTR lpstrRegValue, BinaryProp& binProp) + { + ATLASSERT(m_regkey.m_hKey != NULL); + + return m_regkey.SetBinaryValue(lpstrRegValue, binProp.pBinary, binProp.uSize); + } + +// Specialization for CharArrayProp + template <> + LSTATUS ReadProp(LPCTSTR lpstrRegValue, CharArrayProp& caProp) + { + ATLASSERT(m_regkey.m_hKey != NULL); + + ULONG uSize = 0U; + LSTATUS lRet = m_regkey.QueryStringValue(lpstrRegValue, NULL, &uSize); + if(lRet == ERROR_SUCCESS) + { + if(uSize <= caProp.uSize) + lRet = m_regkey.QueryStringValue(lpstrRegValue, caProp.lpstrText, &caProp.uSize); + else + lRet = ERROR_OUTOFMEMORY; + } + + return lRet; + } + + template <> + LSTATUS WriteProp(LPCTSTR lpstrRegValue, CharArrayProp& caProp) + { + ATLASSERT(m_regkey.m_hKey != NULL); + + return m_regkey.SetStringValue(lpstrRegValue, caProp.lpstrText); + } + +// Specialization for CString +#ifdef __ATLSTR_H__ + template <> + LSTATUS ReadProp(LPCTSTR lpstrRegValue, ATL::CString& strProp) + { + ATLASSERT(m_regkey.m_hKey != NULL); + + ULONG uSize = 0U; + LSTATUS lRet = m_regkey.QueryStringValue(lpstrRegValue, NULL, &uSize); + if(lRet == ERROR_SUCCESS) + { + lRet = m_regkey.QueryStringValue(lpstrRegValue, strProp.GetBufferSetLength(uSize), &uSize); + strProp.ReleaseBuffer(); + } + + return lRet; + } + + template <> + LSTATUS WriteProp(LPCTSTR lpstrRegValue, ATL::CString& strProp) + { + ATLASSERT(m_regkey.m_hKey != NULL); + + return m_regkey.SetStringValue(lpstrRegValue, (LPCTSTR)strProp); + } +#endif // __ATLSTR_H__ + +// Static methods for one time read/write + template + static bool ReadOne(LPCTSTR lpstrRegKey, LPCTSTR lpstrRegValue, TProp& prop, WORD wFlags = REGPROP_CURRENTUSER) + { + CRegProperty rp; + rp.SetFlags(wFlags); + LSTATUS lRet = rp.OpenRegKey(lpstrRegKey, false); + if(lRet == ERROR_SUCCESS) + { + lRet = rp.ReadProp(lpstrRegValue, prop); + rp.CloseRegKey(); + } + + return (lRet == ERROR_SUCCESS) || (lRet == ERROR_FILE_NOT_FOUND); + } + + template + static bool WriteOne(LPCTSTR lpstrRegKey, LPCTSTR lpstrRegValue, TProp& prop, WORD wFlags = REGPROP_CURRENTUSER) + { + CRegProperty rp; + rp.SetFlags(wFlags); + LSTATUS lRet = rp.OpenRegKey(lpstrRegKey, true); + if(lRet == ERROR_SUCCESS) + { + lRet = rp.WriteProp(lpstrRegValue, prop); + rp.CloseRegKey(); + } + + return (lRet == ERROR_SUCCESS); + } +}; + + +#define BEGIN_REGPROP_MAP(class) \ + void ReadWriteAll(bool bWrite) \ + { + +#define REG_PROPERTY(name, prop) \ + this->ReadWriteProp(name, prop, bWrite); + +#define END_REGPROP_MAP() \ + } + +template +class CRegPropertyImpl : public CRegProperty +{ +public: +// Methods + void Read(LPCTSTR lpstrRegKey) + { + T* pT = static_cast(this); + LSTATUS lRet = pT->OpenRegKey(lpstrRegKey, false); + if(lRet == ERROR_SUCCESS) + { + pT->ReadWriteAll(false); + pT->OnRead(lpstrRegKey); + + pT->CloseRegKey(); + } + else if(lRet != ERROR_FILE_NOT_FOUND) + { + pT->OnReadError(NULL, lRet); + } + } + + void Write(LPCTSTR lpstrRegKey) + { + T* pT = static_cast(this); + LSTATUS lRet = pT->OpenRegKey(lpstrRegKey, true); + if(lRet == ERROR_SUCCESS) + { + pT->ReadWriteAll(true); + pT->OnWrite(lpstrRegKey); + + pT->CloseRegKey(); + } + else + { + pT->OnWriteError(NULL, lRet); + } + } + +// Implementation + template + void ReadWriteProp(LPCTSTR lpstrRegValue, TProp& prop, bool bWrite) + { + T* pT = static_cast(this); + if(bWrite) + { + LSTATUS lRet = pT->WriteProp(lpstrRegValue, prop); + if(lRet != ERROR_SUCCESS) + pT->OnWriteError(lpstrRegValue, lRet); + } + else + { + LSTATUS lRet = pT->ReadProp(lpstrRegValue, prop); + if((lRet != ERROR_SUCCESS) && (lRet != ERROR_FILE_NOT_FOUND)) + pT->OnReadError(lpstrRegValue, lRet); + } + } + +// Overrideable handlers + void OnRead(LPCTSTR /*lpstrRegKey*/) + { } + + void OnWrite(LPCTSTR /*lpstrRegKey*/) + { } + + void OnReadError(LPCTSTR /*lpstrRegValue*/, LSTATUS /*lError*/) + { + ATLASSERT(FALSE); + } + + void OnWriteError(LPCTSTR /*lpstrRegValue*/, LSTATUS /*lError*/) + { + ATLASSERT(FALSE); + } +}; + + /////////////////////////////////////////////////////////////////////////////// // Global functions for stock GDI objects inline HPEN AtlGetStockPen(int nPen) { -#if (_WIN32_WINNT >= 0x0500) && !defined(_WIN32_WCE) - ATLASSERT(nPen == WHITE_PEN || nPen == BLACK_PEN || nPen == NULL_PEN || nPen == DC_PEN); -#else - ATLASSERT(nPen == WHITE_PEN || nPen == BLACK_PEN || nPen == NULL_PEN); -#endif + ATLASSERT((nPen == WHITE_PEN) || (nPen == BLACK_PEN) || (nPen == NULL_PEN) || (nPen == DC_PEN)); return (HPEN)::GetStockObject(nPen); } inline HBRUSH AtlGetStockBrush(int nBrush) { -#if (_WIN32_WINNT >= 0x0500) && !defined(_WIN32_WCE) - ATLASSERT((nBrush >= WHITE_BRUSH && nBrush <= HOLLOW_BRUSH) || nBrush == DC_BRUSH); -#else - ATLASSERT(nBrush >= WHITE_BRUSH && nBrush <= HOLLOW_BRUSH); -#endif + ATLASSERT(((nBrush >= WHITE_BRUSH) && (nBrush <= HOLLOW_BRUSH)) || (nBrush == DC_BRUSH)); return (HBRUSH)::GetStockObject(nBrush); } inline HFONT AtlGetStockFont(int nFont) { -#ifndef _WIN32_WCE - ATLASSERT((nFont >= OEM_FIXED_FONT && nFont <= SYSTEM_FIXED_FONT) || nFont == DEFAULT_GUI_FONT); -#else // CE specific - ATLASSERT(nFont == SYSTEM_FONT); -#endif // _WIN32_WCE + ATLASSERT(((nFont >= OEM_FIXED_FONT) && (nFont <= SYSTEM_FIXED_FONT)) || (nFont == DEFAULT_GUI_FONT)); return (HFONT)::GetStockObject(nFont); } @@ -3646,7 +1241,8 @@ inline bool _IsDBCSTrailByte(LPCTSTR lpstr, int nChar) } return ((nChar > 0) && (((nChar - i) & 1) != 0)); #else // _UNICODE - lpstr; nChar; + (void)lpstr; // avoid level 4 warning + (void)nChar; // avoid level 4 warning return false; #endif // _UNICODE } @@ -3663,7 +1259,7 @@ inline bool AtlCompactPath(LPTSTR lpstrOut, LPCTSTR lpstrIn, int cchLen) if(lstrlen(lpstrIn) < cchLen) { - SecureHelper::strcpy_x(lpstrOut, cchLen, lpstrIn); + ATL::Checked::tcscpy_s(lpstrOut, cchLen, lpstrIn); return true; } @@ -3681,23 +1277,23 @@ inline bool AtlCompactPath(LPTSTR lpstrOut, LPCTSTR lpstrIn, int cchLen) LPCTSTR lpstrFileName = lpstrIn; for(LPCTSTR pPath = lpstrIn; *pPath; pPath = ::CharNext(pPath)) { - if((pPath[0] == _T('\\') || pPath[0] == _T(':') || pPath[0] == _T('/')) - && pPath[1] && pPath[1] != _T('\\') && pPath[1] != _T('/')) + if(((pPath[0] == _T('\\')) || (pPath[0] == _T(':')) || (pPath[0] == _T('/'))) + && pPath[1] && (pPath[1] != _T('\\')) && (pPath[1] != _T('/'))) lpstrFileName = pPath + 1; } int cchFileName = lstrlen(lpstrFileName); // handle just the filename without a path - if(lpstrFileName == lpstrIn && cchLen > cchEndEllipsis) + if((lpstrFileName == lpstrIn) && (cchLen > cchEndEllipsis)) { - bool bRet = (SecureHelper::strncpy_x(lpstrOut, cchLen, lpstrIn, cchLen - cchEndEllipsis - 1) == 0); + bool bRet = (ATL::Checked::tcsncpy_s(lpstrOut, cchLen, lpstrIn, cchLen - cchEndEllipsis - 1) == 0); if(bRet) { #ifndef _UNICODE if(_IsDBCSTrailByte(lpstrIn, cchLen - cchEndEllipsis)) lpstrOut[cchLen - cchEndEllipsis - 1] = 0; #endif // _UNICODE - SecureHelper::strcat_x(lpstrOut, cchLen, szEllipsis); + ATL::Checked::tcscat_s(lpstrOut, cchLen, szEllipsis); } return bRet; } @@ -3718,39 +1314,39 @@ inline bool AtlCompactPath(LPTSTR lpstrOut, LPCTSTR lpstrIn, int cchLen) cchToCopy = 0; #ifndef _UNICODE - if(cchToCopy > 0 && _IsDBCSTrailByte(lpstrIn, cchToCopy)) + if((cchToCopy > 0) && _IsDBCSTrailByte(lpstrIn, cchToCopy)) cchToCopy--; #endif // _UNICODE - bool bRet = (SecureHelper::strncpy_x(lpstrOut, cchLen, lpstrIn, cchToCopy) == 0); + bool bRet = (ATL::Checked::tcsncpy_s(lpstrOut, cchLen, lpstrIn, cchToCopy) == 0); if(!bRet) return false; // add ellipsis - SecureHelper::strcat_x(lpstrOut, cchLen, szEllipsis); + ATL::Checked::tcscat_s(lpstrOut, cchLen, szEllipsis); TCHAR szSlash[2] = { chSlash, 0 }; - SecureHelper::strcat_x(lpstrOut, cchLen, szSlash); + ATL::Checked::tcscat_s(lpstrOut, cchLen, szSlash); // add filename (and ellipsis, if needed) if(cchLen > (cchMidEllipsis + cchFileName)) { - SecureHelper::strcat_x(lpstrOut, cchLen, lpstrFileName); + ATL::Checked::tcscat_s(lpstrOut, cchLen, lpstrFileName); } else { cchToCopy = cchLen - cchMidEllipsis - cchEndEllipsis - 1; #ifndef _UNICODE - if(cchToCopy > 0 && _IsDBCSTrailByte(lpstrFileName, cchToCopy)) + if((cchToCopy > 0) && _IsDBCSTrailByte(lpstrFileName, cchToCopy)) cchToCopy--; #endif // _UNICODE - bRet = (SecureHelper::strncpy_x(&lpstrOut[cchMidEllipsis], cchLen - cchMidEllipsis, lpstrFileName, cchToCopy) == 0); + bRet = (ATL::Checked::tcsncpy_s(&lpstrOut[cchMidEllipsis], cchLen - cchMidEllipsis, lpstrFileName, cchToCopy) == 0); if(bRet) - SecureHelper::strcat_x(lpstrOut, cchLen, szEllipsis); + ATL::Checked::tcscat_s(lpstrOut, cchLen, szEllipsis); } return bRet; } -}; // namespace WTL +} // namespace WTL #endif // __ATLMISC_H__ diff --git a/WrlSDK/SampleCode/PluginWinExe/WTL/atlprint.h b/WrlSDK/SampleCode/PluginWinExe/WTL/atlprint.h index 5dc5ab5af6973d6d9a60e01f83b812c1e2c8af9a..743f2a8f3ad516e03bbafd348c39e79687c69868 100644 --- a/WrlSDK/SampleCode/PluginWinExe/WTL/atlprint.h +++ b/WrlSDK/SampleCode/PluginWinExe/WTL/atlprint.h @@ -1,4 +1,4 @@ -// Windows Template Library - WTL version 9.10 +// Windows Template Library - WTL version 10.0 // Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. // // This file is a part of the Windows Template Library. @@ -11,10 +11,6 @@ #pragma once -#ifdef _WIN32_WCE - #error atlprint.h is not supported on Windows CE -#endif - #ifndef __ATLAPP_H__ #error atlprint.h requires atlapp.h to be included first #endif @@ -23,6 +19,8 @@ #error atlprint.h requires atlwin.h to be included first #endif +#include + /////////////////////////////////////////////////////////////////////////////// // Classes in this file: @@ -60,11 +58,8 @@ template <> class _printer_info<4> { public: typedef PRINTER_INFO_4 infotype; }; template <> class _printer_info<5> { public: typedef PRINTER_INFO_5 infotype; }; template <> class _printer_info<6> { public: typedef PRINTER_INFO_6 infotype; }; template <> class _printer_info<7> { public: typedef PRINTER_INFO_7 infotype; }; -// these are not in the old (vc6.0) headers -#ifdef _ATL_USE_NEW_PRINTER_INFO template <> class _printer_info<8> { public: typedef PRINTER_INFO_8 infotype; }; template <> class _printer_info<9> { public: typedef PRINTER_INFO_9 infotype; }; -#endif // _ATL_USE_NEW_PRINTER_INFO template @@ -192,25 +187,18 @@ public: bool OpenDefaultPrinter(const DEVMODE* pDevMode = NULL) { ClosePrinter(); - const int cchBuff = 512; - TCHAR buffer[cchBuff] = { 0 }; - ::GetProfileString(_T("windows"), _T("device"), _T(",,,"), buffer, cchBuff); - int nLen = lstrlen(buffer); - if (nLen != 0) + + DWORD cchBuff = 0; + ::GetDefaultPrinter(NULL, &cchBuff); + TCHAR* pszBuff = new TCHAR[cchBuff]; + BOOL bRet = ::GetDefaultPrinter(pszBuff, &cchBuff); + if(bRet != FALSE) { - LPTSTR lpsz = buffer; - while (*lpsz) - { - if (*lpsz == _T(',')) - { - *lpsz = 0; - break; - } - lpsz = CharNext(lpsz); - } PRINTER_DEFAULTS pdefs = { NULL, (DEVMODE*)pDevMode, PRINTER_ACCESS_USE }; - ::OpenPrinter(buffer, &m_hPrinter, (pDevMode == NULL) ? NULL : &pdefs); + ::OpenPrinter(pszBuff, &m_hPrinter, (pDevMode == NULL) ? NULL : &pdefs); } + delete [] pszBuff; + return m_hPrinter != NULL; } @@ -233,31 +221,43 @@ public: HANDLE CopyToHDEVNAMES() const { - HANDLE h = NULL; + HANDLE hDevNames = NULL; CPrinterInfo<5> pinfon5; CPrinterInfo<2> pinfon2; LPTSTR lpszPrinterName = NULL; + LPTSTR lpszPortName = NULL; // Some printers fail for PRINTER_INFO_5 in some situations - if (pinfon5.GetPrinterInfo(m_hPrinter)) + if(pinfon5.GetPrinterInfo(m_hPrinter)) + { lpszPrinterName = pinfon5.m_pi->pPrinterName; - else if (pinfon2.GetPrinterInfo(m_hPrinter)) + lpszPortName = pinfon5.m_pi->pPortName; + } + else if(pinfon2.GetPrinterInfo(m_hPrinter)) + { lpszPrinterName = pinfon2.m_pi->pPrinterName; - if (lpszPrinterName != NULL) + lpszPortName = pinfon2.m_pi->pPortName; + } + + if(lpszPrinterName != NULL) { - int nLen = sizeof(DEVNAMES) + (lstrlen(lpszPrinterName) + 1) * sizeof(TCHAR); - h = ::GlobalAlloc(GMEM_MOVEABLE, nLen); - BYTE* pv = (BYTE*)::GlobalLock(h); + int nLen = sizeof(DEVNAMES) + (lstrlen(lpszPrinterName) + 1 + lstrlen(lpszPortName) + 1) * sizeof(TCHAR); + hDevNames = ::GlobalAlloc(GMEM_MOVEABLE, nLen); + BYTE* pv = (BYTE*)::GlobalLock(hDevNames); DEVNAMES* pdev = (DEVNAMES*)pv; - if (pv != NULL) + if(pv != NULL) { memset(pv, 0, nLen); pdev->wDeviceOffset = sizeof(DEVNAMES) / sizeof(TCHAR); pv = pv + sizeof(DEVNAMES); // now points to end - SecureHelper::strcpy_x((LPTSTR)pv, lstrlen(lpszPrinterName) + 1, lpszPrinterName); - ::GlobalUnlock(h); + ATL::Checked::tcscpy_s((LPTSTR)pv, lstrlen(lpszPrinterName) + 1, lpszPrinterName); + pdev->wOutputOffset = (WORD)(sizeof(DEVNAMES) / sizeof(TCHAR) + lstrlen(lpszPrinterName) + 1); + pv = pv + (lstrlen(lpszPrinterName) + 1) * sizeof(TCHAR); + ATL::Checked::tcscpy_s((LPTSTR)pv, lstrlen(lpszPortName) + 1, lpszPortName); + ::GlobalUnlock(hDevNames); } } - return h; + + return hDevNames; } HDC CreatePrinterDC(const DEVMODE* pdm = NULL) const @@ -377,7 +377,7 @@ public: if (h != NULL) { void* p = ::GlobalLock(h); - SecureHelper::memcpy_x(p, nSize, pdm, nSize); + ATL::Checked::memcpy_s(p, nSize, pdm, nSize); ::GlobalUnlock(h); } Attach(h); @@ -405,7 +405,7 @@ public: if (h != NULL) { void* p = ::GlobalLock(h); - SecureHelper::memcpy_x(p, nSize, m_pDevMode, nSize); + ATL::Checked::memcpy_s(p, nSize, m_pDevMode, nSize); ::GlobalUnlock(h); } return h; @@ -417,7 +417,7 @@ public: { bool bRet = false; LONG nLen = ::DocumentProperties(NULL, hPrinter, NULL, NULL, NULL, 0); - CTempBuffer buff; + ATL::CTempBuffer buff; DEVMODE* pdm = buff.AllocateBytes(nLen); if(pdm != NULL) { @@ -439,7 +439,7 @@ public: bool bRet = false; LONG nLen = ::DocumentProperties(hWnd, hPrinter, pi.m_pi->pName, NULL, NULL, 0); - CTempBuffer buff; + ATL::CTempBuffer buff; DEVMODE* pdm = buff.AllocateBytes(nLen); if(pdm != NULL) { @@ -531,6 +531,9 @@ public: class ATL_NO_VTABLE CPrintJobInfo : public IPrintJobInfo { public: + CPrintJobInfo() : m_nPJState(0) + { } + virtual void BeginPrintJob(HDC /*hDC*/) // allocate handles needed, etc { } @@ -581,8 +584,10 @@ public: unsigned long m_nEndPage; // Constructor/destructor - CPrintJob() : m_nJobID(0), m_bCancel(false), m_bComplete(true) - { } + CPrintJob() : m_pInfo(NULL), m_pDefDevMode(NULL), m_nJobID(0), m_bCancel(false), m_bComplete(true), m_nStartPage(0), m_nEndPage(0) + { + memset(&m_docinfo, 0, sizeof(m_docinfo)); + } ~CPrintJob() { @@ -625,7 +630,7 @@ public: // Create a thread and return DWORD dwThreadID = 0; -#if !defined(_ATL_MIN_CRT) && defined(_MT) +#ifdef _MT HANDLE hThread = (HANDLE)_beginthreadex(NULL, 0, (UINT (WINAPI*)(void*))StartProc, this, 0, (UINT*)&dwThreadID); #else HANDLE hThread = ::CreateThread(NULL, 0, StartProc, (void*)this, 0, &dwThreadID); @@ -711,8 +716,11 @@ public: DEVMODE* m_pCurDevMode; SIZE m_sizeCurPhysOffset; +// Implementation - data + int m_nCurPage; + // Constructor - CPrintPreview() : m_pInfo(NULL), m_pDefDevMode(NULL), m_pCurDevMode(NULL) + CPrintPreview() : m_pInfo(NULL), m_pDefDevMode(NULL), m_pCurDevMode(NULL), m_nCurPage(0) { m_sizeCurPhysOffset.cx = 0; m_sizeCurPhysOffset.cy = 0; @@ -769,6 +777,11 @@ public: CEnhMetaFileInfo emfinfo(m_meta); ENHMETAHEADER* pmh = emfinfo.GetEnhMetaFileHeader(); + if(pmh == NULL) + { + ATLASSERT(FALSE); + return; + } // Compute whether we are OK vertically or horizontally int x2 = pmh->szlDevice.cx; @@ -802,15 +815,18 @@ public: { CEnhMetaFileInfo emfinfo(m_meta); ENHMETAHEADER* pmh = emfinfo.GetEnhMetaFileHeader(); + if(pmh == NULL) + { + ATLASSERT(FALSE); + return; + } + int nOffsetX = MulDiv(m_sizeCurPhysOffset.cx, rc.right-rc.left, pmh->szlDevice.cx); int nOffsetY = MulDiv(m_sizeCurPhysOffset.cy, rc.bottom-rc.top, pmh->szlDevice.cy); dc.OffsetWindowOrg(-nOffsetX, -nOffsetY); dc.PlayMetaFile(m_meta, &rc); } - -// Implementation - data - int m_nCurPage; }; @@ -821,12 +837,12 @@ template , public CPrintPreview { public: - DECLARE_WND_CLASS_EX(NULL, CS_VREDRAW | CS_HREDRAW, -1) + DECLARE_WND_CLASS_EX2(NULL, T, CS_VREDRAW | CS_HREDRAW, -1) enum { m_cxOffset = 10, m_cyOffset = 10 }; // Constructor - CPrintPreviewWindowImpl() : m_nMaxPage(0), m_nMinPage(0) + CPrintPreviewWindowImpl() : m_nMinPage(0), m_nMaxPage(0) { } // Operations @@ -843,7 +859,7 @@ public: if (m_nCurPage == m_nMaxPage) return false; SetPage(m_nCurPage + 1); - Invalidate(); + this->Invalidate(); return true; } @@ -854,7 +870,7 @@ public: if (m_nCurPage == 0) return false; SetPage(m_nCurPage - 1); - Invalidate(); + this->Invalidate(); return true; } @@ -873,7 +889,7 @@ public: LRESULT OnPaint(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) { T* pT = static_cast(this); - RECT rc = { 0 }; + RECT rc = {}; if(wParam != NULL) { @@ -882,7 +898,7 @@ public: } else { - CPaintDC dc(m_hWnd); + CPaintDC dc(this->m_hWnd); pT->DoPrePaint(dc.m_hDC, rc); pT->DoPaint(dc.m_hDC, rc); } @@ -893,11 +909,11 @@ public: // Painting helper void DoPrePaint(CDCHandle dc, RECT& rc) { - RECT rcClient = { 0 }; - GetClientRect(&rcClient); + RECT rcClient = {}; + this->GetClientRect(&rcClient); RECT rcArea = rcClient; T* pT = static_cast(this); - pT; // avoid level 4 warning + (void)pT; // avoid level 4 warning ::InflateRect(&rcArea, -pT->m_cxOffset, -pT->m_cyOffset); if (rcArea.left > rcArea.right) rcArea.right = rcArea.left; @@ -940,7 +956,7 @@ public: CZoomPrintPreviewWindowImpl() { - SetScrollExtendedStyle(SCRL_DISABLENOSCROLL); + this->SetScrollExtendedStyle(SCRL_DISABLENOSCROLL); InitZoom(); } @@ -948,9 +964,9 @@ public: void InitZoom() { m_bSized = false; - m_nZoomMode = ZOOMMODE_OFF; - m_fZoomScaleMin = 1.0; - m_fZoomScale = 1.0; + this->m_nZoomMode = ZOOMMODE_OFF; + this->m_fZoomScaleMin = 1.0; + this->m_fZoomScale = 1.0; } BEGIN_MSG_MAP(CZoomPrintPreviewWindowImpl) @@ -958,9 +974,6 @@ public: MESSAGE_HANDLER(WM_VSCROLL, CScrollImpl< T >::OnVScroll) MESSAGE_HANDLER(WM_HSCROLL, CScrollImpl< T >::OnHScroll) MESSAGE_HANDLER(WM_MOUSEWHEEL, CScrollImpl< T >::OnMouseWheel) -#if !((_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)) - MESSAGE_HANDLER(m_uMsgMouseWheel, CScrollImpl< T >::OnMouseWheel) -#endif // !((_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)) MESSAGE_HANDLER(WM_MOUSEHWHEEL, CScrollImpl< T >::OnMouseHWheel) MESSAGE_HANDLER(WM_SETTINGCHANGE, CScrollImpl< T >::OnSettingChange) MESSAGE_HANDLER(WM_LBUTTONDOWN, CZoomScrollImpl< T >::OnLButtonDown) @@ -989,14 +1002,14 @@ public: LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { SIZE sizeClient = {GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)}; - POINT ptOffset = m_ptOffset; - SIZE sizeAll = m_sizeAll; - SetScrollSize(sizeClient); + POINT ptOffset = this->m_ptOffset; + SIZE sizeAll = this->m_sizeAll; + this->SetScrollSize(sizeClient); if(sizeAll.cx > 0) - ptOffset.x = ::MulDiv(ptOffset.x, m_sizeAll.cx, sizeAll.cx); + ptOffset.x = ::MulDiv(ptOffset.x, this->m_sizeAll.cx, sizeAll.cx); if(sizeAll.cy > 0) - ptOffset.y = ::MulDiv(ptOffset.y, m_sizeAll.cy, sizeAll.cy); - SetScrollOffset(ptOffset); + ptOffset.y = ::MulDiv(ptOffset.y, this->m_sizeAll.cy, sizeAll.cy); + this->SetScrollOffset(ptOffset); CScrollImpl< T >::OnSize(uMsg, wParam, lParam, bHandled); if(!m_bSized) { @@ -1016,7 +1029,7 @@ public: LRESULT OnPaint(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) { T* pT = static_cast(this); - RECT rc = { 0 }; + RECT rc = {}; if(wParam != NULL) { @@ -1024,11 +1037,11 @@ public: int nMapModeSav = dc.GetMapMode(); dc.SetMapMode(MM_ANISOTROPIC); SIZE szWindowExt = { 0, 0 }; - dc.SetWindowExt(m_sizeLogAll, &szWindowExt); + dc.SetWindowExt(this->m_sizeLogAll, &szWindowExt); SIZE szViewportExt = { 0, 0 }; - dc.SetViewportExt(m_sizeAll, &szViewportExt); + dc.SetViewportExt(this->m_sizeAll, &szViewportExt); POINT ptViewportOrg = { 0, 0 }; - dc.SetViewportOrg(-m_ptOffset.x, -m_ptOffset.y, &ptViewportOrg); + dc.SetViewportOrg(-this->m_ptOffset.x, -this->m_ptOffset.y, &ptViewportOrg); pT->DoPrePaint(dc, rc); pT->DoPaint(dc, rc); @@ -1057,17 +1070,17 @@ public: void DoPrePaint(CDCHandle dc, RECT& rc) { - RECT rcClient = { 0 }; - GetClientRect(&rcClient); + RECT rcClient = {}; + this->GetClientRect(&rcClient); RECT rcArea = rcClient; T* pT = static_cast(this); - pT; // avoid level 4 warning + (void)pT; // avoid level 4 warning ::InflateRect(&rcArea, -pT->m_cxOffset, -pT->m_cyOffset); if (rcArea.left > rcArea.right) rcArea.right = rcArea.left; if (rcArea.top > rcArea.bottom) rcArea.bottom = rcArea.top; - GetPageRect(rcArea, &rc); + this->GetPageRect(rcArea, &rc); HBRUSH hbrOld = dc.SelectBrush(::GetSysColorBrush(COLOR_BTNSHADOW)); dc.PatBlt(rcClient.left, rcClient.top, rc.left - rcClient.left, rcClient.bottom - rcClient.top, PATCOPY); dc.PatBlt(rc.left, rcClient.top, rc.right - rc.left, rc.top - rcClient.top, PATCOPY); @@ -1083,13 +1096,19 @@ public: void DoPaint(CDCHandle dc, RECT& rc) { - CEnhMetaFileInfo emfinfo(m_meta); + CEnhMetaFileInfo emfinfo(this->m_meta); ENHMETAHEADER* pmh = emfinfo.GetEnhMetaFileHeader(); - int nOffsetX = MulDiv(m_sizeCurPhysOffset.cx, rc.right-rc.left, pmh->szlDevice.cx); - int nOffsetY = MulDiv(m_sizeCurPhysOffset.cy, rc.bottom-rc.top, pmh->szlDevice.cy); + if(pmh == NULL) + { + ATLASSERT(FALSE); + return; + } + + int nOffsetX = MulDiv(this->m_sizeCurPhysOffset.cx, rc.right-rc.left, pmh->szlDevice.cx); + int nOffsetY = MulDiv(this->m_sizeCurPhysOffset.cy, rc.bottom-rc.top, pmh->szlDevice.cy); dc.OffsetWindowOrg(-nOffsetX, -nOffsetY); - dc.PlayMetaFile(m_meta, &rc); + dc.PlayMetaFile(this->m_meta, &rc); } }; @@ -1101,6 +1120,6 @@ public: #endif // __ATLSCRL_H__ -}; // namespace WTL +} // namespace WTL #endif // __ATLPRINT_H__ diff --git a/WrlSDK/SampleCode/PluginWinExe/WTL/atlres.h b/WrlSDK/SampleCode/PluginWinExe/WTL/atlres.h index 32544d7b8b0024f584ebde2d574d6fa772de3172..aed58f13466138b369d7852f7478a1ced8aa80b3 100644 --- a/WrlSDK/SampleCode/PluginWinExe/WTL/atlres.h +++ b/WrlSDK/SampleCode/PluginWinExe/WTL/atlres.h @@ -1,4 +1,4 @@ -// Windows Template Library - WTL version 9.10 +// Windows Template Library - WTL version 10.0 // Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. // // This file is a part of the Windows Template Library. @@ -11,33 +11,27 @@ #pragma once -#if defined(_WIN32_WCE) && !defined(__ATLRESCE_H__) - #error Use atlresCE.h instead of atlres.h for Windows CE -#endif - #ifdef RC_INVOKED #ifndef _INC_WINDOWS #define _INC_WINDOWS - #ifndef _WIN32_WCE - #define VS_VERSION_INFO 1 + #define VS_VERSION_INFO 1 - #ifdef APSTUDIO_INVOKED - #define APSTUDIO_HIDDEN_SYMBOLS // Ignore following symbols - #endif // APSTUDIO_INVOKED + #ifdef APSTUDIO_INVOKED + #define APSTUDIO_HIDDEN_SYMBOLS // Ignore following symbols + #endif // APSTUDIO_INVOKED - #ifndef WINVER - #define WINVER 0x0400 // default to Windows Version 4.0 - #endif // !WINVER + #ifndef WINVER + #define WINVER 0x0500 + #endif // !WINVER - #include + #include // operation messages sent to DLGINIT - #define LB_ADDSTRING (WM_USER+1) - #define CB_ADDSTRING (WM_USER+3) - #endif // !_WIN32_WCE + #define LB_ADDSTRING (WM_USER+1) + #define CB_ADDSTRING (WM_USER+3) #ifdef APSTUDIO_INVOKED #undef APSTUDIO_HIDDEN_SYMBOLS diff --git a/WrlSDK/SampleCode/PluginWinExe/WTL/atlribbon.h b/WrlSDK/SampleCode/PluginWinExe/WTL/atlribbon.h index bbcb7d517cd28af781f0638e4ff62f83d1acd737..0d52f65fc3098109bf18d98698985c85cc110b22 100644 --- a/WrlSDK/SampleCode/PluginWinExe/WTL/atlribbon.h +++ b/WrlSDK/SampleCode/PluginWinExe/WTL/atlribbon.h @@ -1,4 +1,4 @@ -// Windows Template Library - WTL version 9.10 +// Windows Template Library - WTL version 10.0 // Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. // // This file is a part of the Windows Template Library. @@ -23,25 +23,16 @@ #error atlribbon.h requires the Windows 7 SDK or higher #endif -#ifdef _WIN32_WCE - #error atlribbon.h is not supported on Windows CE -#endif - #ifndef __ATLAPP_H__ #error atlribbon.h requires atlapp.h to be included first #endif -#if (_ATL_VER < 0x0700) - #include - #pragma comment(lib, "shlwapi.lib") -#endif - #include // for RecentDocumentList classes #include // for Frame and UpdateUI classes #include // required for atlctrlw.h #include // for CCommandBarCtrl -#if !defined(_WTL_USE_CSTRING) && !defined(__ATLSTR_H__) +#ifndef __ATLSTR_H__ #pragma warning(push) #pragma warning(disable: 4530) // unwind semantics not enabled #include @@ -51,8 +42,8 @@ #include #pragma comment(lib, "dwmapi.lib") -#include -#include +#include "UIRibbon.h" +#include "UIRibbonPropertyHelpers.h" #pragma comment(lib, "propsys.lib") #include // for CHARFORMAT2 @@ -134,17 +125,17 @@ public: UPDUI_PERSIST = 0x0020 }; - bool IsRibbonElement(const _AtlUpdateUIMap& UIMap) + bool IsRibbonElement(const CUpdateUIBase::_AtlUpdateUIMap& UIMap) { return (UIMap.m_wType & UPDUI_RIBBON) != 0; } bool IsRibbonID(UINT nID) { - for(int i = 0; i < m_arrUIMap.GetSize(); i++) + for(int i = 0; i < this->m_arrUIMap.GetSize(); i++) { - if(m_arrUIMap[i].m_nID == nID) - return IsRibbonElement(m_arrUIMap[i]); + if(this->m_arrUIMap[i].m_nID == nID) + return IsRibbonElement(this->m_arrUIMap[i]); } return false; @@ -153,19 +144,19 @@ public: // Element bool UIAddRibbonElement(UINT nID) { - return UIAddElement(nID); + return this->UIAddElement(nID); } bool UIRemoveRibbonElement(UINT nID) { - return UIRemoveElement(nID); + return this->UIRemoveElement(nID); } bool UIPersistElement(UINT nID, bool bPersist = true) { return bPersist ? - UIAddElement(nID) : - UIRemoveElement(nID); + this->UIAddElement(nID) : + this->UIRemoveElement(nID); } // methods for Ribbon elements @@ -180,8 +171,8 @@ public: BOOL UISetText(int nID, UINT uIdResource, BOOL bForceUpdate = FALSE) { - CTempBuffer sText(RIBBONUI_MAX_TEXT); - int nRet = AtlLoadString(uIdResource, sText, RIBBONUI_MAX_TEXT); + ATL::CTempBuffer sText(RIBBONUI_MAX_TEXT); + int nRet = ATL::AtlLoadString(uIdResource, sText, RIBBONUI_MAX_TEXT); if(nRet > 0) UISetText(nID, sText, bForceUpdate); return (nRet > 0) ? TRUE : FALSE; @@ -190,12 +181,12 @@ public: LPCTSTR UIGetText(int nID) { T* pT = static_cast(this); - LPCTSTR sUI = CAutoUpdateUI::UIGetText(nID); + LPCTSTR sUI = CAutoUpdateUI::UIGetText(nID); // replace 'tab' by 'space' for RibbonUI elements if (sUI && pT->IsRibbonUI() && IsRibbonID(nID) && wcschr(sUI, L'\t')) { - static WCHAR sText[RIBBONUI_MAX_TEXT] = { 0 }; + static WCHAR sText[RIBBONUI_MAX_TEXT] = {}; wcscpy_s(sText, sUI); WCHAR* pch = wcschr(sText, L'\t'); if (pch != NULL) @@ -244,8 +235,8 @@ namespace RibbonUI { // Minimal string allocation support for various PROPERTYKEY values -#if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) - typedef _CSTRING_NS::CString Text; +#ifdef __ATLSTR_H__ + typedef ATL::CString Text; #else class Text : public std::wstring { @@ -269,7 +260,7 @@ namespace RibbonUI return static_cast(std::wstring::operator =(s)); } }; -#endif +#endif // __ATLSTR_H__ // PROPERTYKEY enum and helpers enum k_KEY @@ -382,13 +373,14 @@ struct CharFormat : CHARFORMAT2 // Copy constructor CharFormat(const CharFormat& cf) { - ::CopyMemory(this, &cf, sizeof(CHARFORMAT2)); + this->CharFormat::CharFormat(); + ::CopyMemory(this, &cf, sizeof(CharFormat)); } // Assign operator CharFormat& operator =(const CharFormat& cf) { - ::CopyMemory(this, &cf, sizeof(CHARFORMAT2)); + ::CopyMemory(this, &cf, sizeof(CharFormat)); return (*this); } @@ -410,15 +402,15 @@ struct CharFormat : CHARFORMAT2 { &CharFormat::Getk_Family, &CharFormat::Getk_FontProperties_Size, - &CharFormat::Getk_MaskEffect, - &CharFormat::Getk_MaskEffect, - &CharFormat::Getk_MaskEffect, - &CharFormat::Getk_MaskEffect, - &CharFormat::Getk_VerticalPositioning, - &CharFormat::Getk_Color, - &CharFormat::Getk_Color, - &CharFormat::Getk_ColorType, - &CharFormat::Getk_ColorType, + &CharFormat::Getk_MaskEffectBold, + &CharFormat::Getk_MaskEffectItalic, + &CharFormat::Getk_MaskEffectUnderline, + &CharFormat::Getk_MaskEffectStrikeout, + &CharFormat::Getk_VerticalPositioning, + &CharFormat::Getk_Color, + &CharFormat::Getk_ColorBack, + &CharFormat::Getk_ColorType, + &CharFormat::Getk_ColorTypeBack, }; DWORD nProps = 0; @@ -474,7 +466,7 @@ private: { if (SUCCEEDED(pStore->GetValue(UI_PKEY_FontProperties_Size, &propvar))) { - DECIMAL decSize = { 0 }; + DECIMAL decSize = {}; UIPropertyToDecimal(UI_PKEY_FontProperties_Size, propvar, &decSize); DOUBLE dSize = 0; VarR8FromDec(&decSize, &dSize); @@ -486,18 +478,37 @@ private: } } - template - void Getk_MaskEffect(IPropertyStore* pStore) + void Getk_MaskEffectBold(IPropertyStore* pStore) + { + Getk_MaskEffectAll(pStore, CFM_BOLD, CFE_BOLD, UI_PKEY_FontProperties_Bold); + } + + void Getk_MaskEffectItalic(IPropertyStore* pStore) + { + Getk_MaskEffectAll(pStore, CFM_ITALIC, CFE_ITALIC, UI_PKEY_FontProperties_Italic); + } + + void Getk_MaskEffectUnderline(IPropertyStore* pStore) + { + Getk_MaskEffectAll(pStore, CFM_UNDERLINE, CFE_UNDERLINE, UI_PKEY_FontProperties_Underline); + } + + void Getk_MaskEffectStrikeout(IPropertyStore* pStore) + { + Getk_MaskEffectAll(pStore, CFM_STRIKEOUT, CFE_STRIKEOUT, UI_PKEY_FontProperties_Strikethrough); + } + + void Getk_MaskEffectAll(IPropertyStore* pStore, DWORD _dwMask, DWORD _dwEffects, REFPROPERTYKEY key) { if (SUCCEEDED(pStore->GetValue(key, &propvar))) { UIPropertyToUInt32(key, propvar, &uValue); if ((UI_FONTPROPERTIES)uValue != UI_FONTPROPERTIES_NOTAVAILABLE) { - dwMask |= t_dwMask; - dwEffects |= ((UI_FONTPROPERTIES) uValue == UI_FONTPROPERTIES_SET) ? t_dwEffects : 0; + dwMask |= _dwMask; + dwEffects |= ((UI_FONTPROPERTIES)uValue == UI_FONTPROPERTIES_SET) ? _dwEffects : 0; } - } + } } void Getk_VerticalPositioning(IPropertyStore* pStore) @@ -517,32 +528,51 @@ private: } } - template void Getk_Color(IPropertyStore* pStore) + { + Getk_ColorAll(pStore, CFM_COLOR, UI_PKEY_FontProperties_ForegroundColor); + } + + void Getk_ColorBack(IPropertyStore* pStore) + { + Getk_ColorAll(pStore, CFM_BACKCOLOR, UI_PKEY_FontProperties_BackgroundColor); + } + + void Getk_ColorAll(IPropertyStore* pStore, DWORD _dwMask, REFPROPERTYKEY key) { UINT32 color = 0; if (SUCCEEDED(pStore->GetValue(key, &propvar))) { UIPropertyToUInt32(key, propvar, &color); - dwMask |= t_dwMask; + dwMask |= _dwMask; - if (t_dwMask == CFM_COLOR) + if (_dwMask == CFM_COLOR) crTextColor = color; else crBackColor = color; } } - template void Getk_ColorType(IPropertyStore* pStore) + { + Getk_ColorTypeAll(pStore, CFM_COLOR, CFE_AUTOCOLOR, UI_SWATCHCOLORTYPE_AUTOMATIC, UI_PKEY_FontProperties_ForegroundColor); + + } + + void Getk_ColorTypeBack(IPropertyStore* pStore) + { + Getk_ColorTypeAll(pStore, CFM_BACKCOLOR, CFE_AUTOBACKCOLOR, UI_SWATCHCOLORTYPE_NOCOLOR, UI_PKEY_FontProperties_BackgroundColor); + } + + void Getk_ColorTypeAll(IPropertyStore* pStore, DWORD _dwMask, DWORD _dwEffects, UI_SWATCHCOLORTYPE _type, REFPROPERTYKEY key) { if (SUCCEEDED(pStore->GetValue(key, &propvar))) { UIPropertyToUInt32(key, propvar, &uValue); - if (t_type == (UI_SWATCHCOLORTYPE)uValue) + if (_type == (UI_SWATCHCOLORTYPE)uValue) { - dwMask |= t_dwMask; - dwEffects |= t_dwEffects; + dwMask |= _dwMask; + dwEffects |= _dwEffects; } } } @@ -686,6 +716,9 @@ public: CtrlImpl() : m_pWndRibbon(T::pWndRibbon) { } + virtual ~CtrlImpl() + { } + WndRibbon& GetWndRibbon() { return *m_pWndRibbon; @@ -778,7 +811,7 @@ public: m_hbm[k_(key) - k_LargeImage].Attach(hbm); return bUpdate ? - GetWndRibbon().InvalidateProperty(GetID(), key) : + this->GetWndRibbon().InvalidateProperty(this->GetID(), key) : S_OK; } @@ -789,7 +822,7 @@ public: const INT iImage = k_(key) - k_LargeImage; if (m_hbm[iImage].IsNull()) - m_hbm[iImage] = GetWndRibbon().OnRibbonQueryImage(GetID(), key); + m_hbm[iImage] = this->GetWndRibbon().OnRibbonQueryImage(this->GetID(), key); return m_hbm[iImage].IsNull() ? E_NOTIMPL : @@ -799,11 +832,11 @@ public: virtual HRESULT DoUpdateProperty(UINT nCmdID, REFPROPERTYKEY key, const PROPVARIANT* ppropvarCurrentValue, PROPVARIANT* ppropvarNewValue) { - ATLASSERT (nCmdID == GetID()); + ATLASSERT (nCmdID == this->GetID()); return (k_(key) <= k_SmallHighContrastImage) && (k_(key) >= k_LargeImage) ? OnGetImage(key, ppropvarNewValue) : - CtrlImpl::DoUpdateProperty(nCmdID, key, ppropvarCurrentValue, ppropvarNewValue); + CtrlImpl::DoUpdateProperty(nCmdID, key, ppropvarCurrentValue, ppropvarNewValue); } }; @@ -871,6 +904,7 @@ class CollectionImplBase public: CollectionImplBase() { + memset(&m_apItems, 0, sizeof(m_apItems)); for (int i = 0; i < t_size; i++) m_apItems[i] = new ItemProperty(i, static_cast(this)); } @@ -951,7 +985,7 @@ public: { if (m_auItemCat[uItem] == UI_COLLECTION_INVALIDINDEX) { - TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); + typename TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); m_auItemCat[uItem] = ribbon.OnRibbonQueryItemCategory(TCtrl::GetID(), uItem); } uCat = m_auItemCat[uItem]; @@ -969,7 +1003,7 @@ public: case k_Label: if (m_asCatName[uCat].IsEmpty()) { - TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); + typename TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); m_asCatName[uCat] = ribbon.OnRibbonQueryCategoryText(TCtrl::GetID(), uCat); } hr = SetPropertyVal(key, (LPCWSTR)m_asCatName[uCat], value); @@ -999,7 +1033,7 @@ public: const PROPVARIANT* ppropvarCurrentValue, PROPVARIANT* /*ppropvarNewValue*/) { ATLASSERT(nCmdID == TCtrl::GetID()); - nCmdID; // avoid level 4 warning + (void)nCmdID; // avoid level 4 warning HRESULT hr = E_NOTIMPL; switch (k_(key)) @@ -1011,7 +1045,7 @@ public: hr = pIUICollection->Clear(); for (UINT i = 0; i < m_size; i++) { - if FAILED(hr = pIUICollection->Add(m_apItems[i])) + if FAILED(hr = pIUICollection->Add(this->m_apItems[i])) break; } ATLASSERT(SUCCEEDED(hr)); @@ -1025,7 +1059,7 @@ public: hr = pIUICategory->Clear(); for (UINT i = t_items; i < (t_items + t_categories); i++) { - if FAILED(hr = pIUICategory->Add(m_apItems[i])) + if FAILED(hr = pIUICategory->Add(this->m_apItems[i])) break; } ATLASSERT(SUCCEEDED(hr)); @@ -1059,7 +1093,7 @@ public: m_asText[uItem] = sText; - return bUpdate ? InvalidateItems() : S_OK; + return bUpdate ? this->InvalidateItems() : S_OK; } UINT GetSelected() @@ -1073,7 +1107,7 @@ public: m_uSelected = uItem; - TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); + typename TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); return bUpdate ? ribbon.SetProperty(TCtrl::GetID(), UI_PKEY_SelectedItem, uItem) : S_OK; @@ -1088,14 +1122,14 @@ public: { if (m_asText[uItem].IsEmpty()) { - TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); + typename TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); m_asText[uItem] = ribbon.OnRibbonQueryItemText(TCtrl::GetID(), uItem); } return SetPropertyVal(key, (LPCWSTR)m_asText[uItem], value); } else { - return Collection::DoGetItem(uItem, key, value); + return CollectionImpl::Collection::DoGetItem(uItem, key, value); } } @@ -1106,7 +1140,7 @@ public: if (k_(key) == k_SelectedItem) { - TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); + typename TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); UINT uSel = UI_COLLECTION_INVALIDINDEX; if ((m_uSelected == UI_COLLECTION_INVALIDINDEX) && ribbon.OnRibbonQuerySelectedItem(TCtrl::GetID(), uSel)) @@ -1116,7 +1150,7 @@ public: } else { - return Collection::DoUpdateProperty(nCmdID, key, ppropvarCurrentValue, ppropvarNewValue); + return CollectionImpl::Collection::DoUpdateProperty(nCmdID, key, ppropvarCurrentValue, ppropvarNewValue); } } }; @@ -1130,11 +1164,6 @@ class ItemCollectionImpl : public TextCollectionImplInvalidateItems() : S_OK; } // Implementation @@ -1156,7 +1185,7 @@ public: { if (m_aBitmap[uItem].IsNull()) { - TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); + typename TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); m_aBitmap[uItem] = ribbon.OnRibbonQueryItemImage(TCtrl::GetID(), uItem); } return m_aBitmap[uItem].IsNull() ? @@ -1165,7 +1194,7 @@ public: } else { - return TextCollection::DoGetItem(uItem, key, value); + return TextCollectionImpl::TextCollection::DoGetItem(uItem, key, value); } } }; @@ -1182,7 +1211,7 @@ public: // Operations HRESULT SetComboText(LPCWSTR sText) { - TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); + typename TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); return ribbon.IsRibbonUI() ? ribbon.SetProperty(TCtrl::GetID(), UI_PKEY_StringValue, sText) : S_OK; @@ -1190,13 +1219,15 @@ public: LPCWSTR GetComboText() { - static WCHAR sCombo[RIBBONUI_MAX_TEXT] = { 0 }; - TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); + static WCHAR sCombo[RIBBONUI_MAX_TEXT] = {}; + typename TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); PROPVARIANT var; if (ribbon.IsRibbonUI()) { HRESULT hr = ribbon.GetIUIFrameworkPtr()->GetUICommandProperty(TCtrl::GetID(), UI_PKEY_StringValue, &var); + ATLASSERT(SUCCEEDED(hr)); hr = PropVariantToString(var, sCombo, RIBBONUI_MAX_TEXT); + ATLASSERT(SUCCEEDED(hr)); return sCombo; } return NULL; @@ -1229,13 +1260,13 @@ public: if (uCommandID == m_auCmd[uItem]) return S_OK; - TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); + typename TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); m_auCmd[uItem] = uCommandID; if (uCommandID != 0) ribbon.UIAddRibbonElement(uCommandID); - return bUpdate ? InvalidateItems() : S_OK; + return bUpdate ? this->InvalidateItems() : S_OK; } HRESULT SetItemCommandType(UINT uItem, UI_COMMANDTYPE type, bool bUpdate = false) @@ -1244,14 +1275,14 @@ public: m_aCmdType[uItem] = (BYTE)type; - return bUpdate ? InvalidateItems() : S_OK; + return bUpdate ? this->InvalidateItems() : S_OK; } // Implementation HRESULT DoGetItem(UINT uItem, REFPROPERTYKEY key, PROPVARIANT *value) { ATLASSERT(uItem < t_items); - TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); + typename TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); HRESULT hr = E_FAIL; switch (k_(key)) @@ -1268,7 +1299,7 @@ public: break; case k_CategoryId: default: - hr = Collection::DoGetItem(uItem, key, value); + hr = CollectionImpl::Collection::DoGetItem(uItem, key, value); break; } @@ -1296,7 +1327,7 @@ public: HRESULT OnGetItem(UINT uItem, REFPROPERTYKEY key, PROPVARIANT *value) { ATLASSERT(uItem < t_size); - TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); + typename TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); HRESULT hr = E_NOTIMPL; switch (k_(key)) @@ -1345,7 +1376,7 @@ public: virtual HRESULT DoUpdateProperty(UINT nCmdID, REFPROPERTYKEY key, const PROPVARIANT* ppropvarCurrentValue, PROPVARIANT* ppropvarNewValue) { - ATLASSERT(nCmdID == GetID()); + ATLASSERT(nCmdID == this->GetID()); ATLASSERT(ppropvarNewValue); HRESULT hr = Collection::DoUpdateProperty(nCmdID, key, ppropvarCurrentValue, ppropvarNewValue); @@ -1359,12 +1390,12 @@ public: const PROPERTYKEY* key, const PROPVARIANT* ppropvarValue, IUISimplePropertySet* /*pCommandExecutionProperties*/) { - ATLASSERT (nCmdID == GetID()); - nCmdID; // avoid level4 warning + ATLASSERT (nCmdID == this->GetID()); + (void)nCmdID; // avoid level4 warning if (key == NULL) // gallery button pressed { - GetWndRibbon().OnRibbonItemSelected(GetID(), UI_EXECUTIONVERB_EXECUTE, UI_COLLECTION_INVALIDINDEX); + this->GetWndRibbon().OnRibbonItemSelected(this->GetID(), UI_EXECUTIONVERB_EXECUTE, UI_COLLECTION_INVALIDINDEX); return S_OK; } @@ -1377,7 +1408,7 @@ public: if (SUCCEEDED(hr)) { - if (GetWndRibbon().OnRibbonItemSelected(GetID(), verb, uSel)) + if (this->GetWndRibbon().OnRibbonItemSelected(this->GetID(), verb, uSel)) TCollection::Select(uSel); } @@ -1405,28 +1436,28 @@ public: { if (pItems[i] != 0) { - m_aCmdType[j] = UI_COMMANDTYPE_ACTION; - m_auCmd[j++] = pItems[i]; + this->m_aCmdType[j] = UI_COMMANDTYPE_ACTION; + this->m_auCmd[j++] = pItems[i]; } } if (j < t_size) - Resize(j); + this->Resize(j); } HRESULT DoGetItem(UINT uItem, REFPROPERTYKEY key, PROPVARIANT *value) { - ATLASSERT(uItem < m_size); - ATLASSERT(m_auCmd[uItem]); + ATLASSERT(uItem < this->m_size); + ATLASSERT(this->m_auCmd[uItem]); HRESULT hr = E_FAIL; switch (k_(key)) { case k_CommandId: - hr = SetPropertyVal(key, m_auCmd[uItem], value); + hr = SetPropertyVal(key, this->m_auCmd[uItem], value); break; case k_CommandType: - hr = SetPropertyVal(key, UINT32(m_aCmdType[uItem]), value); + hr = SetPropertyVal(key, UINT32(this->m_aCmdType[uItem]), value); break; case k_CategoryId: hr = SetPropertyVal(key, UI_COLLECTION_INVALIDINDEX, value); @@ -1464,7 +1495,7 @@ public: m_uSelected = uItem; return bUpdate ? - GetWndRibbon().SetProperty(GetID(), UI_PKEY_SelectedItem, uItem) : + this->GetWndRibbon().SetProperty(this->GetID(), UI_PKEY_SelectedItem, uItem) : S_OK; } @@ -1472,7 +1503,7 @@ public: virtual HRESULT DoUpdateProperty(UINT nCmdID, REFPROPERTYKEY key, const PROPVARIANT* ppropvarCurrentValue, PROPVARIANT* ppropvarNewValue) { - ATLASSERT(nCmdID == GetID()); + ATLASSERT(nCmdID == this->GetID()); ATLASSERT(ppropvarNewValue != NULL); HRESULT hr = S_OK; @@ -1485,7 +1516,7 @@ public: hr = pIUICollection->Clear(); for (UINT i = 0; i < t_size; i++) { - if FAILED(hr = pIUICollection->Add(m_apItems[i])) + if FAILED(hr = pIUICollection->Add(this->m_apItems[i])) break; } ATLASSERT(SUCCEEDED(hr)); @@ -1495,7 +1526,7 @@ public: hr = SetPropertyVal(UI_PKEY_SelectedItem, m_uSelected, ppropvarNewValue); break; default: - hr = CommandCtrlImpl::DoUpdateProperty(nCmdID, key, ppropvarCurrentValue, ppropvarNewValue); + hr = CommandCtrlImpl::DoUpdateProperty(nCmdID, key, ppropvarCurrentValue, ppropvarNewValue); break; } @@ -1506,20 +1537,20 @@ public: const PROPERTYKEY* key, const PROPVARIANT* ppropvarValue, IUISimplePropertySet* /*pCommandExecutionProperties*/) { - ATLASSERT (nCmdID == GetID()); - nCmdID; // avoid level 4 warning + ATLASSERT (nCmdID == this->GetID()); + (void)nCmdID; // avoid level 4 warning HRESULT hr = S_OK; if (key == NULL) // gallery button pressed { - GetWndRibbon().OnRibbonItemSelected(GetID(), UI_EXECUTIONVERB_EXECUTE, UI_COLLECTION_INVALIDINDEX); + this->GetWndRibbon().OnRibbonItemSelected(this->GetID(), UI_EXECUTIONVERB_EXECUTE, UI_COLLECTION_INVALIDINDEX); return hr; } ATLASSERT(k_(*key) == k_SelectedItem); ATLASSERT(ppropvarValue); if SUCCEEDED(hr = UIPropertyToUInt32(*key, *ppropvarValue, &m_uSelected)) - GetWndRibbon().OnRibbonItemSelected(GetID(), verb, m_uSelected); + this->GetWndRibbon().OnRibbonItemSelected(this->GetID(), verb, m_uSelected); return hr; } @@ -1540,14 +1571,14 @@ public: // Implementation HRESULT OnGetItem(UINT uItem, REFPROPERTYKEY key, PROPVARIANT *value) { - ATLASSERT((INT)uItem < GetMaxEntries()); + ATLASSERT((INT)uItem < this->GetMaxEntries()); - LPCWSTR sPath = m_arrDocs[uItem].szDocName; + LPCWSTR sPath = this->m_arrDocs[uItem].szDocName; HRESULT hr = E_NOTIMPL; switch (k_(key)) { case k_Label: - hr = SetPropertyVal(key, GetWndRibbon().OnRibbonQueryRecentItemName(sPath), value); + hr = SetPropertyVal(key, this->GetWndRibbon().OnRibbonQueryRecentItemName(sPath), value); break; case k_LabelDescription: hr = SetPropertyVal(key, sPath, value); @@ -1563,25 +1594,25 @@ public: virtual HRESULT DoUpdateProperty(UINT nCmdID, REFPROPERTYKEY key, const PROPVARIANT* ppropvarCurrentValue, PROPVARIANT* ppropvarNewValue) { - ATLASSERT(nCmdID == GetID()); + ATLASSERT(nCmdID == this->GetID()); ATLASSERT(ppropvarNewValue); HRESULT hr = S_OK; switch (k_(key)) { case k_RecentItems: - if (SAFEARRAY* psa = SafeArrayCreateVector(VT_UNKNOWN, 0, m_arrDocs.GetSize())) + if (SAFEARRAY* psa = SafeArrayCreateVector(VT_UNKNOWN, 0, this->m_arrDocs.GetSize())) { - const int iLastIndex = m_arrDocs.GetSize() - 1; + const int iLastIndex = this->m_arrDocs.GetSize() - 1; for (LONG i = 0; i <= iLastIndex; i++) - SafeArrayPutElement(psa, &i, m_apItems[iLastIndex - i]); // reverse order + SafeArrayPutElement(psa, &i, this->m_apItems[iLastIndex - i]); // reverse order hr = SetPropertyVal(key, psa, ppropvarNewValue); SafeArrayDestroy(psa); } break; default: - hr = CtrlImpl::DoUpdateProperty(nCmdID, key, ppropvarCurrentValue, ppropvarNewValue); + hr = CtrlImpl::DoUpdateProperty(nCmdID, key, ppropvarCurrentValue, ppropvarNewValue); break; } @@ -1592,10 +1623,10 @@ public: const PROPERTYKEY* key, const PROPVARIANT* ppropvarValue, IUISimplePropertySet* /*pCommandExecutionProperties*/) { - ATLASSERT(nCmdID == GetID()); - nCmdID; // avoid level 4 warning + ATLASSERT(nCmdID == this->GetID()); + (void)nCmdID; // avoid level 4 warning ATLASSERT(verb == UI_EXECUTIONVERB_EXECUTE); - verb; // avoid level 4 warning + (void)verb; // avoid level 4 warning ATLASSERT((key) && (k_(*key) == k_SelectedItem)); ATLASSERT(ppropvarValue); @@ -1603,8 +1634,8 @@ public: HRESULT hr = UIPropertyToUInt32(*key, *ppropvarValue, &uSel); if SUCCEEDED(hr) { - ATLASSERT(uSel < (UINT)GetMaxEntries()); - GetWndRibbon().DefCommandExecute(ID_FILE_MRU_FIRST + uSel); + ATLASSERT(uSel < (UINT)this->GetMaxEntries()); + this->GetWndRibbon().DefCommandExecute(ID_FILE_MRU_FIRST + uSel); } return hr; @@ -1629,10 +1660,10 @@ public: const PROPERTYKEY* key, const PROPVARIANT* ppropvarValue, IUISimplePropertySet* pCommandExecutionProperties) { - ATLASSERT (nCmdID == GetID()); - nCmdID; // avoid level 4 warning + ATLASSERT (nCmdID == this->GetID()); + (void)nCmdID; // avoid level 4 warning ATLASSERT ((key) && (k_(*key) == k_FontProperties)); - key; // avoid level 4 warning + (void)key; // avoid level 4 warning HRESULT hr = E_INVALIDARG; switch (verb) @@ -1656,7 +1687,7 @@ public: } if (SUCCEEDED(hr)) - GetWndRibbon().OnRibbonFontCtrlExecute(GetID(), verb, &m_cf); + this->GetWndRibbon().OnRibbonFontCtrlExecute(this->GetID(), verb, &m_cf); else ATLASSERT(FALSE); @@ -1666,7 +1697,7 @@ public: virtual HRESULT DoUpdateProperty(UINT nCmdID, REFPROPERTYKEY key, const PROPVARIANT* ppropvarCurrentValue, PROPVARIANT* ppropvarNewValue) { - if ((k_(key) == k_FontProperties) && (GetWndRibbon().OnRibbonQueryFont(t_ID, m_cf))) + if ((k_(key) == k_FontProperties) && (this->GetWndRibbon().OnRibbonQueryFont(t_ID, m_cf))) { ATL::CComQIPtr pStore(ppropvarCurrentValue->punkVal); m_cf >> pStore; @@ -1674,7 +1705,7 @@ public: } else { - return CtrlImpl::DoUpdateProperty(nCmdID, key, ppropvarCurrentValue, ppropvarNewValue); + return CtrlImpl::DoUpdateProperty(nCmdID, key, ppropvarCurrentValue, ppropvarNewValue); } } }; @@ -1688,8 +1719,8 @@ public: ColorCtrlImpl() : m_colorType(UI_SWATCHCOLORTYPE_NOCOLOR), m_color(0x800080) /*MAGENTA*/ { } - COLORREF m_color; UINT32 m_colorType; // value in UI_SWATCHCOLORTYPE + COLORREF m_color; Text m_sLabels[6]; // k_MoreColorsLabel to k_ThemeColorsCategoryLabel ATL::CSimpleArray m_aColors[2]; ATL::CSimpleArray m_aTooltips[2]; @@ -1700,20 +1731,20 @@ public: if (m_colorType != UI_SWATCHCOLORTYPE_RGB) SetColorType(UI_SWATCHCOLORTYPE_RGB, bUpdate); m_color = color; - return bUpdate ? SetProperty(UI_PKEY_Color, color) : S_OK; + return bUpdate ? this->SetProperty(UI_PKEY_Color, color) : S_OK; } HRESULT SetColorType(UI_SWATCHCOLORTYPE type, bool bUpdate = false) { m_colorType = type; - return bUpdate ? SetProperty(UI_PKEY_ColorType, type) : S_OK; + return bUpdate ? this->SetProperty(UI_PKEY_ColorType, type) : S_OK; } HRESULT SetColorLabel(REFPROPERTYKEY key, LPCWSTR sLabel, bool bUpdate = false) { ATLASSERT((k_(key) >= k_ThemeColorsCategoryLabel) && (k_(key) <= k_MoreColorsLabel)); m_sLabels[k_(key) - k_ThemeColorsCategoryLabel] = sLabel; - return bUpdate ? SetProperty(key, sLabel) : S_OK; + return bUpdate ? this->SetProperty(key, sLabel) : S_OK; } HRESULT SetColorArray(REFPROPERTYKEY key, COLORREF* pColor, bool bUpdate = false) @@ -1729,7 +1760,7 @@ public: { PROPVARIANT var; if SUCCEEDED(InitPropVariantFromUInt32Vector(m_aColors[ic].GetData(), m_aColors[ic].GetSize(), &var)) - return SetProperty(key, var); + return this->SetProperty(key, var); else return E_INVALIDARG; } @@ -1752,7 +1783,7 @@ public: { PROPVARIANT var; if SUCCEEDED(InitPropVariantFromStringVector(m_aTooltips[ic].GetData(), m_aTooltips[ic].GetSize(), &var)) - return SetProperty(key, var); + return this->SetProperty(key, var); else return E_INVALIDARG; } @@ -1767,10 +1798,10 @@ public: const PROPERTYKEY* key, const PROPVARIANT* ppropvarValue, IUISimplePropertySet* pCommandExecutionProperties) { - ATLASSERT (nCmdID == GetID()); - nCmdID; // avoid level 4 warning + ATLASSERT (nCmdID == this->GetID()); + (void)nCmdID; // avoid level 4 warning ATLASSERT (key && (k_(*key) == k_ColorType)); - key; // avoid level 4 warning + (void)key; // avoid level 4 warning ATLASSERT (ppropvarValue); HRESULT hr = PropVariantToUInt32(*ppropvarValue, &m_colorType); @@ -1785,7 +1816,7 @@ public: } if SUCCEEDED(hr) - GetWndRibbon().OnRibbonColorCtrlExecute(GetID(), verb, (UI_SWATCHCOLORTYPE)m_colorType/*uType*/, m_color); + this->GetWndRibbon().OnRibbonColorCtrlExecute(this->GetID(), verb, (UI_SWATCHCOLORTYPE)m_colorType/*uType*/, m_color); else ATLASSERT(FALSE); // something was wrong @@ -1795,7 +1826,7 @@ public: virtual HRESULT DoUpdateProperty(UINT nCmdID, REFPROPERTYKEY key, const PROPVARIANT* ppropvarCurrentValue, PROPVARIANT* ppropvarNewValue) { - ATLASSERT (nCmdID == GetID()); + ATLASSERT (nCmdID == this->GetID()); HRESULT hr = E_NOTIMPL; @@ -1806,7 +1837,7 @@ public: break; case k_Color: if (m_color == 0x800080) /*MAGENTA*/ - m_color = GetWndRibbon().OnRibbonQueryColor(GetID()); + m_color = this->GetWndRibbon().OnRibbonQueryColor(this->GetID()); hr = SetPropertyVal(key, m_color, ppropvarNewValue); break; case k_ColorMode: @@ -1820,7 +1851,7 @@ public: { const UINT iLabel = k_(key) - k_ThemeColorsCategoryLabel; if (m_sLabels[iLabel].IsEmpty()) - if (LPCWSTR psLabel = GetWndRibbon().OnRibbonQueryColorLabel(GetID(), key)) + if (LPCWSTR psLabel = this->GetWndRibbon().OnRibbonQueryColorLabel(this->GetID(), key)) m_sLabels[iLabel] = psLabel; if (!m_sLabels[iLabel].IsEmpty()) hr = SetPropertyVal(key, (LPCWSTR)m_sLabels[iLabel], ppropvarNewValue); @@ -1831,7 +1862,7 @@ public: { const INT ic = k_(key) - k_ThemeColors; if (!m_aColors[ic].GetSize()) - if (COLORREF* pColor = GetWndRibbon().OnRibbonQueryColorArray(GetID(), key)) + if (COLORREF* pColor = this->GetWndRibbon().OnRibbonQueryColorArray(this->GetID(), key)) SetColorArray(key, pColor); if (INT iMax = m_aColors[ic].GetSize()) hr = InitPropVariantFromUInt32Vector(m_aColors[ic].GetData(), iMax, ppropvarNewValue); @@ -1842,14 +1873,14 @@ public: { const INT ic = k_(key) - k_ThemeColorsTooltips; if (m_aTooltips[ic].GetSize() == 0) - if (LPCWSTR* ppsTT = GetWndRibbon().OnRibbonQueryColorTooltips(GetID(), key)) + if (LPCWSTR* ppsTT = this->GetWndRibbon().OnRibbonQueryColorTooltips(this->GetID(), key)) SetColorTooltips(key, ppsTT); if (INT iMax = m_aTooltips[ic].GetSize()) hr = InitPropVariantFromStringVector(m_aTooltips[ic].GetData(), iMax, ppropvarNewValue); } break; default: - hr = CommandCtrlImpl::DoUpdateProperty(nCmdID, key, ppropvarCurrentValue, ppropvarNewValue); + hr = CommandCtrlImpl::DoUpdateProperty(nCmdID, key, ppropvarCurrentValue, ppropvarNewValue); break; } @@ -1928,7 +1959,7 @@ public: } return bUpdate ? - GetWndRibbon().InvalidateProperty(GetID(), key) : + this->GetWndRibbon().InvalidateProperty(this->GetID(), key) : S_OK; } @@ -1945,11 +1976,11 @@ public: { DECIMAL decVal; InitDecimal(val, &decVal); - return SetProperty(key, &decVal); + return this->SetProperty(key, &decVal); } else { - return GetWndRibbon().InvalidateProperty(GetID(), key); + return this->GetWndRibbon().InvalidateProperty(this->GetID(), key); } } else @@ -1960,12 +1991,12 @@ public: HRESULT QueryValue(REFPROPERTYKEY key, LONG* plVal) { - return GetWndRibbon().OnRibbonQuerySpinnerValue(GetID(), key, plVal) ? S_OK : S_FALSE; + return this->GetWndRibbon().OnRibbonQuerySpinnerValue(this->GetID(), key, plVal) ? S_OK : S_FALSE; } HRESULT QueryValue(REFPROPERTYKEY key, DOUBLE* pdVal) { - return GetWndRibbon().OnRibbonQueryFloatSpinnerValue(GetID(), key, pdVal) ? S_OK : S_FALSE; + return this->GetWndRibbon().OnRibbonQueryFloatSpinnerValue(this->GetID(), key, pdVal) ? S_OK : S_FALSE; } HRESULT OnGetValue(REFPROPERTYKEY key, PROPVARIANT* ppv) @@ -1990,7 +2021,7 @@ public: HRESULT OnGetText(REFPROPERTYKEY key, Text& sVal, PROPVARIANT* ppv) { - if (LPCWSTR sNew = GetWndRibbon().OnRibbonQueryText(GetID(), key)) + if (LPCWSTR sNew = this->GetWndRibbon().OnRibbonQueryText(this->GetID(), key)) sVal = sNew; return SetPropertyVal(key, (LPCWSTR)sVal, ppv); } @@ -1999,19 +2030,21 @@ public: const PROPERTYKEY* key, const PROPVARIANT* ppropvarValue, IUISimplePropertySet* /*pCommandExecutionProperties*/) { - ATLASSERT (nCmdID == GetID()); - nCmdID; // avoid level 4 warning + ATLASSERT (nCmdID == this->GetID()); + (void)nCmdID; // avoid level 4 warning ATLASSERT (key && (k_(*key) == k_DecimalValue)); - key; // avoid level 4 warning + (void)key; // avoid level 4 warning ATLASSERT (verb == UI_EXECUTIONVERB_EXECUTE); - verb; // avoid level 4 warning + (void)verb; // avoid level 4 warning DECIMAL decVal; HRESULT hr = UIPropertyToDecimal(UI_PKEY_DecimalValue, *ppropvarValue, &decVal); + ATLASSERT(SUCCEEDED(hr)); hr = InitVal(m_Values[0], &decVal); + ATLASSERT(SUCCEEDED(hr)); - GetWndRibbon().OnRibbonSpinnerCtrlExecute(GetID(), &m_Values[0]); + this->GetWndRibbon().OnRibbonSpinnerCtrlExecute(this->GetID(), &m_Values[0]); return hr; } @@ -2019,7 +2052,7 @@ public: virtual HRESULT DoUpdateProperty(UINT nCmdID, REFPROPERTYKEY key, const PROPVARIANT* ppropvarCurrentValue, PROPVARIANT* ppropvarNewValue) { - ATLASSERT (nCmdID == GetID()); + ATLASSERT (nCmdID == this->GetID()); HRESULT hr = E_NOTIMPL; switch (k_(key)) @@ -2032,15 +2065,13 @@ public: hr = OnGetValue(key, ppropvarNewValue); break; case k_FormatString: - if (m_FormatString.IsEmpty()) - return OnGetText(key, m_FormatString, ppropvarNewValue); + hr = OnGetText(key, m_FormatString, ppropvarNewValue); break; case k_RepresentativeString: - if (m_RepresentativeString.IsEmpty()) - return OnGetText(key, m_RepresentativeString, ppropvarNewValue); + hr = OnGetText(key, m_RepresentativeString, ppropvarNewValue); break; default: - hr = CtrlImpl::DoUpdateProperty(nCmdID, key, ppropvarCurrentValue, ppropvarNewValue); + hr = CtrlImpl::DoUpdateProperty(nCmdID, key, ppropvarCurrentValue, ppropvarNewValue); break; } @@ -2102,7 +2133,7 @@ public: ATLASSERT(SUCCEEDED(hr)); } - ~CRibbonImpl() + virtual ~CRibbonImpl() { ::GlobalFree(m_hgRibbonSettings); m_pIUIFramework.Release(); @@ -2115,8 +2146,8 @@ public: } ATL::CComPtr m_pIUIFramework; - HGLOBAL m_hgRibbonSettings; bool m_bRibbonUI; + HGLOBAL m_hgRibbonSettings; bool IsRibbonUI() { @@ -2194,7 +2225,7 @@ public: HRESULT hr = E_FAIL; if (ATL::CComPtr pIUIRibbon = GetRibbonPtr()) { - const LARGE_INTEGER li0 = { 0 }; + const LARGE_INTEGER li0 = {}; pIStream->Seek(li0, STREAM_SEEK_SET, NULL); hr = pIUIRibbon->SaveSettingsToStream(pIStream); pIStream->Commit(STGC_DEFAULT); @@ -2211,7 +2242,7 @@ public: HRESULT hr = E_FAIL; if (ATL::CComPtr pIUIRibbon = GetRibbonPtr()) { - const LARGE_INTEGER li0 = { 0 }; + const LARGE_INTEGER li0 = {}; pIStream->Seek(li0, STREAM_SEEK_SET, NULL); hr = pIUIRibbon->LoadSettingsFromStream(pIStream); } @@ -2482,10 +2513,10 @@ public: UI_CONTEXTAVAILABILITY OnRibbonQueryTabAvail(UINT nCmdID) { - DWORD dwState = UIGetState(nCmdID); - return ((dwState & UPDUI_DISABLED) == UPDUI_DISABLED) ? + DWORD dwState = this->UIGetState(nCmdID); + return ((dwState & CUpdateUIBase::UPDUI_DISABLED) == CUpdateUIBase::UPDUI_DISABLED) ? UI_CONTEXTAVAILABILITY_NOTAVAILABLE : - (((dwState & UPDUI_CHECKED) == UPDUI_CHECKED) ? + (((dwState & CUpdateUIBase::UPDUI_CHECKED) == CUpdateUIBase::UPDUI_CHECKED) ? UI_CONTEXTAVAILABILITY_ACTIVE : UI_CONTEXTAVAILABILITY_AVAILABLE); } @@ -2609,15 +2640,15 @@ public: bool DefRibbonQueryState(UINT nCmdID, REFPROPERTYKEY key) { - DWORD dwState = UIGetState(nCmdID); + DWORD dwState = this->UIGetState(nCmdID); bool bRet = false; switch (k_(key)) { case k_BooleanValue: - bRet = (dwState & UPDUI_CHECKED) == UPDUI_CHECKED; + bRet = (dwState & CUpdateUIBase::UPDUI_CHECKED) == CUpdateUIBase::UPDUI_CHECKED; break; case k_Enabled: - bRet = (dwState & UPDUI_DISABLED) != UPDUI_DISABLED; + bRet = (dwState & CUpdateUIBase::UPDUI_DISABLED) != CUpdateUIBase::UPDUI_DISABLED; break; default: ATLASSERT(FALSE); @@ -2629,12 +2660,12 @@ public: LPCTSTR DefRibbonQueryText(UINT nCmdID, REFPROPERTYKEY key) { - static WCHAR sText[RIBBONUI_MAX_TEXT] = { 0 }; + static WCHAR sText[RIBBONUI_MAX_TEXT] = {}; if (k_(key) == k_Label) - return UIGetText(nCmdID); + return this->UIGetText(nCmdID); - if (AtlLoadString(nCmdID, sText, RIBBONUI_MAX_TEXT)) + if (ATL::AtlLoadString(nCmdID, sText, RIBBONUI_MAX_TEXT)) { PWCHAR pTitle = wcschr(sText, L'\n'); switch (k_(key)) @@ -2756,6 +2787,8 @@ public: SaveRibbonSettings(); m_bRibbonUI = false; break; + default: + break; } return S_OK; @@ -2763,7 +2796,7 @@ public: STDMETHODIMP OnCreateUICommand(UINT32 nCmdID, UI_COMMANDTYPE typeID, IUICommandHandler** ppCommandHandler) { - UIAddRibbonElement(nCmdID); + this->UIAddRibbonElement(nCmdID); if (typeID == UI_COMMANDTYPE_CONTEXT) CUpdateUIBase::UIEnable(nCmdID, false); *ppCommandHandler = this; @@ -2772,7 +2805,7 @@ public: STDMETHODIMP OnDestroyUICommand(UINT32 nCmdID, UI_COMMANDTYPE, IUICommandHandler*) { - UIRemoveRibbonElement(nCmdID); + this->UIRemoveRibbonElement(nCmdID); return S_OK; } @@ -2874,7 +2907,7 @@ public: } ATLASSERT(verb == UI_EXECUTIONVERB_EXECUTE); - verb; // avoid level 4 warning + (void)verb; // avoid level 4 warning static_cast(this)->OnRibbonCommandExecute(nCmdID); @@ -3001,7 +3034,7 @@ public: public: CRibbonFloatSpinnerCtrl() { - m_Values[4] = 1; // 1 decimal + this->m_Values[4] = 1; // 1 decimal } }; @@ -3031,7 +3064,7 @@ typedef struct } _ribbonCtrl; #pragma warning(pop) -}; // namespace RibbonUI +} // namespace RibbonUI /////////////////////////////////////////////////////////////////////////////// @@ -3058,7 +3091,7 @@ typedef struct // Control message map macros #define RIBBON_GALLERY_CONTROL_HANDLER(id, func) \ - if(uMsg == WM_COMMAND && id == LOWORD(wParam)) \ + if((uMsg == WM_COMMAND) && (id == LOWORD(wParam))) \ { \ bHandled = TRUE; \ lResult = func((UI_EXECUTIONVERB)HIWORD(wParam), LOWORD(wParam), (UINT)lParam, bHandled); \ @@ -3070,7 +3103,7 @@ typedef struct RIBBON_GALLERY_CONTROL_HANDLER(id, func) #define RIBBON_FONT_CONTROL_HANDLER(id, func) \ - if(uMsg == WM_COMMAND && id == LOWORD(wParam)) \ + if((uMsg == WM_COMMAND) && (id == LOWORD(wParam))) \ { \ bHandled = TRUE; \ lResult = func((UI_EXECUTIONVERB)HIWORD(wParam), LOWORD(wParam), (CHARFORMAT2*)lParam, bHandled); \ @@ -3079,7 +3112,7 @@ typedef struct } #define RIBBON_COLOR_CONTROL_HANDLER(id, func) \ - if(uMsg == WM_COMMAND && id == LOWORD(wParam)) \ + if((uMsg == WM_COMMAND) && (id == LOWORD(wParam))) \ { \ bHandled = TRUE; \ lResult = func((UI_EXECUTIONVERB)HIWORD(wParam), LOWORD(wParam), (COLORREF)lParam, bHandled); \ @@ -3088,7 +3121,7 @@ typedef struct } #define RIBBON_SPINNER_CONTROL_HANDLER(id, func) \ - if(uMsg == WM_COMMAND && id == wParam) \ + if((uMsg == WM_COMMAND) && (id == wParam)) \ { \ bHandled = TRUE; \ lResult = func((WORD)wParam, (LONG)lParam, bHandled); \ @@ -3097,7 +3130,7 @@ typedef struct } #define RIBBON_FLOATSPINNER_CONTROL_HANDLER(id, func) \ - if(uMsg == WM_COMMAND && id == wParam) \ + if((uMsg == WM_COMMAND) && (id == wParam)) \ { \ bHandled = TRUE; \ lResult = func((WORD)wParam, (DOUBLE*)lParam, bHandled); \ @@ -3142,15 +3175,15 @@ public: // Win7 Aero fix helpers void ResetFrame() { - const MARGINS margins = { 0 }; - ::DwmExtendFrameIntoClientArea(m_hWnd, &margins); + const MARGINS margins = { 0, 0, 0, 0 }; + ::DwmExtendFrameIntoClientArea(this->m_hWnd, &margins); } INT CalcWin7Fix() { ResetFrame(); - RECT rc = { 0 }; - ::AdjustWindowRectEx(&rc, T::GetWndStyle(0), GetMenu() != NULL, T::GetWndExStyle(0)); + RECT rc = {}; + ::AdjustWindowRectEx(&rc, T::GetWndStyle(0), this->GetMenu() != NULL, T::GetWndExStyle(0)); return -rc.top; } @@ -3169,7 +3202,7 @@ public: } __if_not_exists(T::m_CmdBar) { - bUse; // avoid level 4 warning + (void)bUse; // avoid level 4 warning return false; } } @@ -3179,45 +3212,45 @@ public: if (!RunTimeHelper::IsRibbonUIAvailable()) return false; - ATLASSERT(GetIUIFrameworkPtr()); + ATLASSERT(this->GetIUIFrameworkPtr()); - if (IsRibbonUI() == bShow) + if (this->IsRibbonUI() == bShow) return bShow; - bool bVisible = (IsWindowVisible() != FALSE); + bool bVisible = (this->IsWindowVisible() != FALSE); if(bVisible && !bShow) - SetRedraw(FALSE); + this->SetRedraw(FALSE); - if (bShow && ::IsWindow(m_hWndToolBar)) + if (bShow && ::IsWindow(this->m_hWndToolBar)) { - ::ShowWindow(m_hWndToolBar, SW_HIDE); + ::ShowWindow(this->m_hWndToolBar, SW_HIDE); UpdateLayout(); } m_bWin7Fix = !bShow; - HRESULT hr = bShow ? CreateRibbon(sResName) : DestroyRibbon(); + HRESULT hr = bShow ? this->CreateRibbon(sResName) : this->DestroyRibbon(); m_bWin7Fix = SUCCEEDED(hr) && !bShow; if (SUCCEEDED(hr)) { - if(::IsWindow(m_hWndToolBar) && !bShow) + if(::IsWindow(this->m_hWndToolBar) && !bShow) { - ::ShowWindow(m_hWndToolBar, SW_SHOWNA); + ::ShowWindow(this->m_hWndToolBar, SW_SHOWNA); UpdateLayout(); } else if (bShow) { - PostMessage(WM_SIZE); - SetRibbonModes(imodes); + this->PostMessage(WM_SIZE); + this->SetRibbonModes(imodes); } } if(bVisible && !bShow) { - SetRedraw(TRUE); - RedrawWindow(NULL, NULL, RDW_FRAME | RDW_ERASE | RDW_INVALIDATE | RDW_UPDATENOW | RDW_ALLCHILDREN); + this->SetRedraw(TRUE); + this->RedrawWindow(NULL, NULL, RDW_FRAME | RDW_ERASE | RDW_INVALIDATE | RDW_UPDATENOW | RDW_ALLCHILDREN); } return SUCCEEDED(hr) ? bShow : !bShow; @@ -3232,11 +3265,11 @@ public: return (HBITMAP)::CopyImage(hbm, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION); } - return DefRibbonQueryImage(nCmdID); + return this->DefRibbonQueryImage(nCmdID); } BEGIN_MSG_MAP(CRibbonFrameWindowImplBase) - if (!IsRibbonUI() && NeedWin7Fix()) + if (!this->IsRibbonUI() && NeedWin7Fix()) { MESSAGE_HANDLER(WM_SIZING, OnSizing) MESSAGE_HANDLER(WM_SIZE, OnSize) @@ -3255,10 +3288,10 @@ public: case WMSZ_TOP: case WMSZ_TOPLEFT: case WMSZ_TOPRIGHT: - SetWindowPos(NULL, (LPRECT)lParam, SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED); + this->SetWindowPos(NULL, (LPRECT)lParam, SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED); break; default: - DefWindowProc(); + this->DefWindowProc(); break; } @@ -3268,7 +3301,7 @@ public: LRESULT OnSize(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) { if (wParam != SIZE_MINIMIZED) - SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); + this->SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); bHandled = FALSE; return 1; @@ -3277,7 +3310,7 @@ public: LRESULT OnActivate(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) { if(wParam != WA_INACTIVE) - SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); + this->SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); bHandled = FALSE; return 1; @@ -3285,9 +3318,9 @@ public: LRESULT OnNCCalcSize(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) { - ATLASSERT(!IsRibbonUI() && NeedWin7Fix()); + ATLASSERT(!this->IsRibbonUI() && NeedWin7Fix()); - LRESULT lRet = DefWindowProc(); + LRESULT lRet = this->DefWindowProc(); if(wParam) { @@ -3301,24 +3334,24 @@ public: // Overrides void UpdateLayout(BOOL bResizeBars = TRUE) { - RECT rect = { 0 }; - GetClientRect(&rect); + RECT rect = {}; + this->GetClientRect(&rect); - if (IsRibbonUI() && !IsRibbonHidden()) + if (this->IsRibbonUI() && !this->IsRibbonHidden()) { - rect.top += GetRibbonHeight(); + rect.top += this->GetRibbonHeight(); } - else if (!IsRibbonUI() && NeedWin7Fix()) + else if (!this->IsRibbonUI() && NeedWin7Fix()) { ResetFrame(); } // position bars and offset their dimensions - UpdateBarsPosition(rect, bResizeBars); + this->UpdateBarsPosition(rect, bResizeBars); // resize client window - if(m_hWndClient != NULL) - ::SetWindowPos(m_hWndClient, NULL, rect.left, rect.top, + if(this->m_hWndClient != NULL) + ::SetWindowPos(this->m_hWndClient, NULL, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_NOZORDER | SWP_NOACTIVATE); } @@ -3335,7 +3368,7 @@ public: } __if_not_exists (T::m_CmdBar) { - nCmdID; // avoid level 4 warning + (void)nCmdID; // avoid level 4 warning return NULL; } } @@ -3367,11 +3400,11 @@ public: ATLASSERT(m_Key.m_hKey); } - CRegKeyEx m_Key; + ATL::CRegKey m_Key; LONG Save(bool bRibbonUI, HGLOBAL hgSettings = NULL) { - CRegKeyEx key; + ATL::CRegKey key; const DWORD dwUI = bRibbonUI; LONG lRet = key.Create(m_Key, L"Ribbon"); @@ -3403,7 +3436,7 @@ public: { ATLASSERT(hgSettings == NULL); - CRegKeyEx key; + ATL::CRegKey key; LONG lRet = key.Open(m_Key, L"Ribbon"); if(lRet != ERROR_SUCCESS) diff --git a/WrlSDK/SampleCode/PluginWinExe/WTL/atlscrl.h b/WrlSDK/SampleCode/PluginWinExe/WTL/atlscrl.h index ae483719d150f5d6c01e163e573e1978e715caec..74240c87f29323043ec570017591290816da5863 100644 --- a/WrlSDK/SampleCode/PluginWinExe/WTL/atlscrl.h +++ b/WrlSDK/SampleCode/PluginWinExe/WTL/atlscrl.h @@ -1,4 +1,4 @@ -// Windows Template Library - WTL version 9.10 +// Windows Template Library - WTL version 10.0 // Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. // // This file is a part of the Windows Template Library. @@ -19,14 +19,6 @@ #error atlscrl.h requires atlwin.h to be included first #endif -#if !((_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)) && !defined(_WIN32_WCE) - #include -#endif - -#ifndef GET_WHEEL_DELTA_WPARAM - #define GET_WHEEL_DELTA_WPARAM(wParam) ((short)HIWORD(wParam)) -#endif - /////////////////////////////////////////////////////////////////////////////// // Classes in this file: @@ -51,9 +43,7 @@ namespace WTL #define SCRL_SCROLLCHILDREN 0x00000001 #define SCRL_ERASEBACKGROUND 0x00000002 #define SCRL_NOTHUMBTRACKING 0x00000004 -#if (WINVER >= 0x0500) #define SCRL_SMOOTHSCROLL 0x00000008 -#endif // (WINVER >= 0x0500) #define SCRL_DISABLENOSCROLLV 0x00000010 #define SCRL_DISABLENOSCROLLH 0x00000020 #define SCRL_DISABLENOSCROLL (SCRL_DISABLENOSCROLLV | SCRL_DISABLENOSCROLLH) @@ -72,10 +62,6 @@ public: SIZE m_sizeClient; int m_zDelta; // current wheel value int m_nWheelLines; // number of lines to scroll on wheel -#if !((_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)) && !defined(_WIN32_WCE) - // Note that this message must be forwarded from a top level window - UINT m_uMsgMouseWheel; // MSH_MOUSEWHEEL -#endif // !((_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)) && !defined(_WIN32_WCE) int m_zHDelta; // current horizontal wheel value int m_nHWheelChars; // number of chars to scroll on horizontal wheel UINT m_uScrollFlags; @@ -83,9 +69,6 @@ public: // Constructor CScrollImpl() : m_zDelta(0), m_nWheelLines(3), -#if !((_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)) && !defined(_WIN32_WCE) - m_uMsgMouseWheel(0U), -#endif // !((_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)) && !defined(_WIN32_WCE) m_zHDelta(0), m_nHWheelChars(3), m_uScrollFlags(0U), m_dwExtendedStyle(0) { @@ -118,11 +101,9 @@ public: m_dwExtendedStyle = (m_dwExtendedStyle & ~dwMask) | (dwExtendedStyle & dwMask); // cache scroll flags T* pT = static_cast(this); - pT; // avoid level 4 warning + (void)pT; // avoid level 4 warning m_uScrollFlags = pT->uSCROLL_FLAGS | (IsScrollingChildren() ? SW_SCROLLCHILDREN : 0) | (IsErasingBackground() ? SW_ERASE : 0); -#if (WINVER >= 0x0500) && !defined(_WIN32_WCE) m_uScrollFlags |= (IsSmoothScroll() ? SW_SMOOTHSCROLL : 0); -#endif // (WINVER >= 0x0500) && !defined(_WIN32_WCE) return dwPrevStyle; } @@ -160,11 +141,11 @@ public: } // Move all children if needed - if(IsScrollingChildren() && (dx != 0 || dy != 0)) + if(IsScrollingChildren() && ((dx != 0) || (dy != 0))) { for(HWND hWndChild = ::GetWindow(pT->m_hWnd, GW_CHILD); hWndChild != NULL; hWndChild = ::GetWindow(hWndChild, GW_HWNDNEXT)) { - RECT rect = { 0 }; + RECT rect = {}; ::GetWindowRect(hWndChild, &rect); ::MapWindowPoints(NULL, pT->m_hWnd, (LPPOINT)&rect, 1); ::SetWindowPos(hWndChild, NULL, rect.left + dx, rect.top + dy, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE); @@ -235,11 +216,11 @@ public: } // Move all children if needed - if(IsScrollingChildren() && (dx != 0 || dy != 0)) + if(IsScrollingChildren() && ((dx != 0) || (dy != 0))) { for(HWND hWndChild = ::GetWindow(pT->m_hWnd, GW_CHILD); hWndChild != NULL; hWndChild = ::GetWindow(hWndChild, GW_HWNDNEXT)) { - RECT rect = { 0 }; + RECT rect = {}; ::GetWindowRect(hWndChild, &rect); ::MapWindowPoints(NULL, pT->m_hWnd, (LPPOINT)&rect, 1); ::SetWindowPos(hWndChild, NULL, rect.left + dx, rect.top + dy, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE); @@ -266,8 +247,8 @@ public: // line operations void SetScrollLine(int cxLine, int cyLine) { - ATLASSERT(cxLine >= 0 && cyLine >= 0); - ATLASSERT(m_sizeAll.cx != 0 && m_sizeAll.cy != 0); + ATLASSERT((cxLine >= 0) && (cyLine >= 0)); + ATLASSERT((m_sizeAll.cx != 0) && (m_sizeAll.cy != 0)); m_sizeLine.cx = T::CalcLineOrPage(cxLine, m_sizeAll.cx, 100); m_sizeLine.cy = T::CalcLineOrPage(cyLine, m_sizeAll.cy, 100); @@ -286,8 +267,8 @@ public: // page operations void SetScrollPage(int cxPage, int cyPage) { - ATLASSERT(cxPage >= 0 && cyPage >= 0); - ATLASSERT(m_sizeAll.cx != 0 && m_sizeAll.cy != 0); + ATLASSERT((cxPage >= 0) && (cyPage >= 0)); + ATLASSERT((m_sizeAll.cx != 0) && (m_sizeAll.cy != 0)); m_sizePage.cx = T::CalcLineOrPage(cxPage, m_sizeAll.cx, 10); m_sizePage.cy = T::CalcLineOrPage(cyPage, m_sizeAll.cy, 10); @@ -402,7 +383,7 @@ public: T* pT = static_cast(this); ATLASSERT(::IsWindow(pT->m_hWnd)); - RECT rcClient = { 0 }; + RECT rcClient = {}; pT->GetClientRect(&rcClient); int x = m_ptOffset.x; @@ -425,7 +406,7 @@ public: T* pT = static_cast(this); ATLASSERT(::IsWindow(pT->m_hWnd)); - RECT rect = { 0 }; + RECT rect = {}; ::GetWindowRect(hWnd, &rect); ::OffsetRect(&rect, m_ptOffset.x, m_ptOffset.y); ::MapWindowPoints(NULL, pT->m_hWnd, (LPPOINT)&rect, 2); @@ -437,16 +418,11 @@ public: MESSAGE_HANDLER(WM_VSCROLL, OnVScroll) MESSAGE_HANDLER(WM_HSCROLL, OnHScroll) MESSAGE_HANDLER(WM_MOUSEWHEEL, OnMouseWheel) -#if !((_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)) && !defined(_WIN32_WCE) - MESSAGE_HANDLER(m_uMsgMouseWheel, OnMouseWheel) -#endif // !((_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)) && !defined(_WIN32_WCE) MESSAGE_HANDLER(WM_MOUSEHWHEEL, OnMouseHWheel) MESSAGE_HANDLER(WM_SETTINGCHANGE, OnSettingChange) MESSAGE_HANDLER(WM_SIZE, OnSize) MESSAGE_HANDLER(WM_PAINT, OnPaint) -#ifndef _WIN32_WCE MESSAGE_HANDLER(WM_PRINTCLIENT, OnPaint) -#endif // !_WIN32_WCE // standard scroll commands ALT_MSG_MAP(1) COMMAND_ID_HANDLER(ID_SCROLL_UP, OnScrollUp) @@ -488,17 +464,12 @@ public: return 0; } - LRESULT OnMouseWheel(UINT uMsg, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) + LRESULT OnMouseWheel(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) { T* pT = static_cast(this); ATLASSERT(::IsWindow(pT->m_hWnd)); -#if (_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400) || defined(_WIN32_WCE) - uMsg; int zDelta = (int)GET_WHEEL_DELTA_WPARAM(wParam); -#else - int zDelta = (uMsg == WM_MOUSEWHEEL) ? (int)GET_WHEEL_DELTA_WPARAM(wParam) : (int)wParam; -#endif // !((_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400) || defined(_WIN32_WCE)) int nScrollCode = (m_nWheelLines == WHEEL_PAGESCROLL) ? ((zDelta > 0) ? SB_PAGEUP : SB_PAGEDOWN) : ((zDelta > 0) ? SB_LINEUP : SB_LINEDOWN); m_zDelta += zDelta; // cumulative int zTotal = (m_nWheelLines == WHEEL_PAGESCROLL) ? abs(m_zDelta) : abs(m_zDelta) * m_nWheelLines; @@ -710,7 +681,7 @@ public: void DoScroll(int nType, int nScrollCode, int& cxyOffset, int cxySizeAll, int cxySizePage, int cxySizeLine) { T* pT = static_cast(this); - RECT rect = { 0 }; + RECT rect = {}; pT->GetClientRect(&rect); int cxyClient = (nType == SB_VERT) ? rect.bottom : rect.right; int cxyMax = cxySizeAll - cxyClient; @@ -799,7 +770,7 @@ public: break; } - if(bUpdate && cxyScroll != 0) + if(bUpdate && (cxyScroll != 0)) { pT->SetScrollPos(nType, cxyOffset, TRUE); if(nType == SB_VERT) @@ -842,35 +813,17 @@ public: else if(y < 0) y = 0; - return (x != xOld || y != yOld); + return ((x != xOld) || (y != yOld)); } void GetSystemSettings() { -#ifndef _WIN32_WCE -#ifndef SPI_GETWHEELSCROLLLINES - const UINT SPI_GETWHEELSCROLLLINES = 104; -#endif // !SPI_GETWHEELSCROLLLINES ::SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &m_nWheelLines, 0); #ifndef SPI_GETWHEELSCROLLCHARS const UINT SPI_GETWHEELSCROLLCHARS = 0x006C; -#endif // !SPI_GETWHEELSCROLLCHARS +#endif ::SystemParametersInfo(SPI_GETWHEELSCROLLCHARS, 0, &m_nHWheelChars, 0); - -#if !((_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)) - if(m_uMsgMouseWheel != 0) - m_uMsgMouseWheel = ::RegisterWindowMessage(MSH_MOUSEWHEEL); - - HWND hWndWheel = FindWindow(MSH_WHEELMODULE_CLASS, MSH_WHEELMODULE_TITLE); - if(::IsWindow(hWndWheel)) - { - UINT uMsgScrollLines = ::RegisterWindowMessage(MSH_SCROLL_LINES); - if(uMsgScrollLines != 0) - m_nWheelLines = (int)::SendMessage(hWndWheel, uMsgScrollLines, 0, 0L); - } -#endif // !((_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)) -#endif // !_WIN32_WCE } bool IsScrollingChildren() const @@ -888,12 +841,10 @@ public: return (m_dwExtendedStyle & SCRL_NOTHUMBTRACKING) != 0; } -#if (WINVER >= 0x0500) bool IsSmoothScroll() const { return (m_dwExtendedStyle & SCRL_SMOOTHSCROLL) != 0; } -#endif // (WINVER >= 0x0500) }; @@ -906,19 +857,14 @@ class ATL_NO_VTABLE CScrollWindowImpl : public ATL::CWindowImpl= 1300) BOOL bRet = ATL::CWindowImpl< T, TBase, TWinTraits >::SubclassWindow(hWnd); -#else // !(_MSC_VER >= 1300) - typedef ATL::CWindowImpl< T, TBase, TWinTraits > _baseClass; - BOOL bRet = _baseClass::SubclassWindow(hWnd); -#endif // !(_MSC_VER >= 1300) if(bRet != FALSE) { T* pT = static_cast(this); pT->GetSystemSettings(); - RECT rect = { 0 }; - GetClientRect(&rect); + RECT rect = {}; + this->GetClientRect(&rect); pT->DoSize(rect.right, rect.bottom); } @@ -929,16 +875,11 @@ public: MESSAGE_HANDLER(WM_VSCROLL, CScrollImpl< T >::OnVScroll) MESSAGE_HANDLER(WM_HSCROLL, CScrollImpl< T >::OnHScroll) MESSAGE_HANDLER(WM_MOUSEWHEEL, CScrollImpl< T >::OnMouseWheel) -#if !((_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)) && !defined(_WIN32_WCE) - MESSAGE_HANDLER(m_uMsgMouseWheel, CScrollImpl< T >::OnMouseWheel) -#endif // !((_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)) && !defined(_WIN32_WCE) MESSAGE_HANDLER(WM_MOUSEHWHEEL, CScrollImpl< T >::OnMouseHWheel) MESSAGE_HANDLER(WM_SETTINGCHANGE, CScrollImpl< T >::OnSettingChange) MESSAGE_HANDLER(WM_SIZE, CScrollImpl< T >::OnSize) MESSAGE_HANDLER(WM_PAINT, CScrollImpl< T >::OnPaint) -#ifndef _WIN32_WCE MESSAGE_HANDLER(WM_PRINTCLIENT, CScrollImpl< T >::OnPaint) -#endif // !_WIN32_WCE ALT_MSG_MAP(1) COMMAND_ID_HANDLER(ID_SCROLL_UP, CScrollImpl< T >::OnScrollUp) COMMAND_ID_HANDLER(ID_SCROLL_DOWN, CScrollImpl< T >::OnScrollDown) @@ -959,8 +900,6 @@ public: /////////////////////////////////////////////////////////////////////////////// // CMapScrollImpl - Provides mapping and scrolling support to any window -#ifndef _WIN32_WCE - template class CMapScrollImpl : public CScrollImpl< T > { @@ -984,20 +923,20 @@ public: // mapping mode operations void SetScrollMapMode(int nMapMode) { - ATLASSERT(nMapMode >= MM_MIN && nMapMode <= MM_MAX_FIXEDSCALE); + ATLASSERT((nMapMode >= MM_MIN) && (nMapMode <= MM_MAX_FIXEDSCALE)); m_nMapMode = nMapMode; } int GetScrollMapMode() const { - ATLASSERT(m_nMapMode >= MM_MIN && m_nMapMode <= MM_MAX_FIXEDSCALE); + ATLASSERT((m_nMapMode >= MM_MIN) && (m_nMapMode <= MM_MAX_FIXEDSCALE)); return m_nMapMode; } // offset operations void SetScrollOffset(int x, int y, BOOL bRedraw = TRUE) { - ATLASSERT(m_nMapMode >= MM_MIN && m_nMapMode <= MM_MAX_FIXEDSCALE); + ATLASSERT((m_nMapMode >= MM_MIN) && (m_nMapMode <= MM_MAX_FIXEDSCALE)); POINT ptOff = { x, y }; // block: convert logical to device units { @@ -1015,8 +954,8 @@ public: void GetScrollOffset(POINT& ptOffset) const { - ATLASSERT(m_nMapMode >= MM_MIN && m_nMapMode <= MM_MAX_FIXEDSCALE); - ptOffset = m_ptOffset; + ATLASSERT((m_nMapMode >= MM_MIN) && (m_nMapMode <= MM_MAX_FIXEDSCALE)); + ptOffset = this->m_ptOffset; // block: convert device to logical units { CWindowDC dc(NULL); @@ -1028,12 +967,12 @@ public: // size operations void SetScrollSize(int xMin, int yMin, int xMax, int yMax, BOOL bRedraw = TRUE, bool bResetOffset = true) { - ATLASSERT(xMax > xMin && yMax > yMin); - ATLASSERT(m_nMapMode >= MM_MIN && m_nMapMode <= MM_MAX_FIXEDSCALE); + ATLASSERT((xMax > xMin) && (yMax > yMin)); + ATLASSERT((m_nMapMode >= MM_MIN) && (m_nMapMode <= MM_MAX_FIXEDSCALE)); ::SetRect(&m_rectLogAll, xMin, yMin, xMax, yMax); - SIZE sizeAll = { 0 }; + SIZE sizeAll = {}; sizeAll.cx = xMax - xMin + 1; sizeAll.cy = yMax - yMin + 1; // block: convert logical to device units @@ -1064,15 +1003,15 @@ public: void GetScrollSize(RECT& rcScroll) const { - ATLASSERT(m_nMapMode >= MM_MIN && m_nMapMode <= MM_MAX_FIXEDSCALE); + ATLASSERT((m_nMapMode >= MM_MIN) && (m_nMapMode <= MM_MAX_FIXEDSCALE)); rcScroll = m_rectLogAll; } // line operations void SetScrollLine(int cxLine, int cyLine) { - ATLASSERT(cxLine >= 0 && cyLine >= 0); - ATLASSERT(m_nMapMode >= MM_MIN && m_nMapMode <= MM_MAX_FIXEDSCALE); + ATLASSERT((cxLine >= 0) && (cyLine >= 0)); + ATLASSERT((m_nMapMode >= MM_MIN) && (m_nMapMode <= MM_MAX_FIXEDSCALE)); m_sizeLogLine.cx = cxLine; m_sizeLogLine.cy = cyLine; @@ -1093,15 +1032,15 @@ public: void GetScrollLine(SIZE& sizeLine) const { - ATLASSERT(m_nMapMode >= MM_MIN && m_nMapMode <= MM_MAX_FIXEDSCALE); + ATLASSERT((m_nMapMode >= MM_MIN) && (m_nMapMode <= MM_MAX_FIXEDSCALE)); sizeLine = m_sizeLogLine; } // page operations void SetScrollPage(int cxPage, int cyPage) { - ATLASSERT(cxPage >= 0 && cyPage >= 0); - ATLASSERT(m_nMapMode >= MM_MIN && m_nMapMode <= MM_MAX_FIXEDSCALE); + ATLASSERT((cxPage >= 0) && (cyPage >= 0)); + ATLASSERT((m_nMapMode >= MM_MIN) && (m_nMapMode <= MM_MAX_FIXEDSCALE)); m_sizeLogPage.cx = cxPage; m_sizeLogPage.cy = cyPage; @@ -1122,7 +1061,7 @@ public: void GetScrollPage(SIZE& sizePage) const { - ATLASSERT(m_nMapMode >= MM_MIN && m_nMapMode <= MM_MAX_FIXEDSCALE); + ATLASSERT((m_nMapMode >= MM_MIN) && (m_nMapMode <= MM_MAX_FIXEDSCALE)); sizePage = m_sizeLogPage; } @@ -1130,9 +1069,6 @@ public: MESSAGE_HANDLER(WM_VSCROLL, CScrollImpl< T >::OnVScroll) MESSAGE_HANDLER(WM_HSCROLL, CScrollImpl< T >::OnHScroll) MESSAGE_HANDLER(WM_MOUSEWHEEL, CScrollImpl< T >::OnMouseWheel) -#if !((_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)) - MESSAGE_HANDLER(m_uMsgMouseWheel, CScrollImpl< T >::OnMouseWheel) -#endif // !((_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)) MESSAGE_HANDLER(WM_MOUSEHWHEEL, CScrollImpl< T >::OnMouseHWheel) MESSAGE_HANDLER(WM_SETTINGCHANGE, CScrollImpl< T >::OnSettingChange) MESSAGE_HANDLER(WM_SIZE, CScrollImpl< T >::OnSize) @@ -1164,9 +1100,9 @@ public: dc.SetMapMode(m_nMapMode); POINT ptViewportOrg = { 0, 0 }; if(m_nMapMode == MM_TEXT) - dc.SetViewportOrg(-m_ptOffset.x, -m_ptOffset.y, &ptViewportOrg); + dc.SetViewportOrg(-this->m_ptOffset.x, -this->m_ptOffset.y, &ptViewportOrg); else - dc.SetViewportOrg(-m_ptOffset.x, -m_ptOffset.y + m_sizeAll.cy, &ptViewportOrg); + dc.SetViewportOrg(-this->m_ptOffset.x, -this->m_ptOffset.y + this->m_sizeAll.cy, &ptViewportOrg); POINT ptWindowOrg = { 0, 0 }; dc.SetWindowOrg(m_rectLogAll.left, m_rectLogAll.top, &ptWindowOrg); @@ -1181,9 +1117,9 @@ public: CPaintDC dc(pT->m_hWnd); dc.SetMapMode(m_nMapMode); if(m_nMapMode == MM_TEXT) - dc.SetViewportOrg(-m_ptOffset.x, -m_ptOffset.y); + dc.SetViewportOrg(-this->m_ptOffset.x, -this->m_ptOffset.y); else - dc.SetViewportOrg(-m_ptOffset.x, -m_ptOffset.y + m_sizeAll.cy); + dc.SetViewportOrg(-this->m_ptOffset.x, -this->m_ptOffset.y + this->m_sizeAll.cy); dc.SetWindowOrg(m_rectLogAll.left, m_rectLogAll.top); pT->DoPaint(dc.m_hDC); } @@ -1191,33 +1127,24 @@ public: } }; -#endif // !_WIN32_WCE - /////////////////////////////////////////////////////////////////////////////// // CMapScrollWindowImpl - Implements scrolling window with mapping -#ifndef _WIN32_WCE - template class ATL_NO_VTABLE CMapScrollWindowImpl : public ATL::CWindowImpl< T, TBase, TWinTraits >, public CMapScrollImpl< T > { public: BOOL SubclassWindow(HWND hWnd) { -#if (_MSC_VER >= 1300) BOOL bRet = ATL::CWindowImpl< T, TBase, TWinTraits >::SubclassWindow(hWnd); -#else // !(_MSC_VER >= 1300) - typedef ATL::CWindowImpl< T, TBase, TWinTraits > _baseClass; - BOOL bRet = _baseClass::SubclassWindow(hWnd); -#endif // !(_MSC_VER >= 1300) if(bRet != FALSE) { T* pT = static_cast(this); pT->GetSystemSettings(); - RECT rect = { 0 }; - GetClientRect(&rect); + RECT rect = {}; + this->GetClientRect(&rect); pT->DoSize(rect.right, rect.bottom); } @@ -1228,9 +1155,6 @@ public: MESSAGE_HANDLER(WM_VSCROLL, CScrollImpl< T >::OnVScroll) MESSAGE_HANDLER(WM_HSCROLL, CScrollImpl< T >::OnHScroll) MESSAGE_HANDLER(WM_MOUSEWHEEL, CScrollImpl< T >::OnMouseWheel) -#if !((_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)) - MESSAGE_HANDLER(m_uMsgMouseWheel, CScrollImpl< T >::OnMouseWheel) -#endif // !((_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)) MESSAGE_HANDLER(WM_MOUSEHWHEEL, CScrollImpl< T >::OnMouseHWheel) MESSAGE_HANDLER(WM_SETTINGCHANGE, CScrollImpl< T >::OnSettingChange) MESSAGE_HANDLER(WM_SIZE, CScrollImpl< T >::OnSize) @@ -1252,13 +1176,11 @@ public: END_MSG_MAP() }; -#endif // !_WIN32_WCE - /////////////////////////////////////////////////////////////////////////////// // CFSBWindow - Use as a base instead of CWindow to get flat scroll bar support -#if defined(__ATLCTRLS_H__) && (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) +#ifdef __ATLCTRLS_H__ template class CFSBWindowT : public TBase, public CFlatScrollBarImpl > @@ -1270,7 +1192,7 @@ public: CFSBWindowT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -1278,33 +1200,31 @@ public: // (only those methods that are used by scroll window classes) int SetScrollPos(int nBar, int nPos, BOOL bRedraw = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return FlatSB_SetScrollPos(nBar, nPos, bRedraw); + ATLASSERT(::IsWindow(this->m_hWnd)); + return this->FlatSB_SetScrollPos(nBar, nPos, bRedraw); } BOOL GetScrollInfo(int nBar, LPSCROLLINFO lpScrollInfo) { - ATLASSERT(::IsWindow(m_hWnd)); - return FlatSB_GetScrollInfo(nBar, lpScrollInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + return this->FlatSB_GetScrollInfo(nBar, lpScrollInfo); } BOOL SetScrollInfo(int nBar, LPSCROLLINFO lpScrollInfo, BOOL bRedraw = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return FlatSB_SetScrollInfo(nBar, lpScrollInfo, bRedraw); + ATLASSERT(::IsWindow(this->m_hWnd)); + return this->FlatSB_SetScrollInfo(nBar, lpScrollInfo, bRedraw); } }; typedef CFSBWindowT CFSBWindow; -#endif // defined(__ATLCTRLS_H__) && (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) +#endif // __ATLCTRLS_H__ /////////////////////////////////////////////////////////////////////////////// // CZoomScrollImpl - Provides zooming and scrolling support to any window -#ifndef _WIN32_WCE - // The zoom modes that can be set with the SetZoomMode method enum { @@ -1365,7 +1285,7 @@ public: // size operations void SetScrollSize(int cxLog, int cyLog, BOOL bRedraw = TRUE, bool bResetOffset = true) { - ATLASSERT(cxLog >= 0 && cyLog >= 0); + ATLASSERT((cxLog >= 0) && (cyLog >= 0)); // Set up the defaults if((cxLog == 0) && (cyLog == 0)) @@ -1376,7 +1296,7 @@ public: m_sizeLogAll.cx = cxLog; m_sizeLogAll.cy = cyLog; - SIZE sizeAll = { 0 }; + SIZE sizeAll = {}; sizeAll.cx = (int)((float)m_sizeLogAll.cx * m_fZoomScale); sizeAll.cy = (int)((float)m_sizeLogAll.cy * m_fZoomScale); @@ -1396,12 +1316,12 @@ public: // line operations void SetScrollLine(int cxLogLine, int cyLogLine) { - ATLASSERT(cxLogLine >= 0 && cyLogLine >= 0); + ATLASSERT((cxLogLine >= 0) && (cyLogLine >= 0)); m_sizeLogLine.cx = cxLogLine; m_sizeLogLine.cy = cyLogLine; - SIZE sizeLine = { 0 }; + SIZE sizeLine = {}; sizeLine.cx = (int)((float)m_sizeLogLine.cx * m_fZoomScale); sizeLine.cy = (int)((float)m_sizeLogLine.cy * m_fZoomScale); CScrollImpl< T >::SetScrollLine(sizeLine); @@ -1425,7 +1345,7 @@ public: m_sizeLogPage.cx = cxLogPage; m_sizeLogPage.cy = cyLogPage; - SIZE sizePage = { 0 }; + SIZE sizePage = {}; sizePage.cx = (int)((float)m_sizeLogPage.cx * m_fZoomScale); sizePage.cy = (int)((float)m_sizeLogPage.cy * m_fZoomScale); @@ -1521,11 +1441,11 @@ public: { for(HWND hWndChild = ::GetWindow(pT->m_hWnd, GW_CHILD); hWndChild != NULL; hWndChild = ::GetWindow(hWndChild, GW_HWNDNEXT)) { - RECT rect = { 0 }; + RECT rect = {}; ::GetWindowRect(hWndChild, &rect); ::MapWindowPoints(NULL, pT->m_hWnd, (LPPOINT)&rect, 2); - _ChildPlacement cp = { 0 }; + _ChildPlacement cp = {}; cp.hWnd = hWndChild; cp.x = rect.left; cp.y = rect.top; @@ -1574,7 +1494,7 @@ public: pT->NormalizeRect(rcZoom); SIZE size = { rcZoom.right - rcZoom.left, rcZoom.bottom - rcZoom.top }; POINT pt = { rcZoom.left + size.cx / 2, rcZoom.top + size.cy / 2 }; - if(size.cx < m_cxyMinZoomRect || size.cy < m_cxyMinZoomRect) + if((size.cx < m_cxyMinZoomRect) || (size.cy < m_cxyMinZoomRect)) { pT->Zoom(pt, m_fZoomScale + m_fZoomDelta); return; @@ -1582,8 +1502,8 @@ public: ATLASSERT((size.cx > 0) && (size.cy > 0)); - float fScaleH = (float)(m_sizeClient.cx + 1) / (float)size.cx; - float fScaleV = (float)(m_sizeClient.cy + 1) / (float)size.cy; + float fScaleH = (float)(this->m_sizeClient.cx + 1) / (float)size.cx; + float fScaleV = (float)(this->m_sizeClient.cy + 1) / (float)size.cy; float fZoomScale = __min(fScaleH, fScaleV) * m_fZoomScale; pT->Zoom(pt, fZoomScale); } @@ -1599,10 +1519,10 @@ public: fZoomScale = m_fZoomScaleMax; T* pT = static_cast(this); - POINT pt = { 0 }; + POINT pt = { 0, 0 }; if(bCenter) { - RECT rcClient = { 0 }; + RECT rcClient = {}; ::GetClientRect(pT->m_hWnd, &rcClient); pt.x = rcClient.right / 2; pt.y = rcClient.bottom / 2; @@ -1610,7 +1530,7 @@ public: } // Modify the Viewport extent - SIZE sizeAll = { 0 }; + SIZE sizeAll = {}; sizeAll.cx = (int)((float)m_sizeLogAll.cx * fZoomScale); sizeAll.cy = (int)((float)m_sizeLogAll.cy * fZoomScale); @@ -1640,14 +1560,32 @@ public: pT->CenterOnLogicalPoint(pt); } + void ZoomIn(bool bCenter = true) + { + T* pT = static_cast(this); + pT->Zoom(m_fZoomScale + m_fZoomDelta, bCenter); + } + + void ZoomOut(bool bCenter = true) + { + T* pT = static_cast(this); + pT->Zoom(m_fZoomScale - m_fZoomDelta, bCenter); + } + + void ZoomDefault(bool bCenter = true) + { + T* pT = static_cast(this); + pT->Zoom(1.0f, bCenter); + } + // Helper functions void PrepareDC(CDCHandle dc) { - ATLASSERT(m_sizeAll.cx >= 0 && m_sizeAll.cy >= 0); + ATLASSERT((this->m_sizeAll.cx >= 0) && (this->m_sizeAll.cy >= 0)); dc.SetMapMode(MM_ANISOTROPIC); - dc.SetWindowExt(m_sizeLogAll); - dc.SetViewportExt(m_sizeAll); - dc.SetViewportOrg(-m_ptOffset.x, -m_ptOffset.y); + dc.SetWindowExt(this->m_sizeLogAll); + dc.SetViewportExt(this->m_sizeAll); + dc.SetViewportOrg(-this->m_ptOffset.x, -this->m_ptOffset.y); } void ViewDPtoLP(LPPOINT lpPoints, int nCount = 1) @@ -1674,42 +1612,42 @@ public: void ClientToDevice(POINT &pt) { - pt.x += m_ptOffset.x; - pt.y += m_ptOffset.y; + pt.x += this->m_ptOffset.x; + pt.y += this->m_ptOffset.y; } void DeviceToClient(POINT &pt) { - pt.x -= m_ptOffset.x; - pt.y -= m_ptOffset.y; + pt.x -= this->m_ptOffset.x; + pt.y -= this->m_ptOffset.y; } void CenterOnPoint(POINT pt) { T* pT = static_cast(this); - RECT rect = { 0 }; + RECT rect = {}; pT->GetClientRect(&rect); - int xOfs = pt.x - (rect.right / 2) + m_ptOffset.x; + int xOfs = pt.x - (rect.right / 2) + this->m_ptOffset.x; if(xOfs < 0) { xOfs = 0; } else { - int xMax = __max((int)(m_sizeAll.cx - rect.right), 0); + int xMax = __max((int)(this->m_sizeAll.cx - rect.right), 0); if(xOfs > xMax) xOfs = xMax; } - int yOfs = pt.y - (rect.bottom / 2) + m_ptOffset.y; + int yOfs = pt.y - (rect.bottom / 2) + this->m_ptOffset.y; if(yOfs < 0) { yOfs = 0; } else { - int yMax = __max((int)(m_sizeAll.cy - rect.bottom), 0); + int yMax = __max((int)(this->m_sizeAll.cy - rect.bottom), 0); if(yOfs > yMax) yOfs = yMax; } @@ -1727,8 +1665,8 @@ public: BOOL PtInDevRect(POINT pt) { - RECT rc = { 0, 0, m_sizeAll.cx, m_sizeAll.cy }; - ::OffsetRect(&rc, -m_ptOffset.x, -m_ptOffset.y); + RECT rc = { 0, 0, this->m_sizeAll.cx, this->m_sizeAll.cy }; + ::OffsetRect(&rc, -this->m_ptOffset.x, -this->m_ptOffset.y); return ::PtInRect(&rc, pt); } @@ -1752,13 +1690,12 @@ public: void DrawTrackRect() { T* pT = static_cast(this); - const SIZE sizeLines = { 2, 2 }; RECT rc = m_rcTrack; pT->NormalizeRect(rc); if(!::IsRectEmpty(&rc)) { - ::MapWindowPoints(pT->m_hWnd, NULL, (LPPOINT)&rc, 2); - CWindowDC dc(NULL); + const SIZE sizeLines = { 2, 2 }; + CClientDC dc(pT->m_hWnd); dc.DrawDragRect(&rc, sizeLines, NULL, sizeLines); } } @@ -1771,14 +1708,19 @@ public: ::SendMessage(pT->GetParent(), WM_NOTIFY, (WPARAM)nId, (LPARAM)&nmhdr); } + void DoWheelZoom(int zDelta) + { + float fZoomScale = m_fZoomScale + ((zDelta > 0) ? m_fZoomDelta : -m_fZoomDelta); + T* pT = static_cast(this); + pT->Zoom(fZoomScale); + pT->NotifyParentZoomChanged(); + } + BEGIN_MSG_MAP(CZoomScrollImpl) MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor) MESSAGE_HANDLER(WM_VSCROLL, CScrollImpl< T >::OnVScroll) MESSAGE_HANDLER(WM_HSCROLL, CScrollImpl< T >::OnHScroll) - MESSAGE_HANDLER(WM_MOUSEWHEEL, CScrollImpl< T >::OnMouseWheel) -#if !((_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)) - MESSAGE_HANDLER(m_uMsgMouseWheel, CScrollImpl< T >::OnMouseWheel) -#endif // !((_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)) + MESSAGE_HANDLER(WM_MOUSEWHEEL, OnMouseWheel) MESSAGE_HANDLER(WM_MOUSEHWHEEL, CScrollImpl< T >::OnMouseHWheel) MESSAGE_HANDLER(WM_SETTINGCHANGE, CScrollImpl< T >::OnSettingChange) MESSAGE_HANDLER(WM_SIZE, CScrollImpl< T >::OnSize) @@ -1803,12 +1745,50 @@ public: COMMAND_ID_HANDLER(ID_SCROLL_ALL_RIGHT, CScrollImpl< T >::OnScrollAllRight) END_MSG_MAP() + LRESULT OnSetCursor(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled) + { + if((LOWORD(lParam) == HTCLIENT) && (m_nZoomMode != ZOOMMODE_OFF)) + { + T* pT = static_cast(this); + if((HWND)wParam == pT->m_hWnd) + { + DWORD dwPos = ::GetMessagePos(); + POINT pt = { GET_X_LPARAM(dwPos), GET_Y_LPARAM(dwPos) }; + pT->ScreenToClient(&pt); + if(pT->PtInDevRect(pt)) + { + ::SetCursor(::LoadCursor(NULL, IDC_CROSS)); + return 1; + } + } + } + + bHandled = FALSE; + return 0; + } + + LRESULT OnMouseWheel(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) + { + if((GET_KEYSTATE_WPARAM(wParam) & MK_CONTROL) != 0) // handle zoom if Ctrl is pressed + { + int zDelta = (int)GET_WHEEL_DELTA_WPARAM(wParam); + T* pT = static_cast(this); + pT->DoWheelZoom(zDelta); + } + else + { + CScrollImpl< T >::OnMouseWheel(uMsg, wParam, lParam, bHandled); + } + + return 0; + } + LRESULT OnPaint(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) { T* pT = static_cast(this); ATLASSERT(::IsWindow(pT->m_hWnd)); ATLASSERT((m_sizeLogAll.cx >= 0) && (m_sizeLogAll.cy >= 0)); - ATLASSERT((m_sizeAll.cx >= 0) && (m_sizeAll.cy >= 0)); + ATLASSERT((this->m_sizeAll.cx >= 0) && (this->m_sizeAll.cy >= 0)); if(wParam != NULL) { @@ -1818,9 +1798,9 @@ public: SIZE szWindowExt = { 0, 0 }; dc.SetWindowExt(m_sizeLogAll, &szWindowExt); SIZE szViewportExt = { 0, 0 }; - dc.SetViewportExt(m_sizeAll, &szViewportExt); + dc.SetViewportExt(this->m_sizeAll, &szViewportExt); POINT ptViewportOrg = { 0, 0 }; - dc.SetViewportOrg(-m_ptOffset.x, -m_ptOffset.y, &ptViewportOrg); + dc.SetViewportOrg(-this->m_ptOffset.x, -this->m_ptOffset.y, &ptViewportOrg); pT->DoPaint(dc); @@ -1841,7 +1821,7 @@ public: LRESULT OnLButtonDown(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled) { - if(m_nZoomMode == ZOOMMODE_IN && !m_bTracking) + if((m_nZoomMode == ZOOMMODE_IN) && !m_bTracking) { T* pT = static_cast(this); POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; @@ -1850,6 +1830,18 @@ public: pT->SetCapture(); m_bTracking = true; ::SetRect(&m_rcTrack, pt.x, pt.y, pt.x, pt.y); + + RECT rcClip; + pT->GetClientRect(&rcClip); + if((this->m_ptOffset.x == 0) && (this->m_ptOffset.y == 0)) + { + if(rcClip.right > this->m_sizeAll.cx) + rcClip.right = this->m_sizeAll.cx; + if(rcClip.bottom > this->m_sizeAll.cy) + rcClip.bottom = this->m_sizeAll.cy; + } + ::MapWindowPoints(pT->m_hWnd, NULL, (LPPOINT)&rcClip, 2); + ::ClipCursor(&rcClip); } } @@ -1866,8 +1858,8 @@ public: if(pT->PtInDevRect(pt)) { pT->DrawTrackRect(); - m_rcTrack.right = pt.x; - m_rcTrack.bottom = pt.y; + m_rcTrack.right = pt.x + 1; + m_rcTrack.bottom = pt.y + 1; pT->DrawTrackRect(); } } @@ -1900,33 +1892,12 @@ public: pT->Zoom(m_rcTrack); pT->NotifyParentZoomChanged(); ::SetRectEmpty(&m_rcTrack); + ::ClipCursor(NULL); } bHandled = FALSE; return 0; } - - LRESULT OnSetCursor(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled) - { - if(LOWORD(lParam) == HTCLIENT && m_nZoomMode != ZOOMMODE_OFF) - { - T* pT = static_cast(this); - if((HWND)wParam == pT->m_hWnd) - { - DWORD dwPos = ::GetMessagePos(); - POINT pt = { GET_X_LPARAM(dwPos), GET_Y_LPARAM(dwPos) }; - pT->ScreenToClient(&pt); - if(pT->PtInDevRect(pt)) - { - ::SetCursor(::LoadCursor(NULL, IDC_CROSS)); - return 1; - } - } - } - - bHandled = FALSE; - return 0; - } }; /////////////////////////////////////////////////////////////////////////////// @@ -1938,19 +1909,14 @@ class ATL_NO_VTABLE CZoomScrollWindowImpl : public ATL::CWindowImpl< T, TBase, T public: BOOL SubclassWindow(HWND hWnd) { -#if (_MSC_VER >= 1300) BOOL bRet = ATL::CWindowImpl< T, TBase, TWinTraits >::SubclassWindow(hWnd); -#else // !(_MSC_VER >= 1300) - typedef ATL::CWindowImpl< T, TBase, TWinTraits > _baseClass; - BOOL bRet = _baseClass::SubclassWindow(hWnd); -#endif // !(_MSC_VER >= 1300) if(bRet != FALSE) { T* pT = static_cast(this); pT->GetSystemSettings(); - RECT rect = { 0 }; - GetClientRect(&rect); + RECT rect = {}; + this->GetClientRect(&rect); pT->DoSize(rect.right, rect.bottom); } @@ -1961,10 +1927,7 @@ public: MESSAGE_HANDLER(WM_SETCURSOR, CZoomScrollImpl< T >::OnSetCursor) MESSAGE_HANDLER(WM_VSCROLL, CScrollImpl< T >::OnVScroll) MESSAGE_HANDLER(WM_HSCROLL, CScrollImpl< T >::OnHScroll) - MESSAGE_HANDLER(WM_MOUSEWHEEL, CScrollImpl< T >::OnMouseWheel) -#if !((_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)) - MESSAGE_HANDLER(m_uMsgMouseWheel, CScrollImpl< T >::OnMouseWheel) -#endif // !((_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)) + MESSAGE_HANDLER(WM_MOUSEWHEEL, CZoomScrollImpl< T >::OnMouseWheel) MESSAGE_HANDLER(WM_MOUSEHWHEEL, CScrollImpl< T >::OnMouseHWheel) MESSAGE_HANDLER(WM_SETTINGCHANGE, CScrollImpl< T >::OnSettingChange) MESSAGE_HANDLER(WM_SIZE, CScrollImpl< T >::OnSize) @@ -1990,8 +1953,6 @@ public: END_MSG_MAP() }; -#endif // !_WIN32_WCE - /////////////////////////////////////////////////////////////////////////////// // CScrollContainer @@ -2000,7 +1961,7 @@ template { public: - DECLARE_WND_CLASS_EX(NULL, 0, -1) + DECLARE_WND_CLASS_EX2(NULL, T, 0, -1) typedef CScrollWindowImpl< T, TBase, TWinTraits > _baseClass; @@ -2013,7 +1974,7 @@ public: CScrollContainerImpl() : m_bAutoSizeClient(true), m_bDrawEdgeIfEmpty(false) { // Set CScrollWindowImpl extended style - SetScrollExtendedStyle(SCRL_SCROLLCHILDREN); + this->SetScrollExtendedStyle(SCRL_SCROLLCHILDREN); } // Attributes @@ -2024,13 +1985,13 @@ public: HWND SetClient(HWND hWndClient, bool bClientSizeAsMin = true) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); HWND hWndOldClient = m_wndClient; m_wndClient = hWndClient; - SetRedraw(FALSE); - SetScrollSize(1, 1, FALSE); + this->SetRedraw(FALSE); + this->SetScrollSize(1, 1, FALSE); if(m_wndClient.m_hWnd != NULL) { @@ -2038,18 +1999,18 @@ public: if(bClientSizeAsMin) { - RECT rect = { 0 }; + RECT rect = {}; m_wndClient.GetWindowRect(&rect); - if((rect.right - rect.left) > 0 && (rect.bottom - rect.top) > 0) - SetScrollSize(rect.right - rect.left, rect.bottom - rect.top, FALSE); + if(((rect.right - rect.left) > 0) && ((rect.bottom - rect.top) > 0)) + this->SetScrollSize(rect.right - rect.left, rect.bottom - rect.top, FALSE); } T* pT = static_cast(this); pT->UpdateLayout(); } - SetRedraw(TRUE); - RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_UPDATENOW | RDW_ALLCHILDREN); + this->SetRedraw(TRUE); + this->RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_UPDATENOW | RDW_ALLCHILDREN); return hWndOldClient; } @@ -2088,13 +2049,13 @@ public: void DoPaint(CDCHandle dc) { - if(!m_bAutoSizeClient || m_wndClient.m_hWnd == NULL) + if(!m_bAutoSizeClient || (m_wndClient.m_hWnd == NULL)) { T* pT = static_cast(this); - RECT rect = { 0 }; + RECT rect = {}; pT->GetContainerRect(rect); - if(m_bDrawEdgeIfEmpty && m_wndClient.m_hWnd == NULL) + if(m_bDrawEdgeIfEmpty && (m_wndClient.m_hWnd == NULL)) dc.DrawEdge(&rect, EDGE_SUNKEN, BF_RECT | BF_ADJUST); dc.FillRect(&rect, COLOR_APPWORKSPACE); @@ -2114,11 +2075,11 @@ public: void ScrollToView(HWND hWnd) // client window coordinates { T* pT = static_cast(this); - pT; // avoid level 4 warning + (void)pT; // avoid level 4 warning ATLASSERT(::IsWindow(pT->m_hWnd)); ATLASSERT(m_wndClient.IsWindow()); - RECT rect = { 0 }; + RECT rect = {}; ::GetWindowRect(hWnd, &rect); ::MapWindowPoints(NULL, m_wndClient.m_hWnd, (LPPOINT)&rect, 2); ScrollToView(rect); @@ -2127,31 +2088,31 @@ public: // Implementation - overrideable methods void UpdateLayout() { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); - if(m_bAutoSizeClient && m_wndClient.m_hWnd != NULL) + if(m_bAutoSizeClient && (m_wndClient.m_hWnd != NULL)) { T* pT = static_cast(this); - RECT rect = { 0 }; + RECT rect = {}; pT->GetContainerRect(rect); m_wndClient.SetWindowPos(NULL, &rect, SWP_NOZORDER | SWP_NOMOVE); } else { - Invalidate(); + this->Invalidate(); } } void GetContainerRect(RECT& rect) { - GetClientRect(&rect); + this->GetClientRect(&rect); - if(rect.right < m_sizeAll.cx) - rect.right = m_sizeAll.cx; + if(rect.right < this->m_sizeAll.cx) + rect.right = this->m_sizeAll.cx; - if(rect.bottom < m_sizeAll.cy) - rect.bottom = m_sizeAll.cy; + if(rect.bottom < this->m_sizeAll.cy) + rect.bottom = this->m_sizeAll.cy; } }; @@ -2161,6 +2122,6 @@ public: DECLARE_WND_CLASS_EX(_T("WTL_ScrollContainer"), 0, -1) }; -}; // namespace WTL +} // namespace WTL #endif // __ATLSCRL_H__ diff --git a/WrlSDK/SampleCode/PluginWinExe/WTL/atlsplit.h b/WrlSDK/SampleCode/PluginWinExe/WTL/atlsplit.h index 00a419d494e1d18c251c0d01145e46b269ab9bbf..714269c0bcac94a1dd4c26ad3fe082469d40066f 100644 --- a/WrlSDK/SampleCode/PluginWinExe/WTL/atlsplit.h +++ b/WrlSDK/SampleCode/PluginWinExe/WTL/atlsplit.h @@ -1,4 +1,4 @@ -// Windows Template Library - WTL version 9.10 +// Windows Template Library - WTL version 10.0 // Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. // // This file is a part of the Windows Template Library. @@ -47,18 +47,19 @@ namespace WTL #define SPLIT_RIGHTALIGNED 0x00000004 #define SPLIT_BOTTOMALIGNED SPLIT_RIGHTALIGNED #define SPLIT_GRADIENTBAR 0x00000008 +#define SPLIT_FLATBAR 0x00000020 #define SPLIT_FIXEDBARSIZE 0x00000010 // Note: SPLIT_PROPORTIONAL and SPLIT_RIGHTALIGNED/SPLIT_BOTTOMALIGNED are // mutually exclusive. If both are set, splitter defaults to SPLIT_PROPORTIONAL. -// SPLIT_GRADIENTBAR doesn't work with _ATL_NO_MSIMG +// Also, SPLIT_FLATBAR overrides SPLIT_GRADIENTBAR if both are set. template class CSplitterImpl { public: - enum { m_nPanesCount = 2, m_nPropMax = 10000, m_cxyStep = 10 }; + enum { m_nPanesCount = 2, m_nPropMax = INT_MAX, m_cxyStep = 10 }; bool m_bVertical; HWND m_hWndPane[m_nPanesCount]; @@ -201,7 +202,7 @@ public: int GetSplitterPosPct() const { int cxyTotal = m_bVertical ? (m_rcSplitter.right - m_rcSplitter.left - m_cxySplitBar - m_cxyBarEdge) : (m_rcSplitter.bottom - m_rcSplitter.top - m_cxySplitBar - m_cxyBarEdge); - return ((cxyTotal > 0) && (m_xySplitterPos >= 0)) ? (::MulDiv(m_xySplitterPos, m_nPropMax, cxyTotal) / 100) : -1; + return ((cxyTotal > 0) && (m_xySplitterPos >= 0)) ? ::MulDiv(m_xySplitterPos, 100, cxyTotal) : -1; } bool SetSinglePaneMode(int nPane = SPLIT_PANE_NONE) @@ -471,13 +472,28 @@ public: // Overrideables void DrawSplitterBar(CDCHandle dc) { - RECT rect = { 0 }; + RECT rect = {}; if(GetSplitterBarRect(&rect)) { dc.FillRect(&rect, COLOR_3DFACE); -#if (!defined(_WIN32_WCE) && !defined(_ATL_NO_MSIMG)) || (_WIN32_WCE >= 420) - if((m_dwExtendedStyle & SPLIT_GRADIENTBAR) != 0) + if((m_dwExtendedStyle & SPLIT_FLATBAR) != 0) + { + RECT rect1 = rect; + if(m_bVertical) + rect1.right = rect1.left + 1; + else + rect1.bottom = rect1.top + 1; + dc.FillRect(&rect1, COLOR_WINDOW); + + rect1 = rect; + if(m_bVertical) + rect1.left = rect1.right - 1; + else + rect1.top = rect1.bottom - 1; + dc.FillRect(&rect1, COLOR_3DSHADOW); + } + else if((m_dwExtendedStyle & SPLIT_GRADIENTBAR) != 0) { RECT rect2 = rect; if(m_bVertical) @@ -487,7 +503,6 @@ public: dc.GradientFillRect(rect2, ::GetSysColor(COLOR_3DFACE), ::GetSysColor(COLOR_3DSHADOW), m_bVertical); } -#endif // (!defined(_WIN32_WCE) && !defined(_ATL_NO_MSIMG)) || (_WIN32_WCE >= 420) // draw 3D edge if needed T* pT = static_cast(this); @@ -499,7 +514,7 @@ public: // called only if pane is empty void DrawSplitterPane(CDCHandle dc, int nPane) { - RECT rect = { 0 }; + RECT rect = {}; if(GetSplitterPaneRect(nPane, &rect)) { T* pT = static_cast(this); @@ -513,9 +528,7 @@ public: BEGIN_MSG_MAP(CSplitterImpl) MESSAGE_HANDLER(WM_CREATE, OnCreate) MESSAGE_HANDLER(WM_PAINT, OnPaint) -#ifndef _WIN32_WCE MESSAGE_HANDLER(WM_PRINTCLIENT, OnPaint) -#endif // !_WIN32_WCE if(IsInteractive()) { MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor) @@ -527,9 +540,7 @@ public: MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown) } MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus) -#ifndef _WIN32_WCE MESSAGE_HANDLER(WM_MOUSEACTIVATE, OnMouseActivate) -#endif // !_WIN32_WCE MESSAGE_HANDLER(WM_SETTINGCHANGE, OnSettingChange) END_MSG_MAP() @@ -698,6 +709,7 @@ public: { case VK_RETURN: m_xySplitterPosNew = m_xySplitterPos; + // FALLTHROUGH case VK_ESCAPE: ::ReleaseCapture(); break; @@ -705,7 +717,7 @@ public: case VK_RIGHT: if(m_bVertical) { - POINT pt = { 0, 0 }; + POINT pt = {}; ::GetCursorPos(&pt); int xyPos = m_xySplitterPos + ((wParam == VK_LEFT) ? -pT->m_cxyStep : pT->m_cxyStep); int cxyMax = m_rcSplitter.right - m_rcSplitter.left; @@ -721,7 +733,7 @@ public: case VK_DOWN: if(!m_bVertical) { - POINT pt = { 0, 0 }; + POINT pt = {}; ::GetCursorPos(&pt); int xyPos = m_xySplitterPos + ((wParam == VK_UP) ? -pT->m_cxyStep : pT->m_cxyStep); int cxyMax = m_rcSplitter.bottom - m_rcSplitter.top; @@ -765,7 +777,6 @@ public: return 1; } -#ifndef _WIN32_WCE LRESULT OnMouseActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) { T* pT = static_cast(this); @@ -775,7 +786,7 @@ public: DWORD dwPos = ::GetMessagePos(); POINT pt = { GET_X_LPARAM(dwPos), GET_Y_LPARAM(dwPos) }; pT->ScreenToClient(&pt); - RECT rcPane = { 0 }; + RECT rcPane = {}; for(int nPane = 0; nPane < m_nPanesCount; nPane++) { if(GetSplitterPaneRect(nPane, &rcPane) && (::PtInRect(&rcPane, pt) != FALSE)) @@ -788,7 +799,6 @@ public: return lRet; } -#endif // !_WIN32_WCE LRESULT OnSettingChange(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { @@ -813,7 +823,7 @@ public: return; T* pT = static_cast(this); - RECT rect = { 0 }; + RECT rect = {}; if(m_nSinglePane == SPLIT_PANE_NONE) { if(GetSplitterBarRect(&rect)) @@ -923,8 +933,8 @@ public: bool IsOverSplitterRect(int x, int y) const { // -1 == don't check - return ((x == -1 || (x >= m_rcSplitter.left && x <= m_rcSplitter.right)) && - (y == -1 || (y >= m_rcSplitter.top && y <= m_rcSplitter.bottom))); + return (((x == -1) || ((x >= m_rcSplitter.left) && (x <= m_rcSplitter.right))) && + ((y == -1) || ((y >= m_rcSplitter.top) && (y <= m_rcSplitter.bottom)))); } bool IsOverSplitterBar(int x, int y) const @@ -936,26 +946,26 @@ public: int xy = m_bVertical ? x : y; int xyOff = m_bVertical ? m_rcSplitter.left : m_rcSplitter.top; - return ((xy >= (xyOff + m_xySplitterPos)) && (xy < xyOff + m_xySplitterPos + m_cxySplitBar + m_cxyBarEdge)); + return ((xy >= (xyOff + m_xySplitterPos)) && (xy < (xyOff + m_xySplitterPos + m_cxySplitBar + m_cxyBarEdge))); } void DrawGhostBar() { - RECT rect = { 0 }; + RECT rect = {}; if(GetSplitterBarRect(&rect)) { // convert client to window coordinates T* pT = static_cast(this); - RECT rcWnd = { 0 }; + RECT rcWnd = {}; pT->GetWindowRect(&rcWnd); ::MapWindowPoints(NULL, pT->m_hWnd, (LPPOINT)&rcWnd, 2); ::OffsetRect(&rect, -rcWnd.left, -rcWnd.top); // invert the brush pattern (looks just like frame window sizing) - CWindowDC dc(pT->m_hWnd); - CBrush brush = CDCHandle::GetHalftoneBrush(); + CBrush brush(CDCHandle::GetHalftoneBrush()); if(brush.m_hBrush != NULL) { + CWindowDC dc(pT->m_hWnd); CBrushHandle brushOld = dc.SelectBrush(brush); dc.PatBlt(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, PATINVERT); dc.SelectBrush(brushOld); @@ -967,11 +977,7 @@ public: { if((m_dwExtendedStyle & SPLIT_FIXEDBARSIZE) == 0) { -#ifndef _WIN32_WCE m_cxySplitBar = ::GetSystemMetrics(m_bVertical ? SM_CXSIZEFRAME : SM_CYSIZEFRAME); -#else // CE specific - m_cxySplitBar = 2 * ::GetSystemMetrics(m_bVertical ? SM_CXEDGE : SM_CYEDGE); -#endif // _WIN32_WCE } T* pT = static_cast(this); @@ -986,9 +992,7 @@ public: m_cxyMin = 2 * ::GetSystemMetrics(m_bVertical ? SM_CXEDGE : SM_CYEDGE); } -#ifndef _WIN32_WCE ::SystemParametersInfo(SPI_GETDRAGFULLWINDOWS, 0, &m_bFullDrag, 0); -#endif // !_WIN32_WCE if(bUpdate) UpdateSplitterLayout(); @@ -1061,25 +1065,20 @@ template , public CSplitterImpl< T > { public: - DECLARE_WND_CLASS_EX(NULL, CS_DBLCLKS, COLOR_WINDOW) + DECLARE_WND_CLASS_EX2(NULL, T, CS_DBLCLKS, COLOR_WINDOW) CSplitterWindowImpl(bool bVertical = true) : CSplitterImpl< T >(bVertical) { } BOOL SubclassWindow(HWND hWnd) { -#if (_MSC_VER >= 1300) BOOL bRet = ATL::CWindowImpl< T, TBase, TWinTraits >::SubclassWindow(hWnd); -#else // !(_MSC_VER >= 1300) - typedef ATL::CWindowImpl< T, TBase, TWinTraits > _baseClass; - BOOL bRet = _baseClass::SubclassWindow(hWnd); -#endif // !(_MSC_VER >= 1300) if(bRet != FALSE) { T* pT = static_cast(this); pT->Init(); - SetSplitterRect(); + this->SetSplitterRect(); } return bRet; @@ -1101,7 +1100,7 @@ public: LRESULT OnSize(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) { if(wParam != SIZE_MINIMIZED) - SetSplitterRect(); + this->SetSplitterRect(); bHandled = FALSE; return 1; @@ -1116,7 +1115,7 @@ template class CSplitterWindowT : public CSplitterWindowImpl > { public: - DECLARE_WND_CLASS_EX(_T("WTL_SplitterWindow"), CS_DBLCLKS, COLOR_WINDOW) + DECLARE_WND_CLASS_EX2(_T("WTL_SplitterWindow"), CSplitterWindowT, CS_DBLCLKS, COLOR_WINDOW) CSplitterWindowT() : CSplitterWindowImpl >(t_bVertical) { } @@ -1125,6 +1124,6 @@ public: typedef CSplitterWindowT CSplitterWindow; typedef CSplitterWindowT CHorSplitterWindow; -}; // namespace WTL +} // namespace WTL #endif // __ATLSPLIT_H__ diff --git a/WrlSDK/SampleCode/PluginWinExe/WTL/atltheme.h b/WrlSDK/SampleCode/PluginWinExe/WTL/atltheme.h index b453a41bccf62f603acb86ee33faf2d35a651a8a..9855f0014c81329f10de6ff2efd48403ccba956c 100644 --- a/WrlSDK/SampleCode/PluginWinExe/WTL/atltheme.h +++ b/WrlSDK/SampleCode/PluginWinExe/WTL/atltheme.h @@ -1,4 +1,4 @@ -// Windows Template Library - WTL version 9.10 +// Windows Template Library - WTL version 10.0 // Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. // // This file is a part of the Windows Template Library. @@ -11,10 +11,6 @@ #pragma once -#ifdef _WIN32_WCE - #error atltheme.h is not supported on Windows CE -#endif - #ifndef __ATLAPP_H__ #error atltheme.h requires atlapp.h to be included first #endif @@ -23,20 +19,7 @@ #error atltheme.h requires atlwin.h to be included first #endif -#if (_WIN32_WINNT < 0x0501) - #error atltheme.h requires _WIN32_WINNT >= 0x0501 -#endif // (_WIN32_WINNT < 0x0501) - -#if defined(_WTL_USE_VSSYM32) || (defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_LONGHORN)) - #include -#else - #ifndef TMSCHEMA_H - #include - #endif -#endif - -#include -#pragma comment(lib, "uxtheme.lib") +#include // Note: To create an application that also runs on older versions of Windows, // use delay load of uxtheme.dll and ensure that no calls to the Theme API are @@ -56,20 +39,6 @@ // Delay load is NOT AUTOMATIC for VC++ 7, you have to link to delayimp.lib, // and add uxtheme.dll in the Linker.Input.Delay Loaded DLLs section of the // project properties. -#if (_MSC_VER < 1300) && !defined(_WTL_NO_THEME_DELAYLOAD) - #pragma comment(lib, "delayimp.lib") - #pragma comment(linker, "/delayload:uxtheme.dll") -#endif // (_MSC_VER < 1300) && !defined(_WTL_NO_THEME_DELAYLOAD) - -// Hack: Signatures in uxtheme.h changed - the only way to check which variant of uxtheme.h -// is included is to check for presence of new defines MAX_THEMECOLOR and MAX_THEMESIZE -// Note: In WinSDK 7.0 (and higher) they are defined with #if (_WIN32_WINNT >= 0x0600), -// so you have to compile with _WTL_NEW_UXTHEME defined for _WIN32_WINNT < 0x0600 -#ifndef _WTL_NEW_UXTHEME - #if defined(MAX_THEMECOLOR) && defined(MAX_THEMESIZE) - #define _WTL_NEW_UXTHEME - #endif // defined(MAX_THEMECOLOR) && defined(MAX_THEMESIZE) -#endif // _WTL_NEW_UXTHEME /////////////////////////////////////////////////////////////////////////////// @@ -224,12 +193,7 @@ public: HRESULT GetThemePartSize(HDC hDC, int nPartID, int nStateID, LPCRECT pRect, enum THEMESIZE eSize, LPSIZE pSize) const { ATLASSERT(m_hTheme != NULL); -#ifdef _WTL_NEW_UXTHEME return ::GetThemePartSize(m_hTheme, hDC, nPartID, nStateID, pRect, eSize, pSize); -#else // !_WTL_NEW_UXTHEME - // Note: The cast to LPRECT is because uxtheme.h incorrectly uses it instead of LPCRECT - return ::GetThemePartSize(m_hTheme, hDC, nPartID, nStateID, (LPRECT)pRect, eSize, pSize); -#endif // !_WTL_NEW_UXTHEME } HRESULT GetThemeTextExtent(HDC hDC, int nPartID, int nStateID, LPCWSTR pszText, int nCharCount, DWORD dwTextFlags, LPCRECT pBoundingRect, LPRECT pExtentRect) const @@ -241,12 +205,7 @@ public: HRESULT GetThemeTextMetrics(HDC hDC, int nPartID, int nStateID, PTEXTMETRICW pTextMetric) const { ATLASSERT(m_hTheme != NULL); -#ifdef _WTL_NEW_UXTHEME return ::GetThemeTextMetrics(m_hTheme, hDC, nPartID, nStateID, pTextMetric); -#else // !_WTL_NEW_UXTHEME - // Note: The cast to PTEXTMETRIC is because uxtheme.h incorrectly uses it instead of PTEXTMETRICW - return ::GetThemeTextMetrics(m_hTheme, hDC, nPartID, nStateID, (PTEXTMETRIC)pTextMetric); -#endif // !_WTL_NEW_UXTHEME } HRESULT GetThemeBackgroundRegion(HDC hDC, int nPartID, int nStateID, LPCRECT pRect, HRGN* pRegion) const @@ -331,23 +290,13 @@ public: HRESULT GetThemeFont(int nPartID, HDC hDC, int nStateID, int nPropID, LOGFONTW* pFont) const { ATLASSERT(m_hTheme != NULL); -#ifdef _WTL_NEW_UXTHEME return ::GetThemeFont(m_hTheme, hDC, nPartID, nStateID, nPropID, pFont); -#else // !_WTL_NEW_UXTHEME - // Note: The cast to LOGFONT* is because uxtheme.h incorrectly uses it instead of LOGFONTW* - return ::GetThemeFont(m_hTheme, hDC, nPartID, nStateID, nPropID, (LOGFONT*)pFont); -#endif // !_WTL_NEW_UXTHEME } HRESULT GetThemeFont(HDC hDC, int nPartID, int nStateID, int nPropID, LOGFONTW* pFont) const { ATLASSERT(m_hTheme != NULL); -#ifdef _WTL_NEW_UXTHEME return ::GetThemeFont(m_hTheme, hDC, nPartID, nStateID, nPropID, pFont); -#else // !_WTL_NEW_UXTHEME - // Note: The cast to LOGFONT* is because uxtheme.h incorrectly uses it instead of LOGFONTW* - return ::GetThemeFont(m_hTheme, hDC, nPartID, nStateID, nPropID, (LOGFONT*)pFont); -#endif // !_WTL_NEW_UXTHEME } HRESULT GetThemeRect(int nPartID, int nStateID, int nPropID, LPRECT pRect) const @@ -407,12 +356,7 @@ public: HRESULT GetThemeSysFont(int nFontID, LOGFONTW* plf) const { ATLASSERT(m_hTheme != NULL); -#ifdef _WTL_NEW_UXTHEME return ::GetThemeSysFont(m_hTheme, nFontID, plf); -#else // !_WTL_NEW_UXTHEME - // Note: The cast to LOGFONT* is because uxtheme.h incorrectly uses it instead of LOGFONTW* - return ::GetThemeSysFont(m_hTheme, nFontID, (LOGFONT*)plf); -#endif // !_WTL_NEW_UXTHEME } HRESULT GetThemeSysString(int nStringID, LPWSTR pszStringBuff, int cchMaxStringChars) const @@ -427,7 +371,6 @@ public: return ::GetThemeSysInt(m_hTheme, nIntID, pnValue); } -#ifdef _WTL_NEW_UXTHEME HTHEME OpenThemeDataEx(HWND hWnd, LPCWSTR pszClassList, DWORD dwFlags) { if(!IsThemingSupported()) @@ -451,7 +394,6 @@ public: return ::GetThemeTransitionDuration(m_hTheme, nPartID, nFromStateID, nToStateID, nPropID, &dwDuration); } #endif // (_WIN32_WINNT >= 0x0600) -#endif // _WTL_NEW_UXTHEME #if (_WIN32_WINNT >= 0x0600) HRESULT GetThemeBitmap(int nPartID, int nStateID, int nPropID, ULONG uFlags, HBITMAP& hBitmap) @@ -525,7 +467,7 @@ inline bool AtlDrawThemeClientEdge(HTHEME hTheme, HWND hWnd, HRGN hRgnUpdate = N if(SUCCEEDED(::GetThemeInt(hTheme, nPartID, nStateID, TMT_SIZINGBORDERWIDTH, &cxBorder))) cyBorder = cxBorder; - RECT rect = { 0 }; + RECT rect = {}; ::GetWindowRect(hWnd, &rect); // Remove the client edge from the update region @@ -552,12 +494,7 @@ inline bool AtlDrawThemeClientEdge(HTHEME hTheme, HWND hWnd, HRGN hRgnUpdate = N if((cxBorder < cxEdge) && (cyBorder < cyEdge)) { if(hBrush == NULL) -// need conditional code because types don't match in winuser.h -#ifdef _WIN64 hBrush = (HBRUSH)::GetClassLongPtr(hWnd, GCLP_HBRBACKGROUND); -#else - hBrush = (HBRUSH)UlongToPtr(::GetClassLongPtr(hWnd, GCLP_HBRBACKGROUND)); -#endif ::InflateRect(&rect, cxBorder - cxEdge, cyBorder - cyEdge); dc.FillRect(&rect, hBrush); @@ -607,7 +544,7 @@ public: if(m_lpstrThemeClassList == NULL) return false; - SecureHelper::strcpyW_x(m_lpstrThemeClassList, cchLen, lpstrThemeClassList); + ATL::Checked::wcscpy_s(m_lpstrThemeClassList, cchLen, lpstrThemeClassList); return true; } @@ -618,7 +555,7 @@ public: if(cchListBuffer < cchLen) return false; - SecureHelper::strcpyW_x(lpstrThemeClassList, cchListBuffer, m_lpstrThemeClassList); + ATL::Checked::wcscpy_s(lpstrThemeClassList, cchListBuffer, m_lpstrThemeClassList); return true; } @@ -652,7 +589,7 @@ public: ATLASSERT(m_lpstrThemeClassList != NULL); if(m_lpstrThemeClassList == NULL) return NULL; - CloseThemeData(); + this->CloseThemeData(); return TBase::OpenThemeData(pT->m_hWnd, m_lpstrThemeClassList); } @@ -667,7 +604,7 @@ public: HRESULT SetWindowTheme(LPCWSTR pszSubAppName, LPCWSTR pszSubIDList) { - if(!IsThemingSupported()) + if(!this->IsThemingSupported()) return S_FALSE; T* pT = static_cast(this); @@ -677,7 +614,7 @@ public: HTHEME GetWindowTheme() const { - if(!IsThemingSupported()) + if(!this->IsThemingSupported()) return NULL; const T* pT = static_cast(this); @@ -687,7 +624,7 @@ public: HRESULT EnableThemeDialogTexture(DWORD dwFlags) { - if(!IsThemingSupported()) + if(!this->IsThemingSupported()) return S_FALSE; T* pT = static_cast(this); @@ -697,7 +634,7 @@ public: BOOL IsThemeDialogTextureEnabled() const { - if(!IsThemingSupported()) + if(!this->IsThemingSupported()) return FALSE; const T* pT = static_cast(this); @@ -707,22 +644,18 @@ public: HRESULT DrawThemeParentBackground(HDC hDC, const RECT* pRect = NULL) { - if(!IsThemingSupported()) + if(!this->IsThemingSupported()) return S_FALSE; T* pT = static_cast(this); ATLASSERT(::IsWindow(pT->m_hWnd)); -#ifdef _WTL_NEW_UXTHEME return ::DrawThemeParentBackground(pT->m_hWnd, hDC, pRect); -#else - return ::DrawThemeParentBackground(pT->m_hWnd, hDC, (RECT*)pRect); -#endif } -#if defined(_WTL_NEW_UXTHEME) && (_WIN32_WINNT >= 0x0600) +#if (_WIN32_WINNT >= 0x0600) HRESULT SetWindowThemeAttribute(WINDOWTHEMEATTRIBUTETYPE type, PVOID pvAttribute, DWORD cbAttribute) { - if(!IsThemingSupported()) + if(!this->IsThemingSupported()) return S_FALSE; T* pT = static_cast(this); @@ -732,7 +665,7 @@ public: HRESULT SetWindowThemeNonClientAttributes(DWORD dwAttributes, DWORD dwMask) { - if(!IsThemingSupported()) + if(!this->IsThemingSupported()) return S_FALSE; T* pT = static_cast(this); @@ -743,14 +676,14 @@ public: HRESULT DrawThemeParentBackgroundEx(HDC hDC, DWORD dwFlags, const RECT* lpRect = NULL) { - if(!IsThemingSupported()) + if(!this->IsThemingSupported()) return S_FALSE; T* pT = static_cast(this); ATLASSERT(::IsWindow(pT->m_hWnd)); return ::DrawThemeParentBackgroundEx(pT->m_hWnd, hDC, dwFlags, lpRect); } -#endif // defined(_WTL_NEW_UXTHEME) && (_WIN32_WINNT >= 0x0600) +#endif // (_WIN32_WINNT >= 0x0600) // Message map and handlers // Note: If you handle any of these messages in your derived class, @@ -773,7 +706,7 @@ public: LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) { - CloseThemeData(); + this->CloseThemeData(); bHandled = FALSE; return 1; @@ -781,9 +714,9 @@ public: LRESULT OnThemeChanged(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) { - CloseThemeData(); + this->CloseThemeData(); if(m_lpstrThemeClassList != NULL) - OpenThemeData(); + this->OpenThemeData(); bHandled = FALSE; return 1; @@ -795,14 +728,14 @@ public: ATLASSERT(::IsWindow(pT->m_hWnd)); LRESULT lRet = 0; bHandled = FALSE; - if(IsThemingSupported() && ((pT->GetExStyle() & WS_EX_CLIENTEDGE) != 0)) + if(this->IsThemingSupported() && ((pT->GetExStyle() & WS_EX_CLIENTEDGE) != 0)) { if((m_dwExtendedStyle & THEME_EX_3DCLIENTEDGE) != 0) { lRet = ::DefWindowProc(pT->m_hWnd, uMsg, wParam, lParam); bHandled = TRUE; } - else if((m_hTheme != NULL) && ((m_dwExtendedStyle & THEME_EX_THEMECLIENTEDGE) != 0)) + else if((this->m_hTheme != NULL) && ((m_dwExtendedStyle & THEME_EX_THEMECLIENTEDGE) != 0)) { HRGN hRgn = (wParam != 1) ? (HRGN)wParam : NULL; if(pT->DrawThemeClientEdge(hRgn)) @@ -817,14 +750,14 @@ public: bool DrawThemeClientEdge(HRGN hRgnUpdate) { T* pT = static_cast(this); - return AtlDrawThemeClientEdge(m_hTheme, pT->m_hWnd, hRgnUpdate, NULL, 0, 0); + return AtlDrawThemeClientEdge(this->m_hTheme, pT->m_hWnd, hRgnUpdate, NULL, 0, 0); } }; /////////////////////////////////////////////////////////////////////////////// // Buffered Paint and Animation -#if defined(_WTL_NEW_UXTHEME) && (_WIN32_WINNT >= 0x0600) +#if (_WIN32_WINNT >= 0x0600) /////////////////////////////////////////////////////////////////////////////// // CBufferedPaintBase - Buffered Paint support for othe classes @@ -989,7 +922,7 @@ public: T* pT = static_cast(this); if(wParam != NULL) { - RECT rect = { 0 }; + RECT rect = {}; pT->GetClientRect(&rect); pT->DoPaint((HDC)wParam, rect); } @@ -1164,7 +1097,7 @@ public: T* pT = static_cast(this); if(wParam != NULL) { - RECT rect = { 0 }; + RECT rect = {}; pT->GetClientRect(&rect); pT->DoPaint((HDC)wParam, rect, m_NewState); } @@ -1250,8 +1183,8 @@ public: END_MSG_MAP() }; -#endif // defined(_WTL_NEW_UXTHEME) && (_WIN32_WINNT >= 0x0600) +#endif // (_WIN32_WINNT >= 0x0600) -}; // namespace WTL +} // namespace WTL #endif // __ATLTHEME_H__ diff --git a/WrlSDK/SampleCode/PluginWinExe/WTL/atluser.h b/WrlSDK/SampleCode/PluginWinExe/WTL/atluser.h index 24b9bd21767e75cbd04cedf3a6a56af3aee17b9f..9f8e0f4a3f121618cf74cd2ee0791d0ab84cd882 100644 --- a/WrlSDK/SampleCode/PluginWinExe/WTL/atluser.h +++ b/WrlSDK/SampleCode/PluginWinExe/WTL/atluser.h @@ -1,4 +1,4 @@ -// Windows Template Library - WTL version 9.10 +// Windows Template Library - WTL version 10.0 // Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. // // This file is a part of the Windows Template Library. @@ -54,7 +54,7 @@ namespace WTL inline int AtlMessageBox(HWND hWndOwner, ATL::_U_STRINGorID message, ATL::_U_STRINGorID title = (LPCTSTR)NULL, UINT uType = MB_OK | MB_ICONINFORMATION) { - ATLASSERT(hWndOwner == NULL || ::IsWindow(hWndOwner)); + ATLASSERT((hWndOwner == NULL) || ::IsWindow(hWndOwner)); LPTSTR lpstrMessage = NULL; if(IS_INTRESOURCE(message.m_lpstr)) @@ -78,7 +78,7 @@ inline int AtlMessageBox(HWND hWndOwner, ATL::_U_STRINGorID message, ATL::_U_STR } LPTSTR lpstrTitle = NULL; - if(IS_INTRESOURCE(title.m_lpstr) && LOWORD(title.m_lpstr) != 0) + if(IS_INTRESOURCE(title.m_lpstr) && (LOWORD(title.m_lpstr) != 0)) { for(int nLen = 256; ; nLen *= 2) { @@ -110,19 +110,6 @@ inline int AtlMessageBox(HWND hWndOwner, ATL::_U_STRINGorID message, ATL::_U_STR /////////////////////////////////////////////////////////////////////////////// // CMenu -#if (WINVER >= 0x0500) - #ifndef MII_SIZEOF_STRUCT - #define MII_SIZEOF_STRUCT(structname, member) (((int)((LPBYTE)(&((structname*)0)->member) - ((LPBYTE)((structname*)0)))) + sizeof(((structname*)0)->member)) - #endif - #define MENUITEMINFO_SIZE_VERSION_400A MII_SIZEOF_STRUCT(MENUITEMINFOA, cch) - #define MENUITEMINFO_SIZE_VERSION_400W MII_SIZEOF_STRUCT(MENUITEMINFOW, cch) - #ifdef UNICODE - #define MENUITEMINFO_SIZE_VERSION_400 MENUITEMINFO_SIZE_VERSION_400W - #else - #define MENUITEMINFO_SIZE_VERSION_400 MENUITEMINFO_SIZE_VERSION_400A - #endif // !UNICODE -#endif // (WINVER >= 0x0500) - class CMenuItemInfo : public MENUITEMINFO { public: @@ -130,14 +117,6 @@ public: { memset(this, 0, sizeof(MENUITEMINFO)); cbSize = sizeof(MENUITEMINFO); -#if (WINVER >= 0x0500) - // adjust struct size if running on older version of Windows - if(AtlIsOldWindows()) - { - ATLASSERT(cbSize > MENUITEMINFO_SIZE_VERSION_400); // must be - cbSize = MENUITEMINFO_SIZE_VERSION_400; - } -#endif // (WINVER >= 0x0500) } }; @@ -161,7 +140,7 @@ public: ~CMenuT() { - if(t_bManaged && m_hMenu != NULL) + if(t_bManaged && (m_hMenu != NULL)) DestroyMenu(); } @@ -174,7 +153,7 @@ public: void Attach(HMENU hMenuNew) { ATLASSERT(::IsMenu(hMenuNew)); - if(t_bManaged && m_hMenu != NULL && m_hMenu != hMenuNew) + if(t_bManaged && (m_hMenu != NULL) && (m_hMenu != hMenuNew)) ::DestroyMenu(m_hMenu); m_hMenu = hMenuNew; } @@ -217,14 +196,12 @@ public: return (m_hMenu != NULL) ? TRUE : FALSE; } -#ifndef _WIN32_WCE BOOL LoadMenuIndirect(const void* lpMenuTemplate) { ATLASSERT(m_hMenu == NULL); m_hMenu = ::LoadMenuIndirect(lpMenuTemplate); return (m_hMenu != NULL) ? TRUE : FALSE; } -#endif // !_WIN32_WCE BOOL DestroyMenu() { @@ -246,27 +223,17 @@ public: BOOL TrackPopupMenu(UINT nFlags, int x, int y, HWND hWnd, LPCRECT lpRect = NULL) { ATLASSERT(::IsMenu(m_hMenu)); -#ifndef _WIN32_WCE -#if (WINVER >= 0x0500) x = _FixTrackMenuPopupX(x, y); -#endif // !(WINVER >= 0x0500) return ::TrackPopupMenu(m_hMenu, nFlags, x, y, 0, hWnd, lpRect); -#else // CE specific - lpRect; - return ::TrackPopupMenuEx(m_hMenu, nFlags, x, y, hWnd, NULL); -#endif // _WIN32_WCE } BOOL TrackPopupMenuEx(UINT uFlags, int x, int y, HWND hWnd, LPTPMPARAMS lptpm = NULL) { ATLASSERT(::IsMenu(m_hMenu)); -#if (WINVER >= 0x0500) && !defined(_WIN32_WCE) x = _FixTrackMenuPopupX(x, y); -#endif // (WINVER >= 0x0500) && !defined(_WIN32_WCE) return ::TrackPopupMenuEx(m_hMenu, uFlags, x, y, hWnd, lptpm); } -#if (WINVER >= 0x0500) && !defined(_WIN32_WCE) // helper that fixes popup menu X position when it's off-screen static int _FixTrackMenuPopupX(int x, int y) { @@ -302,7 +269,6 @@ public: ATLASSERT(::IsMenu(m_hMenu)); return ::SetMenuInfo(m_hMenu, lpMenuInfo); } -#endif // (WINVER >= 0x0500) && !defined(_WIN32_WCE) // Menu Item Operations BOOL AppendMenu(UINT nFlags, UINT_PTR nIDNewItem = 0, LPCTSTR lpszNewItem = NULL) @@ -318,7 +284,6 @@ public: return ::AppendMenu(m_hMenu, nFlags | MF_POPUP, (UINT_PTR)hSubMenu, lpszNewItem); } -#ifndef _WIN32_WCE BOOL AppendMenu(UINT nFlags, UINT_PTR nIDNewItem, HBITMAP hBmp) { ATLASSERT(::IsMenu(m_hMenu)); @@ -331,7 +296,6 @@ public: ATLASSERT(::IsMenu(hSubMenu)); return ::AppendMenu(m_hMenu, nFlags | (MF_BITMAP | MF_POPUP), (UINT_PTR)hSubMenu, (LPCTSTR)hBmp); } -#endif // !_WIN32_WCE UINT CheckMenuItem(UINT nIDCheckItem, UINT nCheck) { @@ -345,7 +309,6 @@ public: return ::EnableMenuItem(m_hMenu, nIDEnableItem, nEnable); } -#ifndef _WIN32_WCE BOOL HiliteMenuItem(HWND hWnd, UINT uIDHiliteItem, UINT uHilite) { ATLASSERT(::IsMenu(m_hMenu)); @@ -382,7 +345,6 @@ public: return ::GetMenuString(m_hMenu, nIDItem, NULL, 0, nFlags); } -#ifndef _ATL_NO_COM BOOL GetMenuString(UINT nIDItem, BSTR& bstrText, UINT nFlags) const { USES_CONVERSION; @@ -397,7 +359,7 @@ public: } nLen++; // increment to include terminating NULL char - CTempBuffer buff; + ATL::CTempBuffer buff; LPTSTR lpszText = buff.Allocate(nLen); if(lpszText == NULL) return FALSE; @@ -408,42 +370,9 @@ public: bstrText = ::SysAllocString(T2OLE(lpszText)); return (bstrText != NULL) ? TRUE : FALSE; } -#endif // !_ATL_NO_COM - -#elif (_ATL_VER >= 0x0800) - int GetMenuItemCount() const - { - ATLASSERT(::IsMenu(m_hMenu)); - return ATL::GetMenuItemCount(m_hMenu); - } - - UINT GetMenuItemID(int nPos) const - { - ATLASSERT(::IsMenu(m_hMenu)); - return ATL::GetMenuItemID(m_hMenu, nPos); - } - - UINT GetMenuState(UINT nID, UINT nFlags) const - { - ATLASSERT(::IsMenu(m_hMenu)); - return ATL::GetMenuState(m_hMenu, nID, nFlags); - } - int GetMenuString(UINT nIDItem, LPTSTR lpString, int nMaxCount, UINT nFlags) const - { - ATLASSERT(::IsMenu(m_hMenu)); - return ATL::GetMenuString(m_hMenu, nIDItem, lpString, nMaxCount, nFlags); - } - - int GetMenuStringLen(UINT nIDItem, UINT nFlags) const - { - ATLASSERT(::IsMenu(m_hMenu)); - return ATL::GetMenuString(m_hMenu, nIDItem, NULL, 0, nFlags); - } -#endif // (_ATL_VER >= 0x0800) - -#if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) - int GetMenuString(UINT nIDItem, _CSTRING_NS::CString& strText, UINT nFlags) const +#ifdef __ATLSTR_H__ + int GetMenuString(UINT nIDItem, ATL::CString& strText, UINT nFlags) const { ATLASSERT(::IsMenu(m_hMenu)); @@ -459,7 +388,7 @@ public: strText.ReleaseBuffer(); return nRet; } -#endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) +#endif // __ATLSTR_H__ CMenuHandle GetSubMenu(int nPos) const { @@ -480,7 +409,6 @@ public: return ::InsertMenu(m_hMenu, nPosition, nFlags | MF_POPUP, (UINT_PTR)hSubMenu, lpszNewItem); } -#ifndef _WIN32_WCE BOOL InsertMenu(UINT nPosition, UINT nFlags, UINT_PTR nIDNewItem, HBITMAP hBmp) { ATLASSERT(::IsMenu(m_hMenu)); @@ -519,7 +447,6 @@ public: ATLASSERT(::IsMenu(hSubMenu)); return ::ModifyMenu(m_hMenu, nPosition, nFlags | (MF_BITMAP | MF_POPUP), (UINT_PTR)hSubMenu, (LPCTSTR)hBmp); } -#endif // !_WIN32_WCE BOOL RemoveMenu(UINT nPosition, UINT nFlags) { @@ -527,13 +454,11 @@ public: return ::RemoveMenu(m_hMenu, nPosition, nFlags); } -#ifndef _WIN32_WCE BOOL SetMenuItemBitmaps(UINT nPosition, UINT nFlags, HBITMAP hBmpUnchecked, HBITMAP hBmpChecked) { ATLASSERT(::IsMenu(m_hMenu)); return ::SetMenuItemBitmaps(m_hMenu, nPosition, nFlags, hBmpUnchecked, hBmpChecked); } -#endif // !_WIN32_WCE BOOL CheckMenuRadioItem(UINT nIDFirst, UINT nIDLast, UINT nIDItem, UINT nFlags) { @@ -553,7 +478,6 @@ public: return (BOOL)::SetMenuItemInfo(m_hMenu, uItem, bByPosition, lpmii); } -#ifndef _WIN32_WCE BOOL InsertMenuItem(UINT uItem, BOOL bByPosition, LPMENUITEMINFO lpmii) { ATLASSERT(::IsMenu(m_hMenu)); @@ -596,7 +520,6 @@ public: ATLASSERT(::IsMenu(m_hMenu)); return ::GetMenuContextHelpId(m_hMenu); } -#endif // !_WIN32_WCE }; @@ -615,7 +538,7 @@ public: ~CAcceleratorT() { - if(t_bManaged && m_hAccel != NULL) + if(t_bManaged && (m_hAccel != NULL)) ::DestroyAcceleratorTable(m_hAccel); } @@ -627,7 +550,7 @@ public: void Attach(HACCEL hAccel) { - if(t_bManaged && m_hAccel != NULL) + if(t_bManaged && (m_hAccel != NULL)) ::DestroyAcceleratorTable(m_hAccel); m_hAccel = hAccel; } @@ -669,7 +592,6 @@ public: } // Operations -#ifndef _WIN32_WCE int CopyAcceleratorTable(LPACCEL lpAccelDst, int cEntries) { ATLASSERT(m_hAccel != NULL); @@ -682,7 +604,6 @@ public: ATLASSERT(m_hAccel != NULL); return ::CopyAcceleratorTable(m_hAccel, NULL, 0); } -#endif // !_WIN32_WCE BOOL TranslateAccelerator(HWND hWnd, LPMSG pMsg) { @@ -712,7 +633,7 @@ public: ~CIconT() { - if(t_bManaged && m_hIcon != NULL) + if(t_bManaged && (m_hIcon != NULL)) ::DestroyIcon(m_hIcon); } @@ -724,7 +645,7 @@ public: void Attach(HICON hIcon) { - if(t_bManaged && m_hIcon != NULL) + if(t_bManaged && (m_hIcon != NULL)) ::DestroyIcon(m_hIcon); m_hIcon = hIcon; } @@ -755,7 +676,6 @@ public: return m_hIcon; } -#ifndef _WIN32_WCE HICON LoadOEMIcon(LPCTSTR lpstrIconName) { ATLASSERT(m_hIcon == NULL); @@ -789,7 +709,6 @@ public: m_hIcon = ::CreateIconFromResourceEx(pbBits, cbBits, TRUE, dwVersion, cxDesired, cyDesired, uFlags); return m_hIcon; } -#endif // !_WIN32_WCE HICON CreateIconIndirect(PICONINFO pIconInfo) { @@ -799,7 +718,6 @@ public: return m_hIcon; } -#ifndef _WIN32_WCE HICON ExtractIcon(LPCTSTR lpszExeFileName, UINT nIconIndex) { ATLASSERT(m_hIcon == NULL); @@ -816,7 +734,6 @@ public: m_hIcon = ::ExtractAssociatedIcon(hInst, lpIconPath, lpiIcon); return m_hIcon; } -#endif // !_WIN32_WCE BOOL DestroyIcon() { @@ -828,7 +745,6 @@ public: } // Operations -#ifndef _WIN32_WCE HICON CopyIcon() { ATLASSERT(m_hIcon != NULL); @@ -840,26 +756,17 @@ public: ATLASSERT(m_hIcon != NULL); return ::DuplicateIcon(NULL, m_hIcon); } -#endif // !_WIN32_WCE BOOL DrawIcon(HDC hDC, int x, int y) { ATLASSERT(m_hIcon != NULL); -#ifndef _WIN32_WCE return ::DrawIcon(hDC, x, y, m_hIcon); -#else // CE specific - return ::DrawIconEx(hDC, x, y, m_hIcon, 0, 0, 0, NULL, DI_NORMAL); -#endif // _WIN32_WCE } BOOL DrawIcon(HDC hDC, POINT pt) { ATLASSERT(m_hIcon != NULL); -#ifndef _WIN32_WCE return ::DrawIcon(hDC, pt.x, pt.y, m_hIcon); -#else // CE specific - return ::DrawIconEx(hDC, pt.x, pt.y, m_hIcon, 0, 0, 0, NULL, DI_NORMAL); -#endif // _WIN32_WCE } BOOL DrawIconEx(HDC hDC, int x, int y, int cxWidth, int cyWidth, UINT uStepIfAniCur = 0, HBRUSH hbrFlickerFreeDraw = NULL, UINT uFlags = DI_NORMAL) @@ -874,7 +781,6 @@ public: return ::DrawIconEx(hDC, pt.x, pt.y, m_hIcon, size.cx, size.cy, uStepIfAniCur, hbrFlickerFreeDraw, uFlags); } -#ifndef _WIN32_WCE BOOL GetIconInfo(PICONINFO pIconInfo) const { ATLASSERT(m_hIcon != NULL); @@ -921,22 +827,19 @@ public: return ::LoadIconWithScaleDown(NULL, (LPCWSTR)lpstrIconName, cx, cy, &m_hIcon); } #endif // defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_LONGHORN) -#endif // !_WIN32_WCE // Helper -#ifndef _WIN32_WCE static bool IsOEMIcon(LPCTSTR lpstrIconName) { #if (WINVER >= 0x0600) - return (lpstrIconName == IDI_APPLICATION || lpstrIconName == IDI_ASTERISK || lpstrIconName == IDI_EXCLAMATION || - lpstrIconName == IDI_HAND || lpstrIconName == IDI_QUESTION || lpstrIconName == IDI_WINLOGO || - lpstrIconName == IDI_SHIELD); + return ((lpstrIconName == IDI_APPLICATION) || (lpstrIconName == IDI_ASTERISK) || (lpstrIconName == IDI_EXCLAMATION) || + (lpstrIconName == IDI_HAND) || (lpstrIconName == IDI_QUESTION) || (lpstrIconName == IDI_WINLOGO) || + (lpstrIconName == IDI_SHIELD)); #else // !(WINVER >= 0x0600) - return (lpstrIconName == IDI_APPLICATION || lpstrIconName == IDI_ASTERISK || lpstrIconName == IDI_EXCLAMATION || - lpstrIconName == IDI_HAND || lpstrIconName == IDI_QUESTION || lpstrIconName == IDI_WINLOGO); + return ((lpstrIconName == IDI_APPLICATION) || (lpstrIconName == IDI_ASTERISK) || (lpstrIconName == IDI_EXCLAMATION) || + (lpstrIconName == IDI_HAND) || (lpstrIconName == IDI_QUESTION) || (lpstrIconName == IDI_WINLOGO)); #endif // !(WINVER >= 0x0600) } -#endif // !_WIN32_WCE }; typedef CIconT CIconHandle; @@ -963,7 +866,7 @@ public: ~CCursorT() { - if(t_bManaged && m_hCursor != NULL) + if(t_bManaged && (m_hCursor != NULL)) DestroyCursor(); } @@ -975,7 +878,7 @@ public: void Attach(HCURSOR hCursor) { - if(t_bManaged && m_hCursor != NULL) + if(t_bManaged && (m_hCursor != NULL)) DestroyCursor(); m_hCursor = hCursor; } @@ -1002,20 +905,12 @@ public: HCURSOR LoadSysCursor(LPCTSTR lpstrCursorName) { ATLASSERT(m_hCursor == NULL); -#if (WINVER >= 0x0500) - ATLASSERT(lpstrCursorName == IDC_ARROW || lpstrCursorName == IDC_IBEAM || lpstrCursorName == IDC_WAIT || - lpstrCursorName == IDC_CROSS || lpstrCursorName == IDC_UPARROW || lpstrCursorName == IDC_SIZE || - lpstrCursorName == IDC_ICON || lpstrCursorName == IDC_SIZENWSE || lpstrCursorName == IDC_SIZENESW || - lpstrCursorName == IDC_SIZEWE || lpstrCursorName == IDC_SIZENS || lpstrCursorName == IDC_SIZEALL || - lpstrCursorName == IDC_NO || lpstrCursorName == IDC_APPSTARTING || lpstrCursorName == IDC_HELP || - lpstrCursorName == IDC_HAND); -#else // !(WINVER >= 0x0500) - ATLASSERT(lpstrCursorName == IDC_ARROW || lpstrCursorName == IDC_IBEAM || lpstrCursorName == IDC_WAIT || - lpstrCursorName == IDC_CROSS || lpstrCursorName == IDC_UPARROW || lpstrCursorName == IDC_SIZE || - lpstrCursorName == IDC_ICON || lpstrCursorName == IDC_SIZENWSE || lpstrCursorName == IDC_SIZENESW || - lpstrCursorName == IDC_SIZEWE || lpstrCursorName == IDC_SIZENS || lpstrCursorName == IDC_SIZEALL || - lpstrCursorName == IDC_NO || lpstrCursorName == IDC_APPSTARTING || lpstrCursorName == IDC_HELP); -#endif // !(WINVER >= 0x0500) + ATLASSERT((lpstrCursorName == IDC_ARROW) || (lpstrCursorName == IDC_IBEAM) || (lpstrCursorName == IDC_WAIT) || + (lpstrCursorName == IDC_CROSS) || (lpstrCursorName == IDC_UPARROW) || (lpstrCursorName == IDC_SIZE) || + (lpstrCursorName == IDC_ICON) || (lpstrCursorName == IDC_SIZENWSE) || (lpstrCursorName == IDC_SIZENESW) || + (lpstrCursorName == IDC_SIZEWE) || (lpstrCursorName == IDC_SIZENS) || (lpstrCursorName == IDC_SIZEALL) || + (lpstrCursorName == IDC_NO) || (lpstrCursorName == IDC_APPSTARTING) || (lpstrCursorName == IDC_HELP) || + (lpstrCursorName == IDC_HAND)); m_hCursor = ::LoadCursor(NULL, lpstrCursorName); return m_hCursor; } @@ -1033,7 +928,6 @@ public: return m_hCursor; } -#ifndef _WIN32_WCE HCURSOR LoadCursorFromFile(LPCTSTR pstrFilename) { ATLASSERT(m_hCursor == NULL); @@ -1041,18 +935,14 @@ public: m_hCursor = ::LoadCursorFromFile(pstrFilename); return m_hCursor; } -#endif // !_WIN32_WCE -#if !defined(_WIN32_WCE) || ((_WIN32_WCE >= 0x400) && !(defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP))) HCURSOR CreateCursor(int xHotSpot, int yHotSpot, int nWidth, int nHeight, CONST VOID *pvANDPlane, CONST VOID *pvXORPlane) { ATLASSERT(m_hCursor == NULL); m_hCursor = ::CreateCursor(ModuleHelper::GetResourceInstance(), xHotSpot, yHotSpot, nWidth, nHeight, pvANDPlane, pvXORPlane); return m_hCursor; } -#endif // !defined(_WIN32_WCE) || ((_WIN32_WCE >= 0x400) && !(defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP))) -#ifndef _WIN32_WCE HCURSOR CreateCursorFromResource(PBYTE pBits, DWORD dwResSize, DWORD dwVersion = 0x00030000) { ATLASSERT(m_hCursor == NULL); @@ -1069,39 +959,29 @@ public: m_hCursor = (HCURSOR)::CreateIconFromResourceEx(pbBits, cbBits, FALSE, dwVersion, cxDesired, cyDesired, uFlags); return m_hCursor; } -#endif // !_WIN32_WCE BOOL DestroyCursor() { ATLASSERT(m_hCursor != NULL); -#if !defined(_WIN32_WCE) || ((_WIN32_WCE >= 0x400) && !(defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP))) BOOL bRet = ::DestroyCursor(m_hCursor); if(bRet != FALSE) m_hCursor = NULL; return bRet; -#else // !(!defined(_WIN32_WCE) || ((_WIN32_WCE >= 0x400) && !(defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP)))) - ATLTRACE2(atlTraceUI, 0, _T("Warning: This version of Windows CE does not have ::DestroyCursor()\n")); - return FALSE; -#endif // !(!defined(_WIN32_WCE) || ((_WIN32_WCE >= 0x400) && !(defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP)))) } // Operations -#ifndef _WIN32_WCE HCURSOR CopyCursor() { ATLASSERT(m_hCursor != NULL); return (HCURSOR)::CopyIcon((HICON)m_hCursor); } -#endif // !_WIN32_WCE -#if (WINVER >= 0x0500) && !defined(_WIN32_WCE) BOOL GetCursorInfo(LPCURSORINFO pCursorInfo) { ATLASSERT(m_hCursor != NULL); ATLASSERT(pCursorInfo != NULL); return ::GetCursorInfo(pCursorInfo); } -#endif // (WINVER >= 0x0500) && !defined(_WIN32_WCE) }; typedef CCursorT CCursorHandle; @@ -1148,7 +1028,6 @@ public: return true; } -#ifndef _WIN32_WCE bool LoadEx(ATL::_U_STRINGorID ID, ATL::_U_STRINGorID Type, WORD wLanguage) { ATLASSERT(m_hResource == NULL); @@ -1167,7 +1046,6 @@ public: return true; } -#endif // !_WIN32_WCE // Misc. operations DWORD GetSize() const @@ -1235,7 +1113,7 @@ inline HBITMAP AtlLoadSysBitmap(ATL::_U_STRINGorID bitmap) { #ifdef _DEBUG WORD wID = LOWORD(bitmap.m_lpstr); - ATLASSERT(wID >= 32734 && wID <= 32767); + ATLASSERT((wID >= 32734) && (wID <= 32767)); #endif // _DEBUG return ::LoadBitmap(NULL, bitmap.m_lpstr); } @@ -1248,20 +1126,12 @@ inline HCURSOR AtlLoadCursor(ATL::_U_STRINGorID cursor) inline HCURSOR AtlLoadSysCursor(LPCTSTR lpCursorName) { -#if (WINVER >= 0x0500) - ATLASSERT(lpCursorName == IDC_ARROW || lpCursorName == IDC_IBEAM || lpCursorName == IDC_WAIT || - lpCursorName == IDC_CROSS || lpCursorName == IDC_UPARROW || lpCursorName == IDC_SIZE || - lpCursorName == IDC_ICON || lpCursorName == IDC_SIZENWSE || lpCursorName == IDC_SIZENESW || - lpCursorName == IDC_SIZEWE || lpCursorName == IDC_SIZENS || lpCursorName == IDC_SIZEALL || - lpCursorName == IDC_NO || lpCursorName == IDC_APPSTARTING || lpCursorName == IDC_HELP || - lpCursorName == IDC_HAND); -#else // !(WINVER >= 0x0500) - ATLASSERT(lpCursorName == IDC_ARROW || lpCursorName == IDC_IBEAM || lpCursorName == IDC_WAIT || - lpCursorName == IDC_CROSS || lpCursorName == IDC_UPARROW || lpCursorName == IDC_SIZE || - lpCursorName == IDC_ICON || lpCursorName == IDC_SIZENWSE || lpCursorName == IDC_SIZENESW || - lpCursorName == IDC_SIZEWE || lpCursorName == IDC_SIZENS || lpCursorName == IDC_SIZEALL || - lpCursorName == IDC_NO || lpCursorName == IDC_APPSTARTING || lpCursorName == IDC_HELP); -#endif // !(WINVER >= 0x0500) + ATLASSERT((lpCursorName == IDC_ARROW) || (lpCursorName == IDC_IBEAM) || (lpCursorName == IDC_WAIT) || + (lpCursorName == IDC_CROSS) || (lpCursorName == IDC_UPARROW) || (lpCursorName == IDC_SIZE) || + (lpCursorName == IDC_ICON) || (lpCursorName == IDC_SIZENWSE) || (lpCursorName == IDC_SIZENESW) || + (lpCursorName == IDC_SIZEWE) || (lpCursorName == IDC_SIZENS) || (lpCursorName == IDC_SIZEALL) || + (lpCursorName == IDC_NO) || (lpCursorName == IDC_APPSTARTING) || (lpCursorName == IDC_HELP) || + (lpCursorName == IDC_HAND)); return ::LoadCursor(NULL, lpCursorName); } @@ -1270,20 +1140,18 @@ inline HICON AtlLoadIcon(ATL::_U_STRINGorID icon) return ::LoadIcon(ModuleHelper::GetResourceInstance(), icon.m_lpstr); } -#ifndef _WIN32_WCE inline HICON AtlLoadSysIcon(LPCTSTR lpIconName) { #if (WINVER >= 0x0600) - ATLASSERT(lpIconName == IDI_APPLICATION || lpIconName == IDI_ASTERISK || lpIconName == IDI_EXCLAMATION || - lpIconName == IDI_HAND || lpIconName == IDI_QUESTION || lpIconName == IDI_WINLOGO || - lpIconName == IDI_SHIELD); + ATLASSERT((lpIconName == IDI_APPLICATION) || (lpIconName == IDI_ASTERISK) || (lpIconName == IDI_EXCLAMATION) || + (lpIconName == IDI_HAND) || (lpIconName == IDI_QUESTION) || (lpIconName == IDI_WINLOGO) || + (lpIconName == IDI_SHIELD)); #else // !(WINVER >= 0x0600) - ATLASSERT(lpIconName == IDI_APPLICATION || lpIconName == IDI_ASTERISK || lpIconName == IDI_EXCLAMATION || - lpIconName == IDI_HAND || lpIconName == IDI_QUESTION || lpIconName == IDI_WINLOGO); + ATLASSERT((lpIconName == IDI_APPLICATION) || (lpIconName == IDI_ASTERISK) || (lpIconName == IDI_EXCLAMATION) || + (lpIconName == IDI_HAND) || (lpIconName == IDI_QUESTION) || (lpIconName == IDI_WINLOGO)); #endif // !(WINVER >= 0x0600) return ::LoadIcon(NULL, lpIconName); } -#endif // !_WIN32_WCE inline HBITMAP AtlLoadBitmapImage(ATL::_U_STRINGorID bitmap, UINT fuLoad = LR_DEFAULTCOLOR) { @@ -1303,7 +1171,7 @@ inline HICON AtlLoadIconImage(ATL::_U_STRINGorID icon, UINT fuLoad = LR_DEFAULTC #ifdef OEMRESOURCE inline HBITMAP AtlLoadSysBitmapImage(WORD wBitmapID, UINT fuLoad = LR_DEFAULTCOLOR) { - ATLASSERT(wBitmapID >= 32734 && wBitmapID <= 32767); + ATLASSERT((wBitmapID >= 32734) && (wBitmapID <= 32767)); ATLASSERT((fuLoad & LR_LOADFROMFILE) == 0); // this one doesn't load from a file return (HBITMAP)::LoadImage(NULL, MAKEINTRESOURCE(wBitmapID), IMAGE_BITMAP, 0, 0, fuLoad); } @@ -1313,7 +1181,7 @@ inline HCURSOR AtlLoadSysCursorImage(ATL::_U_STRINGorID cursor, UINT fuLoad = LR { #ifdef _DEBUG WORD wID = LOWORD(cursor.m_lpstr); - ATLASSERT((wID >= 32512 && wID <= 32516) || (wID >= 32640 && wID <= 32648) || (wID == 32650) || (wID == 32651)); + ATLASSERT(((wID >= 32512) && (wID <= 32516)) || ((wID >= 32640) && (wID <= 32648)) || (wID == 32650) || (wID == 32651)); ATLASSERT((fuLoad & LR_LOADFROMFILE) == 0); // this one doesn't load from a file #endif // _DEBUG return (HCURSOR)::LoadImage(NULL, cursor.m_lpstr, IMAGE_CURSOR, cxDesired, cyDesired, fuLoad); @@ -1323,36 +1191,12 @@ inline HICON AtlLoadSysIconImage(ATL::_U_STRINGorID icon, UINT fuLoad = LR_DEFAU { #ifdef _DEBUG WORD wID = LOWORD(icon.m_lpstr); - ATLASSERT(wID >= 32512 && wID <= 32517); + ATLASSERT((wID >= 32512) && (wID <= 32517)); ATLASSERT((fuLoad & LR_LOADFROMFILE) == 0); // this one doesn't load from a file #endif // _DEBUG return (HICON)::LoadImage(NULL, icon.m_lpstr, IMAGE_ICON, cxDesired, cyDesired, fuLoad); } -#if (_ATL_VER < 0x0700) -inline int AtlLoadString(UINT uID, LPTSTR lpBuffer, int nBufferMax) -{ - return ::LoadString(ModuleHelper::GetResourceInstance(), uID, lpBuffer, nBufferMax); -} -#else - -using ATL::AtlLoadString; - -#endif // (_ATL_VER < 0x0700) - -#ifdef _WIN32_WCE // CE only direct access to the resource -inline LPCTSTR AtlLoadString(UINT uID) -{ - LPCTSTR s = (LPCTSTR)::LoadString(ModuleHelper::GetResourceInstance(), uID, NULL, 0); -#ifdef DEBUG // Check for null-termination - if(s != NULL) - // Note: RC -n compiles null-terminated resource strings - ATLASSERT(s[*((WORD*)s -1) - 1] == L'\0'); -#endif - return s; -} -#endif // _WIN32_WCE - inline bool AtlLoadString(UINT uID, BSTR& bstrText) { USES_CONVERSION; @@ -1382,6 +1226,6 @@ inline bool AtlLoadString(UINT uID, BSTR& bstrText) return (bstrText != NULL) ? true : false; } -}; // namespace WTL +} // namespace WTL #endif // __ATLUSER_H__ diff --git a/WrlSDK/SampleCode/PluginWinExe/WTL/atlwinx.h b/WrlSDK/SampleCode/PluginWinExe/WTL/atlwinx.h index e6873a3f0a6684d5af9f61560996c3327c9d191f..b89c513782be1e29f7f7a1b05e13c3e143d1a721 100644 --- a/WrlSDK/SampleCode/PluginWinExe/WTL/atlwinx.h +++ b/WrlSDK/SampleCode/PluginWinExe/WTL/atlwinx.h @@ -1,4 +1,4 @@ -// Windows Template Library - WTL version 9.10 +// Windows Template Library - WTL version 10.0 // Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. // // This file is a part of the Windows Template Library. @@ -15,17 +15,45 @@ #error atlwinx.h requires atlapp.h to be included first #endif -#if (_ATL_VER >= 0x0700) - #include -#endif // (_ATL_VER >= 0x0700) +#include /////////////////////////////////////////////////////////////////////////////// // Classes in this file: // -// _U_RECT -// _U_MENUorID -// _U_STRINGorID +// CWindowEx + + +///////////////////////////////////////////////////////////////////////////// +// Additional macros needed for template classes + +#ifndef DECLARE_WND_CLASS_EX2 + #define DECLARE_WND_CLASS_EX2(WndClassName, EnclosingClass, style, bkgnd) \ + static ATL::CWndClassInfo& GetWndClassInfo() \ + { \ + static ATL::CWndClassInfo wc = \ + { \ + { sizeof(WNDCLASSEX), style, EnclosingClass::StartWindowProc, \ + 0, 0, NULL, NULL, NULL, (HBRUSH)(bkgnd + 1), NULL, WndClassName, NULL }, \ + NULL, NULL, IDC_ARROW, TRUE, 0, _T("") \ + }; \ + return wc; \ + } +#endif // DECLARE_WND_CLASS_EX2 + +#ifndef DECLARE_WND_SUPERCLASS2 + #define DECLARE_WND_SUPERCLASS2(WndClassName, EnclosingClass, OrigWndClassName) \ + static ATL::CWndClassInfo& GetWndClassInfo() \ + { \ + static ATL::CWndClassInfo wc = \ + { \ + { sizeof(WNDCLASSEX), 0, EnclosingClass::StartWindowProc, \ + 0, 0, NULL, NULL, NULL, NULL, NULL, WndClassName, NULL }, \ + OrigWndClassName, NULL, NULL, TRUE, 0, _T("") \ + }; \ + return wc; \ + } +#endif // DECLARE_WND_SUPERCLASS2 /////////////////////////////////////////////////////////////////////////////// @@ -85,7 +113,6 @@ inline LRESULT WtlReflectNotificationsFiltered(HWND hWndParent, UINT uMsg, WPARA hWndChild = ((LPNMHDR)lParam)->hwndFrom; idFrom = ((LPNMHDR)lParam)->idFrom; break; -#ifndef _WIN32_WCE case WM_PARENTNOTIFY: switch(LOWORD(wParam)) { @@ -100,7 +127,6 @@ inline LRESULT WtlReflectNotificationsFiltered(HWND hWndParent, UINT uMsg, WPARA break; } break; -#endif // !_WIN32_WCE case WM_DRAWITEM: if(wParam) // not from a menu { @@ -133,9 +159,6 @@ inline LRESULT WtlReflectNotificationsFiltered(HWND hWndParent, UINT uMsg, WPARA case WM_CHARTOITEM: case WM_HSCROLL: case WM_VSCROLL: - hWndChild = (HWND)lParam; - idFrom = (UINT_PTR)::GetDlgCtrlID(hWndChild); - break; case WM_CTLCOLORBTN: case WM_CTLCOLORDLG: case WM_CTLCOLOREDIT: @@ -178,14 +201,14 @@ inline LRESULT WtlReflectNotificationsFiltered(HWND hWndParent, UINT uMsg, WPARA return lResult; } -}; // namespace WTL +} // namespace WTL // Try to prevent problems with WM_CTLCOLOR* messages when // the message wasn't really handled #define REFLECT_NOTIFICATIONS_EX() \ { \ bHandled = TRUE; \ - lResult = ReflectNotifications(uMsg, wParam, lParam, bHandled); \ + lResult = this->ReflectNotifications(uMsg, wParam, lParam, bHandled); \ if((lResult == 0) && (uMsg >= WM_CTLCOLORMSGBOX) && (uMsg <= WM_CTLCOLORSTATIC)) \ bHandled = FALSE; \ if(bHandled) \ @@ -195,7 +218,7 @@ inline LRESULT WtlReflectNotificationsFiltered(HWND hWndParent, UINT uMsg, WPARA #define REFLECT_NOTIFICATIONS_MSG_FILTERED(uMsgFilter) \ { \ bHandled = TRUE; \ - lResult = WTL::WtlReflectNotificationsFiltered(m_hWnd, uMsg, wParam, lParam, bHandled, uMsgFilter, 0, NULL); \ + lResult = WTL::WtlReflectNotificationsFiltered(this->m_hWnd, uMsg, wParam, lParam, bHandled, uMsgFilter, 0, NULL); \ if(bHandled) \ return TRUE; \ } @@ -203,7 +226,7 @@ inline LRESULT WtlReflectNotificationsFiltered(HWND hWndParent, UINT uMsg, WPARA #define REFLECT_NOTIFICATIONS_ID_FILTERED(idFromFilter) \ { \ bHandled = TRUE; \ - lResult = WTL::WtlReflectNotificationsFiltered(m_hWnd, uMsg, wParam, lParam, bHandled, WM_NULL, idFromFilter, NULL); \ + lResult = WTL::WtlReflectNotificationsFiltered(this->m_hWnd, uMsg, wParam, lParam, bHandled, WM_NULL, idFromFilter, NULL); \ if(bHandled) \ return TRUE; \ } @@ -211,7 +234,7 @@ inline LRESULT WtlReflectNotificationsFiltered(HWND hWndParent, UINT uMsg, WPARA #define REFLECT_NOTIFICATIONS_HWND_FILTERED(hWndChildFilter) \ { \ bHandled = TRUE; \ - lResult = WTL::WtlReflectNotificationsFiltered(m_hWnd, uMsg, wParam, lParam, bHandled, WM_NULL, 0, hWndChildFilter); \ + lResult = WTL::WtlReflectNotificationsFiltered(this->m_hWnd, uMsg, wParam, lParam, bHandled, WM_NULL, 0, hWndChildFilter); \ if(bHandled) \ return TRUE; \ } @@ -219,7 +242,7 @@ inline LRESULT WtlReflectNotificationsFiltered(HWND hWndParent, UINT uMsg, WPARA #define REFLECT_NOTIFICATIONS_MSG_ID_FILTERED(uMsgFilter, idFromFilter) \ { \ bHandled = TRUE; \ - lResult = WTL::WtlReflectNotificationsFiltered(m_hWnd, uMsg, wParam, lParam, bHandled, uMsgFilter, idFromFilter, NULL); \ + lResult = WTL::WtlReflectNotificationsFiltered(this->m_hWnd, uMsg, wParam, lParam, bHandled, uMsgFilter, idFromFilter, NULL); \ if(bHandled) \ return TRUE; \ } @@ -227,296 +250,374 @@ inline LRESULT WtlReflectNotificationsFiltered(HWND hWndParent, UINT uMsg, WPARA #define REFLECT_NOTIFICATIONS_MSG_HWND_FILTERED(uMsgFilter, hWndChildFilter) \ { \ bHandled = TRUE; \ - lResult = WTL::WtlReflectNotificationsFiltered(m_hWnd, uMsg, wParam, lParam, bHandled, uMsgFilter, 0, hWndChildFilter); \ + lResult = WTL::WtlReflectNotificationsFiltered(this->m_hWnd, uMsg, wParam, lParam, bHandled, uMsgFilter, 0, hWndChildFilter); \ if(bHandled) \ return TRUE; \ } #define REFLECT_COMMAND(id, code) \ - if(uMsg == WM_COMMAND && id == LOWORD(wParam) && code == HIWORD(wParam)) \ + if((uMsg == WM_COMMAND) && (id == LOWORD(wParam)) && (code == HIWORD(wParam))) \ { \ bHandled = TRUE; \ - lResult = ReflectNotifications(uMsg, wParam, lParam, bHandled); \ + lResult = this->ReflectNotifications(uMsg, wParam, lParam, bHandled); \ if(bHandled) \ return TRUE; \ } #define REFLECT_COMMAND_ID(id) \ - if(uMsg == WM_COMMAND && id == LOWORD(wParam)) \ + if((uMsg == WM_COMMAND) && (id == LOWORD(wParam))) \ { \ bHandled = TRUE; \ - lResult = ReflectNotifications(uMsg, wParam, lParam, bHandled); \ + lResult = this->ReflectNotifications(uMsg, wParam, lParam, bHandled); \ if(bHandled) \ return TRUE; \ } #define REFLECT_COMMAND_CODE(code) \ - if(uMsg == WM_COMMAND && code == HIWORD(wParam)) \ + if((uMsg == WM_COMMAND) && (code == HIWORD(wParam))) \ { \ bHandled = TRUE; \ - lResult = ReflectNotifications(uMsg, wParam, lParam, bHandled); \ + lResult = this->ReflectNotifications(uMsg, wParam, lParam, bHandled); \ if(bHandled) \ return TRUE; \ } #define REFLECT_COMMAND_RANGE(idFirst, idLast) \ - if(uMsg == WM_COMMAND && LOWORD(wParam) >= idFirst && LOWORD(wParam) <= idLast) \ + if((uMsg == WM_COMMAND) && (LOWORD(wParam) >= idFirst) && (LOWORD(wParam) <= idLast)) \ { \ bHandled = TRUE; \ - lResult = ReflectNotifications(uMsg, wParam, lParam, bHandled); \ + lResult = this->ReflectNotifications(uMsg, wParam, lParam, bHandled); \ if(bHandled) \ return TRUE; \ } #define REFLECT_COMMAND_RANGE_CODE(idFirst, idLast, code) \ - if(uMsg == WM_COMMAND && code == HIWORD(wParam) && LOWORD(wParam) >= idFirst && LOWORD(wParam) <= idLast) \ + if((uMsg == WM_COMMAND) && (code == HIWORD(wParam)) && (LOWORD(wParam) >= idFirst) && (LOWORD(wParam) <= idLast)) \ { \ bHandled = TRUE; \ - lResult = ReflectNotifications(uMsg, wParam, lParam, bHandled); \ + lResult = this->ReflectNotifications(uMsg, wParam, lParam, bHandled); \ if(bHandled) \ return TRUE; \ } #define REFLECT_NOTIFY(id, cd) \ - if(uMsg == WM_NOTIFY && id == ((LPNMHDR)lParam)->idFrom && cd == ((LPNMHDR)lParam)->code) \ + if((uMsg == WM_NOTIFY) && (id == ((LPNMHDR)lParam)->idFrom) && (cd == ((LPNMHDR)lParam)->code)) \ { \ bHandled = TRUE; \ - lResult = ReflectNotifications(uMsg, wParam, lParam, bHandled); \ + lResult = this->ReflectNotifications(uMsg, wParam, lParam, bHandled); \ if(bHandled) \ return TRUE; \ } #define REFLECT_NOTIFY_ID(id) \ - if(uMsg == WM_NOTIFY && id == ((LPNMHDR)lParam)->idFrom) \ + if((uMsg == WM_NOTIFY) && (id == ((LPNMHDR)lParam)->idFrom)) \ { \ bHandled = TRUE; \ - lResult = ReflectNotifications(uMsg, wParam, lParam, bHandled); \ + lResult = this->ReflectNotifications(uMsg, wParam, lParam, bHandled); \ if(bHandled) \ return TRUE; \ } #define REFLECT_NOTIFY_CODE(cd) \ - if(uMsg == WM_NOTIFY && cd == ((LPNMHDR)lParam)->code) \ + if((uMsg == WM_NOTIFY) && (cd == ((LPNMHDR)lParam)->code)) \ { \ bHandled = TRUE; \ - lResult = ReflectNotifications(uMsg, wParam, lParam, bHandled); \ + lResult = this->ReflectNotifications(uMsg, wParam, lParam, bHandled); \ if(bHandled) \ return TRUE; \ } #define REFLECT_NOTIFY_RANGE(idFirst, idLast) \ - if(uMsg == WM_NOTIFY && ((LPNMHDR)lParam)->idFrom >= idFirst && ((LPNMHDR)lParam)->idFrom <= idLast) \ + if((uMsg == WM_NOTIFY) && (((LPNMHDR)lParam)->idFrom >= idFirst) && (((LPNMHDR)lParam)->idFrom <= idLast)) \ { \ bHandled = TRUE; \ - lResult = ReflectNotifications(uMsg, wParam, lParam, bHandled); \ + lResult = this->ReflectNotifications(uMsg, wParam, lParam, bHandled); \ if(bHandled) \ return TRUE; \ } #define REFLECT_NOTIFY_RANGE_CODE(idFirst, idLast, cd) \ - if(uMsg == WM_NOTIFY && cd == ((LPNMHDR)lParam)->code && ((LPNMHDR)lParam)->idFrom >= idFirst && ((LPNMHDR)lParam)->idFrom <= idLast) \ + if((uMsg == WM_NOTIFY) && (cd == ((LPNMHDR)lParam)->code) && (((LPNMHDR)lParam)->idFrom >= idFirst) && (((LPNMHDR)lParam)->idFrom <= idLast)) \ { \ bHandled = TRUE; \ - lResult = ReflectNotifications(uMsg, wParam, lParam, bHandled); \ + lResult = this->ReflectNotifications(uMsg, wParam, lParam, bHandled); \ if(bHandled) \ return TRUE; \ } /////////////////////////////////////////////////////////////////////////////// -// Reflected message handler macros for message maps (for ATL 3.0) +// GetClassLong/SetClassLong redefinition to avoid problems with class members + +#ifdef SetClassLongPtrA + #undef SetClassLongPtrA + inline LONG_PTR SetClassLongPtrA(HWND hWnd, int nIndex, LONG_PTR dwNewLong) + { + return ::SetClassLongA(hWnd, nIndex, LONG(dwNewLong)); + } +#endif -#if (_ATL_VER < 0x0700) +#ifdef SetClassLongPtrW + #undef SetClassLongPtrW + inline LONG_PTR SetClassLongPtrW(HWND hWnd, int nIndex, LONG_PTR dwNewLong) + { + return ::SetClassLongW(hWnd, nIndex, LONG(dwNewLong)); + } +#endif -#define REFLECTED_COMMAND_HANDLER(id, code, func) \ - if(uMsg == OCM_COMMAND && id == LOWORD(wParam) && code == HIWORD(wParam)) \ - { \ - bHandled = TRUE; \ - lResult = func(HIWORD(wParam), LOWORD(wParam), (HWND)lParam, bHandled); \ - if(bHandled) \ - return TRUE; \ +#ifdef GetClassLongPtrA + #undef GetClassLongPtrA + inline LONG_PTR GetClassLongPtrA(HWND hWnd, int nIndex) + { + return ::GetClassLongA(hWnd, nIndex); + } +#endif + +#ifdef GetClassLongPtrW + #undef GetClassLongPtrW + inline LONG_PTR GetClassLongPtrW(HWND hWnd, int nIndex) + { + return ::GetClassLongW(hWnd, nIndex); + } +#endif + + +/////////////////////////////////////////////////////////////////////////////// +// CWindowEx - extension of ATL::CWindow + +namespace WTL +{ + +class CWindowEx : public ATL::CWindow +{ +public: + CWindowEx(HWND hWnd = NULL) : ATL::CWindow(hWnd) + { } + + CWindowEx& operator =(HWND hWnd) + { + m_hWnd = hWnd; + return *this; } -#define REFLECTED_COMMAND_ID_HANDLER(id, func) \ - if(uMsg == OCM_COMMAND && id == LOWORD(wParam)) \ - { \ - bHandled = TRUE; \ - lResult = func(HIWORD(wParam), LOWORD(wParam), (HWND)lParam, bHandled); \ - if(bHandled) \ - return TRUE; \ + operator HWND() const + { + return m_hWnd; } -#define REFLECTED_COMMAND_CODE_HANDLER(code, func) \ - if(uMsg == OCM_COMMAND && code == HIWORD(wParam)) \ - { \ - bHandled = TRUE; \ - lResult = func(HIWORD(wParam), LOWORD(wParam), (HWND)lParam, bHandled); \ - if(bHandled) \ - return TRUE; \ +// Methods + BOOL PrintWindow(HDC hDC, UINT uFlags = 0) + { + ATLASSERT(::IsWindow(m_hWnd)); + return ::PrintWindow(m_hWnd, hDC, uFlags); } -#define REFLECTED_COMMAND_RANGE_HANDLER(idFirst, idLast, func) \ - if(uMsg == OCM_COMMAND && LOWORD(wParam) >= idFirst && LOWORD(wParam) <= idLast) \ - { \ - bHandled = TRUE; \ - lResult = func(HIWORD(wParam), LOWORD(wParam), (HWND)lParam, bHandled); \ - if(bHandled) \ - return TRUE; \ + BOOL DragDetect(POINT pt) + { + ATLASSERT(::IsWindow(m_hWnd)); + return ::DragDetect(m_hWnd, pt); } -#define REFLECTED_COMMAND_RANGE_CODE_HANDLER(idFirst, idLast, code, func) \ - if(uMsg == OCM_COMMAND && code == HIWORD(wParam) && LOWORD(wParam) >= idFirst && LOWORD(wParam) <= idLast) \ - { \ - bHandled = TRUE; \ - lResult = func(HIWORD(wParam), LOWORD(wParam), (HWND)lParam, bHandled); \ - if(bHandled) \ - return TRUE; \ + BOOL DragDetect() + { + ATLASSERT(::IsWindow(m_hWnd)); + + POINT pt = {}; + ::GetCursorPos(&pt); + return ::DragDetect(m_hWnd, pt); } -#define REFLECTED_NOTIFY_HANDLER(id, cd, func) \ - if(uMsg == OCM_NOTIFY && id == ((LPNMHDR)lParam)->idFrom && cd == ((LPNMHDR)lParam)->code) \ - { \ - bHandled = TRUE; \ - lResult = func((int)wParam, (LPNMHDR)lParam, bHandled); \ - if(bHandled) \ - return TRUE; \ + CWindowEx GetAncestor(UINT uFlags) const + { + ATLASSERT(::IsWindow(m_hWnd)); + return CWindowEx(::GetAncestor(m_hWnd, uFlags)); } -#define REFLECTED_NOTIFY_ID_HANDLER(id, func) \ - if(uMsg == OCM_NOTIFY && id == ((LPNMHDR)lParam)->idFrom) \ - { \ - bHandled = TRUE; \ - lResult = func((int)wParam, (LPNMHDR)lParam, bHandled); \ - if(bHandled) \ - return TRUE; \ + // Note: Does not work properly on Vista Aero and above + BOOL AnimateWindow(DWORD dwFlags, DWORD dwTime = 200) + { + ATLASSERT(::IsWindow(m_hWnd)); + return ::AnimateWindow(m_hWnd, dwTime, dwFlags); } -#define REFLECTED_NOTIFY_CODE_HANDLER(cd, func) \ - if(uMsg == OCM_NOTIFY && cd == ((LPNMHDR)lParam)->code) \ - { \ - bHandled = TRUE; \ - lResult = func((int)wParam, (LPNMHDR)lParam, bHandled); \ - if(bHandled) \ - return TRUE; \ + BOOL FlashWindowEx(DWORD dwFlags, UINT uCount, DWORD dwTimeout = 0) + { + ATLASSERT(::IsWindow(m_hWnd)); + + FLASHWINFO fi = { sizeof(FLASHWINFO) }; + fi.hwnd = m_hWnd; + fi.dwFlags = dwFlags; + fi.uCount = uCount; + fi.dwTimeout = dwTimeout; + return ::FlashWindowEx(&fi); } -#define REFLECTED_NOTIFY_RANGE_HANDLER(idFirst, idLast, func) \ - if(uMsg == OCM_NOTIFY && ((LPNMHDR)lParam)->idFrom >= idFirst && ((LPNMHDR)lParam)->idFrom <= idLast) \ - { \ - bHandled = TRUE; \ - lResult = func((int)wParam, (LPNMHDR)lParam, bHandled); \ - if(bHandled) \ - return TRUE; \ + BOOL StopFlashWindowEx() + { + ATLASSERT(::IsWindow(m_hWnd)); + + FLASHWINFO fi = { sizeof(FLASHWINFO) }; + fi.hwnd = m_hWnd; + fi.dwFlags = FLASHW_STOP; + return ::FlashWindowEx(&fi); } -#define REFLECTED_NOTIFY_RANGE_CODE_HANDLER(idFirst, idLast, cd, func) \ - if(uMsg == OCM_NOTIFY && cd == ((LPNMHDR)lParam)->code && ((LPNMHDR)lParam)->idFrom >= idFirst && ((LPNMHDR)lParam)->idFrom <= idLast) \ - { \ - bHandled = TRUE; \ - lResult = func((int)wParam, (LPNMHDR)lParam, bHandled); \ - if(bHandled) \ - return TRUE; \ +// Class long properties + DWORD GetClassLong(int nIndex) const + { + ATLASSERT(::IsWindow(m_hWnd)); + return ::GetClassLong(m_hWnd, nIndex); } -#endif // (_ATL_VER < 0x0700) + DWORD SetClassLong(int nIndex, LONG dwNewLong) + { + ATLASSERT(::IsWindow(m_hWnd)); + return ::SetClassLong(m_hWnd, nIndex, dwNewLong); + } + ULONG_PTR GetClassLongPtr(int nIndex) const + { + ATLASSERT(::IsWindow(m_hWnd)); + return ::GetClassLongPtr(m_hWnd, nIndex); + } -/////////////////////////////////////////////////////////////////////////////// -// Dual argument helper classes (for ATL 3.0) + ULONG_PTR SetClassLongPtr(int nIndex, LONG_PTR dwNewLong) + { + ATLASSERT(::IsWindow(m_hWnd)); + return ::SetClassLongPtr(m_hWnd, nIndex, dwNewLong); + } -#if (_ATL_VER < 0x0700) +// Layered windows + BOOL SetLayeredWindowAttributes(COLORREF crlKey, BYTE byteAlpha, DWORD dwFlags) + { + ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT((GetExStyle() & WS_EX_LAYERED) != 0); -namespace ATL -{ + return ::SetLayeredWindowAttributes(m_hWnd, crlKey, byteAlpha, dwFlags); + } -class _U_RECT -{ -public: - _U_RECT(LPRECT lpRect) : m_lpRect(lpRect) - { } - _U_RECT(RECT& rc) : m_lpRect(&rc) - { } - LPRECT m_lpRect; -}; + BOOL UpdateLayeredWindow(HDC hdcDst, LPPOINT pptDst, LPSIZE psize, HDC hdcSrc, LPPOINT pptSrc, COLORREF crlKey, BLENDFUNCTION* pblend, DWORD dwFlags) + { + ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT((GetExStyle() & WS_EX_LAYERED) != 0); -class _U_MENUorID -{ -public: - _U_MENUorID(HMENU hMenu) : m_hMenu(hMenu) - { } - _U_MENUorID(UINT nID) : m_hMenu((HMENU)LongToHandle(nID)) - { } - HMENU m_hMenu; -}; + return ::UpdateLayeredWindow(m_hWnd, hdcDst, pptDst, psize, hdcSrc, pptSrc, crlKey, pblend, dwFlags); + } -class _U_STRINGorID -{ -public: - _U_STRINGorID(LPCTSTR lpString) : m_lpstr(lpString) - { } - _U_STRINGorID(UINT nID) : m_lpstr(MAKEINTRESOURCE(nID)) - { } - LPCTSTR m_lpstr; -}; + BOOL UpdateLayeredWindow(LPPOINT pptDst = NULL) + { + ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT((GetExStyle() & WS_EX_LAYERED) != 0); -}; // namespace ATL + return ::UpdateLayeredWindow(m_hWnd, NULL, pptDst, NULL, NULL, NULL, CLR_NONE, NULL, 0); + } -#endif // (_ATL_VER < 0x0700) + BOOL GetLayeredWindowAttributes(COLORREF* pcrlKey, BYTE* pbyteAlpha, DWORD* pdwFlags) const + { + ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT((GetExStyle() & WS_EX_LAYERED) != 0); + return ::GetLayeredWindowAttributes(m_hWnd, pcrlKey, pbyteAlpha, pdwFlags); + } -namespace WTL -{ +// Mouse tracking + BOOL StartTrackMouseLeave() + { + ATLASSERT(::IsWindow(m_hWnd)); -/////////////////////////////////////////////////////////////////////////////// -// Forward notifications support for message maps (for ATL 3.0) + TRACKMOUSEEVENT tme = {}; + tme.cbSize = sizeof(TRACKMOUSEEVENT); + tme.dwFlags = TME_LEAVE; + tme.hwndTrack = m_hWnd; + return ::TrackMouseEvent(&tme); + } -#if (_ATL_VER < 0x0700) + BOOL StartTrackMouse(DWORD dwFlags, DWORD dwHoverTime = HOVER_DEFAULT) + { + ATLASSERT(::IsWindow(m_hWnd)); -// forward notifications support -#define FORWARD_NOTIFICATIONS() \ - { \ - bHandled = TRUE; \ - lResult = WTL::Atl3ForwardNotifications(m_hWnd, uMsg, wParam, lParam, bHandled); \ - if(bHandled) \ - return TRUE; \ + TRACKMOUSEEVENT tme = {}; + tme.cbSize = sizeof(TRACKMOUSEEVENT); + tme.dwFlags = dwFlags; + tme.hwndTrack = m_hWnd; + tme.dwHoverTime = dwHoverTime; + return ::TrackMouseEvent(&tme); } -static LRESULT Atl3ForwardNotifications(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) -{ - LRESULT lResult = 0; - switch(uMsg) + BOOL CancelTrackMouse(DWORD dwType) { - case WM_COMMAND: - case WM_NOTIFY: -#ifndef _WIN32_WCE - case WM_PARENTNOTIFY: -#endif // !_WIN32_WCE - case WM_DRAWITEM: - case WM_MEASUREITEM: - case WM_COMPAREITEM: - case WM_DELETEITEM: - case WM_VKEYTOITEM: - case WM_CHARTOITEM: - case WM_HSCROLL: - case WM_VSCROLL: - case WM_CTLCOLORBTN: - case WM_CTLCOLORDLG: - case WM_CTLCOLOREDIT: - case WM_CTLCOLORLISTBOX: - case WM_CTLCOLORMSGBOX: - case WM_CTLCOLORSCROLLBAR: - case WM_CTLCOLORSTATIC: - lResult = ::SendMessage(::GetParent(hWnd), uMsg, wParam, lParam); - break; - default: - bHandled = FALSE; - break; + ATLASSERT(::IsWindow(m_hWnd)); + + TRACKMOUSEEVENT tme = {}; + tme.cbSize = sizeof(TRACKMOUSEEVENT); + tme.dwFlags = TME_CANCEL | dwType; + tme.hwndTrack = m_hWnd; + return ::TrackMouseEvent(&tme); } - return lResult; -} -#endif // (_ATL_VER < 0x0700) +// CString support +#ifdef __ATLSTR_H__ + int GetWindowText(ATL::CString& strText) const + { + int nLength = GetWindowTextLength(); + LPTSTR pszText = strText.GetBuffer(nLength + 1); + nLength = ::GetWindowText(m_hWnd, pszText, nLength + 1); + strText.ReleaseBuffer(nLength); + + return nLength; + } + + UINT GetDlgItemText(int nID, ATL::CString& strText) const + { + ATLASSERT(::IsWindow(m_hWnd)); + + HWND hItem = GetDlgItem(nID); + if(hItem != NULL) + { + int nLength = ::GetWindowTextLength(hItem); + LPTSTR pszText = strText.GetBuffer(nLength + 1); + nLength = ::GetWindowText(hItem, pszText, nLength + 1); + strText.ReleaseBuffer(nLength); + + return nLength; + } + else + { + strText.Empty(); + + return 0; + } + } +#endif // __ATLSTR_H__ + +// Dialog window only + UINT DlgGetDefID() const + { + ATLASSERT(::IsWindow(m_hWnd)); + + LRESULT lRet = ::SendMessage(m_hWnd, DM_GETDEFID, 0, 0L); + UINT uID = 0U; + if(HIWORD(lRet) == DC_HASDEFID) + uID = LOWORD(lRet); + + return uID; + } + + void DlgSetDefID(UINT uID) + { + ATLASSERT(::IsWindow(m_hWnd)); + + ::SendMessage(m_hWnd, DM_SETDEFID, uID, 0L); + } + + void DlgReposition() + { + ATLASSERT(::IsWindow(m_hWnd)); + + ::SendMessage(m_hWnd, DM_REPOSITION, 0, 0L); + } +}; -}; // namespace WTL +} // namespace WTL #endif // __ATLWINX_H__ diff --git a/WrlSDK/SampleCode/PluginWinExe/stdafx.h b/WrlSDK/SampleCode/PluginWinExe/stdafx.h index c94baf9553bd9bd87e2967e286047145d1a4287b..b5674f128b74ef1b4b82858f5af40a174f2e4fd9 100644 --- a/WrlSDK/SampleCode/PluginWinExe/stdafx.h +++ b/WrlSDK/SampleCode/PluginWinExe/stdafx.h @@ -6,11 +6,13 @@ #pragma once // Change these values to use different versions -#define WINVER 0x0502 -#define _WIN32_WINNT 0x0502 -#define _WIN32_IE 0x0600 +#define WINVER 0x0501 +#define _WIN32_WINNT 0x0501 +#define _WIN32_IE 0x0800 #define _RICHEDIT_VER 0x0500 +#define _CRT_SECURE_NO_WARNINGS + #include /// ʹATLCString #define _CSTRING_NS ATL @@ -49,5 +51,8 @@ using namespace ATL; #pragma warning( disable : 4610 ) #pragma warning( disable : 4206 ) +#include +#include + #import "..\\Bin\\WrlEngine.dll" no_namespace, raw_interfaces_only, raw_native_types, named_guids #import "..\\Bin\\WrlBase.dll" no_namespace, raw_interfaces_only, raw_native_types, named_guids \ No newline at end of file diff --git a/ZbaSDK/Package/ZbaEngine.dll b/ZbaSDK/Package/ZbaEngine.dll index 750e713fde23637ef3e5cafabfc6f2bf1ec96bde..6d8ae18137f72be0d54a92a36bba6b8275c8328e 100644 Binary files a/ZbaSDK/Package/ZbaEngine.dll and b/ZbaSDK/Package/ZbaEngine.dll differ diff --git a/ZbaSDK/Package/ZbaPackage.exe b/ZbaSDK/Package/ZbaPackage.exe index 0954f70d57ab190ac715962968434d82273cea94..5e8df1c497d3a01b823a0df8b084dba9852cdcd9 100644 Binary files a/ZbaSDK/Package/ZbaPackage.exe and b/ZbaSDK/Package/ZbaPackage.exe differ diff --git "a/ZbaSDK/PluginOK\344\270\255\351\227\264\344\273\266\345\256\211\345\205\250\350\247\243\345\206\263\346\226\271\346\241\210.doc" "b/ZbaSDK/PluginOK\344\270\255\351\227\264\344\273\266\345\256\211\345\205\250\350\247\243\345\206\263\346\226\271\346\241\210.doc" index 78a77352af96adef37a5a0d7e6ce838b61055df4..5655b95988e740909cfcb4c6cff5b011bce09a5f 100644 Binary files "a/ZbaSDK/PluginOK\344\270\255\351\227\264\344\273\266\345\256\211\345\205\250\350\247\243\345\206\263\346\226\271\346\241\210.doc" and "b/ZbaSDK/PluginOK\344\270\255\351\227\264\344\273\266\345\256\211\345\205\250\350\247\243\345\206\263\346\226\271\346\241\210.doc" differ diff --git a/ZbaSDK/SampleCode/Bin/ZbaApplet.dll b/ZbaSDK/SampleCode/Bin/ZbaApplet.dll index c886f287d811635043b669de7c6f9aa7f3266974..6f186d20c02d36d3b27bbb0725d45f6e06728d69 100644 Binary files a/ZbaSDK/SampleCode/Bin/ZbaApplet.dll and b/ZbaSDK/SampleCode/Bin/ZbaApplet.dll differ diff --git a/ZbaSDK/SampleCode/Bin/ZbaBase.dll b/ZbaSDK/SampleCode/Bin/ZbaBase.dll index 859dda027fbb5e05d359bbfd3f7d05fd0d498a0e..69a27c04f061c41be51fc865aac916905cd22e58 100644 Binary files a/ZbaSDK/SampleCode/Bin/ZbaBase.dll and b/ZbaSDK/SampleCode/Bin/ZbaBase.dll differ diff --git a/ZbaSDK/SampleCode/Bin/ZbaEngine.dll b/ZbaSDK/SampleCode/Bin/ZbaEngine.dll index 750e713fde23637ef3e5cafabfc6f2bf1ec96bde..6d8ae18137f72be0d54a92a36bba6b8275c8328e 100644 Binary files a/ZbaSDK/SampleCode/Bin/ZbaEngine.dll and b/ZbaSDK/SampleCode/Bin/ZbaEngine.dll differ diff --git a/ZbaSDK/SampleCode/PluginComDll/PluginComDll.rc b/ZbaSDK/SampleCode/PluginComDll/PluginComDll.rc index 24a37d1d104fb282c3fa86dfeb7c542933ae228e..0580d69b76f6b0123eaa89afc539b512bad22948 100644 Binary files a/ZbaSDK/SampleCode/PluginComDll/PluginComDll.rc and b/ZbaSDK/SampleCode/PluginComDll/PluginComDll.rc differ diff --git a/ZbaSDK/SampleCode/PluginComDll/PluginComDll.suo b/ZbaSDK/SampleCode/PluginComDll/PluginComDll.suo index 6e74689e9c38f5d30ce8a2fe92bf27afde7a85bf..005bb44159c836f564b1beb4e92dcdb6d18858ae 100644 Binary files a/ZbaSDK/SampleCode/PluginComDll/PluginComDll.suo and b/ZbaSDK/SampleCode/PluginComDll/PluginComDll.suo differ diff --git a/ZbaSDK/SampleCode/PluginComDll/PluginConfig.json b/ZbaSDK/SampleCode/PluginComDll/PluginConfig.json index a154d3ea10127716d8d5f15b39f283fe91d62772..ad3c8865351df831d74b9de0af9e3170f68338ef 100644 --- a/ZbaSDK/SampleCode/PluginComDll/PluginConfig.json +++ b/ZbaSDK/SampleCode/PluginComDll/PluginConfig.json @@ -2,13 +2,14 @@ "Type": 1, "OS": 1, "Control": 0, + "Http": 1, "OSMinVer": "5.0", - "Version": "2.0.2.1", - "Name": "无窗口小程序范例(C++语言)", + "Version": "2.1.1.1", + "Name": "DLL小程序范例(C++语言)", "Corp": "ZorroSoft", "Icon": "", - "Date": "2020.08.25", - "Desc": "无窗口小程序(C++语言)-读写TXT记事本及获取当前系统信息", + "Date": "2021.01.12", + "Desc": "无窗小程序(C++语言)-读写TXT记事本及获取当前系统信息", "Home": "http://zorrosoft.com/WRL", "Down": "http://zorrosoft.com/WRL", "Module": "PluginComDll.dll", diff --git a/ZbaSDK/SampleCode/PluginComDll/TextFile.h b/ZbaSDK/SampleCode/PluginComDll/TextFile.h index 62c0303b77b6dca8df9bbd0c78c5f313fed6ad91..c6c918ee41d97589370b3e5c656b60fb3ab23a39 100644 --- a/ZbaSDK/SampleCode/PluginComDll/TextFile.h +++ b/ZbaSDK/SampleCode/PluginComDll/TextFile.h @@ -27,7 +27,11 @@ class ATL_NO_VTABLE CTextFile : #else public IDispatchImpl, #endif +#ifdef WRL_VRSION_STANDALONE + public IDispatchImpl +#else public IDispatchImpl +#endif { protected: @@ -44,9 +48,9 @@ public: BEGIN_COM_MAP(CTextFile) COM_INTERFACE_ENTRY(ITextFile) - COM_INTERFACE_ENTRY2(IDispatch, IWrlConn) - COM_INTERFACE_ENTRY(IConnectionPointContainer) COM_INTERFACE_ENTRY(IWrlConn) + COM_INTERFACE_ENTRY(IConnectionPointContainer) + COM_INTERFACE_ENTRY2(IDispatch, IWrlConn) END_COM_MAP() BEGIN_CONNECTION_POINT_MAP(CTextFile) @@ -112,10 +116,16 @@ public: return S_FALSE; } - STDMETHOD(HttpRequst)(BSTR bstrUrl,BSTR bstrPara, BSTR* pVal) + STDMETHOD(HttpRequst)(BSTR bstrUrl,BSTR bstrPara,BSTR* pVal) { - /// HTTPӦ - return E_NOTIMPL; + /// յHTTPЭҪǰͬ󣬱ǰҪȴܼ + /// ɸݴݵIJֱִвͬĹܣDLLСУҪִУ޸мļNoServiceΪ1°װмЧ + ::MessageBox(NULL,L"ִв",L"ʾ",MB_OK); + /// ÷ݣ鶼JSONʽڽ + CComBSTR bstrVal(L"{\"ret\":0,\"data\":{\"Ret\":0,\"Code\":1}}"); + bstrVal.CopyTo(pVal); + bstrVal.Empty(); + return S_OK; } }; diff --git a/ZbaSDK/SampleCode/PluginExeDemo/Config.json b/ZbaSDK/SampleCode/PluginExeDemo/Config.json index df74b525d165ee7b8baad558dea3de7cfdcab49c..7753acb85d59d9832d235bbd6a15ba63518255f7 100644 --- a/ZbaSDK/SampleCode/PluginExeDemo/Config.json +++ b/ZbaSDK/SampleCode/PluginExeDemo/Config.json @@ -1,3 +1,4 @@ { - "PORT": 12900 + "PORT": 12900, + "HTTP": 12903 } \ No newline at end of file diff --git a/ZbaSDK/SampleCode/PluginExeDemo/Form1.cs b/ZbaSDK/SampleCode/PluginExeDemo/Form1.cs index 794620df74f85b84f06b74456d779742318fd5e4..930373572775c27f95f8680caa9192149bf96d08 100644 --- a/ZbaSDK/SampleCode/PluginExeDemo/Form1.cs +++ b/ZbaSDK/SampleCode/PluginExeDemo/Form1.cs @@ -103,7 +103,7 @@ namespace PluginExeDemo MessageBox.Show("还未有来自网页的连接!"); return; } - Send(strLastSID, this.textBox1.Text); + Send(strLastSID,this.textBox1.Text); this.textBox1.Text = ""; } @@ -144,7 +144,7 @@ namespace PluginExeDemo } /// - /// 通知新连接 + /// 通知收到新连接 /// /// public void NewConnEvent(string bstrSID) @@ -164,7 +164,7 @@ namespace PluginExeDemo /// public void RecMsgEvent(string bstrSID, uint nReqID, string bstrPushName, string bstrMsg) { - m_Form.textBox2.AppendText("收到新数据包,请求序号:"); + m_Form.textBox2.AppendText("收到新数据包,请求序号:"); m_Form.textBox2.AppendText(nReqID.ToString()); m_Form.textBox2.AppendText("协议名:"); m_Form.textBox2.AppendText(bstrPushName); @@ -201,31 +201,64 @@ namespace PluginExeDemo } /// - /// + /// 通知连接收到字节流内容 /// /// /// /// public void RecByteEvent(string bstrSID, Object Content, uint nLen) { + m_Form.textBox2.AppendText("收到二进制流:"); + m_Form.textBox2.AppendText(Content.ToString()); + m_Form.textBox2.AppendText("\r\n"); + } + + /// + /// 通知HTTP同步请求处理 + /// + /// + /// + /// + public void HttpReqEvent(string bstrSID, string bstrProtocol, string bstrUrl, string bstrPara, out string pVal) + { + /// 收到HTTP协议请求,主要用于前端同步请求,比如前端需要等待请求完成浏览器才能继续操作 + /// 这里执行阻塞操作,比如弹出模态对话框 + pVal = "{\"ret\":0,\"data\":{\"Ret\":0,\"Code\":1}}"; } /// - /// + /// 通知HTTP侦听端口 + /// + /// + public void HttpPortEvent(ushort nPort) + { + m_Form.textBox2.AppendText("HTTP侦听端口:"); + m_Form.textBox2.AppendText(nPort.ToString()); + m_Form.textBox2.AppendText("\r\n"); + } + + /// + /// WS连接请求中出现错误 /// - /// /// /// - public void HttpReqEvent(uint nSessionID, string strUrl, string strPara) + /// + public void RecErrEvent(string bstrSID, uint nReqID, string bstrErrInfo) { + m_Form.textBox2.AppendText("连接出现错误:"); + m_Form.textBox2.AppendText(bstrErrInfo); + m_Form.textBox2.AppendText("\r\n"); } /// /// 通知关闭连接 /// /// - public void ConnCloseEvent(string bstrSID) + public void ConnCloseEvent(string bstrSID, string bstrReason) { + m_Form.textBox2.AppendText("关闭连接:"); + m_Form.textBox2.AppendText(bstrReason); + m_Form.textBox2.AppendText("\r\n"); } } } diff --git a/ZbaSDK/SampleCode/PluginExeDemo/PluginConfig.json b/ZbaSDK/SampleCode/PluginExeDemo/PluginConfig.json index f8939f678ce21e94eb30944924aec64e82db79e6..2360c2d892e4a43252d66f1520153e3b792ace68 100644 --- a/ZbaSDK/SampleCode/PluginExeDemo/PluginConfig.json +++ b/ZbaSDK/SampleCode/PluginExeDemo/PluginConfig.json @@ -2,12 +2,13 @@ "Type": 2, "OS": 1, "Control": 0, + "Http": 1, "OSMinVer": "5.0", - "Version": "2.0.2.1", + "Version": "2.1.1.1", "Name": "弹窗小程序范例(C#语言)", "Corp": "ZorroSoft", "Icon": "", - "Date": "2020.08.25", + "Date": "2021.01.20", "Desc": "弹窗小程序范例(C#语言)-演示脚本请求打开指定网站", "Home": "http://zorrosoft.com/WRL", "Down": "http://zorrosoft.com/WRL", diff --git a/ZbaSDK/SampleCode/PluginNetDll/PluginConfig.json b/ZbaSDK/SampleCode/PluginNetDll/PluginConfig.json index dccd312ea63d3c7688abf6b8878aa1e8312f44ff..ca69f5690636872d236e3322ff4258f7693b56bb 100644 --- a/ZbaSDK/SampleCode/PluginNetDll/PluginConfig.json +++ b/ZbaSDK/SampleCode/PluginNetDll/PluginConfig.json @@ -2,13 +2,14 @@ "Type": 1, "OS": 1, "Control": 0, + "Http": 1, "Asm": 1, "OSMinVer": "5.0", - "Version": "2.0.2.1", - "Name": "无窗口小程序范例(C#语言)", + "Version": "2.1.1.1", + "Name": "DLL小程序范例(C#语言)", "Corp": "ZorroSoft", "Icon": "", - "Date": "2020.08.25", + "Date": "2021.01.20", "Desc": "无窗口小程序范例(C#语言)", "Home": "http://zorrosoft.com/WRL", "Down": "http://zorrosoft.com/WRL", diff --git a/ZbaSDK/SampleCode/PluginNetDll/PluginNetDll.suo b/ZbaSDK/SampleCode/PluginNetDll/PluginNetDll.suo index 9de3912b264c5e253d00ff7bea4ec36230b8043f..addaa00bdc181f186dca4ca236825634a755808a 100644 Binary files a/ZbaSDK/SampleCode/PluginNetDll/PluginNetDll.suo and b/ZbaSDK/SampleCode/PluginNetDll/PluginNetDll.suo differ diff --git a/ZbaSDK/SampleCode/PluginNetDll/TestWrl.cs b/ZbaSDK/SampleCode/PluginNetDll/TestWrl.cs index 1e180efe23d05d4431cbdac62c37ff3272116b30..96ef10571b7e29b60db8bcaade840e5e852db441 100644 --- a/ZbaSDK/SampleCode/PluginNetDll/TestWrl.cs +++ b/ZbaSDK/SampleCode/PluginNetDll/TestWrl.cs @@ -48,8 +48,10 @@ namespace PluginNetDll string IWrlConn.HttpRequst(string bstrUrl, string bstrPara) { - /// 收到HTTP类型请求,暂未实现 - return ""; + WriteLog(bstrUrl, bstrPara); + /// 收到HTTP协议请求,主要用于前端同步请求,比如前端需要等待请求完成浏览器才能继续操作 + /// 可根据传递的参数分别执行不同的功能,在DLL小程序中,如需要弹窗执行,请先修改中间件配置文件参数NoService为1后再重新安装中间件生效! + return "{\"ret\":0,\"data\":{\"Ret\":0,\"Code\":1}}"; } void IWrlConn.RecByte(ref byte pContent, uint nLen) @@ -85,19 +87,18 @@ namespace PluginNetDll string strName = JsonService.GetStringValue("Name"); string strContent = JsonService.GetStringValue("Content"); - string strAppPath = this.GetType().Assembly.Location; - strAppPath.Replace(".exe",""); - strAppPath += "\\Data\\"; - StreamWriter swFile = new StreamWriter(strAppPath + strName, true, Encoding.Unicode); + string strAppPath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Data"); + if (!System.IO.Directory.Exists(strAppPath)) + System.IO.Directory.CreateDirectory(strAppPath); + StreamWriter swFile = new StreamWriter(strAppPath + "\\" + strName, true, Encoding.Unicode); swFile.WriteLine(strContent); swFile.Close(); swFile.Dispose(); - strReturn = strAppPath + strName + "写入内容" ; + strReturn = strAppPath + "\\" + strName + " 文件中写入内容"; } else strReturn = "收到未知请求:" + bstrPushName; - WriteLog(bstrPushName, strReturn); /// 给前端回复请求 m_WebSocketConnect.AsynSendText(strReturn); } diff --git a/ZbaSDK/SampleCode/PluginWinExe/Config.json b/ZbaSDK/SampleCode/PluginWinExe/Config.json index e2f2dd527d5554394a59853a7365a2da79276429..f6b1b05e329c52a2d0e4c36ba0c9be4e06aadcb8 100644 --- a/ZbaSDK/SampleCode/PluginWinExe/Config.json +++ b/ZbaSDK/SampleCode/PluginWinExe/Config.json @@ -1,3 +1,4 @@ { - "PORT": 12800 + "PORT": 12800, + "HTTP": 12803 } \ No newline at end of file diff --git a/ZbaSDK/SampleCode/PluginWinExe/MainDlg.cpp b/ZbaSDK/SampleCode/PluginWinExe/MainDlg.cpp index 55b61132797ab595b674704c416cffb93e981802..1e8240dd37182664f7d3edca98d2d5ba53d6a05e 100644 --- a/ZbaSDK/SampleCode/PluginWinExe/MainDlg.cpp +++ b/ZbaSDK/SampleCode/PluginWinExe/MainDlg.cpp @@ -48,9 +48,98 @@ LRESULT CMainDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam m_spiSocketProxyEvent = NULL; this->PostMessage(WM_APP,0,0); /// 첽ʼ + SetCheckTimer(500); return TRUE; } +BOOL FindProName(DWORD dwPID,ATL::CString& strFileName) +{ + BOOL bFindFlag = FALSE; + HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0); + ATLASSERT(hSnapshot); + + PROCESSENTRY32 pe = {0}; + pe.dwSize = sizeof(pe); + BOOL fok = Process32First(hSnapshot, &pe); + DWORD dwGetProcessID = dwPID; + if(!dwGetProcessID) + dwGetProcessID = ::GetCurrentProcessId(); + for(;fok ;fok = Process32Next(hSnapshot , &pe)) + { + if(pe.th32ProcessID == dwGetProcessID) + { + strFileName = _wcsupr(pe.szExeFile); + strFileName.MakeLower(); + bFindFlag = TRUE; + break; + } + } + + CloseHandle(hSnapshot); + hSnapshot = NULL; + return bFindFlag; +} + +LRESULT CMainDlg::OnTimer ( UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/ ) +{ + if(wParam == WRL_BROWSER_CHECKTIMER) + { + DWORD dwPID = 0; + /// 㴰ǷΪȸ + HWND hWnd = ::GetForegroundWindow(); + ::GetWindowThreadProcessId(hWnd,&dwPID); + if(dwPID != ::GetCurrentProcessId()) + { + /// ݽIDִгļжǷΪӦĹȸ + CString strExeFile; + FindProName(dwPID,strExeFile); + CString strExeName; + switch(m_eBrowserType) + { + case BROWSERTYPE_IE: + strExeName = L"iexplore.exe"; + break; + case BROWSERTYPE_EDGE: + strExeName = L"msedge.exe"; + break; + case BROWSERTYPE_FIREFOX: + strExeName = L"firefox.exe"; + break; + case BROWSERTYPE_OPERA: + strExeName = L"opera.exe"; + break; + case BROWSERTYPE_360: + strExeName = L"360chrome.exe"; + break; + case BROWSERTYPE_360SE: + strExeName = L"360se.exe"; + break; + case BROWSERTYPE_360ENTSE: + strExeName = L"360ent.exe"; + break; + case BROWSERTYPE_QQ: + strExeName = L"qqbrowser.exe"; + break; + case BROWSERTYPE_SOGOU: + strExeName = L"sogouexplorer.exe"; + break; + default: + strExeName = L"chrome.exe"; + break; + } + if(-1 != strExeFile.CompareNoCase(strExeName)) + { + SetWindowPos(HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE); + } + else + { + SetWindowPos(HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE); + } + } + } + return 0; +} + void CMainDlg::InitWebCtrl() { CRect rcClient; @@ -102,6 +191,21 @@ void CMainDlg::InitWebCtrl() } } +void CMainDlg::SetCheckTimer(UINT nElapse) +{ + if(m_nTimerID) + return; + m_nTimerID = ::SetTimer(this->m_hWnd,WRL_BROWSER_CHECKTIMER,nElapse,NULL); +} + +void CMainDlg::KillCheckTimer() +{ + if(!m_nTimerID) + return; + ::KillTimer(this->m_hWnd,m_nTimerID); + m_nTimerID = 0; +} + LRESULT CMainDlg::OnOpenUrl(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/) { if(NULL == m_spiWebBrowser) @@ -215,12 +319,12 @@ LRESULT CMainDlg::OnInitConn(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/ { if(NULL != m_spiSocketProxy) return 0;/// Ѿʼ - HRESULT hRet = m_spiSocketProxy.CreateInstance(__uuidof(SocketProxy)); - ATLASSERT(SUCCEEDED(hRet)); - if(FAILED(hRet)) + HRESULT hRet(E_FAIL); + hRet = m_spiSocketProxy.CreateInstance(__uuidof(SocketProxy)); + if(NULL == m_spiSocketProxy) { - this->MessageBox(L"Web Socketδעɹ"); InitWebCtrl(); + this->MessageBox(L"Web Socketδעɹ"); return 0; } #ifdef NEED_FINAL_CONSTRUCT @@ -256,34 +360,71 @@ LRESULT CMainDlg::OnNewConnect(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, { BSTR bstrSID = (BSTR)lParam; /// ¼ӱʶȻԵ֪ͨϢ - m_mapConnID[bstrSID] = bstrSID; + m_mapConnID[bstrSID] = NULL; this->GetDlgItem(IDC_EDIT_LOG).SetWindowText(CString(L"յ֪ͨ") + bstrSID); return 0; } +LRESULT CMainDlg::OnHttpReq(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) +{ + /// յHTTPЭҪǰͬ󣬱ǰҪȴܼ + HttpReqData* phd = (HttpReqData*)lParam; + if(NULL != phd) + { + /// ִ絯ģ̬Ի + this->MessageBox(L"ִ",L"ʾ",MB_OK); + /// ÷ֵ + phd->strRet = L"{\"ret\":0,\"data\":{\"Ret\":0,\"Code\":1}}"; + } + return 0; +} + +LRESULT CMainDlg::OnHttpPort(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) +{ + m_nHttpPort = (USHORT)lParam; + return 0; +} + +LRESULT CMainDlg::OnRecError(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) +{ + return 0; +} + LRESULT CMainDlg::OnRecMessage(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) { - CString strReqName = (BSTR)wParam; - BSTR bstrContent = (BSTR)lParam; + if(NULL == m_spiSocketProxyEvent) + return 0; + IJsonServicePtr spiJsonService = NULL; + HRESULT hRet = spiJsonService.CreateInstance(__uuidof(JsonService)); + if(NULL == spiJsonService) + return 0; + BSTR bstrSID = (BSTR)wParam; + ULONG nReqID = (ULONG)lParam; + CRecData* pRecData = m_spiSocketProxyEvent->GetCatchData(bstrSID,nReqID,TRUE); + if(NULL == pRecData) + { + spiJsonService = NULL; + return 0; + } + CString strReqName = pRecData->strReqName; CString strMsg; - strMsg.Format(L"յΪ %s JSONݰ:%s",strReqName,(CString)bstrContent); + strMsg.Format(L"յΪ %s JSONݰ:%s",strReqName,pRecData->strRecText); this->GetDlgItem(IDC_EDIT_LOG).SetWindowText(strMsg); strMsg.Empty(); - ULONG nReqID = 0; - m_spiSocketProxy->AsynSendText(CComBSTR(m_mapConnID.begin()->first),\ - CComBSTR(CString(L"APPյ:")+bstrContent),&nReqID); + + ULONG nSendID = 0; + m_spiSocketProxy->AsynSendText(bstrSID,\ + CComBSTR(CString(L"APPյ:")+pRecData->strRecText),&nSendID); /// յ - IJsonServicePtr spiJsonService = NULL; - HRESULT hRet = spiJsonService.CreateInstance(__uuidof(JsonService)); - if(NULL == spiJsonService) - return 0; VARIANT_BOOL bLoadFlag = VARIANT_FALSE; spiJsonService->put_CodingType(CODINGTYPE_US2); - spiJsonService->ParseString(bstrContent,&bLoadFlag); + spiJsonService->ParseString(CComBSTR(pRecData->strRecText),&bLoadFlag); if(VARIANT_FALSE == bLoadFlag) { spiJsonService = NULL; + delete pRecData; + pRecData = NULL; return 0; } if(0 == strReqName.CompareNoCase(L"Demo_OpenUrl")) @@ -296,7 +437,19 @@ LRESULT CMainDlg::OnRecMessage(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL /// ֪ͨվ this->PostMessage(WM_APP_OPENURL,0,0); } + else if(0 == strReqName.CompareNoCase(L"Demo_HttpPort")) + { + /// 󷵻HTTP˿ + nSendID = 0; + CString strRetInfo; + strRetInfo.Format(L"{\"ret\":0,\"data\":{\"Port\":%ld}}",m_nHttpPort); + m_spiSocketProxy->AsynSendText(bstrSID,\ + CComBSTR(strRetInfo),&nSendID); + strRetInfo.Empty(); + } spiJsonService = NULL; + delete pRecData; + pRecData = NULL; return 0; } diff --git a/ZbaSDK/SampleCode/PluginWinExe/MainDlg.h b/ZbaSDK/SampleCode/PluginWinExe/MainDlg.h index f7b332705f79aa2f65e9b5bf0eddb9038c512e5f..218a0be9a0dcbce5287d0e56e28f891c427e11f4 100644 --- a/ZbaSDK/SampleCode/PluginWinExe/MainDlg.h +++ b/ZbaSDK/SampleCode/PluginWinExe/MainDlg.h @@ -8,8 +8,10 @@ #include "BrowserHost.h" #define WM_APP_OPENURL WM_USER + 500 +#define WRL_BROWSER_CHECKTIMER 9 -typedef std::map CSTRING_MAP; +typedef std::map CSTRING_MAP; +typedef std::map STRINGULONG_MAP; int Us2ToChar(const ATL::CString& strSrc, char** pDst,int nCodePage = CP_ACP); @@ -27,20 +29,29 @@ protected: /// Ϊ CDocHostUIHandler m_DocHostUIHandler; - /// ˿ - USHORT m_nPort; + /// ʱʶ + UINT_PTR m_nTimerID; + + /// + EWrlBrowserType m_eBrowserType; + + /// WS˿ + USHORT m_nPort; + /// HTTP˿ + USHORT m_nHttpPort; + /// ỰID - CString m_strSID; + CString m_strSID; /// ȨϢ - CString m_strAuthInfo; + CString m_strAuthInfo; - CSTRING_MAP m_mapPara; + CSTRING_MAP m_mapPara; /// ׼򿪵URLַ - CString m_strOpenUrl; + CString m_strOpenUrl; /// ¼еӱʶ - CSTRING_MAP m_mapConnID; + STRINGULONG_MAP m_mapConnID; /// ͨѶ ISocketProxyPtr m_spiSocketProxy; @@ -49,6 +60,10 @@ protected: /// ¼ CComObject* m_spiSocketProxyEvent; + void KillCheckTimer(); + + void SetCheckTimer(UINT nElapse); + void UnAdviseSocket(); void InitWebCtrl(); @@ -67,7 +82,10 @@ protected: public: CMainDlg() - :m_nPort(12900) + :m_nTimerID(0) + ,m_nPort(12900) + ,m_nHttpPort(0) + ,m_eBrowserType(BROWSERTYPE_UNKNOWN) ,m_spiWebBrowser(NULL) ,m_spiHtmlDoc(NULL) ,m_spiSocketProxy(NULL) @@ -102,7 +120,6 @@ public: if(it != m_mapPara.end()) m_strSID = it->second; it = m_mapPara.find(L"AI"); - ATLASSERT(it != m_mapPara.end()); if(it != m_mapPara.end()) m_strAuthInfo = it->second; } @@ -117,12 +134,16 @@ public: BEGIN_MSG_MAP(CMainDlg) MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) MESSAGE_HANDLER(WM_APP, OnInitConn) + MESSAGE_HANDLER(WM_TIMER, OnTimer) MESSAGE_HANDLER(WM_APP_OPENURL, OnOpenUrl) MESSAGE_HANDLER(WM_PROXYSEREREVENT_NEWCONNECT, OnNewConnect) MESSAGE_HANDLER(WM_PROXYSEREREVENT_RECMESSAGE, OnRecMessage) MESSAGE_HANDLER(WM_PROXYSEREREVENT_RECTEXT, OnRecText) MESSAGE_HANDLER(WM_PROXYSEREREVENT_CLOSECONN, OnCloseConnect) MESSAGE_HANDLER(WM_PROXYSEREREVENT_BYTE, OnRecByte) + MESSAGE_HANDLER(WM_PROXYSEREREVENT_HTTPREQ, OnHttpReq) + MESSAGE_HANDLER(WM_PROXYSEREREVENT_HTTPPORT, OnHttpPort) + MESSAGE_HANDLER(WM_PROXYSEREREVENT_RECERR, OnRecError) COMMAND_ID_HANDLER(ID_APP_ABOUT, OnAppAbout) COMMAND_ID_HANDLER(IDOK, OnOK) @@ -137,12 +158,16 @@ public: LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); LRESULT OnInitConn(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/ ); LRESULT OnOpenUrl(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/ ); + LRESULT OnTimer(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); LRESULT OnNewConnect(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); LRESULT OnRecMessage(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); LRESULT OnRecText(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); LRESULT OnRecByte(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); LRESULT OnCloseConnect(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); + LRESULT OnHttpReq(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); + LRESULT OnHttpPort(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); + LRESULT OnRecError(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); LRESULT OnAppAbout(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); LRESULT OnOK(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/); diff --git a/ZbaSDK/SampleCode/PluginWinExe/PluginConfig.json b/ZbaSDK/SampleCode/PluginWinExe/PluginConfig.json index 0cbec4e2f6513269e3b8d0edcde308f8d334a500..0f3b7cbc09d3ccd3b8dde3a6edfd753937bf6532 100644 --- a/ZbaSDK/SampleCode/PluginWinExe/PluginConfig.json +++ b/ZbaSDK/SampleCode/PluginWinExe/PluginConfig.json @@ -2,12 +2,13 @@ "Type": 2, "OS": 1, "Control": 0, + "Http": 1, "OSMinVer": "5.0", - "Version": "2.0.2.1", + "Version": "2.1.1.1", "Name": "弹窗小程序范例(C++语言)", "Corp": "ZorroSoft", "Icon": "", - "Date": "2020.08.25", + "Date": "2021.01.20", "Desc": "弹窗小程序(C++语言)-演示脚本请求打开指定网站", "Home": "http://zorrosoft.com/WRL", "Down": "http://zorrosoft.com/WRL", diff --git a/ZbaSDK/SampleCode/PluginWinExe/PluginWinExe.rc b/ZbaSDK/SampleCode/PluginWinExe/PluginWinExe.rc index 33999264abfc83b31e6dd87bd8746a55b1ac79ac..6f6aa9f1aa1f760c907fcae804e017800acfdf86 100644 --- a/ZbaSDK/SampleCode/PluginWinExe/PluginWinExe.rc +++ b/ZbaSDK/SampleCode/PluginWinExe/PluginWinExe.rc @@ -46,7 +46,7 @@ END IDD_MAINDLG DIALOGEX 0, 0, 400, 362 STYLE DS_SETFONT | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_CAPTION | WS_SYSMENU -CAPTION "C++Сʾ" +CAPTION "Сʾ(C++)" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN EDITTEXT IDC_EDIT_CONTENT,17,279,171,52,ES_MULTILINE | ES_AUTOVSCROLL @@ -89,8 +89,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,0,1,1 - PRODUCTVERSION 2,0,1,1 + FILEVERSION 2,1,1,1 + PRODUCTVERSION 2,1,1,1 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -105,13 +105,13 @@ BEGIN BEGIN BLOCK "040904b0" BEGIN - VALUE "FileDescription", "Сʾ(C++)" - VALUE "FileVersion", "2,0,1,1" + VALUE "FileDescription", "Сʾ(C++)" + VALUE "FileVersion", "2,1,1,1" VALUE "InternalName", "PluginWinExe" VALUE "LegalCopyright", "Copyright(C) 2013-? ZorroSoft. All Rights Reserved." VALUE "OriginalFilename", "PluginWinExe.exe" VALUE "ProductName", "PluginOK" - VALUE "ProductVersion", "2,0,1,1" + VALUE "ProductVersion", "2,1,1,1" END END BLOCK "VarFileInfo" diff --git a/ZbaSDK/SampleCode/PluginWinExe/PluginWinExe.vcxproj b/ZbaSDK/SampleCode/PluginWinExe/PluginWinExe.vcxproj index 762e169bd543205282dc3a36f6c030de3f573f3b..ac5a1245b721eab5c64e583a5c777fc988c16f00 100644 --- a/ZbaSDK/SampleCode/PluginWinExe/PluginWinExe.vcxproj +++ b/ZbaSDK/SampleCode/PluginWinExe/PluginWinExe.vcxproj @@ -230,6 +230,7 @@ + @@ -242,11 +243,14 @@ + + + diff --git a/ZbaSDK/SampleCode/PluginWinExe/PluginWinExe.vcxproj.filters b/ZbaSDK/SampleCode/PluginWinExe/PluginWinExe.vcxproj.filters index 4edf20a93428ae1ba713954c0cdb3fa8c054cb3e..f239b04cfa4bf54141676c2522067d99b5738a23 100644 --- a/ZbaSDK/SampleCode/PluginWinExe/PluginWinExe.vcxproj.filters +++ b/ZbaSDK/SampleCode/PluginWinExe/PluginWinExe.vcxproj.filters @@ -30,6 +30,9 @@ Source Files + + Source Files + @@ -50,6 +53,15 @@ Header Files + + Header Files + + + Header Files + + + Header Files + diff --git a/ZbaSDK/SampleCode/PluginWinExe/ProxyServerEvent.cpp b/ZbaSDK/SampleCode/PluginWinExe/ProxyServerEvent.cpp index 65f75d80b69e3356d78af3d0b4cd6ee832c68c90..99fbd9485471d9023ec8f7fbaf0ed6c2c6dadb4e 100644 --- a/ZbaSDK/SampleCode/PluginWinExe/ProxyServerEvent.cpp +++ b/ZbaSDK/SampleCode/PluginWinExe/ProxyServerEvent.cpp @@ -28,14 +28,13 @@ STDMETHODIMP CProxyServerEvent::Invoke( DISPID dispIdMember,REFIID riid,LCID lci CComVariant varSID; VariantInit(&varSID); - hRet = VariantChangeTypeEx( &varSID,&(pDispParams->rgvarg[0]),lcid,0,VT_BSTR); + hRet = VariantChangeTypeEx(&varSID,&(pDispParams->rgvarg[0]),lcid,0,VT_BSTR); if FAILED(hRet) return DISP_E_BADVARTYPE; hRet = NewConn(varSID.bstrVal); VariantClear(&varSID); break; } - case 0x00000002: { if ( pDispParams->cArgs != 4 ) @@ -48,16 +47,16 @@ STDMETHODIMP CProxyServerEvent::Invoke( DISPID dispIdMember,REFIID riid,LCID lci VariantInit(&varReqID); VariantInit(&varReqName); VariantInit(&varMsgInfo); - hRet = VariantChangeTypeEx( &varSID,&(pDispParams->rgvarg[3]),lcid,0,VT_BSTR); + hRet = VariantChangeTypeEx(&varSID,&(pDispParams->rgvarg[3]),lcid,0,VT_BSTR); if FAILED(hRet) return DISP_E_BADVARTYPE; - hRet = VariantChangeTypeEx( &varReqID,&(pDispParams->rgvarg[2]),lcid,0,VT_I4); + hRet = VariantChangeTypeEx(&varReqID,&(pDispParams->rgvarg[2]),lcid,0,VT_I4); if FAILED(hRet) return DISP_E_BADVARTYPE; - hRet = VariantChangeTypeEx( &varReqName,&(pDispParams->rgvarg[1]),lcid,0,VT_BSTR); + hRet = VariantChangeTypeEx(&varReqName,&(pDispParams->rgvarg[1]),lcid,0,VT_BSTR); if FAILED(hRet) return DISP_E_BADVARTYPE; - hRet = VariantChangeTypeEx( &varMsgInfo,&(pDispParams->rgvarg[0]),lcid,0,VT_BSTR); + hRet = VariantChangeTypeEx(&varMsgInfo,&(pDispParams->rgvarg[0]),lcid,0,VT_BSTR); if FAILED(hRet) return DISP_E_BADVARTYPE; hRet = RecMsgEvent(varSID.bstrVal,varReqID.ulVal,varReqName.bstrVal,varMsgInfo.bstrVal); @@ -77,10 +76,10 @@ STDMETHODIMP CProxyServerEvent::Invoke( DISPID dispIdMember,REFIID riid,LCID lci CComVariant varText,varSID; VariantInit(&varText); VariantInit(&varSID); - hRet = VariantChangeTypeEx( &varSID,&(pDispParams->rgvarg[1]),lcid,0,VT_BSTR); + hRet = VariantChangeTypeEx(&varSID,&(pDispParams->rgvarg[1]),lcid,0,VT_BSTR); if FAILED(hRet) return DISP_E_BADVARTYPE; - hRet = VariantChangeTypeEx( &varText,&(pDispParams->rgvarg[0]),lcid,0,VT_BSTR); + hRet = VariantChangeTypeEx(&varText,&(pDispParams->rgvarg[0]),lcid,0,VT_BSTR); if FAILED(hRet) return DISP_E_BADVARTYPE; hRet = RecTextEvent(varSID.bstrVal,varText.bstrVal); @@ -99,13 +98,13 @@ STDMETHODIMP CProxyServerEvent::Invoke( DISPID dispIdMember,REFIID riid,LCID lci VariantInit(&varSID); VariantInit(&varByte); VariantInit(&varLen); - hRet = VariantChangeTypeEx( &varSID,&(pDispParams->rgvarg[2]),lcid,0,VT_BSTR); + hRet = VariantChangeTypeEx(&varSID,&(pDispParams->rgvarg[2]),lcid,0,VT_BSTR); if FAILED(hRet) return DISP_E_BADVARTYPE; - hRet = VariantChangeTypeEx( &varByte,&(pDispParams->rgvarg[1]),lcid,0,VT_PTR); + hRet = VariantChangeTypeEx(&varByte,&(pDispParams->rgvarg[1]),lcid,0,VT_PTR); if FAILED(hRet) return DISP_E_BADVARTYPE; - hRet = VariantChangeTypeEx( &varLen,&(pDispParams->rgvarg[0]),lcid,0,VT_UI4); + hRet = VariantChangeTypeEx(&varLen,&(pDispParams->rgvarg[0]),lcid,0,VT_UI4); if FAILED(hRet) return DISP_E_BADVARTYPE; hRet = RecByte(varSID.bstrVal,varByte.pbVal,varLen.uiVal); @@ -114,7 +113,6 @@ STDMETHODIMP CProxyServerEvent::Invoke( DISPID dispIdMember,REFIID riid,LCID lci VariantClear(&varLen); break; } - case 0x00000005: { if ( pDispParams->cArgs != 2 ) @@ -125,10 +123,10 @@ STDMETHODIMP CProxyServerEvent::Invoke( DISPID dispIdMember,REFIID riid,LCID lci CComVariant varReason,varSID; VariantInit(&varReason); VariantInit(&varSID); - hRet = VariantChangeTypeEx( &varSID,&(pDispParams->rgvarg[1]),lcid,0,VT_BSTR); + hRet = VariantChangeTypeEx(&varSID,&(pDispParams->rgvarg[1]),lcid,0,VT_BSTR); if FAILED(hRet) return DISP_E_BADVARTYPE; - hRet = VariantChangeTypeEx( &varReason,&(pDispParams->rgvarg[0]),lcid,0,VT_BSTR); + hRet = VariantChangeTypeEx(&varReason,&(pDispParams->rgvarg[0]),lcid,0,VT_BSTR); if FAILED(hRet) return DISP_E_BADVARTYPE; hRet = CloseEvent(varSID.bstrVal,varReason.bstrVal); @@ -136,12 +134,110 @@ STDMETHODIMP CProxyServerEvent::Invoke( DISPID dispIdMember,REFIID riid,LCID lci VariantClear(&varSID); break; } + case 0x00000006: + { + if ( pDispParams->cArgs != 5 ) + return DISP_E_BADPARAMCOUNT; + if ( pDispParams->cNamedArgs ) + return DISP_E_NONAMEDARGS; + + CComVariant varSID,varProtocol,varUrl,varPara; + VariantInit(&varSID); + VariantInit(&varProtocol); + VariantInit(&varUrl); + VariantInit(&varPara); + hRet = VariantChangeTypeEx(&varSID,&(pDispParams->rgvarg[4]),lcid,0,VT_BSTR); + hRet = VariantChangeTypeEx(&varProtocol,&(pDispParams->rgvarg[3]),lcid,0,VT_BSTR); + hRet = VariantChangeTypeEx(&varUrl,&(pDispParams->rgvarg[2]),lcid,0,VT_BSTR); + if FAILED(hRet) + return DISP_E_BADVARTYPE; + hRet = VariantChangeTypeEx(&varPara,&(pDispParams->rgvarg[1]),lcid,0,VT_BSTR); + if FAILED(hRet) + return DISP_E_BADVARTYPE; + pDispParams->rgvarg[0].bstrVal = NULL; + pDispParams->rgvarg[0].vt = VT_BSTR; + if(NULL != m_hMsgWnd && ::IsWindow(m_hMsgWnd)) + { + /// ͬ󣬱SendMessage + HttpReqData hd; + hd.strProtocol = varProtocol.bstrVal; + hd.strUri = varUrl.bstrVal; + hd.strPara = varPara.bstrVal; + ::SendMessage(m_hMsgWnd,WM_PROXYSEREREVENT_HTTPREQ,0,(LPARAM)&hd); + CComBSTR bstrRet(hd.strRet); + bstrRet.CopyTo(&(pDispParams->rgvarg[0].bstrVal)); + bstrRet.Empty(); + } + VariantClear(&varSID); + VariantClear(&varProtocol); + VariantClear(&varUrl); + VariantClear(&varPara); + break; + } + case 0x00000007: + { + if ( pDispParams->cArgs != 3 ) + return DISP_E_BADPARAMCOUNT; + if ( pDispParams->cNamedArgs ) + return DISP_E_NONAMEDARGS; + + CComVariant varReason,varReqID,varSessionID; + VariantInit(&varReason); + VariantInit(&varReqID); + VariantInit(&varSessionID); + hRet = VariantChangeTypeEx( &varSessionID,&(pDispParams->rgvarg[2]),lcid,0,VT_UI4); + if FAILED(hRet) + return DISP_E_BADVARTYPE; + hRet = VariantChangeTypeEx( &varReqID,&(pDispParams->rgvarg[1]),lcid,0,VT_UI4); + if FAILED(hRet) + return DISP_E_BADVARTYPE; + hRet = VariantChangeTypeEx( &varReason,&(pDispParams->rgvarg[0]),lcid,0,VT_BSTR); + if FAILED(hRet) + return DISP_E_BADVARTYPE; + hRet = RecErrEvent(varSessionID.ulVal,varReqID.ulVal,varReason.bstrVal); + VariantClear(&varReason); + VariantClear(&varReqID); + VariantClear(&varSessionID); + break; + } + case 0x00000008: + { + if ( pDispParams->cArgs != 1 ) + return DISP_E_BADPARAMCOUNT; + if ( pDispParams->cNamedArgs ) + return DISP_E_NONAMEDARGS; + + CComVariant varPort; + VariantInit(&varPort); + hRet = VariantChangeTypeEx(&varPort,&(pDispParams->rgvarg[0]),lcid,0,VT_UI2); + if FAILED(hRet) + return DISP_E_BADVARTYPE; + if(NULL != m_hMsgWnd && ::IsWindow(m_hMsgWnd)) + { + /// ֪ͨHTTP˿ + ::PostMessage(m_hMsgWnd,WM_PROXYSEREREVENT_HTTPPORT,0,(LPARAM)varPort.uiVal); + } + VariantClear(&varPort); + break; + } default: break; } return hRet; } +STDMETHODIMP CProxyServerEvent::RecErrEvent(ULONG nSocketID,ULONG nReqID,BSTR bstrText) +{ + HRESULT hRet(E_FAIL); + if(NULL == bstrText) + return hRet; + if(NULL != m_hMsgWnd && ::IsWindow(m_hMsgWnd)) + { + ::SendMessage(m_hMsgWnd,WM_PROXYSEREREVENT_RECERR,nSocketID,(LPARAM)bstrText); + } + return hRet; +} + STDMETHODIMP CProxyServerEvent::NewConn(BSTR bstrSID) { HRESULT hRet(E_FAIL); @@ -155,19 +251,27 @@ STDMETHODIMP CProxyServerEvent::NewConn(BSTR bstrSID) return hRet; } -STDMETHODIMP CProxyServerEvent::RecMsgEvent(BSTR bstrSID,ULONG nReqID,BSTR bstrReqName,BSTR bstrRecInfo) +STDMETHODIMP CProxyServerEvent::RecMsgEvent(BSTR bstrSID,ULONG nReqID,\ + BSTR bstrReqName,BSTR bstrRecInfo) { HRESULT hRet(E_FAIL); if(!nReqID || NULL == bstrSID) - { return hRet; - } if(NULL != m_hMsgWnd && ::IsWindow(m_hMsgWnd)) { - m_nReqID = nReqID; - if(0 != m_strSID.CompareNoCase(bstrSID)) - m_strSID = bstrSID; - ::SendMessage(m_hMsgWnd,WM_PROXYSEREREVENT_RECMESSAGE,(WPARAM)bstrReqName,(LPARAM)bstrRecInfo); + CString strKey; + strKey.Format(L"%ld_%s",nReqID,(CString)bstrSID); + CRecData* pRecData = new CRecData(); + if(NULL != pRecData) + { + pRecData->pbContent = NULL; + pRecData->strReqName = bstrReqName; + pRecData->strRecText = bstrRecInfo; + } + m_DataLock.Lock(L"RecMsgEvent"); + m_CatchData[strKey] = pRecData; + m_DataLock.Unlock(L"RecMsgEvent"); + ::SendMessage(m_hMsgWnd,WM_PROXYSEREREVENT_RECMESSAGE,(WPARAM)bstrSID,(LPARAM)nReqID); } return hRet; } @@ -191,9 +295,15 @@ STDMETHODIMP CProxyServerEvent::RecByte(BSTR bstrSID,BYTE* pContent,ULONG nLen) return hRet; if(NULL != m_hMsgWnd && ::IsWindow(m_hMsgWnd)) { - if(0 != m_strSID.CompareNoCase(bstrSID)) - m_strSID = bstrSID; - ::SendMessage(m_hMsgWnd,WM_PROXYSEREREVENT_BYTE,(WPARAM)pContent,(LPARAM)nLen); + CString strKey; + strKey.Format(L"%ld_%s",nLen,(CString)bstrSID); + CRecData* pRecData = new CRecData(); + if(NULL != pRecData) + pRecData->pbContent = pContent; + m_DataLock.Lock(L"RecByte"); + m_CatchData[strKey] = pRecData; + m_DataLock.Unlock(L"RecByte"); + ::SendMessage(m_hMsgWnd,WM_PROXYSEREREVENT_BYTE,(WPARAM)bstrSID,(LPARAM)nLen); } return hRet; } diff --git a/ZbaSDK/SampleCode/PluginWinExe/ProxyServerEvent.h b/ZbaSDK/SampleCode/PluginWinExe/ProxyServerEvent.h index af15221f753c658979c0c2a1d0ddf3b1734379ad..9caaad4cddabdb164dc99cb8f0eaff0908079a35 100644 --- a/ZbaSDK/SampleCode/PluginWinExe/ProxyServerEvent.h +++ b/ZbaSDK/SampleCode/PluginWinExe/ProxyServerEvent.h @@ -1,15 +1,40 @@ #pragma once - -#define WM_PROXYSEREREVENT_NEWCONNECT WM_USER + 2000 -#define WM_PROXYSEREREVENT_RECMESSAGE WM_USER + 2001 -#define WM_PROXYSEREREVENT_RECTEXT WM_USER + 2002 -#define WM_PROXYSEREREVENT_BYTE WM_USER + 2003 -#define WM_PROXYSEREREVENT_CLOSECONN WM_USER + 2005 +#include +#include "BaseFuncLib.h" + +#define WM_PROXYSEREREVENT_NEWCONNECT WM_USER + 2000 +#define WM_PROXYSEREREVENT_RECMESSAGE WM_USER + 2001 +#define WM_PROXYSEREREVENT_RECTEXT WM_USER + 2002 +#define WM_PROXYSEREREVENT_BYTE WM_USER + 2003 +#define WM_PROXYSEREREVENT_CLOSECONN WM_USER + 2005 +#define WM_PROXYSEREREVENT_HTTPREQ WM_USER + 2006 +#define WM_PROXYSEREREVENT_HTTPPORT WM_USER + 2007 +#define WM_PROXYSEREREVENT_RECERR WM_USER + 2008 #ifndef NEED_FINAL_CONSTRUCT #define NEED_FINAL_CONSTRUCT #endif +struct HttpReqData +{ + CString strUri; + CString strPara; + CString strRet; + + CString strProtocol; +}; + +struct CRecData +{ + CString strReqName; + CString strRecText; + + // յĶ + BYTE* pbContent; +}; + +typedef std::map RECDATA_MAP; + // CProxyServerEvent class CProxyServerEvent : public CComObjectRoot, @@ -19,13 +44,25 @@ class CProxyServerEvent : protected: /// Ϣ - HWND m_hMsgWnd; + HWND m_hMsgWnd; + + CThreadDataLock m_DataLock; - /// ǰỰID - CString m_strSID; + RECDATA_MAP m_CatchData; - /// ǰ - ULONG m_nReqID; + void FreeAll() + { + m_DataLock.Lock(L"FreeAll"); + RECDATA_MAP::iterator it = m_CatchData.begin(); + while(it != m_CatchData.end()) + { + if(NULL != it->second) + delete it->second; + it++; + } + m_CatchData.clear(); + m_DataLock.Unlock(L"FreeAll"); + } public: CProxyServerEvent() @@ -35,16 +72,7 @@ public: ~CProxyServerEvent() { - } - - CString GetCurSID() - { - return m_strSID; - } - - ULONG GetCurReqID() - { - return m_nReqID; + FreeAll(); } void SetCallPara(HWND hMsgWnd) @@ -57,6 +85,23 @@ public: m_hMsgWnd = hMsgWnd; } + CRecData* GetCatchData(const CString& strSID,ULONG nReqID,BOOL bRemove = TRUE) + { + CRecData* pRecData = NULL; + CString strKey; + strKey.Format(L"%ld_%s",nReqID,strSID); + m_DataLock.Lock(L"GetCatchData"); + RECDATA_MAP::iterator it = m_CatchData.find(strKey); + if(it != m_CatchData.end()) + { + pRecData = it->second; + if(bRemove) + m_CatchData.erase(it); + } + m_DataLock.Unlock(L"GetCatchData"); + return pRecData; + } + BEGIN_COM_MAP(CProxyServerEvent) COM_INTERFACE_ENTRY(_ISocketProxyEvents) END_COM_MAP() @@ -85,9 +130,10 @@ public: // _ISocketProxyEvents STDMETHOD(NewConn)(BSTR bstrSID); - STDMETHOD(RecMsgEvent)(BSTR bstrSID,ULONG nReqID,BSTR nReqName,BSTR bstrRecText); + STDMETHOD(RecMsgEvent)(BSTR bstrSID,ULONG nReqID,BSTR bstrReqName,BSTR bstrRecText); STDMETHOD(RecTextEvent)(BSTR bstrSID,BSTR bstrText); STDMETHOD(RecByte)(BSTR bstrSID,BYTE* pContent,ULONG nLen); + STDMETHOD(RecErrEvent)(ULONG nSocketID,ULONG nReqID,BSTR bstrErrInfo); STDMETHOD(CloseEvent)(BSTR bstrSID,BSTR bstrReason); }; \ No newline at end of file diff --git a/ZbaSDK/SampleCode/PluginWinExe/WRLRegKey.cpp b/ZbaSDK/SampleCode/PluginWinExe/WRLRegKey.cpp index 527eecdcf984352fb839be8becbfd4420b5044e1..9f2241dcfcf277b720342bb43a94986005503cd5 100644 --- a/ZbaSDK/SampleCode/PluginWinExe/WRLRegKey.cpp +++ b/ZbaSDK/SampleCode/PluginWinExe/WRLRegKey.cpp @@ -1,15 +1,37 @@ -// WrlRegKey.cpp : עװʵ +/** + * @file ZMRegKey.cpp + * + * Copyright (c) 2013-?,ɶ + * All rights reserved. + * + * @ingroup + * + * @brief עװʵ + * + * + * + * @version + * + * @date 2018-09-01 + * + * @author WZH + * + * @history + * + */ +// ZMRegKey.cpp : עװʵ #include "stdafx.h" -#include "WrlRegKey.h" +#include "WRLRegKey.h" +#include "BaseFuncLib.h" CWrlRegKey::CWrlRegKey(const ATL::CString& strMainRegPath,\ const ATL::CString& strChildName, HKEY hKey,REGSAM samDesired) { m_bOpenFlag = FALSE; m_dwLastErr = 0; - if(!strMainRegPath.IsEmpty()) - NewRegPath(strMainRegPath,strChildName,hKey,samDesired); + ATLASSERT(strMainRegPath.GetLength()); + NewRegPath(strMainRegPath,strChildName,hKey,samDesired); } void CWrlRegKey::Close() @@ -24,25 +46,21 @@ void CWrlRegKey::Close() BOOL CWrlRegKey::NewRegPath(const ATL::CString& strMainRegPath,\ const ATL::CString& strChildName, HKEY hKey,REGSAM samDesired) { - Close(); + if(m_bOpenFlag) + Close(); ATL::CString strRegPath; if(!strChildName.IsEmpty()) - { - if(strMainRegPath.GetLength()) - strRegPath.Format(_T("%s\\%s"),strMainRegPath,strChildName); - else - strRegPath = strChildName; - } + strRegPath.Format(_T("%s\\%s"),strMainRegPath,strChildName); else strRegPath = strMainRegPath; m_dwLastErr = Open(hKey,strRegPath,samDesired); if(ERROR_SUCCESS != m_dwLastErr) { - if(ERROR_ACCESS_DENIED != m_dwLastErr) + if(ERROR_ACCESS_DENIED != m_dwLastErr && ERROR_WRITE_PROTECT != m_dwLastErr) { - /// ڣԶ + /// ָעĿԶ m_dwLastErr = Create(hKey,strRegPath,NULL,0,samDesired); } } @@ -53,20 +71,32 @@ BOOL CWrlRegKey::NewRegPath(const ATL::CString& strMainRegPath,\ return m_bOpenFlag; } -BOOL CWrlRegKey::GetRegStringVal(const ATL::CString& strKeyName, - ATL::CString& strKeyValue) +BOOL CWrlRegKey::GetRegStringVal( + const ATL::CString& strKeyName,ATL::CString& strKeyValue) { BOOL bGetFlag = FALSE; if(!m_bOpenFlag) + { return bGetFlag; + } DWORD dwSize = 0; - m_dwLastErr = CRegKey::QueryStringValue(strKeyName,NULL,&dwSize); - + if(strKeyName.IsEmpty()) + m_dwLastErr = CRegKey::QueryStringValue(NULL,NULL,&dwSize); + else + m_dwLastErr = CRegKey::QueryStringValue(strKeyName,NULL,&dwSize); + if(!dwSize) + { + /// ûֵ + return bGetFlag; + } TCHAR *szBuf = new TCHAR[dwSize+1]; if(NULL == szBuf) return bGetFlag; memset(szBuf,0,(dwSize+1)*sizeof(TCHAR)); - m_dwLastErr = CRegKey::QueryStringValue(strKeyName,szBuf,&dwSize); + if(strKeyName.IsEmpty()) + m_dwLastErr = CRegKey::QueryStringValue(NULL,szBuf,&dwSize); + else + m_dwLastErr = CRegKey::QueryStringValue(strKeyName,szBuf,&dwSize); if(m_dwLastErr != ERROR_SUCCESS) { if(NULL != szBuf) @@ -120,56 +150,6 @@ BOOL CWrlRegKey::SetRegDwordVal(const ATL::CString& strKeyName, return TRUE; } -BOOL CWrlRegKey::GetRegBinaryValue(const ATL::CString &strKeyName,BYTE **ppValue,ULONG* pnBytes) -{ - if(!m_bOpenFlag) - return FALSE; - ATLASSERT(ppValue && pnBytes); - m_dwLastErr = CRegKey::QueryBinaryValue(strKeyName,NULL,pnBytes); - if(0 == *pnBytes || m_dwLastErr != ERROR_SUCCESS) - { - *ppValue = NULL; - return FALSE; - } - ULONG nLen = (*pnBytes)+1; - *ppValue = new BYTE[nLen]; - memset(*ppValue,0,nLen*sizeof(BYTE)); - m_dwLastErr = CRegKey::QueryBinaryValue(strKeyName,*ppValue,pnBytes); - if(m_dwLastErr != ERROR_SUCCESS) - return FALSE; - return TRUE; -} - -BOOL CWrlRegKey::SetRegBinaryValue(const ATL::CString &strKeyName,const BYTE* Value,ULONG nBytes) -{ - if(!m_bOpenFlag) - return FALSE; - m_dwLastErr = CRegKey::SetBinaryValue(strKeyName,Value,nBytes); - if(m_dwLastErr != ERROR_SUCCESS) - return FALSE; - return TRUE; -} - -BOOL CWrlRegKey::GetRegGuidValue(const ATL::CString &strKeyName,GUID &Value) -{ - if(!m_bOpenFlag) - return FALSE; - m_dwLastErr = CRegKey::QueryGUIDValue(strKeyName,Value)==ERROR_SUCCESS; - if(m_dwLastErr != ERROR_SUCCESS) - return FALSE; - return TRUE; -} - -BOOL CWrlRegKey::SetRegGuidValue(const ATL::CString &strKeyName,GUID Value) -{ - if(!m_bOpenFlag) - return FALSE; - m_dwLastErr = CRegKey::SetGUIDValue(strKeyName,Value); - if(m_dwLastErr != ERROR_SUCCESS) - return FALSE; - return TRUE; -} - BOOL CWrlRegKey::DelKeyName(const ATL::CString& strKeyName) { if(!m_bOpenFlag) @@ -178,4 +158,4 @@ BOOL CWrlRegKey::DelKeyName(const ATL::CString& strKeyName) if(m_dwLastErr != ERROR_SUCCESS) return FALSE; return TRUE; -} +} \ No newline at end of file diff --git a/ZbaSDK/SampleCode/PluginWinExe/WRLRegKey.h b/ZbaSDK/SampleCode/PluginWinExe/WRLRegKey.h index e016079df457abb61be7f49f641f2029b7dd7a95..a0e0702bb3a211bc60404eff6eab95d7228293d8 100644 --- a/ZbaSDK/SampleCode/PluginWinExe/WRLRegKey.h +++ b/ZbaSDK/SampleCode/PluginWinExe/WRLRegKey.h @@ -1,130 +1,71 @@ +/** + * @file WRLRegKey.h + * + * Copyright (c) 2013-?,ɶ޹˾ + * All rights reserved. + * + * @ingroup + * + * @brief עװ + * + * + * + * @version + * + * @date 2020-07-13 + * + * @author WZH + * + * @history + * + */ // WRLRegKey.h : עͷļ // -////////////////////////////////////////////////////////////////////// #pragma once +#include "WRLBaseDef.h" + +/// Ʒעеİװ· +#define PRODUCT_COMMAN_INSPATH L"InsPath" +/// Ʒעе汾 +#define PRODUCT_COMMAN_MAINVERNAME L"MainVer" +/// ƷעеĴΰ汾 +#define PRODUCT_COMMAN_MINIVERNAME L"MiniVer" +/// ƷעеС汾 +#define PRODUCT_COMMAN_SMALLVERNAME L"SmallVer" +/// Ʒעеı汾 +#define PRODUCT_COMMAN_BUILDVERNAME L"BuildVer" + class CWrlRegKey : public CRegKey { public: - CWrlRegKey(const ATL::CString& strMainRegPath,\ - const ATL::CString& strChildName, \ - HKEY hKey,REGSAM samDesired); + CWrlRegKey(const ATL::CString& strMainRegPath = COMPANY_REGPATH,\ + const ATL::CString& strChildName = PRODUCT_REGNODENAME, \ + HKEY hKey = HKEY_CURRENT_USER,REGSAM samDesired = KEY_ALL_ACCESS); virtual ~CWrlRegKey(void) { - /// ʱԶرգй¶ Close(); } - /// жǷע BOOL IsOpen() { return m_bOpenFlag; } - /** - * @brief ·ʵ - * - * - * @param strMainRegPath עλ - * @param strChildName עĿ¼ - * @param bCurrentUser ǷΪûעΪϵͳע - * @return - */ - BOOL NewRegPath(const ATL::CString& strMainRegPath,\ - const ATL::CString& strChildName,\ - HKEY hKey,REGSAM samDesired); - - /** - * @brief ݼƻַͼֵ - * - * - * @param strKeyName - * @param strKeyValue ֵ - * @return Ƿɹȡ - */ + BOOL NewRegPath(const ATL::CString& strMainRegPath = COMPANY_REGPATH,\ + const ATL::CString& strChildName = PRODUCT_REGNODENAME,\ + HKEY hKey = HKEY_CURRENT_USER,REGSAM samDesired = KEY_ALL_ACCESS); + BOOL GetRegStringVal(const ATL::CString& strKeyName,ATL::CString& strKeyValue); - - /** - * @brief עֵַ - * - * - * @param strKeyName - * @param strKeyValue ֵ - * @return Ƿɹ - */ + BOOL SetRegStringVal(const ATL::CString& strKeyName,const ATL::CString& strKeyValue); - /** - * @brief עDWORDֵ - * - * - * @param strKeyName - * @param dwKeyValue ֵ - * @return Ƿȡɹ - */ BOOL GetRegDwordVal(const ATL::CString& strKeyName,DWORD& dwKeyValue); - /** - * @brief עDWORDֵ - * - * - * @param strKeyName - * @param dwKeyValue ֵ - * @return Ƿɹ - */ BOOL SetRegDwordVal(const ATL::CString& strKeyName,DWORD dwKeyValue); - /** - * @brief עֵ - * - * - * @param strKeyName - * @param ppValue ֵ - * @param pnBytes س - * @return Ƿȡɹ - */ - BOOL GetRegBinaryValue(const ATL::CString &strKeyName,BYTE **ppValue,ULONG* pnBytes); - - /** - * @brief öֵ - * - * - * @param strKeyName - * @param Value ֵ - * @param pnBytes س - * @return Ƿóɹ - */ - BOOL SetRegBinaryValue(const ATL::CString &strKeyName,const BYTE* Value,ULONG nBytes); - - /** - * @brief GUIDעֵ - * - * - * @param strKeyName - * @param Value ֵ - * @return Ƿȡɹ - */ - BOOL GetRegGuidValue(const ATL::CString &strKeyName,GUID &Value); - - /** - * @brief GUIDעֵ - * - * - * @param strKeyName - * @param Value ֵ - * @return Ƿóɹ - */ - BOOL SetRegGuidValue(const ATL::CString &strKeyName,GUID Value); - - /** - * @brief ɾָļֵ - * - * - * @param strKeyName - * @return - */ BOOL DelKeyName(const ATL::CString& strKeyName); DWORD GetLastErr() @@ -132,18 +73,11 @@ public: return m_dwLastErr; } - /** - * @brief رע - * - * - */ virtual void Close(); protected: - /// DWORD m_dwLastErr; - /// Ƿע BOOL m_bOpenFlag; }; diff --git a/ZbaSDK/SampleCode/PluginWinExe/WTL/atlapp.h b/ZbaSDK/SampleCode/PluginWinExe/WTL/atlapp.h index 4b3fe38d846da65e2f04257dec2bd4c0bb63cf8e..8be6edc59a794cd87e90c679005f323b5d183a3c 100644 --- a/ZbaSDK/SampleCode/PluginWinExe/WTL/atlapp.h +++ b/ZbaSDK/SampleCode/PluginWinExe/WTL/atlapp.h @@ -1,4 +1,4 @@ -// Windows Template Library - WTL version 9.10 +// Windows Template Library - WTL version 10.0 // Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. // // This file is a part of the Windows Template Library. @@ -19,64 +19,76 @@ #error atlapp.h requires atlbase.h to be included first #endif -#ifndef _WIN32_WCE - #if (WINVER < 0x0400) - #error WTL requires Windows version 4.0 or higher - #endif - - #if (_WIN32_IE < 0x0300) - #error WTL requires IE version 3.0 or higher - #endif +#ifdef _WIN32_WCE + #error WTL10 doesn't support Windows CE #endif #ifdef _ATL_NO_COMMODULE - #error WTL requires that _ATL_NO_COMMODULE is not defined + #error WTL doesn't support _ATL_NO_COMMODULE #endif -#if (_ATL_VER >= 0x0900) && defined(_ATL_MIN_CRT) - #error _ATL_MIN_CRT is not supported with ATL 9.0 and higher +#ifdef _ATL_NO_WIN_SUPPORT + #error WTL doesn't support _ATL_NO_WIN_SUPPORT #endif -#if defined(_WIN32_WCE) && defined(_ATL_MIN_CRT) - #pragma message("Warning: WTL for Windows CE doesn't use _ATL_MIN_CRT") +#if (_MSC_VER < 1400) + #error WTL10 requires C++ compiler version 14 (Visual C++ 2005) or higher #endif -#include -#if !defined(_ATL_MIN_CRT) && defined(_MT) && !defined(_WIN32_WCE) - #include // for _beginthreadex +#if (WINVER < 0x0501) + #error WTL requires WINVER >= 0x0501 #endif -#if (_ATL_VER < 0x0800) && !defined(_DEBUG) - #include +#if (_WIN32_WINNT < 0x0501) + #error WTL requires _WIN32_WINNT >= 0x0501 #endif -#include -#ifndef _WIN32_WCE - #pragma comment(lib, "comctl32.lib") +#if (_WIN32_IE < 0x0600) + #error WTL requires _WIN32_IE >= 0x0600 #endif -#if defined(_SYSINFOAPI_H_) && defined(NOT_BUILD_WINDOWS_DEPRECATE) && (_WIN32_WINNT >= 0x0501) - #include +#if (_ATL_VER < 0x0800) + #error WTL10 requires ATL version 8 or higher #endif -#ifndef _WIN32_WCE - #include "atlres.h" -#else // CE specific - #include "atlresce.h" -#endif // _WIN32_WCE +#ifdef _ATL_MIN_CRT + #error WTL10 doesn't support _ATL_MIN_CRT +#endif -// We need to disable this warning because of template class arguments -#pragma warning(disable: 4127) +#ifdef _ATL_NO_MSIMG + #error WTL10 doesn't support _ATL_NO_MSIMG +#endif -#if (_ATL_VER >= 0x0900) && !defined(_SECURE_ATL) - #define _SECURE_ATL 1 +#include +#ifdef _MT + #include // for _beginthreadex #endif +#include +#pragma comment(lib, "comctl32.lib") + +#include +#include + +// Check for VS2005 without newer WinSDK +#if (_MSC_VER == 1400) && !defined(RB_GETEXTENDEDSTYLE) + #error WTL10 requires WinSDK 6.0 ot higher +#endif + +#include +#pragma comment(lib, "uxtheme.lib") + +#if defined(_SYSINFOAPI_H_) && defined(NOT_BUILD_WINDOWS_DEPRECATE) + #include +#endif + +#include "atlres.h" + /////////////////////////////////////////////////////////////////////////////// // WTL version number -#define _WTL_VER 0x0910 +#define _WTL_VER 0x1000 // version 10.0 /////////////////////////////////////////////////////////////////////////////// @@ -89,416 +101,12 @@ // CAppModule // CServerAppModule // -// CRegKeyEx -// // Global functions: +// AtlInitCommonControls() // AtlGetDefaultGuiFont() // AtlCreateControlFont() // AtlCreateBoldFont() -// AtlInitCommonControls() - - -/////////////////////////////////////////////////////////////////////////////// -// Global support for Windows CE - -#ifdef _WIN32_WCE - -#ifndef SW_SHOWDEFAULT - #define SW_SHOWDEFAULT SW_SHOWNORMAL -#endif // !SW_SHOWDEFAULT - -// These get's OR-ed in a constant and will have no effect. -// Defining them reduces the number of #ifdefs required for CE. -#define LR_DEFAULTSIZE 0 -#define LR_LOADFROMFILE 0 - -#ifndef SM_CXCURSOR - #define SM_CXCURSOR 13 -#endif -#ifndef SM_CYCURSOR - #define SM_CYCURSOR 14 -#endif - -inline BOOL IsMenu(HMENU hMenu) -{ - MENUITEMINFO mii = { sizeof(MENUITEMINFO) }; - ::SetLastError(0); - BOOL bRet = ::GetMenuItemInfo(hMenu, 0, TRUE, &mii); - if(!bRet) - bRet = (::GetLastError() != ERROR_INVALID_MENU_HANDLE) ? TRUE : FALSE; - return bRet; -} - -#if (_WIN32_WCE >= 410) -extern "C" void WINAPI ListView_SetItemSpacing(HWND hwndLV, int iHeight); -#endif // (_WIN32_WCE >= 410) - -inline int MulDiv(IN int nNumber, IN int nNumerator, IN int nDenominator) -{ - __int64 multiple = nNumber * nNumerator; - return static_cast(multiple / nDenominator); -} - -#if (_ATL_VER >= 0x0800) - -#ifndef _WTL_KEEP_WS_OVERLAPPEDWINDOW - #ifdef WS_OVERLAPPEDWINDOW - #undef WS_OVERLAPPEDWINDOW - #define WS_OVERLAPPEDWINDOW 0 - #endif // WS_OVERLAPPEDWINDOW -#endif // !_WTL_KEEP_WS_OVERLAPPEDWINDOW - -#ifndef RDW_FRAME - #define RDW_FRAME 0 -#endif // !RDW_FRAME - -#ifndef WM_WINDOWPOSCHANGING - #define WM_WINDOWPOSCHANGING 0 -#endif // !WM_WINDOWPOSCHANGING - -#define FreeResource(x) -#define UnlockResource(x) - -namespace ATL -{ - inline HRESULT CComModule::RegisterClassObjects(DWORD /*dwClsContext*/, DWORD /*dwFlags*/) throw() - { return E_NOTIMPL; } - inline HRESULT CComModule::RevokeClassObjects() throw() - { return E_NOTIMPL; } -}; // namespace ATL - -#ifndef lstrlenW - #define lstrlenW (int)ATL::lstrlenW -#endif // lstrlenW - -inline int WINAPI lstrlenA(LPCSTR lpszString) -{ return ATL::lstrlenA(lpszString); } - -#ifdef lstrcpyn - #undef lstrcpyn - #define lstrcpyn ATL::lstrcpynW -#endif // lstrcpyn - -#ifndef SetWindowLongPtrW - inline LONG_PTR tmp_SetWindowLongPtrW( HWND hWnd, int nIndex, LONG_PTR dwNewLong ) - { - return( ::SetWindowLongW( hWnd, nIndex, LONG( dwNewLong ) ) ); - } - #define SetWindowLongPtrW tmp_SetWindowLongPtrW -#endif - -#ifndef GetWindowLongPtrW - inline LONG_PTR tmp_GetWindowLongPtrW( HWND hWnd, int nIndex ) - { - return( ::GetWindowLongW( hWnd, nIndex ) ); - } - #define GetWindowLongPtrW tmp_GetWindowLongPtrW -#endif - -#ifndef LongToPtr - #define LongToPtr(x) ((void*)x) -#endif - -#ifndef PtrToInt - #define PtrToInt( p ) ((INT)(INT_PTR) (p) ) -#endif - -#else // !(_ATL_VER >= 0x0800) - -#ifdef lstrlenW - #undef lstrlenW - #define lstrlenW (int)::wcslen -#endif // lstrlenW - -#define lstrlenA (int)strlen - -#ifndef lstrcpyn - inline LPTSTR lstrcpyn(LPTSTR lpstrDest, LPCTSTR lpstrSrc, int nLength) - { - if(lpstrDest == NULL || lpstrSrc == NULL || nLength <= 0) - return NULL; - int nLen = __min(lstrlen(lpstrSrc), nLength - 1); - LPTSTR lpstrRet = (LPTSTR)memcpy(lpstrDest, lpstrSrc, nLen * sizeof(TCHAR)); - lpstrDest[nLen] = 0; - return lpstrRet; - } -#endif // !lstrcpyn - -#ifndef lstrcpynW - inline LPWSTR lstrcpynW(LPWSTR lpstrDest, LPCWSTR lpstrSrc, int nLength) - { - return lstrcpyn(lpstrDest, lpstrSrc, nLength); // WinCE is Unicode only - } -#endif // !lstrcpynW - -#ifndef lstrcpynA - inline LPSTR lstrcpynA(LPSTR lpstrDest, LPCSTR lpstrSrc, int nLength) - { - if(lpstrDest == NULL || lpstrSrc == NULL || nLength <= 0) - return NULL; - int nLen = __min(lstrlenA(lpstrSrc), nLength - 1); - LPSTR lpstrRet = (LPSTR)memcpy(lpstrDest, lpstrSrc, nLen * sizeof(char)); - lpstrDest[nLen] = 0; - return lpstrRet; - } -#endif // !lstrcpyn - -#ifdef TrackPopupMenu - #undef TrackPopupMenu -#endif // TrackPopupMenu - -#define DECLARE_WND_CLASS_EX(WndClassName, style, bkgnd) \ -static CWndClassInfo& GetWndClassInfo() \ -{ \ - static CWndClassInfo wc = \ - { \ - { style, StartWindowProc, \ - 0, 0, NULL, NULL, NULL, (HBRUSH)(bkgnd + 1), NULL, WndClassName }, \ - NULL, NULL, IDC_ARROW, TRUE, 0, _T("") \ - }; \ - return wc; \ -} - -#ifndef _MAX_FNAME - #define _MAX_FNAME _MAX_PATH -#endif // _MAX_FNAME - -#if (_WIN32_WCE < 400) - #define MAKEINTATOM(i) (LPTSTR)((ULONG_PTR)((WORD)(i))) -#endif // (_WIN32_WCE < 400) - -#if (_WIN32_WCE < 410) - #define WHEEL_PAGESCROLL (UINT_MAX) - #define WHEEL_DELTA 120 -#endif // (_WIN32_WCE < 410) - -#ifdef DrawIcon - #undef DrawIcon -#endif - -#ifndef VARCMP_LT - #define VARCMP_LT 0 -#endif -#ifndef VARCMP_EQ - #define VARCMP_EQ 1 -#endif -#ifndef VARCMP_GT - #define VARCMP_GT 2 -#endif -#ifndef VARCMP_NULL - #define VARCMP_NULL 3 -#endif - -#ifndef RDW_ALLCHILDREN - #define RDW_ALLCHILDREN 0 -#endif - -#endif // !(_ATL_VER >= 0x0800) - -#endif // _WIN32_WCE - - -/////////////////////////////////////////////////////////////////////////////// -// Global support for using original VC++ 6.0 headers with WTL - -#if (_MSC_VER < 1300) && !defined(_WIN32_WCE) - #ifndef REG_QWORD - #define REG_QWORD 11 - #endif - - #ifndef BS_PUSHBOX - #define BS_PUSHBOX 0x0000000AL - #endif - - struct __declspec(uuid("000214e6-0000-0000-c000-000000000046")) IShellFolder; - struct __declspec(uuid("000214f9-0000-0000-c000-000000000046")) IShellLinkW; - struct __declspec(uuid("000214ee-0000-0000-c000-000000000046")) IShellLinkA; -#endif // (_MSC_VER < 1300) && !defined(_WIN32_WCE) - -#ifndef _ATL_NO_OLD_HEADERS_WIN64 -#if !defined(_WIN64) && (_ATL_VER < 0x0700) - - #ifndef PSM_INSERTPAGE - #define PSM_INSERTPAGE (WM_USER + 119) - #endif // !PSM_INSERTPAGE - - #ifndef GetClassLongPtr - #define GetClassLongPtrA GetClassLongA - #define GetClassLongPtrW GetClassLongW - #ifdef UNICODE - #define GetClassLongPtr GetClassLongPtrW - #else - #define GetClassLongPtr GetClassLongPtrA - #endif // !UNICODE - #endif // !GetClassLongPtr - - #ifndef GCLP_HICONSM - #define GCLP_HICONSM (-34) - #endif // !GCLP_HICONSM - - #ifndef GetWindowLongPtr - #define GetWindowLongPtrA GetWindowLongA - #define GetWindowLongPtrW GetWindowLongW - #ifdef UNICODE - #define GetWindowLongPtr GetWindowLongPtrW - #else - #define GetWindowLongPtr GetWindowLongPtrA - #endif // !UNICODE - #endif // !GetWindowLongPtr - - #ifndef SetWindowLongPtr - #define SetWindowLongPtrA SetWindowLongA - #define SetWindowLongPtrW SetWindowLongW - #ifdef UNICODE - #define SetWindowLongPtr SetWindowLongPtrW - #else - #define SetWindowLongPtr SetWindowLongPtrA - #endif // !UNICODE - #endif // !SetWindowLongPtr - - #ifndef GWLP_WNDPROC - #define GWLP_WNDPROC (-4) - #endif - #ifndef GWLP_HINSTANCE - #define GWLP_HINSTANCE (-6) - #endif - #ifndef GWLP_HWNDPARENT - #define GWLP_HWNDPARENT (-8) - #endif - #ifndef GWLP_USERDATA - #define GWLP_USERDATA (-21) - #endif - #ifndef GWLP_ID - #define GWLP_ID (-12) - #endif - - #ifndef DWLP_MSGRESULT - #define DWLP_MSGRESULT 0 - #endif - - typedef long LONG_PTR; - typedef unsigned long ULONG_PTR; - typedef ULONG_PTR DWORD_PTR; - - #ifndef HandleToUlong - #define HandleToUlong( h ) ((ULONG)(ULONG_PTR)(h) ) - #endif - #ifndef HandleToLong - #define HandleToLong( h ) ((LONG)(LONG_PTR) (h) ) - #endif - #ifndef LongToHandle - #define LongToHandle( h) ((HANDLE)(LONG_PTR) (h)) - #endif - #ifndef PtrToUlong - #define PtrToUlong( p ) ((ULONG)(ULONG_PTR) (p) ) - #endif - #ifndef PtrToLong - #define PtrToLong( p ) ((LONG)(LONG_PTR) (p) ) - #endif - #ifndef PtrToUint - #define PtrToUint( p ) ((UINT)(UINT_PTR) (p) ) - #endif - #ifndef PtrToInt - #define PtrToInt( p ) ((INT)(INT_PTR) (p) ) - #endif - #ifndef PtrToUshort - #define PtrToUshort( p ) ((unsigned short)(ULONG_PTR)(p) ) - #endif - #ifndef PtrToShort - #define PtrToShort( p ) ((short)(LONG_PTR)(p) ) - #endif - #ifndef IntToPtr - #define IntToPtr( i ) ((VOID *)(INT_PTR)((int)i)) - #endif - #ifndef UIntToPtr - #define UIntToPtr( ui ) ((VOID *)(UINT_PTR)((unsigned int)ui)) - #endif - #ifndef LongToPtr - #define LongToPtr( l ) ((VOID *)(LONG_PTR)((long)l)) - #endif - #ifndef ULongToPtr - #define ULongToPtr( ul ) ((VOID *)(ULONG_PTR)((unsigned long)ul)) - #endif - -#endif // !defined(_WIN64) && (_ATL_VER < 0x0700) -#endif // !_ATL_NO_OLD_HEADERS_WIN64 - - -/////////////////////////////////////////////////////////////////////////////// -// Global support for using original VC++ 7.x headers with WTL - -#if (_MSC_VER >= 1300) && (_MSC_VER < 1400) - - #ifndef BS_PUSHBOX - #define BS_PUSHBOX 0x0000000AL - #endif - - #pragma warning(disable: 4244) // conversion from 'type1' to 'type2', possible loss of data - -#endif // (_MSC_VER >= 1300) && (_MSC_VER < 1400) - - -/////////////////////////////////////////////////////////////////////////////// -// Global support for old SDK headers - -#ifndef BTNS_BUTTON - #define BTNS_BUTTON TBSTYLE_BUTTON -#endif - -#ifndef BTNS_SEP - #define BTNS_SEP TBSTYLE_SEP -#endif - -#ifndef BTNS_CHECK - #define BTNS_CHECK TBSTYLE_CHECK -#endif - -#ifndef BTNS_GROUP - #define BTNS_GROUP TBSTYLE_GROUP -#endif - -#ifndef BTNS_CHECKGROUP - #define BTNS_CHECKGROUP TBSTYLE_CHECKGROUP -#endif - -#if (_WIN32_IE >= 0x0300) - #ifndef BTNS_DROPDOWN - #define BTNS_DROPDOWN TBSTYLE_DROPDOWN - #endif -#endif - -#if (_WIN32_IE >= 0x0400) - #ifndef BTNS_AUTOSIZE - #define BTNS_AUTOSIZE TBSTYLE_AUTOSIZE - #endif - - #ifndef BTNS_NOPREFIX - #define BTNS_NOPREFIX TBSTYLE_NOPREFIX - #endif -#endif - - -/////////////////////////////////////////////////////////////////////////////// -// Global support for SecureHelper functions - -#ifndef _TRUNCATE - #define _TRUNCATE ((size_t)-1) -#endif - -#ifndef _ERRCODE_DEFINED - #define _ERRCODE_DEFINED - typedef int errno_t; -#endif - -#ifndef _SECURECRT_ERRCODE_VALUES_DEFINED - #define _SECURECRT_ERRCODE_VALUES_DEFINED - #define EINVAL 22 - #define STRUNCATE 80 -#endif - -#ifndef _countof - #define _countof(_Array) (sizeof(_Array) / sizeof(_Array[0])) -#endif +// AtlGetStringPtr() /////////////////////////////////////////////////////////////////////////////// @@ -523,124 +131,90 @@ static CWndClassInfo& GetWndClassInfo() \ #endif // Dummy structs for compiling with /CLR -#if (_MSC_VER >= 1300) && defined(_MANAGED) +#ifdef _MANAGED __if_not_exists(_IMAGELIST::_IMAGELIST) { struct _IMAGELIST { }; } __if_not_exists(_TREEITEM::_TREEITEM) { struct _TREEITEM { }; } __if_not_exists(_PSP::_PSP) { struct _PSP { }; } #endif -// Define ATLVERIFY macro for ATL3 -#if (_ATL_VER < 0x0700) - #ifndef ATLVERIFY - #ifdef _DEBUG - #define ATLVERIFY(expr) ATLASSERT(expr) - #else - #define ATLVERIFY(expr) (expr) - #endif // DEBUG - #endif // ATLVERIFY -#endif // (_ATL_VER < 0x0700) - -// Forward declaration for ATL3 and ATL11 fix -#if (((_ATL_VER < 0x0700) && defined(_ATL_DLL)) || (_ATL_VER >= 0x0B00)) && !defined(_WIN32_WCE) - namespace ATL { HRESULT AtlGetCommCtrlVersion(LPDWORD pdwMajor, LPDWORD pdwMinor); }; +// Forward declaration for ATL11 fix +#if (_ATL_VER >= 0x0B00) + namespace ATL { HRESULT AtlGetCommCtrlVersion(LPDWORD pdwMajor, LPDWORD pdwMinor); } #endif #ifndef WM_MOUSEHWHEEL #define WM_MOUSEHWHEEL 0x020E #endif +// Used for stack allocations with ATL::CTempBuffer +#ifndef _WTL_STACK_ALLOC_THRESHOLD + #define _WTL_STACK_ALLOC_THRESHOLD 512 +#endif + namespace WTL { -#if (_ATL_VER >= 0x0700) - DECLARE_TRACE_CATEGORY(atlTraceUI); - #ifdef _DEBUG - __declspec(selectany) ATL::CTraceCategory atlTraceUI(_T("atlTraceUI")); - #endif // _DEBUG -#else // !(_ATL_VER >= 0x0700) - enum wtlTraceFlags - { - atlTraceUI = 0x10000000 - }; -#endif // !(_ATL_VER >= 0x0700) - -// Windows version helper -inline bool AtlIsOldWindows() +DECLARE_TRACE_CATEGORY(atlTraceUI) +#ifdef _DEBUG + __declspec(selectany) ATL::CTraceCategory atlTraceUI(_T("atlTraceUI")); +#endif // _DEBUG + +// Common Controls initialization helper +inline BOOL AtlInitCommonControls(DWORD dwFlags) { -#ifdef _versionhelpers_H_INCLUDED_ - return !::IsWindowsVersionOrGreater(4, 90, 0); -#else // !_versionhelpers_H_INCLUDED_ -OSVERSIONINFO ovi = { sizeof(OSVERSIONINFO) }; - BOOL bRet = ::GetVersionEx(&ovi); - return (!bRet || !((ovi.dwMajorVersion >= 5) || (ovi.dwMajorVersion == 4 && ovi.dwMinorVersion >= 90))); -#endif // _versionhelpers_H_INCLUDED_ + INITCOMMONCONTROLSEX iccx = { sizeof(INITCOMMONCONTROLSEX), dwFlags }; + BOOL bRet = ::InitCommonControlsEx(&iccx); + ATLASSERT(bRet); + return bRet; } // Default GUI font helper - "MS Shell Dlg" stock font inline HFONT AtlGetDefaultGuiFont() { -#ifndef _WIN32_WCE return (HFONT)::GetStockObject(DEFAULT_GUI_FONT); -#else // CE specific - return (HFONT)::GetStockObject(SYSTEM_FONT); -#endif // _WIN32_WCE } // Control font helper - default font for controls not in a dialog // (NOTE: Caller owns the font, and should destroy it when it's no longer needed) inline HFONT AtlCreateControlFont() { -#ifndef _WIN32_WCE - LOGFONT lf = { 0 }; + LOGFONT lf = {}; ATLVERIFY(::SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(LOGFONT), &lf, 0) != FALSE); HFONT hFont = ::CreateFontIndirect(&lf); ATLASSERT(hFont != NULL); return hFont; -#else // CE specific - return (HFONT)::GetStockObject(SYSTEM_FONT); -#endif // _WIN32_WCE } // Bold font helper // (NOTE: Caller owns the font, and should destroy it when it's no longer needed) inline HFONT AtlCreateBoldFont(HFONT hFont = NULL) { - LOGFONT lf = { 0 }; -#ifndef _WIN32_WCE + LOGFONT lf = {}; if(hFont == NULL) ATLVERIFY(::SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(LOGFONT), &lf, 0) != FALSE); else ATLVERIFY(::GetObject(hFont, sizeof(LOGFONT), &lf) == sizeof(LOGFONT)); -#else // CE specific - if(hFont == NULL) - hFont = (HFONT)::GetStockObject(SYSTEM_FONT); - ATLVERIFY(::GetObject(hFont, sizeof(LOGFONT), &lf) == sizeof(LOGFONT)); -#endif // _WIN32_WCE lf.lfWeight = FW_BOLD; HFONT hFontBold = ::CreateFontIndirect(&lf); ATLASSERT(hFontBold != NULL); return hFontBold; } -// Common Controls initialization helper -inline BOOL AtlInitCommonControls(DWORD dwFlags) +// Resource string pointer +inline LPCWSTR AtlGetStringPtr(UINT uID, int* pch = NULL) { - INITCOMMONCONTROLSEX iccx = { sizeof(INITCOMMONCONTROLSEX), dwFlags }; - BOOL bRet = ::InitCommonControlsEx(&iccx); - ATLASSERT(bRet); - return bRet; + LPCWSTR lpstr = NULL; + int nRet = ::LoadStringW(ATL::_AtlBaseModule.GetResourceInstance(), uID, (LPWSTR)&lpstr, 0); + if(pch != NULL) + *pch = nRet; + return lpstr; } /////////////////////////////////////////////////////////////////////////////// // RunTimeHelper - helper functions for Windows version and structure sizes -// Not for Windows CE -#if defined(_WIN32_WCE) && !defined(_WTL_NO_RUNTIME_STRUCT_SIZE) - #define _WTL_NO_RUNTIME_STRUCT_SIZE -#endif - #ifndef _WTL_NO_RUNTIME_STRUCT_SIZE #ifndef _SIZEOF_STRUCT @@ -663,19 +237,18 @@ inline BOOL AtlInitCommonControls(DWORD dwFlags) #define MCHITTESTINFO_V1_SIZE _SIZEOF_STRUCT(MCHITTESTINFO, st) #endif // defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_LONGHORN) && !defined(MCHITTESTINFO_V1_SIZE) -#if !defined(_WIN32_WCE) && (WINVER >= 0x0600) && !defined(NONCLIENTMETRICS_V1_SIZE) +#if (WINVER >= 0x0600) && !defined(NONCLIENTMETRICS_V1_SIZE) #define NONCLIENTMETRICS_V1_SIZE _SIZEOF_STRUCT(NONCLIENTMETRICS, lfMessageFont) -#endif // !defined(_WIN32_WCE) && (WINVER >= 0x0600) && !defined(NONCLIENTMETRICS_V1_SIZE) +#endif // (WINVER >= 0x0600) && !defined(NONCLIENTMETRICS_V1_SIZE) -#if !defined(_WIN32_WCE) && (_WIN32_WINNT >= 0x0501) && !defined(TTTOOLINFO_V2_SIZE) +#ifndef TTTOOLINFO_V2_SIZE #define TTTOOLINFO_V2_SIZE _SIZEOF_STRUCT(TTTOOLINFO, lParam) -#endif // !defined(_WIN32_WCE) && (_WIN32_WINNT >= 0x0501) && !defined(TTTOOLINFO_V2_SIZE) +#endif #endif // !_WTL_NO_RUNTIME_STRUCT_SIZE namespace RunTimeHelper { -#ifndef _WIN32_WCE inline bool IsCommCtrl6() { DWORD dwMajor = 0, dwMinor = 0; @@ -696,30 +269,7 @@ namespace RunTimeHelper inline bool IsThemeAvailable() { - bool bRet = false; - - if(IsCommCtrl6()) - { - HMODULE hThemeDLL = ::LoadLibrary(_T("uxtheme.dll")); - if(hThemeDLL != NULL) - { - typedef BOOL (STDAPICALLTYPE *PFN_IsThemeActive)(); - PFN_IsThemeActive pfnIsThemeActive = (PFN_IsThemeActive)::GetProcAddress(hThemeDLL, "IsThemeActive"); - ATLASSERT(pfnIsThemeActive != NULL); - bRet = (pfnIsThemeActive != NULL) && (pfnIsThemeActive() != FALSE); - if(bRet) - { - typedef BOOL (STDAPICALLTYPE *PFN_IsAppThemed)(); - PFN_IsAppThemed pfnIsAppThemed = (PFN_IsAppThemed)::GetProcAddress(hThemeDLL, "IsAppThemed"); - ATLASSERT(pfnIsAppThemed != NULL); - bRet = (pfnIsAppThemed != NULL) && (pfnIsAppThemed() != FALSE); - } - - ::FreeLibrary(hThemeDLL); - } - } - - return bRet; + return IsCommCtrl6() && (::IsThemeActive() != FALSE) && (::IsAppThemed() != FALSE); } inline bool IsWin7() @@ -729,7 +279,7 @@ namespace RunTimeHelper #else // !_versionhelpers_H_INCLUDED_ OSVERSIONINFO ovi = { sizeof(OSVERSIONINFO) }; BOOL bRet = ::GetVersionEx(&ovi); - return ((bRet != FALSE) && (ovi.dwMajorVersion == 6) && (ovi.dwMinorVersion >= 1)); + return ((bRet != FALSE) && ((ovi.dwMajorVersion > 6) || ((ovi.dwMajorVersion == 6) && (ovi.dwMinorVersion >= 1)))); #endif // _versionhelpers_H_INCLUDED_ } @@ -761,8 +311,6 @@ namespace RunTimeHelper return (iRibbonUI == 1); } -#endif // !_WIN32_WCE - inline UINT SizeOf_REBARBANDINFO() { UINT uSize = sizeof(REBARBANDINFO); @@ -773,7 +321,6 @@ namespace RunTimeHelper return uSize; } -#if (_WIN32_WINNT >= 0x501) inline UINT SizeOf_LVGROUP() { UINT uSize = sizeof(LVGROUP); @@ -793,7 +340,6 @@ namespace RunTimeHelper #endif // !defined(_WTL_NO_RUNTIME_STRUCT_SIZE) && (_WIN32_WINNT >= 0x0600) return uSize; } -#endif // (_WIN32_WINNT >= 0x501) inline UINT SizeOf_MCHITTESTINFO() { @@ -805,7 +351,6 @@ namespace RunTimeHelper return uSize; } -#ifndef _WIN32_WCE inline UINT SizeOf_NONCLIENTMETRICS() { UINT uSize = sizeof(NONCLIENTMETRICS); @@ -819,86 +364,56 @@ namespace RunTimeHelper inline UINT SizeOf_TOOLINFO() { UINT uSize = sizeof(TOOLINFO); -#if !defined(_WTL_NO_RUNTIME_STRUCT_SIZE) && (_WIN32_WINNT >= 0x0501) +#ifndef _WTL_NO_RUNTIME_STRUCT_SIZE if(!IsVista()) uSize = TTTOOLINFO_V2_SIZE; -#endif // !defined(_WTL_NO_RUNTIME_STRUCT_SIZE) && (_WIN32_WINNT >= 0x0501) +#endif return uSize; } -#endif // !_WIN32_WCE -}; +} // namespace RunTimeHelper /////////////////////////////////////////////////////////////////////////////// -// ModuleHelper - helper functions for ATL3 and ATL7 module classes +// ModuleHelper - helper functions for ATL (deprecated) namespace ModuleHelper { inline HINSTANCE GetModuleInstance() { -#if (_ATL_VER >= 0x0700) return ATL::_AtlBaseModule.GetModuleInstance(); -#else // !(_ATL_VER >= 0x0700) - return ATL::_pModule->GetModuleInstance(); -#endif // !(_ATL_VER >= 0x0700) } inline HINSTANCE GetResourceInstance() { -#if (_ATL_VER >= 0x0700) return ATL::_AtlBaseModule.GetResourceInstance(); -#else // !(_ATL_VER >= 0x0700) - return ATL::_pModule->GetResourceInstance(); -#endif // !(_ATL_VER >= 0x0700) } inline void AddCreateWndData(ATL::_AtlCreateWndData* pData, void* pObject) { -#if (_ATL_VER >= 0x0700) ATL::_AtlWinModule.AddCreateWndData(pData, pObject); -#else // !(_ATL_VER >= 0x0700) - ATL::_pModule->AddCreateWndData(pData, pObject); -#endif // !(_ATL_VER >= 0x0700) } inline void* ExtractCreateWndData() { -#if (_ATL_VER >= 0x0700) return ATL::_AtlWinModule.ExtractCreateWndData(); -#else // !(_ATL_VER >= 0x0700) - return ATL::_pModule->ExtractCreateWndData(); -#endif // !(_ATL_VER >= 0x0700) } -}; +} // namespace ModuleHelper /////////////////////////////////////////////////////////////////////////////// -// SecureHelper - helper functions for VS2005 secure CRT +// SecureHelper - WTL10 requires use of secure functions +// these are here only for compatibility with existing projects namespace SecureHelper { inline void strcpyA_x(char* lpstrDest, size_t cchDest, const char* lpstrSrc) { -#if _SECURE_ATL ATL::Checked::strcpy_s(lpstrDest, cchDest, lpstrSrc); -#else - if(cchDest > (size_t)lstrlenA(lpstrSrc)) - ATLVERIFY(lstrcpyA(lpstrDest, lpstrSrc) != NULL); - else - ATLASSERT(FALSE); -#endif } inline void strcpyW_x(wchar_t* lpstrDest, size_t cchDest, const wchar_t* lpstrSrc) { -#if _SECURE_ATL ATL::Checked::wcscpy_s(lpstrDest, cchDest, lpstrSrc); -#else - if(cchDest > (size_t)lstrlenW(lpstrSrc)) - ATLVERIFY(lstrcpyW(lpstrDest, lpstrSrc) != NULL); - else - ATLASSERT(FALSE); -#endif } inline void strcpy_x(LPTSTR lpstrDest, size_t cchDest, LPCTSTR lpstrSrc) @@ -912,56 +427,12 @@ namespace SecureHelper inline errno_t strncpyA_x(char* lpstrDest, size_t cchDest, const char* lpstrSrc, size_t cchCount) { -#if _SECURE_ATL return ATL::Checked::strncpy_s(lpstrDest, cchDest, lpstrSrc, cchCount); -#else - errno_t nRet = 0; - if(lpstrDest == NULL || cchDest == 0 || lpstrSrc == NULL) - { - nRet = EINVAL; - } - else if(cchCount == _TRUNCATE) - { - cchCount = __min(cchDest - 1, size_t(lstrlenA(lpstrSrc))); - nRet = STRUNCATE; - } - else if(cchDest <= cchCount) - { - lpstrDest[0] = 0; - nRet = EINVAL; - } - if(nRet == 0 || nRet == STRUNCATE) - nRet = (lstrcpynA(lpstrDest, lpstrSrc, (int)cchCount + 1) != NULL) ? nRet : EINVAL; - ATLASSERT(nRet == 0 || nRet == STRUNCATE); - return nRet; -#endif } inline errno_t strncpyW_x(wchar_t* lpstrDest, size_t cchDest, const wchar_t* lpstrSrc, size_t cchCount) { -#if _SECURE_ATL return ATL::Checked::wcsncpy_s(lpstrDest, cchDest, lpstrSrc, cchCount); -#else - errno_t nRet = 0; - if(lpstrDest == NULL || cchDest == 0 || lpstrSrc == NULL) - { - nRet = EINVAL; - } - else if(cchCount == _TRUNCATE) - { - cchCount = __min(cchDest - 1, size_t(lstrlenW(lpstrSrc))); - nRet = STRUNCATE; - } - else if(cchDest <= cchCount) - { - lpstrDest[0] = 0; - nRet = EINVAL; - } - if(nRet == 0 || nRet == STRUNCATE) - nRet = (lstrcpynW(lpstrDest, lpstrSrc, (int)cchCount + 1) != NULL) ? nRet : EINVAL; - ATLASSERT(nRet == 0 || nRet == STRUNCATE); - return nRet; -#endif } inline errno_t strncpy_x(LPTSTR lpstrDest, size_t cchDest, LPCTSTR lpstrSrc, size_t cchCount) @@ -975,26 +446,12 @@ namespace SecureHelper inline void strcatA_x(char* lpstrDest, size_t cchDest, const char* lpstrSrc) { -#if _SECURE_ATL ATL::Checked::strcat_s(lpstrDest, cchDest, lpstrSrc); -#else - if(cchDest > (size_t)lstrlenA(lpstrSrc)) - ATLVERIFY(lstrcatA(lpstrDest, lpstrSrc) != NULL); - else - ATLASSERT(FALSE); -#endif } inline void strcatW_x(wchar_t* lpstrDest, size_t cchDest, const wchar_t* lpstrSrc) { -#if _SECURE_ATL ATL::Checked::wcscat_s(lpstrDest, cchDest, lpstrSrc); -#else - if(cchDest > (size_t)lstrlenW(lpstrSrc)) - ATLVERIFY(lstrcatW(lpstrDest, lpstrSrc) != NULL); - else - ATLASSERT(FALSE); -#endif } inline void strcat_x(LPTSTR lpstrDest, size_t cchDest, LPCTSTR lpstrSrc) @@ -1008,49 +465,22 @@ namespace SecureHelper inline void memcpy_x(void* pDest, size_t cbDest, const void* pSrc, size_t cbSrc) { -#if _SECURE_ATL ATL::Checked::memcpy_s(pDest, cbDest, pSrc, cbSrc); -#else - if(cbDest >= cbSrc) - memcpy(pDest, pSrc, cbSrc); - else - ATLASSERT(FALSE); -#endif } inline void memmove_x(void* pDest, size_t cbDest, const void* pSrc, size_t cbSrc) { -#if _SECURE_ATL ATL::Checked::memmove_s(pDest, cbDest, pSrc, cbSrc); -#else - if(cbDest >= cbSrc) - memmove(pDest, pSrc, cbSrc); - else - ATLASSERT(FALSE); -#endif } inline int vsprintf_x(LPTSTR lpstrBuff, size_t cchBuff, LPCTSTR lpstrFormat, va_list args) { -#if _SECURE_ATL && !defined(_ATL_MIN_CRT) && !defined(_WIN32_WCE) return _vstprintf_s(lpstrBuff, cchBuff, lpstrFormat, args); -#else - cchBuff; // Avoid unused argument warning - #pragma warning(push) - #pragma warning(disable: 4996) - return _vstprintf(lpstrBuff, lpstrFormat, args); - #pragma warning(pop) -#endif } inline int wvsprintf_x(LPTSTR lpstrBuff, size_t cchBuff, LPCTSTR lpstrFormat, va_list args) { -#if _SECURE_ATL && !defined(_ATL_MIN_CRT) && !defined(_WIN32_WCE) return _vstprintf_s(lpstrBuff, cchBuff, lpstrFormat, args); -#else - cchBuff; // Avoid unused argument warning - return ::wvsprintf(lpstrBuff, lpstrFormat, args); -#endif } inline int sprintf_x(LPTSTR lpstrBuff, size_t cchBuff, LPCTSTR lpstrFormat, ...) @@ -1070,92 +500,40 @@ namespace SecureHelper va_end(args); return nRes; } -}; // namespace SecureHelper +} // namespace SecureHelper /////////////////////////////////////////////////////////////////////////////// -// MinCrtHelper - helper functions for using _ATL_MIN_CRT +// MinCrtHelper - WTL10 doesn't support _ATL_MIN_CRT, +// these are here only for compatibility with existing projects namespace MinCrtHelper { inline int _isspace(TCHAR ch) { -#ifndef _ATL_MIN_CRT return _istspace(ch); -#else // _ATL_MIN_CRT - WORD type = 0; - ::GetStringTypeEx(::GetThreadLocale(), CT_CTYPE1, &ch, 1, &type); - return (type & C1_SPACE) == C1_SPACE; -#endif // _ATL_MIN_CRT } inline int _isdigit(TCHAR ch) { -#ifndef _ATL_MIN_CRT return _istdigit(ch); -#else // _ATL_MIN_CRT - WORD type = 0; - ::GetStringTypeEx(::GetThreadLocale(), CT_CTYPE1, &ch, 1, &type); - return (type & C1_DIGIT) == C1_DIGIT; -#endif // _ATL_MIN_CRT } inline int _atoi(LPCTSTR str) { -#ifndef _ATL_MIN_CRT return _ttoi(str); -#else // _ATL_MIN_CRT - while(_isspace(*str) != 0) - ++str; - - TCHAR ch = *str++; - TCHAR sign = ch; // save sign indication - if(ch == _T('-') || ch == _T('+')) - ch = *str++; // skip sign - - int total = 0; - while(_isdigit(ch) != 0) - { - total = 10 * total + (ch - '0'); // accumulate digit - ch = *str++; // get next char - } - - return (sign == '-') ? -total : total; // return result, negated if necessary -#endif // _ATL_MIN_CRT } inline LPCTSTR _strrchr(LPCTSTR str, TCHAR ch) { -#ifndef _ATL_MIN_CRT return _tcsrchr(str, ch); -#else // _ATL_MIN_CRT - LPCTSTR lpsz = NULL; - while(*str != 0) - { - if(*str == ch) - lpsz = str; - str = ::CharNext(str); - } - return lpsz; -#endif // _ATL_MIN_CRT } inline LPTSTR _strrchr(LPTSTR str, TCHAR ch) { -#ifndef _ATL_MIN_CRT return _tcsrchr(str, ch); -#else // _ATL_MIN_CRT - LPTSTR lpsz = NULL; - while(*str != 0) - { - if(*str == ch) - lpsz = str; - str = ::CharNext(str); - } - return lpsz; -#endif // _ATL_MIN_CRT } -}; // namespace MinCrtHelper +} // namespace MinCrtHelper /////////////////////////////////////////////////////////////////////////////// @@ -1173,21 +551,13 @@ namespace GenericWndClass inline ATOM Register() { -#ifndef _WIN32_WCE WNDCLASSEX wc = { sizeof(WNDCLASSEX) }; -#else - WNDCLASS wc = { 0 }; -#endif wc.lpfnWndProc = ::DefWindowProc; wc.hInstance = ModuleHelper::GetModuleInstance(); wc.hCursor = ::LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); wc.lpszClassName = GetName(); -#ifndef _WIN32_WCE ATOM atom = ::RegisterClassEx(&wc); -#else - ATOM atom = ::RegisterClass(&wc); -#endif ATLASSERT(atom != 0); return atom; } @@ -1196,13 +566,13 @@ namespace GenericWndClass { return ::UnregisterClass(GetName(), ModuleHelper::GetModuleInstance()); } -}; // namespace GenericWndClass +} // namespace GenericWndClass /////////////////////////////////////////////////////////////////////////////// // CMessageFilter - Interface for message filter support -class CMessageFilter +class ATL_NO_VTABLE CMessageFilter { public: virtual BOOL PreTranslateMessage(MSG* pMsg) = 0; @@ -1212,18 +582,12 @@ public: /////////////////////////////////////////////////////////////////////////////// // CIdleHandler - Interface for idle processing -class CIdleHandler +class ATL_NO_VTABLE CIdleHandler { public: virtual BOOL OnIdle() = 0; }; -#ifndef _ATL_NO_OLD_NAMES - // for compatilibility with old names only - typedef CIdleHandler CUpdateUIObject; - #define DoUpdate OnIdle -#endif // !_ATL_NO_OLD_NAMES - /////////////////////////////////////////////////////////////////////////////// // CMessageLoop - message loop implementation @@ -1235,6 +599,14 @@ public: ATL::CSimpleArray m_aIdleHandler; MSG m_msg; + CMessageLoop() + { + memset(&m_msg, 0, sizeof(m_msg)); + } + + virtual ~CMessageLoop() + { } + // Message filter operations BOOL AddMessageFilter(CMessageFilter* pMessageFilter) { @@ -1257,27 +629,12 @@ public: return m_aIdleHandler.Remove(pIdleHandler); } -#ifndef _ATL_NO_OLD_NAMES - // for compatilibility with old names only - BOOL AddUpdateUI(CIdleHandler* pIdleHandler) - { - ATLTRACE2(atlTraceUI, 0, _T("CUpdateUIObject and AddUpdateUI are deprecated. Please change your code to use CIdleHandler and OnIdle\n")); - return AddIdleHandler(pIdleHandler); - } - - BOOL RemoveUpdateUI(CIdleHandler* pIdleHandler) - { - ATLTRACE2(atlTraceUI, 0, _T("CUpdateUIObject and RemoveUpdateUI are deprecated. Please change your code to use CIdleHandler and OnIdle\n")); - return RemoveIdleHandler(pIdleHandler); - } -#endif // !_ATL_NO_OLD_NAMES - // message loop int Run() { BOOL bDoIdle = TRUE; int nIdleCount = 0; - BOOL bRet; + BOOL bRet = FALSE; for(;;) { @@ -1316,23 +673,6 @@ public: return (int)m_msg.wParam; } - static BOOL IsIdleMessage(MSG* pMsg) - { - // These messages should NOT cause idle processing - switch(pMsg->message) - { - case WM_MOUSEMOVE: -#ifndef _WIN32_WCE - case WM_NCMOUSEMOVE: -#endif // !_WIN32_WCE - case WM_PAINT: - case 0x0118: // WM_SYSTIMER (caret blink) - return FALSE; - } - - return TRUE; - } - // Overrideables // Override to change message filtering virtual BOOL PreTranslateMessage(MSG* pMsg) @@ -1341,7 +681,7 @@ public: for(int i = m_aMsgFilter.GetSize() - 1; i >= 0; i--) { CMessageFilter* pMessageFilter = m_aMsgFilter[i]; - if(pMessageFilter != NULL && pMessageFilter->PreTranslateMessage(pMsg)) + if((pMessageFilter != NULL) && pMessageFilter->PreTranslateMessage(pMsg)) return TRUE; } return FALSE; // not translated @@ -1358,40 +698,45 @@ public: } return FALSE; // don't continue } + + // override to change non-idle messages + virtual BOOL IsIdleMessage(MSG* pMsg) const + { + // These messages should NOT cause idle processing + switch(pMsg->message) + { + case WM_MOUSEMOVE: + case WM_NCMOUSEMOVE: + case WM_PAINT: + case 0x0118: // WM_SYSTIMER (caret blink) + return FALSE; + } + + return TRUE; + } }; /////////////////////////////////////////////////////////////////////////////// // CStaticDataInitCriticalSectionLock and CWindowCreateCriticalSectionLock -// internal classes to manage critical sections for both ATL3 and ATL7 +// internal classes to manage critical sections for ATL (deprecated) class CStaticDataInitCriticalSectionLock { public: -#if (_ATL_VER >= 0x0700) ATL::CComCritSecLock m_cslock; CStaticDataInitCriticalSectionLock() : m_cslock(ATL::_pAtlModule->m_csStaticDataInitAndTypeInfo, false) { } -#endif // (_ATL_VER >= 0x0700) HRESULT Lock() { -#if (_ATL_VER >= 0x0700) return m_cslock.Lock(); -#else // !(_ATL_VER >= 0x0700) - ::EnterCriticalSection(&ATL::_pModule->m_csStaticDataInit); - return S_OK; -#endif // !(_ATL_VER >= 0x0700) } void Unlock() { -#if (_ATL_VER >= 0x0700) m_cslock.Unlock(); -#else // !(_ATL_VER >= 0x0700) - ::LeaveCriticalSection(&ATL::_pModule->m_csStaticDataInit); -#endif // !(_ATL_VER >= 0x0700) } }; @@ -1399,118 +744,32 @@ public: class CWindowCreateCriticalSectionLock { public: -#if (_ATL_VER >= 0x0700) ATL::CComCritSecLock m_cslock; CWindowCreateCriticalSectionLock() : m_cslock(ATL::_AtlWinModule.m_csWindowCreate, false) { } -#endif // (_ATL_VER >= 0x0700) HRESULT Lock() { -#if (_ATL_VER >= 0x0700) return m_cslock.Lock(); -#else // !(_ATL_VER >= 0x0700) - ::EnterCriticalSection(&ATL::_pModule->m_csWindowCreate); - return S_OK; -#endif // !(_ATL_VER >= 0x0700) } void Unlock() { -#if (_ATL_VER >= 0x0700) m_cslock.Unlock(); -#else // !(_ATL_VER >= 0x0700) - ::LeaveCriticalSection(&ATL::_pModule->m_csWindowCreate); -#endif // !(_ATL_VER >= 0x0700) } }; /////////////////////////////////////////////////////////////////////////////// -// CTempBuffer - helper class for stack allocations for ATL3 - -#ifndef _WTL_STACK_ALLOC_THRESHOLD - #define _WTL_STACK_ALLOC_THRESHOLD 512 -#endif - -#if (_ATL_VER >= 0x0700) - -using ATL::CTempBuffer; - -#else // !(_ATL_VER >= 0x0700) +// CAppModule - module class for an application -#ifndef SIZE_MAX - #ifdef _WIN64 - #define SIZE_MAX _UI64_MAX - #else - #define SIZE_MAX UINT_MAX - #endif +#if (_MSC_VER == 1400) // VS2005 + #pragma warning(push) + #pragma warning(disable : 4244) + #pragma warning(disable : 4312) #endif -#pragma warning(push) -#pragma warning(disable: 4284) // warning for operator -> - -template -class CTempBuffer -{ -public: - CTempBuffer() : m_p(NULL) - { - } - - CTempBuffer(size_t nElements) : m_p(NULL) - { - Allocate(nElements); - } - - ~CTempBuffer() - { - if(m_p != reinterpret_cast(m_abFixedBuffer)) - free(m_p); - } - - operator T*() const - { - return m_p; - } - - T* operator ->() const - { - ATLASSERT(m_p != NULL); - return m_p; - } - - T* Allocate(size_t nElements) - { - ATLASSERT(nElements <= (SIZE_MAX / sizeof(T))); - return AllocateBytes(nElements * sizeof(T)); - } - - T* AllocateBytes(size_t nBytes) - { - ATLASSERT(m_p == NULL); - if(nBytes > t_nFixedBytes) - m_p = static_cast(malloc(nBytes)); - else - m_p = reinterpret_cast(m_abFixedBuffer); - - return m_p; - } - -private: - T* m_p; - BYTE m_abFixedBuffer[t_nFixedBytes]; -}; - -#pragma warning(pop) - -#endif // !(_ATL_VER >= 0x0700) - - -/////////////////////////////////////////////////////////////////////////////// -// CAppModule - module class for an application - class CAppModule : public ATL::CComModule { public: @@ -1518,6 +777,9 @@ public: ATL::CSimpleMap* m_pMsgLoopMap; ATL::CSimpleArray* m_pSettingChangeNotify; + CAppModule() : m_dwMainThreadID(0), m_pMsgLoopMap(NULL), m_pSettingChangeNotify(NULL) + { } + // Overrides of CComModule::Init and Term HRESULT Init(ATL::_ATL_OBJMAP_ENTRY* pObjMap, HINSTANCE hInstance, const GUID* pLibID = NULL) { @@ -1618,7 +880,7 @@ public: } BOOL bRet = (m_pSettingChangeNotify != NULL); - if(bRet && m_pSettingChangeNotify->GetSize() == 0) + if(bRet && (m_pSettingChangeNotify->GetSize() == 0)) { // init everything _ATL_EMPTY_DLGTEMPLATE templ; @@ -1626,12 +888,7 @@ public: ATLASSERT(::IsWindow(hNtfWnd)); if(::IsWindow(hNtfWnd)) { -// need conditional code because types don't match in winuser.h -#ifdef _WIN64 ::SetWindowLongPtr(hNtfWnd, GWLP_USERDATA, (LONG_PTR)this); -#else - ::SetWindowLongPtr(hNtfWnd, GWLP_USERDATA, PtrToLong(this)); -#endif bRet = m_pSettingChangeNotify->Add(hNtfWnd); } else @@ -1655,7 +912,7 @@ public: return; } - if(m_pSettingChangeNotify != NULL && m_pSettingChangeNotify->GetSize() > 0) + if((m_pSettingChangeNotify != NULL) && (m_pSettingChangeNotify->GetSize() > 0)) ::DestroyWindow((*m_pSettingChangeNotify)[0]); delete m_pSettingChangeNotify; m_pSettingChangeNotify = NULL; @@ -1713,40 +970,28 @@ public: WORD wMenu, wClass, wTitle; }; -#ifdef _WIN64 static INT_PTR CALLBACK _SettingChangeDlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -#else - static BOOL CALLBACK _SettingChangeDlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -#endif { if(uMsg == WM_SETTINGCHANGE) { -// need conditional code because types don't match in winuser.h -#ifdef _WIN64 CAppModule* pModule = (CAppModule*)::GetWindowLongPtr(hWnd, GWLP_USERDATA); -#else - CAppModule* pModule = (CAppModule*)LongToPtr(::GetWindowLongPtr(hWnd, GWLP_USERDATA)); -#endif ATLASSERT(pModule != NULL); ATLASSERT(pModule->m_pSettingChangeNotify != NULL); const UINT uTimeout = 1500; // ms for(int i = 1; i < pModule->m_pSettingChangeNotify->GetSize(); i++) - { -#if !defined(_WIN32_WCE) ::SendMessageTimeout((*pModule->m_pSettingChangeNotify)[i], uMsg, wParam, lParam, SMTO_ABORTIFHUNG, uTimeout, NULL); -#elif(_WIN32_WCE >= 400) // CE specific - ::SendMessageTimeout((*pModule->m_pSettingChangeNotify)[i], uMsg, wParam, lParam, SMTO_NORMAL, uTimeout, NULL); -#else // _WIN32_WCE < 400 specific - uTimeout; - ::SendMessage((*pModule->m_pSettingChangeNotify)[i], uMsg, wParam, lParam); -#endif - } + return TRUE; } + return FALSE; } }; +#if (_MSC_VER == 1400) // VS2005 + #pragma warning(pop) +#endif + /////////////////////////////////////////////////////////////////////////////// // CServerAppModule - module class for a COM server application @@ -1759,6 +1004,9 @@ public: DWORD m_dwTimeOut; DWORD m_dwPause; + CServerAppModule() : m_hEventShutdown(NULL), m_bActivity(false), m_dwTimeOut(5000), m_dwPause(1000) + { } + // Override of CAppModule::Init HRESULT Init(ATL::_ATL_OBJMAP_ENTRY* pObjMap, HINSTANCE hInstance, const GUID* pLibID = NULL) { @@ -1769,17 +1017,13 @@ public: void Term() { - if(m_hEventShutdown != NULL && ::CloseHandle(m_hEventShutdown)) + if((m_hEventShutdown != NULL) && ::CloseHandle(m_hEventShutdown)) m_hEventShutdown = NULL; CAppModule::Term(); } // COM Server methods -#if (_MSC_VER >= 1300) LONG Unlock() throw() -#else - LONG Unlock() -#endif { LONG lRet = CComModule::Unlock(); if(lRet == 0) @@ -1803,11 +1047,11 @@ public: } while(dwWait == WAIT_OBJECT_0); // timed out - if(!m_bActivity && m_nLockCnt == 0) // if no activity let's really bail + if(!m_bActivity && (m_nLockCnt == 0)) // if no activity let's really bail { -#if ((_WIN32_WINNT >= 0x0400 ) || defined(_WIN32_DCOM)) && defined(_ATL_FREE_THREADED) && !defined(_WIN32_WCE) +#if defined(_WIN32_DCOM) && defined(_ATL_FREE_THREADED) ::CoSuspendClassObjects(); - if(!m_bActivity && m_nLockCnt == 0) + if(!m_bActivity && (m_nLockCnt == 0)) #endif break; } @@ -1825,7 +1069,7 @@ public: if(m_hEventShutdown == NULL) return false; DWORD dwThreadID = 0; -#if !defined(_ATL_MIN_CRT) && defined(_MT) && !defined(_WIN32_WCE) +#ifdef _MT HANDLE hThread = (HANDLE)_beginthreadex(NULL, 0, (UINT (WINAPI*)(void*))MonitorProc, this, 0, (UINT*)&dwThreadID); #else HANDLE hThread = ::CreateThread(NULL, 0, MonitorProc, this, 0, &dwThreadID); @@ -1842,322 +1086,35 @@ public: p->MonitorShutdown(); return 0; } - -#if (_ATL_VER < 0x0700) - // search for an occurence of string p2 in string p1 - static LPCTSTR FindOneOf(LPCTSTR p1, LPCTSTR p2) - { - while(p1 != NULL && *p1 != NULL) - { - LPCTSTR p = p2; - while(p != NULL && *p != NULL) - { - if(*p1 == *p) - return ::CharNext(p1); - p = ::CharNext(p); - } - p1 = ::CharNext(p1); - } - return NULL; - } -#endif // (_ATL_VER < 0x0700) }; /////////////////////////////////////////////////////////////////////////////// -// CRegKeyEx - adds type-specific methods to ATL3 CRegKey - -#if (_ATL_VER < 0x0700) - -class CRegKeyEx : public ATL::CRegKey -{ -public: -// Constructors and operators - CRegKeyEx(HKEY hKey = NULL) - { - m_hKey = hKey; - } - - CRegKeyEx(CRegKeyEx& key) - { - Attach(key.Detach()); - } - - CRegKeyEx& operator =(CRegKeyEx& key) - { - Close(); - Attach(key.Detach()); - return *this; - } - -// Methods - LONG SetValue(LPCTSTR pszValueName, DWORD dwType, const void* pValue, ULONG nBytes) - { - ATLASSERT(m_hKey != NULL); - return ::RegSetValueEx(m_hKey, pszValueName, NULL, dwType, static_cast(pValue), nBytes); - } - - LONG SetGUIDValue(LPCTSTR pszValueName, REFGUID guidValue) - { - ATLASSERT(m_hKey != NULL); - - OLECHAR szGUID[64] = { 0 }; - ::StringFromGUID2(guidValue, szGUID, 64); - - USES_CONVERSION; - LPCTSTR lpstr = OLE2CT(szGUID); -#ifndef _UNICODE - if(lpstr == NULL) - return E_OUTOFMEMORY; -#endif - return SetStringValue(pszValueName, lpstr); - } - - LONG SetBinaryValue(LPCTSTR pszValueName, const void* pValue, ULONG nBytes) - { - ATLASSERT(m_hKey != NULL); - return ::RegSetValueEx(m_hKey, pszValueName, NULL, REG_BINARY, reinterpret_cast(pValue), nBytes); - } - - LONG SetDWORDValue(LPCTSTR pszValueName, DWORD dwValue) - { - ATLASSERT(m_hKey != NULL); - return ::RegSetValueEx(m_hKey, pszValueName, NULL, REG_DWORD, reinterpret_cast(&dwValue), sizeof(DWORD)); - } - -#ifndef _WIN32_WCE - LONG SetQWORDValue(LPCTSTR pszValueName, ULONGLONG qwValue) - { - ATLASSERT(m_hKey != NULL); - return ::RegSetValueEx(m_hKey, pszValueName, NULL, REG_QWORD, reinterpret_cast(&qwValue), sizeof(ULONGLONG)); - } -#endif - - LONG SetStringValue(LPCTSTR pszValueName, LPCTSTR pszValue, DWORD dwType = REG_SZ) - { - ATLASSERT(m_hKey != NULL); - if(pszValue == NULL) - { - ATLASSERT(FALSE); - return ERROR_INVALID_DATA; - } - ATLASSERT((dwType == REG_SZ) || (dwType == REG_EXPAND_SZ)); - - return ::RegSetValueEx(m_hKey, pszValueName, NULL, dwType, reinterpret_cast(pszValue), (lstrlen(pszValue) + 1) * sizeof(TCHAR)); - } - - LONG SetMultiStringValue(LPCTSTR pszValueName, LPCTSTR pszValue) - { - ATLASSERT(m_hKey != NULL); - if(pszValue == NULL) - { - ATLASSERT(FALSE); - return ERROR_INVALID_DATA; - } - - ULONG nBytes = 0; - ULONG nLength = 0; - LPCTSTR pszTemp = pszValue; - do - { - nLength = lstrlen(pszTemp) + 1; - pszTemp += nLength; - nBytes += nLength * sizeof(TCHAR); - } while (nLength != 1); - - return ::RegSetValueEx(m_hKey, pszValueName, NULL, REG_MULTI_SZ, reinterpret_cast(pszValue), nBytes); - } - - LONG QueryValue(LPCTSTR pszValueName, DWORD* pdwType, void* pData, ULONG* pnBytes) - { - ATLASSERT(m_hKey != NULL); - return ::RegQueryValueEx(m_hKey, pszValueName, NULL, pdwType, static_cast(pData), pnBytes); - } - - LONG QueryGUIDValue(LPCTSTR pszValueName, GUID& guidValue) - { - ATLASSERT(m_hKey != NULL); - - guidValue = GUID_NULL; - - TCHAR szGUID[64] = { 0 }; - ULONG nCount = 64; - LONG lRes = QueryStringValue(pszValueName, szGUID, &nCount); - - if (lRes != ERROR_SUCCESS) - return lRes; - - if(szGUID[0] != _T('{')) - return ERROR_INVALID_DATA; - - USES_CONVERSION; - LPOLESTR lpstr = T2OLE(szGUID); -#ifndef _UNICODE - if(lpstr == NULL) - return E_OUTOFMEMORY; -#endif - - HRESULT hr = ::CLSIDFromString(lpstr, &guidValue); - if (FAILED(hr)) - return ERROR_INVALID_DATA; - - return ERROR_SUCCESS; - } - - LONG QueryBinaryValue(LPCTSTR pszValueName, void* pValue, ULONG* pnBytes) - { - ATLASSERT(pnBytes != NULL); - ATLASSERT(m_hKey != NULL); - - DWORD dwType = 0; - LONG lRes = ::RegQueryValueEx(m_hKey, pszValueName, NULL, &dwType, reinterpret_cast(pValue), pnBytes); - if (lRes != ERROR_SUCCESS) - return lRes; - if (dwType != REG_BINARY) - return ERROR_INVALID_DATA; - - return ERROR_SUCCESS; - } - - LONG QueryDWORDValue(LPCTSTR pszValueName, DWORD& dwValue) - { - ATLASSERT(m_hKey != NULL); - - ULONG nBytes = sizeof(DWORD); - DWORD dwType = 0; - LONG lRes = ::RegQueryValueEx(m_hKey, pszValueName, NULL, &dwType, reinterpret_cast(&dwValue), &nBytes); - if (lRes != ERROR_SUCCESS) - return lRes; - if (dwType != REG_DWORD) - return ERROR_INVALID_DATA; - - return ERROR_SUCCESS; - } - -#ifndef _WIN32_WCE - LONG QueryQWORDValue(LPCTSTR pszValueName, ULONGLONG& qwValue) - { - ATLASSERT(m_hKey != NULL); - - ULONG nBytes = sizeof(ULONGLONG); - DWORD dwType = 0; - LONG lRes = ::RegQueryValueEx(m_hKey, pszValueName, NULL, &dwType, reinterpret_cast(&qwValue), &nBytes); - if (lRes != ERROR_SUCCESS) - return lRes; - if (dwType != REG_QWORD) - return ERROR_INVALID_DATA; - - return ERROR_SUCCESS; - } -#endif - - LONG QueryStringValue(LPCTSTR pszValueName, LPTSTR pszValue, ULONG* pnChars) - { - ATLASSERT(m_hKey != NULL); - ATLASSERT(pnChars != NULL); - - ULONG nBytes = (*pnChars) * sizeof(TCHAR); - DWORD dwType = 0; - *pnChars = 0; - LONG lRes = ::RegQueryValueEx(m_hKey, pszValueName, NULL, &dwType, reinterpret_cast(pszValue), &nBytes); - - if (lRes != ERROR_SUCCESS) - { - return lRes; - } - - if(dwType != REG_SZ && dwType != REG_EXPAND_SZ) - { - return ERROR_INVALID_DATA; - } - - if (pszValue != NULL) - { - if(nBytes != 0) - { - if ((nBytes % sizeof(TCHAR) != 0) || (pszValue[nBytes / sizeof(TCHAR) -1] != 0)) - return ERROR_INVALID_DATA; - } - else - { - pszValue[0] = _T('\0'); - } - } - - *pnChars = nBytes / sizeof(TCHAR); - - return ERROR_SUCCESS; - } - - LONG QueryMultiStringValue(LPCTSTR pszValueName, LPTSTR pszValue, ULONG* pnChars) - { - ATLASSERT(m_hKey != NULL); - ATLASSERT(pnChars != NULL); - - if (pszValue != NULL && *pnChars < 2) - return ERROR_INSUFFICIENT_BUFFER; - - ULONG nBytes = (*pnChars) * sizeof(TCHAR); - DWORD dwType = 0; - *pnChars = 0; - LONG lRes = ::RegQueryValueEx(m_hKey, pszValueName, NULL, &dwType, reinterpret_cast(pszValue), &nBytes); - if (lRes != ERROR_SUCCESS) - return lRes; - if (dwType != REG_MULTI_SZ) - return ERROR_INVALID_DATA; - if (pszValue != NULL && (nBytes % sizeof(TCHAR) != 0 || nBytes / sizeof(TCHAR) < 1 || pszValue[nBytes / sizeof(TCHAR) - 1] != 0 || ((nBytes / sizeof(TCHAR)) > 1 && pszValue[nBytes / sizeof(TCHAR) - 2] != 0))) - return ERROR_INVALID_DATA; - - *pnChars = nBytes / sizeof(TCHAR); - - return ERROR_SUCCESS; - } -}; - -#else // !(_ATL_VER < 0x0700) +// CRegKeyEx - not used any more, here only for compatibility with old projects typedef ATL::CRegKey CRegKeyEx; -#endif // !(_ATL_VER < 0x0700) +} // namespace WTL /////////////////////////////////////////////////////////////////////////////// // CString forward reference (enables CString use in atluser.h and atlgdi.h) -#if defined(_WTL_FORWARD_DECLARE_CSTRING) && !defined(_WTL_USE_CSTRING) - #define _WTL_USE_CSTRING -#endif // defined(_WTL_FORWARD_DECLARE_CSTRING) && !defined(_WTL_USE_CSTRING) - -#ifdef _WTL_USE_CSTRING - class CString; // forward declaration (include atlmisc.h for the whole class) -#endif // _WTL_USE_CSTRING +#if (defined(_WTL_USE_CSTRING) || defined(_WTL_FORWARD_DECLARE_CSTRING)) && !defined(__ATLSTR_H__) + #include +#endif // CString namespace -#ifndef _CSTRING_NS - #ifdef __ATLSTR_H__ - #define _CSTRING_NS ATL - #else - #define _CSTRING_NS WTL - #endif -#endif // _CSTRING_NS +#define _CSTRING_NS ATL // Type classes namespace -#ifndef _WTYPES_NS - #ifdef __ATLTYPES_H__ - #define _WTYPES_NS - #else - #define _WTYPES_NS WTL - #endif -#endif // _WTYPES_NS - -}; // namespace WTL +#define _WTYPES_NS /////////////////////////////////////////////////////////////////////////////// -// General DLL version helpers -// (ATL3: excluded from atlbase.h if _ATL_DLL is defined; ATL11: removed) +// General DLL version helpers (removed in ATL11) -#if (((_ATL_VER < 0x0700) && defined(_ATL_DLL)) || (_ATL_VER >= 0x0B00)) && !defined(_WIN32_WCE) +#if (_ATL_VER >= 0x0B00) namespace ATL { @@ -2192,8 +1149,8 @@ inline HRESULT AtlGetDllVersion(LPCTSTR lpstrDllName, DLLVERSIONINFO* pDllVersio // IE 4.0 maj=4 min=71 inline HRESULT AtlGetCommCtrlVersion(LPDWORD pdwMajor, LPDWORD pdwMinor) { - ATLASSERT(pdwMajor != NULL && pdwMinor != NULL); - if(pdwMajor == NULL || pdwMinor == NULL) + ATLASSERT((pdwMajor != NULL) && (pdwMinor != NULL)); + if((pdwMajor == NULL) || (pdwMinor == NULL)) return E_INVALIDARG; DLLVERSIONINFO dvi; @@ -2225,8 +1182,8 @@ inline HRESULT AtlGetCommCtrlVersion(LPDWORD pdwMajor, LPDWORD pdwMinor) // IE 4.01 with Web Integrated Desktop maj=4 min=72 inline HRESULT AtlGetShellVersion(LPDWORD pdwMajor, LPDWORD pdwMinor) { - ATLASSERT(pdwMajor != NULL && pdwMinor != NULL); - if(pdwMajor == NULL || pdwMinor == NULL) + ATLASSERT((pdwMajor != NULL) && (pdwMinor != NULL)); + if((pdwMajor == NULL) || (pdwMinor == NULL)) return E_INVALIDARG; DLLVERSIONINFO dvi; @@ -2251,9 +1208,9 @@ inline HRESULT AtlGetShellVersion(LPDWORD pdwMajor, LPDWORD pdwMinor) return hRet; } -}; // namespace ATL +} // namespace ATL -#endif // (_ATL_VER < 0x0700) && defined(_ATL_DLL) && !defined(_WIN32_WCE) +#endif // (_ATL_VER >= 0x0B00) // These are always included diff --git a/ZbaSDK/SampleCode/PluginWinExe/WTL/atlcrack.h b/ZbaSDK/SampleCode/PluginWinExe/WTL/atlcrack.h index e824966f8bbe81babd1407ec17697b758a0013ea..da6a8963c80434f99476c6e2c0bb685b70f69e32 100644 --- a/ZbaSDK/SampleCode/PluginWinExe/WTL/atlcrack.h +++ b/ZbaSDK/SampleCode/PluginWinExe/WTL/atlcrack.h @@ -1,4 +1,4 @@ -// Windows Template Library - WTL version 9.10 +// Windows Template Library - WTL version 10.0 // Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. // // This file is a part of the Windows Template Library. @@ -20,9 +20,8 @@ // Message map macro for cracked handlers // Note about message maps with cracked handlers: -// For ATL 3.0, a message map using cracked handlers MUST use BEGIN_MSG_MAP_EX. -// For ATL 7.0 or higher, you can use BEGIN_MSG_MAP for CWindowImpl/CDialogImpl derived classes, -// but must use BEGIN_MSG_MAP_EX for classes that don't derive from CWindowImpl/CDialogImpl. +// You can use BEGIN_MSG_MAP for classes that derive from CWindowImpl/CDialogImpl, +// but must use BEGIN_MSG_MAP_EX for classes that don't. #define BEGIN_MSG_MAP_EX(theClass) \ public: \ @@ -64,9 +63,9 @@ public: \ #define MSG_WM_CREATE(func) \ if (uMsg == WM_CREATE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((LPCREATESTRUCT)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -74,9 +73,9 @@ public: \ #define MSG_WM_INITDIALOG(func) \ if (uMsg == WM_INITDIALOG) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((HWND)wParam, lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -84,9 +83,9 @@ public: \ #define MSG_WM_COPYDATA(func) \ if (uMsg == WM_COPYDATA) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((HWND)wParam, (PCOPYDATASTRUCT)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -94,10 +93,10 @@ public: \ #define MSG_WM_DESTROY(func) \ if (uMsg == WM_DESTROY) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func(); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -105,10 +104,10 @@ public: \ #define MSG_WM_MOVE(func) \ if (uMsg == WM_MOVE) \ { \ - SetMsgHandled(TRUE); \ - func(_WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + this->SetMsgHandled(TRUE); \ + func(::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -116,10 +115,10 @@ public: \ #define MSG_WM_SIZE(func) \ if (uMsg == WM_SIZE) \ { \ - SetMsgHandled(TRUE); \ - func((UINT)wParam, _WTYPES_NS::CSize(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CSize(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -127,10 +126,10 @@ public: \ #define MSG_WM_ACTIVATE(func) \ if (uMsg == WM_ACTIVATE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)LOWORD(wParam), (BOOL)HIWORD(wParam), (HWND)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -138,10 +137,10 @@ public: \ #define MSG_WM_SETFOCUS(func) \ if (uMsg == WM_SETFOCUS) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((HWND)wParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -149,10 +148,10 @@ public: \ #define MSG_WM_KILLFOCUS(func) \ if (uMsg == WM_KILLFOCUS) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((HWND)wParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -160,10 +159,10 @@ public: \ #define MSG_WM_ENABLE(func) \ if (uMsg == WM_ENABLE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((BOOL)wParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -171,10 +170,10 @@ public: \ #define MSG_WM_PAINT(func) \ if (uMsg == WM_PAINT) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((HDC)wParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -182,10 +181,10 @@ public: \ #define MSG_WM_CLOSE(func) \ if (uMsg == WM_CLOSE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func(); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -193,9 +192,9 @@ public: \ #define MSG_WM_QUERYENDSESSION(func) \ if (uMsg == WM_QUERYENDSESSION) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((UINT)wParam, (UINT)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -203,9 +202,9 @@ public: \ #define MSG_WM_QUERYOPEN(func) \ if (uMsg == WM_QUERYOPEN) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func(); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -213,9 +212,9 @@ public: \ #define MSG_WM_ERASEBKGND(func) \ if (uMsg == WM_ERASEBKGND) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((HDC)wParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -223,10 +222,10 @@ public: \ #define MSG_WM_SYSCOLORCHANGE(func) \ if (uMsg == WM_SYSCOLORCHANGE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func(); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -234,10 +233,10 @@ public: \ #define MSG_WM_ENDSESSION(func) \ if (uMsg == WM_ENDSESSION) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((BOOL)wParam, (UINT)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -245,10 +244,10 @@ public: \ #define MSG_WM_SHOWWINDOW(func) \ if (uMsg == WM_SHOWWINDOW) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((BOOL)wParam, (int)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -256,9 +255,9 @@ public: \ #define MSG_WM_CTLCOLOREDIT(func) \ if (uMsg == WM_CTLCOLOREDIT) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -266,9 +265,9 @@ public: \ #define MSG_WM_CTLCOLORLISTBOX(func) \ if (uMsg == WM_CTLCOLORLISTBOX) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -276,9 +275,9 @@ public: \ #define MSG_WM_CTLCOLORBTN(func) \ if (uMsg == WM_CTLCOLORBTN) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -286,9 +285,9 @@ public: \ #define MSG_WM_CTLCOLORDLG(func) \ if (uMsg == WM_CTLCOLORDLG) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -296,9 +295,9 @@ public: \ #define MSG_WM_CTLCOLORSCROLLBAR(func) \ if (uMsg == WM_CTLCOLORSCROLLBAR) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -306,9 +305,9 @@ public: \ #define MSG_WM_CTLCOLORSTATIC(func) \ if (uMsg == WM_CTLCOLORSTATIC) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -316,10 +315,10 @@ public: \ #define MSG_WM_SETTINGCHANGE(func) \ if (uMsg == WM_SETTINGCHANGE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)wParam, (LPCTSTR)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -327,10 +326,10 @@ public: \ #define MSG_WM_DEVMODECHANGE(func) \ if (uMsg == WM_DEVMODECHANGE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((LPCTSTR)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -338,10 +337,10 @@ public: \ #define MSG_WM_ACTIVATEAPP(func) \ if (uMsg == WM_ACTIVATEAPP) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((BOOL)wParam, (DWORD)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -349,10 +348,10 @@ public: \ #define MSG_WM_FONTCHANGE(func) \ if (uMsg == WM_FONTCHANGE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func(); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -360,10 +359,10 @@ public: \ #define MSG_WM_TIMECHANGE(func) \ if (uMsg == WM_TIMECHANGE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func(); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -371,10 +370,10 @@ public: \ #define MSG_WM_CANCELMODE(func) \ if (uMsg == WM_CANCELMODE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func(); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -382,9 +381,9 @@ public: \ #define MSG_WM_SETCURSOR(func) \ if (uMsg == WM_SETCURSOR) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((HWND)wParam, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam)); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -392,9 +391,9 @@ public: \ #define MSG_WM_MOUSEACTIVATE(func) \ if (uMsg == WM_MOUSEACTIVATE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((HWND)wParam, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam)); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -402,10 +401,10 @@ public: \ #define MSG_WM_CHILDACTIVATE(func) \ if (uMsg == WM_CHILDACTIVATE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func(); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -413,10 +412,10 @@ public: \ #define MSG_WM_GETMINMAXINFO(func) \ if (uMsg == WM_GETMINMAXINFO) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((LPMINMAXINFO)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -424,10 +423,10 @@ public: \ #define MSG_WM_ICONERASEBKGND(func) \ if (uMsg == WM_ICONERASEBKGND) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((HDC)wParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -435,10 +434,10 @@ public: \ #define MSG_WM_SPOOLERSTATUS(func) \ if (uMsg == WM_SPOOLERSTATUS) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)wParam, (UINT)LOWORD(lParam)); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -446,10 +445,10 @@ public: \ #define MSG_WM_DRAWITEM(func) \ if (uMsg == WM_DRAWITEM) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)wParam, (LPDRAWITEMSTRUCT)lParam); \ lResult = TRUE; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -457,10 +456,10 @@ public: \ #define MSG_WM_MEASUREITEM(func) \ if (uMsg == WM_MEASUREITEM) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)wParam, (LPMEASUREITEMSTRUCT)lParam); \ lResult = TRUE; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -468,10 +467,10 @@ public: \ #define MSG_WM_DELETEITEM(func) \ if (uMsg == WM_DELETEITEM) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)wParam, (LPDELETEITEMSTRUCT)lParam); \ lResult = TRUE; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -479,9 +478,9 @@ public: \ #define MSG_WM_CHARTOITEM(func) \ if (uMsg == WM_CHARTOITEM) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), (HWND)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -489,9 +488,9 @@ public: \ #define MSG_WM_VKEYTOITEM(func) \ if (uMsg == WM_VKEYTOITEM) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), (HWND)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -499,9 +498,9 @@ public: \ #define MSG_WM_QUERYDRAGICON(func) \ if (uMsg == WM_QUERYDRAGICON) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func(); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -509,9 +508,9 @@ public: \ #define MSG_WM_COMPAREITEM(func) \ if (uMsg == WM_COMPAREITEM) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((UINT)wParam, (LPCOMPAREITEMSTRUCT)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -519,10 +518,10 @@ public: \ #define MSG_WM_COMPACTING(func) \ if (uMsg == WM_COMPACTING) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)wParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -530,9 +529,9 @@ public: \ #define MSG_WM_NCCREATE(func) \ if (uMsg == WM_NCCREATE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((LPCREATESTRUCT)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -540,10 +539,10 @@ public: \ #define MSG_WM_NCDESTROY(func) \ if (uMsg == WM_NCDESTROY) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func(); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -551,9 +550,9 @@ public: \ #define MSG_WM_NCCALCSIZE(func) \ if (uMsg == WM_NCCALCSIZE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = func((BOOL)wParam, lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -561,9 +560,9 @@ public: \ #define MSG_WM_NCHITTEST(func) \ if (uMsg == WM_NCHITTEST) \ { \ - SetMsgHandled(TRUE); \ - lResult = (LRESULT)func(_WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ - if(IsMsgHandled()) \ + this->SetMsgHandled(TRUE); \ + lResult = (LRESULT)func(::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -571,10 +570,10 @@ public: \ #define MSG_WM_NCPAINT(func) \ if (uMsg == WM_NCPAINT) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((HRGN)wParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -582,9 +581,9 @@ public: \ #define MSG_WM_NCACTIVATE(func) \ if (uMsg == WM_NCACTIVATE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((BOOL)wParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -592,9 +591,9 @@ public: \ #define MSG_WM_GETDLGCODE(func) \ if (uMsg == WM_GETDLGCODE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((LPMSG)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -602,10 +601,10 @@ public: \ #define MSG_WM_NCMOUSEMOVE(func) \ if (uMsg == WM_NCMOUSEMOVE) \ { \ - SetMsgHandled(TRUE); \ - func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -613,10 +612,10 @@ public: \ #define MSG_WM_NCLBUTTONDOWN(func) \ if (uMsg == WM_NCLBUTTONDOWN) \ { \ - SetMsgHandled(TRUE); \ - func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -624,10 +623,10 @@ public: \ #define MSG_WM_NCLBUTTONUP(func) \ if (uMsg == WM_NCLBUTTONUP) \ { \ - SetMsgHandled(TRUE); \ - func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -635,10 +634,10 @@ public: \ #define MSG_WM_NCLBUTTONDBLCLK(func) \ if (uMsg == WM_NCLBUTTONDBLCLK) \ { \ - SetMsgHandled(TRUE); \ - func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -646,10 +645,10 @@ public: \ #define MSG_WM_NCRBUTTONDOWN(func) \ if (uMsg == WM_NCRBUTTONDOWN) \ { \ - SetMsgHandled(TRUE); \ - func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -657,10 +656,10 @@ public: \ #define MSG_WM_NCRBUTTONUP(func) \ if (uMsg == WM_NCRBUTTONUP) \ { \ - SetMsgHandled(TRUE); \ - func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -668,10 +667,10 @@ public: \ #define MSG_WM_NCRBUTTONDBLCLK(func) \ if (uMsg == WM_NCRBUTTONDBLCLK) \ { \ - SetMsgHandled(TRUE); \ - func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -679,10 +678,10 @@ public: \ #define MSG_WM_NCMBUTTONDOWN(func) \ if (uMsg == WM_NCMBUTTONDOWN) \ { \ - SetMsgHandled(TRUE); \ - func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -690,10 +689,10 @@ public: \ #define MSG_WM_NCMBUTTONUP(func) \ if (uMsg == WM_NCMBUTTONUP) \ { \ - SetMsgHandled(TRUE); \ - func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -701,10 +700,10 @@ public: \ #define MSG_WM_NCMBUTTONDBLCLK(func) \ if (uMsg == WM_NCMBUTTONDBLCLK) \ { \ - SetMsgHandled(TRUE); \ - func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -712,10 +711,10 @@ public: \ #define MSG_WM_KEYDOWN(func) \ if (uMsg == WM_KEYDOWN) \ { \ - SetMsgHandled(TRUE); \ - func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -723,32 +722,32 @@ public: \ #define MSG_WM_KEYUP(func) \ if (uMsg == WM_KEYUP) \ { \ - SetMsgHandled(TRUE); \ - func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } -// void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) +// void OnChar(TCHAR chChar, UINT nRepCnt, UINT nFlags) #define MSG_WM_CHAR(func) \ if (uMsg == WM_CHAR) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } -// void OnDeadChar(UINT nChar, UINT nRepCnt, UINT nFlags) +// void OnDeadChar(TCHAR chChar, UINT nRepCnt, UINT nFlags) #define MSG_WM_DEADCHAR(func) \ if (uMsg == WM_DEADCHAR) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -756,10 +755,10 @@ public: \ #define MSG_WM_SYSKEYDOWN(func) \ if (uMsg == WM_SYSKEYDOWN) \ { \ - SetMsgHandled(TRUE); \ - func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -767,32 +766,32 @@ public: \ #define MSG_WM_SYSKEYUP(func) \ if (uMsg == WM_SYSKEYUP) \ { \ - SetMsgHandled(TRUE); \ - func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } -// void OnSysChar(UINT nChar, UINT nRepCnt, UINT nFlags) +// void OnSysChar(TCHAR chChar, UINT nRepCnt, UINT nFlags) #define MSG_WM_SYSCHAR(func) \ if (uMsg == WM_SYSCHAR) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } -// void OnSysDeadChar(UINT nChar, UINT nRepCnt, UINT nFlags) +// void OnSysDeadChar(TCHAR chChar, UINT nRepCnt, UINT nFlags) #define MSG_WM_SYSDEADCHAR(func) \ if (uMsg == WM_SYSDEADCHAR) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -800,10 +799,10 @@ public: \ #define MSG_WM_SYSCOMMAND(func) \ if (uMsg == WM_SYSCOMMAND) \ { \ - SetMsgHandled(TRUE); \ - func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -811,10 +810,10 @@ public: \ #define MSG_WM_TCARD(func) \ if (uMsg == WM_TCARD) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)wParam, (DWORD)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -822,10 +821,10 @@ public: \ #define MSG_WM_TIMER(func) \ if (uMsg == WM_TIMER) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT_PTR)wParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -833,10 +832,10 @@ public: \ #define MSG_WM_HSCROLL(func) \ if (uMsg == WM_HSCROLL) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((int)LOWORD(wParam), (short)HIWORD(wParam), (HWND)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -844,10 +843,10 @@ public: \ #define MSG_WM_VSCROLL(func) \ if (uMsg == WM_VSCROLL) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((int)LOWORD(wParam), (short)HIWORD(wParam), (HWND)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -855,10 +854,10 @@ public: \ #define MSG_WM_INITMENU(func) \ if (uMsg == WM_INITMENU) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((HMENU)wParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -866,10 +865,10 @@ public: \ #define MSG_WM_INITMENUPOPUP(func) \ if (uMsg == WM_INITMENUPOPUP) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((HMENU)wParam, (UINT)LOWORD(lParam), (BOOL)HIWORD(lParam)); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -877,10 +876,10 @@ public: \ #define MSG_WM_MENUSELECT(func) \ if (uMsg == WM_MENUSELECT) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), (HMENU)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -888,9 +887,9 @@ public: \ #define MSG_WM_MENUCHAR(func) \ if (uMsg == WM_MENUCHAR) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = func((TCHAR)LOWORD(wParam), (UINT)HIWORD(wParam), (HMENU)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -898,9 +897,9 @@ public: \ #define MSG_WM_NOTIFY(func) \ if (uMsg == WM_NOTIFY) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = func((int)wParam, (LPNMHDR)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -908,10 +907,10 @@ public: \ #define MSG_WM_ENTERIDLE(func) \ if (uMsg == WM_ENTERIDLE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)wParam, (HWND)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -919,10 +918,10 @@ public: \ #define MSG_WM_MOUSEMOVE(func) \ if (uMsg == WM_MOUSEMOVE) \ { \ - SetMsgHandled(TRUE); \ - func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -930,9 +929,9 @@ public: \ #define MSG_WM_MOUSEWHEEL(func) \ if (uMsg == WM_MOUSEWHEEL) \ { \ - SetMsgHandled(TRUE); \ - lResult = (LRESULT)func((UINT)LOWORD(wParam), (short)HIWORD(wParam), _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ - if(IsMsgHandled()) \ + this->SetMsgHandled(TRUE); \ + lResult = (LRESULT)func((UINT)LOWORD(wParam), (short)HIWORD(wParam), ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -940,10 +939,10 @@ public: \ #define MSG_WM_LBUTTONDOWN(func) \ if (uMsg == WM_LBUTTONDOWN) \ { \ - SetMsgHandled(TRUE); \ - func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -951,10 +950,10 @@ public: \ #define MSG_WM_LBUTTONUP(func) \ if (uMsg == WM_LBUTTONUP) \ { \ - SetMsgHandled(TRUE); \ - func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -962,10 +961,10 @@ public: \ #define MSG_WM_LBUTTONDBLCLK(func) \ if (uMsg == WM_LBUTTONDBLCLK) \ { \ - SetMsgHandled(TRUE); \ - func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -973,10 +972,10 @@ public: \ #define MSG_WM_RBUTTONDOWN(func) \ if (uMsg == WM_RBUTTONDOWN) \ { \ - SetMsgHandled(TRUE); \ - func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -984,10 +983,10 @@ public: \ #define MSG_WM_RBUTTONUP(func) \ if (uMsg == WM_RBUTTONUP) \ { \ - SetMsgHandled(TRUE); \ - func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -995,10 +994,10 @@ public: \ #define MSG_WM_RBUTTONDBLCLK(func) \ if (uMsg == WM_RBUTTONDBLCLK) \ { \ - SetMsgHandled(TRUE); \ - func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1006,10 +1005,10 @@ public: \ #define MSG_WM_MBUTTONDOWN(func) \ if (uMsg == WM_MBUTTONDOWN) \ { \ - SetMsgHandled(TRUE); \ - func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1017,10 +1016,10 @@ public: \ #define MSG_WM_MBUTTONUP(func) \ if (uMsg == WM_MBUTTONUP) \ { \ - SetMsgHandled(TRUE); \ - func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1028,10 +1027,10 @@ public: \ #define MSG_WM_MBUTTONDBLCLK(func) \ if (uMsg == WM_MBUTTONDBLCLK) \ { \ - SetMsgHandled(TRUE); \ - func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1039,21 +1038,21 @@ public: \ #define MSG_WM_PARENTNOTIFY(func) \ if (uMsg == WM_PARENTNOTIFY) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } -// void OnMDIActivate(CWindow wndActivate, CWindow wndDeactivate) +// void OnMDIActivate(CWindow wndDeactivate, CWindow wndActivate) #define MSG_WM_MDIACTIVATE(func) \ if (uMsg == WM_MDIACTIVATE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((HWND)wParam, (HWND)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1061,10 +1060,10 @@ public: \ #define MSG_WM_RENDERFORMAT(func) \ if (uMsg == WM_RENDERFORMAT) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)wParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1072,10 +1071,10 @@ public: \ #define MSG_WM_RENDERALLFORMATS(func) \ if (uMsg == WM_RENDERALLFORMATS) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func(); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1083,10 +1082,10 @@ public: \ #define MSG_WM_DESTROYCLIPBOARD(func) \ if (uMsg == WM_DESTROYCLIPBOARD) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func(); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1094,10 +1093,10 @@ public: \ #define MSG_WM_DRAWCLIPBOARD(func) \ if (uMsg == WM_DRAWCLIPBOARD) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func(); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1105,11 +1104,11 @@ public: \ #define MSG_WM_PAINTCLIPBOARD(func) \ if (uMsg == WM_PAINTCLIPBOARD) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((HWND)wParam, (const LPPAINTSTRUCT)::GlobalLock((HGLOBAL)lParam)); \ ::GlobalUnlock((HGLOBAL)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1117,10 +1116,10 @@ public: \ #define MSG_WM_VSCROLLCLIPBOARD(func) \ if (uMsg == WM_VSCROLLCLIPBOARD) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((HWND)wParam, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam)); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1128,10 +1127,10 @@ public: \ #define MSG_WM_CONTEXTMENU(func) \ if (uMsg == WM_CONTEXTMENU) \ { \ - SetMsgHandled(TRUE); \ - func((HWND)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + this->SetMsgHandled(TRUE); \ + func((HWND)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1139,11 +1138,11 @@ public: \ #define MSG_WM_SIZECLIPBOARD(func) \ if (uMsg == WM_SIZECLIPBOARD) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((HWND)wParam, (const LPRECT)::GlobalLock((HGLOBAL)lParam)); \ ::GlobalUnlock((HGLOBAL)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1151,10 +1150,10 @@ public: \ #define MSG_WM_ASKCBFORMATNAME(func) \ if (uMsg == WM_ASKCBFORMATNAME) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)wParam, (LPTSTR)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1162,10 +1161,10 @@ public: \ #define MSG_WM_CHANGECBCHAIN(func) \ if (uMsg == WM_CHANGECBCHAIN) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((HWND)wParam, (HWND)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1173,10 +1172,10 @@ public: \ #define MSG_WM_HSCROLLCLIPBOARD(func) \ if (uMsg == WM_HSCROLLCLIPBOARD) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((HWND)wParam, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam)); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1184,9 +1183,9 @@ public: \ #define MSG_WM_QUERYNEWPALETTE(func) \ if (uMsg == WM_QUERYNEWPALETTE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func(); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1194,10 +1193,10 @@ public: \ #define MSG_WM_PALETTECHANGED(func) \ if (uMsg == WM_PALETTECHANGED) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((HWND)wParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1205,10 +1204,10 @@ public: \ #define MSG_WM_PALETTEISCHANGING(func) \ if (uMsg == WM_PALETTEISCHANGING) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((HWND)wParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1216,10 +1215,10 @@ public: \ #define MSG_WM_DROPFILES(func) \ if (uMsg == WM_DROPFILES) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((HDROP)wParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1227,10 +1226,10 @@ public: \ #define MSG_WM_WINDOWPOSCHANGING(func) \ if (uMsg == WM_WINDOWPOSCHANGING) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((LPWINDOWPOS)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1238,10 +1237,10 @@ public: \ #define MSG_WM_WINDOWPOSCHANGED(func) \ if (uMsg == WM_WINDOWPOSCHANGED) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((LPWINDOWPOS)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1249,10 +1248,10 @@ public: \ #define MSG_WM_EXITMENULOOP(func) \ if (uMsg == WM_EXITMENULOOP) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((BOOL)wParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1260,10 +1259,10 @@ public: \ #define MSG_WM_ENTERMENULOOP(func) \ if (uMsg == WM_ENTERMENULOOP) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((BOOL)wParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1271,10 +1270,10 @@ public: \ #define MSG_WM_STYLECHANGED(func) \ if (uMsg == WM_STYLECHANGED) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)wParam, (LPSTYLESTRUCT)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1282,10 +1281,10 @@ public: \ #define MSG_WM_STYLECHANGING(func) \ if (uMsg == WM_STYLECHANGING) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)wParam, (LPSTYLESTRUCT)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1293,10 +1292,10 @@ public: \ #define MSG_WM_SIZING(func) \ if (uMsg == WM_SIZING) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)wParam, (LPRECT)lParam); \ lResult = TRUE; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1304,10 +1303,10 @@ public: \ #define MSG_WM_MOVING(func) \ if (uMsg == WM_MOVING) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)wParam, (LPRECT)lParam); \ lResult = TRUE; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1315,10 +1314,10 @@ public: \ #define MSG_WM_CAPTURECHANGED(func) \ if (uMsg == WM_CAPTURECHANGED) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((HWND)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1326,9 +1325,9 @@ public: \ #define MSG_WM_DEVICECHANGE(func) \ if (uMsg == WM_DEVICECHANGE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((UINT)wParam, (DWORD_PTR)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1336,10 +1335,10 @@ public: \ #define MSG_WM_COMMAND(func) \ if (uMsg == WM_COMMAND) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1347,10 +1346,10 @@ public: \ #define MSG_WM_DISPLAYCHANGE(func) \ if (uMsg == WM_DISPLAYCHANGE) \ { \ - SetMsgHandled(TRUE); \ - func((UINT)wParam, _WTYPES_NS::CSize(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CSize(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1358,10 +1357,10 @@ public: \ #define MSG_WM_ENTERSIZEMOVE(func) \ if (uMsg == WM_ENTERSIZEMOVE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func(); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1369,10 +1368,10 @@ public: \ #define MSG_WM_EXITSIZEMOVE(func) \ if (uMsg == WM_EXITSIZEMOVE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func(); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1380,9 +1379,9 @@ public: \ #define MSG_WM_GETFONT(func) \ if (uMsg == WM_GETFONT) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func(); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1390,9 +1389,9 @@ public: \ #define MSG_WM_GETHOTKEY(func) \ if (uMsg == WM_GETHOTKEY) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = func(); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1400,9 +1399,9 @@ public: \ #define MSG_WM_GETICON(func) \ if (uMsg == WM_GETICON) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((UINT)wParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1410,9 +1409,9 @@ public: \ #define MSG_WM_GETTEXT(func) \ if (uMsg == WM_GETTEXT) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((int)wParam, (LPTSTR)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1420,9 +1419,9 @@ public: \ #define MSG_WM_GETTEXTLENGTH(func) \ if (uMsg == WM_GETTEXTLENGTH) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func(); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1430,10 +1429,10 @@ public: \ #define MSG_WM_HELP(func) \ if (uMsg == WM_HELP) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((LPHELPINFO)lParam); \ lResult = TRUE; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1441,10 +1440,10 @@ public: \ #define MSG_WM_HOTKEY(func) \ if (uMsg == WM_HOTKEY) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((int)wParam, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam)); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1452,10 +1451,10 @@ public: \ #define MSG_WM_INPUTLANGCHANGE(func) \ if (uMsg == WM_INPUTLANGCHANGE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((DWORD)wParam, (HKL)lParam); \ lResult = TRUE; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1463,10 +1462,10 @@ public: \ #define MSG_WM_INPUTLANGCHANGEREQUEST(func) \ if (uMsg == WM_INPUTLANGCHANGEREQUEST) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((BOOL)wParam, (HKL)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1474,10 +1473,10 @@ public: \ #define MSG_WM_NEXTDLGCTL(func) \ if (uMsg == WM_NEXTDLGCTL) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((BOOL)LOWORD(lParam), wParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1485,10 +1484,10 @@ public: \ #define MSG_WM_NEXTMENU(func) \ if (uMsg == WM_NEXTMENU) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((int)wParam, (LPMDINEXTMENU)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1496,9 +1495,9 @@ public: \ #define MSG_WM_NOTIFYFORMAT(func) \ if (uMsg == WM_NOTIFYFORMAT) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((HWND)wParam, (int)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1506,9 +1505,9 @@ public: \ #define MSG_WM_POWERBROADCAST(func) \ if (uMsg == WM_POWERBROADCAST) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((DWORD)wParam, (DWORD_PTR)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1516,10 +1515,10 @@ public: \ #define MSG_WM_PRINT(func) \ if (uMsg == WM_PRINT) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((HDC)wParam, (UINT)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1527,10 +1526,10 @@ public: \ #define MSG_WM_PRINTCLIENT(func) \ if (uMsg == WM_PRINTCLIENT) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((HDC)wParam, (UINT)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1538,10 +1537,10 @@ public: \ #define MSG_WM_RASDIALEVENT(func) \ if (uMsg == WM_RASDIALEVENT) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((RASCONNSTATE)wParam, (DWORD)lParam); \ lResult = TRUE; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1549,10 +1548,10 @@ public: \ #define MSG_WM_SETFONT(func) \ if (uMsg == WM_SETFONT) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((HFONT)wParam, (BOOL)LOWORD(lParam)); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1560,9 +1559,9 @@ public: \ #define MSG_WM_SETHOTKEY(func) \ if (uMsg == WM_SETHOTKEY) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((int)LOBYTE(LOWORD(wParam)), (UINT)HIBYTE(LOWORD(wParam))); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1570,9 +1569,9 @@ public: \ #define MSG_WM_SETICON(func) \ if (uMsg == WM_SETICON) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((UINT)wParam, (HICON)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1580,10 +1579,10 @@ public: \ #define MSG_WM_SETREDRAW(func) \ if (uMsg == WM_SETREDRAW) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((BOOL)wParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1591,9 +1590,9 @@ public: \ #define MSG_WM_SETTEXT(func) \ if (uMsg == WM_SETTEXT) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((LPCTSTR)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1601,26 +1600,24 @@ public: \ #define MSG_WM_USERCHANGED(func) \ if (uMsg == WM_USERCHANGED) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func(); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } /////////////////////////////////////////////////////////////////////////////// -// New NT4 & NT5 messages - -#if (_WIN32_WINNT >= 0x0400) +// Newer Windows messages // void OnMouseHover(WPARAM wParam, CPoint ptPos) #define MSG_WM_MOUSEHOVER(func) \ if (uMsg == WM_MOUSEHOVER) \ { \ - SetMsgHandled(TRUE); \ - func(wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + this->SetMsgHandled(TRUE); \ + func(wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1628,25 +1625,43 @@ public: \ #define MSG_WM_MOUSELEAVE(func) \ if (uMsg == WM_MOUSELEAVE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func(); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } -#endif // _WIN32_WINNT >= 0x0400 +// void OnNcMouseHover(UINT nHitTest, CPoint ptPos) +#define MSG_WM_NCMOUSEHOVER(func) \ + if (uMsg == WM_NCMOUSEHOVER) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(MAKEPOINTS(lParam).x, MAKEPOINTS(lParam).y)); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } -#if (WINVER >= 0x0500) +// void OnNcMouseLeave() +#define MSG_WM_NCMOUSELEAVE(func) \ + if (uMsg == WM_NCMOUSELEAVE) \ + { \ + this->SetMsgHandled(TRUE); \ + func(); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } // void OnMenuRButtonUp(WPARAM wParam, CMenuHandle menu) #define MSG_WM_MENURBUTTONUP(func) \ if (uMsg == WM_MENURBUTTONUP) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func(wParam, (HMENU)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1654,9 +1669,9 @@ public: \ #define MSG_WM_MENUDRAG(func) \ if (uMsg == WM_MENUDRAG) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = func(wParam, (HMENU)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1664,9 +1679,9 @@ public: \ #define MSG_WM_MENUGETOBJECT(func) \ if (uMsg == WM_MENUGETOBJECT) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = func((PMENUGETOBJECTINFO)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1674,10 +1689,10 @@ public: \ #define MSG_WM_UNINITMENUPOPUP(func) \ if (uMsg == WM_UNINITMENUPOPUP) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)HIWORD(lParam), (HMENU)wParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1685,24 +1700,20 @@ public: \ #define MSG_WM_MENUCOMMAND(func) \ if (uMsg == WM_MENUCOMMAND) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func(wParam, (HMENU)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } -#endif // WINVER >= 0x0500 - -#if (_WIN32_WINNT >= 0x0500) - // BOOL OnAppCommand(CWindow wndFocus, short cmd, WORD uDevice, int dwKeys) #define MSG_WM_APPCOMMAND(func) \ if (uMsg == WM_APPCOMMAND) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((HWND)wParam, GET_APPCOMMAND_LPARAM(lParam), GET_DEVICE_LPARAM(lParam), GET_KEYSTATE_LPARAM(lParam)); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1710,10 +1721,10 @@ public: \ #define MSG_WM_NCXBUTTONDOWN(func) \ if (uMsg == WM_NCXBUTTONDOWN) \ { \ - SetMsgHandled(TRUE); \ - func(GET_XBUTTON_WPARAM(wParam), GET_NCHITTEST_WPARAM(wParam), _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ - lResult = 0; \ - if(IsMsgHandled()) \ + this->SetMsgHandled(TRUE); \ + func(GET_XBUTTON_WPARAM(wParam), GET_NCHITTEST_WPARAM(wParam), ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + lResult = (LRESULT)TRUE; \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1721,10 +1732,10 @@ public: \ #define MSG_WM_NCXBUTTONUP(func) \ if (uMsg == WM_NCXBUTTONUP) \ { \ - SetMsgHandled(TRUE); \ - func(GET_XBUTTON_WPARAM(wParam), GET_NCHITTEST_WPARAM(wParam), _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ - lResult = 0; \ - if(IsMsgHandled()) \ + this->SetMsgHandled(TRUE); \ + func(GET_XBUTTON_WPARAM(wParam), GET_NCHITTEST_WPARAM(wParam), ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + lResult = (LRESULT)TRUE; \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1732,10 +1743,10 @@ public: \ #define MSG_WM_NCXBUTTONDBLCLK(func) \ if (uMsg == WM_NCXBUTTONDBLCLK) \ { \ - SetMsgHandled(TRUE); \ - func(GET_XBUTTON_WPARAM(wParam), GET_NCHITTEST_WPARAM(wParam), _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ - lResult = 0; \ - if(IsMsgHandled()) \ + this->SetMsgHandled(TRUE); \ + func(GET_XBUTTON_WPARAM(wParam), GET_NCHITTEST_WPARAM(wParam), ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + lResult = (LRESULT)TRUE; \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1743,10 +1754,10 @@ public: \ #define MSG_WM_XBUTTONDOWN(func) \ if (uMsg == WM_XBUTTONDOWN) \ { \ - SetMsgHandled(TRUE); \ - func(GET_XBUTTON_WPARAM(wParam), GET_KEYSTATE_WPARAM(wParam), _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ - lResult = 0; \ - if(IsMsgHandled()) \ + this->SetMsgHandled(TRUE); \ + func(GET_XBUTTON_WPARAM(wParam), GET_KEYSTATE_WPARAM(wParam), ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + lResult = (LRESULT)TRUE; \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1754,10 +1765,10 @@ public: \ #define MSG_WM_XBUTTONUP(func) \ if (uMsg == WM_XBUTTONUP) \ { \ - SetMsgHandled(TRUE); \ - func(GET_XBUTTON_WPARAM(wParam), GET_KEYSTATE_WPARAM(wParam), _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ - lResult = 0; \ - if(IsMsgHandled()) \ + this->SetMsgHandled(TRUE); \ + func(GET_XBUTTON_WPARAM(wParam), GET_KEYSTATE_WPARAM(wParam), ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + lResult = (LRESULT)TRUE; \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1765,10 +1776,10 @@ public: \ #define MSG_WM_XBUTTONDBLCLK(func) \ if (uMsg == WM_XBUTTONDBLCLK) \ { \ - SetMsgHandled(TRUE); \ - func(GET_XBUTTON_WPARAM(wParam), GET_KEYSTATE_WPARAM(wParam), _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ - lResult = 0; \ - if(IsMsgHandled()) \ + this->SetMsgHandled(TRUE); \ + func(GET_XBUTTON_WPARAM(wParam), GET_KEYSTATE_WPARAM(wParam), ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + lResult = (LRESULT)TRUE; \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1776,10 +1787,10 @@ public: \ #define MSG_WM_CHANGEUISTATE(func) \ if (uMsg == WM_CHANGEUISTATE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func(LOWORD(wParam), HIWORD(wParam)); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1787,10 +1798,10 @@ public: \ #define MSG_WM_UPDATEUISTATE(func) \ if (uMsg == WM_UPDATEUISTATE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func(LOWORD(wParam), HIWORD(wParam)); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1798,24 +1809,20 @@ public: \ #define MSG_WM_QUERYUISTATE(func) \ if (uMsg == WM_QUERYUISTATE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = func(); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } -#endif // (_WIN32_WINNT >= 0x0500) - -#if(_WIN32_WINNT >= 0x0501) - // void OnInput(WPARAM RawInputCode, HRAWINPUT hRawInput) #define MSG_WM_INPUT(func) \ if (uMsg == WM_INPUT) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func(GET_RAWINPUT_CODE_WPARAM(wParam), (HRAWINPUT)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1823,23 +1830,23 @@ public: \ #define MSG_WM_UNICHAR(func) \ if (uMsg == WM_UNICHAR) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ { \ lResult = (wParam == UNICODE_NOCHAR) ? TRUE : FALSE; \ return TRUE; \ } \ } -// void OnWTSSessionChange(WPARAM nStatusCode, PWTSSESSION_NOTIFICATION nSessionID) +// void OnWTSSessionChange(WPARAM nStatusCode, DWORD dwSessionID) #define MSG_WM_WTSSESSION_CHANGE(func) \ if (uMsg == WM_WTSSESSION_CHANGE) \ { \ - SetMsgHandled(TRUE); \ - func(wParam, (PWTSSESSION_NOTIFICATION)lParam); \ + this->SetMsgHandled(TRUE); \ + func(wParam, (DWORD)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1847,29 +1854,96 @@ public: \ #define MSG_WM_THEMECHANGED(func) \ if (uMsg == WM_THEMECHANGED) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func(); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } -#endif // _WIN32_WINNT >= 0x0501 - #if (_WIN32_WINNT >= 0x0600) // BOOL OnMouseHWheel(UINT nFlags, short zDelta, CPoint pt) #define MSG_WM_MOUSEHWHEEL(func) \ if (uMsg == WM_MOUSEHWHEEL) \ { \ - SetMsgHandled(TRUE); \ - lResult = (LRESULT)func((UINT)LOWORD(wParam), (short)HIWORD(wParam), _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ - if(IsMsgHandled()) \ + this->SetMsgHandled(TRUE); \ + lResult = (LRESULT)func((UINT)LOWORD(wParam), (short)HIWORD(wParam), ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + if(this->IsMsgHandled()) \ return TRUE; \ } #endif // (_WIN32_WINNT >= 0x0600) +#if (WINVER >= 0x0601) + +// void OnGesture(ULONGLONG ullArguments, HGESTUREINFO hGestureInfo) +#define MSG_WM_GESTURE(func) \ + if (uMsg == WM_GESTURE) \ + { \ + this->SetMsgHandled(TRUE); \ + func((ULONGLONG)wParam, (HGESTUREINFO)lParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnGestureNotify(PGESTURENOTIFYSTRUCT pGestureNotifyStruct) +#define MSG_WM_GESTURENOTIFY(func) \ + if (uMsg == WM_GESTURENOTIFY) \ + { \ + func((PGESTURENOTIFYSTRUCT)lParam); \ + } + +// void OnDpiChanged(UINT nDpiX, UINT nDpiY, PRECT pRect) +#define MSG_WM_DPICHANGED(func) \ + if (uMsg == WM_DPICHANGED) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), (PRECT)lParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +#endif // (WINVER >= 0x0601) + +#if (WINVER >= 0x0605) + +// void OnDpiChangedBeforeParent() +#define MSG_WM_DPICHANGED_BEFOREPARENT(func) \ + if (uMsg == WM_DPICHANGED_BEFOREPARENT) \ + { \ + this->SetMsgHandled(TRUE); \ + func(); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnDpiChangedAfterParent() +#define MSG_WM_DPICHANGED_AFTERPARENT(func) \ + if (uMsg == WM_DPICHANGED_AFTERPARENT) \ + { \ + this->SetMsgHandled(TRUE); \ + func(); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// BOOL OnGetDpiScaledSize(UINT uDpi, PSIZE pSize) +#define MSG_WM_GETDPISCALEDSIZE(func) \ +if (uMsg == WM_GETDPISCALEDSIZE) \ +{ \ + this->SetMsgHandled(TRUE); \ + lResult = (LRESULT)func((UINT)wParam, (PSIZE)lParam); \ + if(this->IsMsgHandled()) \ + return TRUE; \ +} + +#endif // (WINVER >= 0x0605) + /////////////////////////////////////////////////////////////////////////////// // ATL defined messages @@ -1877,9 +1951,9 @@ public: \ #define MSG_WM_FORWARDMSG(func) \ if (uMsg == WM_FORWARDMSG) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((LPMSG)lParam, (DWORD)wParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1890,9 +1964,9 @@ public: \ #define MSG_DM_GETDEFID(func) \ if (uMsg == DM_GETDEFID) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = func(); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1900,10 +1974,10 @@ public: \ #define MSG_DM_SETDEFID(func) \ if (uMsg == DM_SETDEFID) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)wParam); \ lResult = TRUE; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1911,10 +1985,10 @@ public: \ #define MSG_DM_REPOSITION(func) \ if (uMsg == DM_REPOSITION) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func(); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1925,10 +1999,10 @@ public: \ #define MSG_OCM_COMMAND(func) \ if (uMsg == OCM_COMMAND) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1936,9 +2010,9 @@ public: \ #define MSG_OCM_NOTIFY(func) \ if (uMsg == OCM_NOTIFY) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = func((int)wParam, (LPNMHDR)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1946,10 +2020,10 @@ public: \ #define MSG_OCM_PARENTNOTIFY(func) \ if (uMsg == OCM_PARENTNOTIFY) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1957,10 +2031,10 @@ public: \ #define MSG_OCM_DRAWITEM(func) \ if (uMsg == OCM_DRAWITEM) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)wParam, (LPDRAWITEMSTRUCT)lParam); \ lResult = TRUE; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1968,10 +2042,10 @@ public: \ #define MSG_OCM_MEASUREITEM(func) \ if (uMsg == OCM_MEASUREITEM) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)wParam, (LPMEASUREITEMSTRUCT)lParam); \ lResult = TRUE; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1979,9 +2053,9 @@ public: \ #define MSG_OCM_COMPAREITEM(func) \ if (uMsg == OCM_COMPAREITEM) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((UINT)wParam, (LPCOMPAREITEMSTRUCT)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -1989,10 +2063,10 @@ public: \ #define MSG_OCM_DELETEITEM(func) \ if (uMsg == OCM_DELETEITEM) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)wParam, (LPDELETEITEMSTRUCT)lParam); \ lResult = TRUE; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -2000,9 +2074,9 @@ public: \ #define MSG_OCM_VKEYTOITEM(func) \ if (uMsg == OCM_VKEYTOITEM) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), (HWND)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -2010,9 +2084,9 @@ public: \ #define MSG_OCM_CHARTOITEM(func) \ if (uMsg == OCM_CHARTOITEM) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), (HWND)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -2020,10 +2094,10 @@ public: \ #define MSG_OCM_HSCROLL(func) \ if (uMsg == OCM_HSCROLL) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((int)LOWORD(wParam), (short)HIWORD(wParam), (HWND)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -2031,10 +2105,10 @@ public: \ #define MSG_OCM_VSCROLL(func) \ if (uMsg == OCM_VSCROLL) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((int)LOWORD(wParam), (short)HIWORD(wParam), (HWND)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -2042,9 +2116,9 @@ public: \ #define MSG_OCM_CTLCOLOREDIT(func) \ if (uMsg == OCM_CTLCOLOREDIT) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -2052,9 +2126,9 @@ public: \ #define MSG_OCM_CTLCOLORLISTBOX(func) \ if (uMsg == OCM_CTLCOLORLISTBOX) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -2062,9 +2136,9 @@ public: \ #define MSG_OCM_CTLCOLORBTN(func) \ if (uMsg == OCM_CTLCOLORBTN) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -2072,9 +2146,9 @@ public: \ #define MSG_OCM_CTLCOLORDLG(func) \ if (uMsg == OCM_CTLCOLORDLG) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -2082,9 +2156,9 @@ public: \ #define MSG_OCM_CTLCOLORSCROLLBAR(func) \ if (uMsg == OCM_CTLCOLORSCROLLBAR) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -2092,9 +2166,9 @@ public: \ #define MSG_OCM_CTLCOLORSTATIC(func) \ if (uMsg == OCM_CTLCOLORSTATIC) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -2105,10 +2179,10 @@ public: \ #define MSG_WM_CLEAR(func) \ if (uMsg == WM_CLEAR) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func(); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -2116,10 +2190,10 @@ public: \ #define MSG_WM_COPY(func) \ if (uMsg == WM_COPY) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func(); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -2127,10 +2201,10 @@ public: \ #define MSG_WM_CUT(func) \ if (uMsg == WM_CUT) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func(); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -2138,10 +2212,10 @@ public: \ #define MSG_WM_PASTE(func) \ if (uMsg == WM_PASTE) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func(); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -2149,10 +2223,10 @@ public: \ #define MSG_WM_UNDO(func) \ if (uMsg == WM_UNDO) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func(); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -2163,19 +2237,19 @@ public: \ #define MESSAGE_HANDLER_EX(msg, func) \ if(uMsg == msg) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = func(uMsg, wParam, lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } // LRESULT OnMessageRangeHandlerEX(UINT uMsg, WPARAM wParam, LPARAM lParam) #define MESSAGE_RANGE_HANDLER_EX(msgFirst, msgLast, func) \ - if(uMsg >= msgFirst && uMsg <= msgLast) \ + if((uMsg >= msgFirst) && (uMsg <= msgLast)) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = func(uMsg, wParam, lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } @@ -2184,211 +2258,222 @@ public: \ // void OnCommandHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl) #define COMMAND_HANDLER_EX(id, code, func) \ - if (uMsg == WM_COMMAND && code == HIWORD(wParam) && id == LOWORD(wParam)) \ + if ((uMsg == WM_COMMAND) && (code == HIWORD(wParam)) && (id == LOWORD(wParam))) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } // void OnCommandIDHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl) #define COMMAND_ID_HANDLER_EX(id, func) \ - if (uMsg == WM_COMMAND && id == LOWORD(wParam)) \ + if ((uMsg == WM_COMMAND) && (id == LOWORD(wParam))) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } // void OnCommandCodeHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl) #define COMMAND_CODE_HANDLER_EX(code, func) \ - if (uMsg == WM_COMMAND && code == HIWORD(wParam)) \ + if ((uMsg == WM_COMMAND) && (code == HIWORD(wParam))) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } // LRESULT OnNotifyHandlerEX(LPNMHDR pnmh) #define NOTIFY_HANDLER_EX(id, cd, func) \ - if (uMsg == WM_NOTIFY && cd == ((LPNMHDR)lParam)->code && id == ((LPNMHDR)lParam)->idFrom) \ + if ((uMsg == WM_NOTIFY) && (cd == ((LPNMHDR)lParam)->code) && (id == ((LPNMHDR)lParam)->idFrom)) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = func((LPNMHDR)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } // LRESULT OnNotifyIDHandlerEX(LPNMHDR pnmh) #define NOTIFY_ID_HANDLER_EX(id, func) \ - if (uMsg == WM_NOTIFY && id == ((LPNMHDR)lParam)->idFrom) \ + if ((uMsg == WM_NOTIFY) && (id == ((LPNMHDR)lParam)->idFrom)) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = func((LPNMHDR)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } // LRESULT OnNotifyCodeHandlerEX(LPNMHDR pnmh) #define NOTIFY_CODE_HANDLER_EX(cd, func) \ - if (uMsg == WM_NOTIFY && cd == ((LPNMHDR)lParam)->code) \ + if ((uMsg == WM_NOTIFY) && (cd == ((LPNMHDR)lParam)->code)) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = func((LPNMHDR)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } // void OnCommandRangeHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl) #define COMMAND_RANGE_HANDLER_EX(idFirst, idLast, func) \ - if(uMsg == WM_COMMAND && LOWORD(wParam) >= idFirst && LOWORD(wParam) <= idLast) \ + if((uMsg == WM_COMMAND) && (LOWORD(wParam) >= idFirst) && (LOWORD(wParam) <= idLast)) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } // void OnCommandRangeCodeHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl) #define COMMAND_RANGE_CODE_HANDLER_EX(idFirst, idLast, code, func) \ - if(uMsg == WM_COMMAND && code == HIWORD(wParam) && LOWORD(wParam) >= idFirst && LOWORD(wParam) <= idLast) \ + if((uMsg == WM_COMMAND) && (code == HIWORD(wParam)) && (LOWORD(wParam) >= idFirst) && (LOWORD(wParam) <= idLast)) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } // LRESULT OnNotifyRangeHandlerEX(LPNMHDR pnmh) #define NOTIFY_RANGE_HANDLER_EX(idFirst, idLast, func) \ - if(uMsg == WM_NOTIFY && ((LPNMHDR)lParam)->idFrom >= idFirst && ((LPNMHDR)lParam)->idFrom <= idLast) \ + if((uMsg == WM_NOTIFY) && (((LPNMHDR)lParam)->idFrom >= idFirst) && (((LPNMHDR)lParam)->idFrom <= idLast)) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = func((LPNMHDR)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } // LRESULT OnNotifyRangeCodeHandlerEX(LPNMHDR pnmh) #define NOTIFY_RANGE_CODE_HANDLER_EX(idFirst, idLast, cd, func) \ - if(uMsg == WM_NOTIFY && cd == ((LPNMHDR)lParam)->code && ((LPNMHDR)lParam)->idFrom >= idFirst && ((LPNMHDR)lParam)->idFrom <= idLast) \ + if((uMsg == WM_NOTIFY) && (cd == ((LPNMHDR)lParam)->code) && (((LPNMHDR)lParam)->idFrom >= idFirst) && (((LPNMHDR)lParam)->idFrom <= idLast)) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = func((LPNMHDR)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } // LRESULT OnReflectedCommandHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl) #define REFLECTED_COMMAND_HANDLER_EX(id, code, func) \ - if (uMsg == OCM_COMMAND && code == HIWORD(wParam) && id == LOWORD(wParam)) \ + if ((uMsg == OCM_COMMAND) && (code == HIWORD(wParam)) && (id == LOWORD(wParam))) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } // LRESULT OnReflectedCommandIDHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl) #define REFLECTED_COMMAND_ID_HANDLER_EX(id, func) \ - if (uMsg == OCM_COMMAND && id == LOWORD(wParam)) \ + if ((uMsg == OCM_COMMAND) && (id == LOWORD(wParam))) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } // LRESULT OnReflectedCommandCodeHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl) #define REFLECTED_COMMAND_CODE_HANDLER_EX(code, func) \ - if (uMsg == OCM_COMMAND && code == HIWORD(wParam)) \ + if ((uMsg == OCM_COMMAND) && (code == HIWORD(wParam))) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } // LRESULT OnReflectedNotifyHandlerEX(LPNMHDR pnmh) #define REFLECTED_NOTIFY_HANDLER_EX(id, cd, func) \ - if (uMsg == OCM_NOTIFY && cd == ((LPNMHDR)lParam)->code && id == ((LPNMHDR)lParam)->idFrom) \ + if ((uMsg == OCM_NOTIFY) && (cd == ((LPNMHDR)lParam)->code) && (id == ((LPNMHDR)lParam)->idFrom)) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = func((LPNMHDR)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } // LRESULT OnReflectedNotifyIDHandlerEX(LPNMHDR pnmh) #define REFLECTED_NOTIFY_ID_HANDLER_EX(id, func) \ - if (uMsg == OCM_NOTIFY && id == ((LPNMHDR)lParam)->idFrom) \ + if ((uMsg == OCM_NOTIFY) && (id == ((LPNMHDR)lParam)->idFrom)) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = func((LPNMHDR)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } // LRESULT OnReflectedNotifyCodeHandlerEX(LPNMHDR pnmh) #define REFLECTED_NOTIFY_CODE_HANDLER_EX(cd, func) \ - if (uMsg == OCM_NOTIFY && cd == ((LPNMHDR)lParam)->code) \ + if ((uMsg == OCM_NOTIFY) && (cd == ((LPNMHDR)lParam)->code)) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = func((LPNMHDR)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } // void OnReflectedCommandRangeHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl) #define REFLECTED_COMMAND_RANGE_HANDLER_EX(idFirst, idLast, func) \ - if(uMsg == OCM_COMMAND && LOWORD(wParam) >= idFirst && LOWORD(wParam) <= idLast) \ + if((uMsg == OCM_COMMAND) && (LOWORD(wParam) >= idFirst) && (LOWORD(wParam) <= idLast)) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } // void OnReflectedCommandRangeCodeHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl) #define REFLECTED_COMMAND_RANGE_CODE_HANDLER_EX(idFirst, idLast, code, func) \ - if(uMsg == OCM_COMMAND && code == HIWORD(wParam) && LOWORD(wParam) >= idFirst && LOWORD(wParam) <= idLast) \ + if((uMsg == OCM_COMMAND) && (code == HIWORD(wParam)) && (LOWORD(wParam) >= idFirst) && (LOWORD(wParam) <= idLast)) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \ lResult = 0; \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } // LRESULT OnReflectedNotifyRangeHandlerEX(LPNMHDR pnmh) #define REFLECTED_NOTIFY_RANGE_HANDLER_EX(idFirst, idLast, func) \ - if(uMsg == OCM_NOTIFY && ((LPNMHDR)lParam)->idFrom >= idFirst && ((LPNMHDR)lParam)->idFrom <= idLast) \ + if((uMsg == OCM_NOTIFY) && (((LPNMHDR)lParam)->idFrom >= idFirst) && (((LPNMHDR)lParam)->idFrom <= idLast)) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = func((LPNMHDR)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ return TRUE; \ } // LRESULT OnReflectedNotifyRangeCodeHandlerEX(LPNMHDR pnmh) #define REFLECTED_NOTIFY_RANGE_CODE_HANDLER_EX(idFirst, idLast, cd, func) \ - if(uMsg == OCM_NOTIFY && cd == ((LPNMHDR)lParam)->code && ((LPNMHDR)lParam)->idFrom >= idFirst && ((LPNMHDR)lParam)->idFrom <= idLast) \ + if((uMsg == OCM_NOTIFY) && (cd == ((LPNMHDR)lParam)->code) && (((LPNMHDR)lParam)->idFrom >= idFirst) && (((LPNMHDR)lParam)->idFrom <= idLast)) \ { \ - SetMsgHandled(TRUE); \ + this->SetMsgHandled(TRUE); \ lResult = func((LPNMHDR)lParam); \ - if(IsMsgHandled()) \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnAppCommandHandler(UINT uDevice, DWORD dwKeys, CWindow wndFocus) +#define APPCOMMAND_HANDLER_EX(cmd, func) \ + if((uMsg == WM_APPCOMMAND) && (cmd == GET_APPCOMMAND_LPARAM(lParam))) \ + { \ + this->SetMsgHandled(TRUE); \ + func(GET_DEVICE_LPARAM(lParam), GET_KEYSTATE_LPARAM(lParam), (HWND)wParam); \ + lResult = TRUE; \ + if(this->IsMsgHandled()) \ return TRUE; \ } diff --git a/ZbaSDK/SampleCode/PluginWinExe/WTL/atlctrls.h b/ZbaSDK/SampleCode/PluginWinExe/WTL/atlctrls.h index cd015102877313057277bb7a746aacd16509d743..61df4279d6df02f770c3f895754292b3ca6dd3a6 100644 --- a/ZbaSDK/SampleCode/PluginWinExe/WTL/atlctrls.h +++ b/ZbaSDK/SampleCode/PluginWinExe/WTL/atlctrls.h @@ -1,4 +1,4 @@ -// Windows Template Library - WTL version 9.10 +// Windows Template Library - WTL version 10.0 // Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. // // This file is a part of the Windows Template Library. @@ -19,12 +19,12 @@ #error atlctrls.h requires atlwin.h to be included first #endif -#ifndef _WIN32_WCE - #include - #include -#elif defined(WIN32_PLATFORM_WFSP) && !defined(_WINUSERM_H_) - #include -#endif // !_WIN32_WCE +#include +#include + +#if (_RICHEDIT_VER < 0x0300) + #error WTL10 requires _RICHEDIT_VER >= 0x0300 +#endif // protect template members from windowsx.h macros #ifdef _INC_WINDOWSX @@ -75,9 +75,6 @@ // CLinkCtrlT - CLinkCtrl // // CCustomDraw -// -// CCECommandBarCtrlT - CCECommandBarCtrl -// CCECommandBandsCtrlT - CCECommandBandsCtrl namespace WTL @@ -112,7 +109,7 @@ public: CStaticT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -129,66 +126,52 @@ public: return _T("STATIC"); } -#ifndef _WIN32_WCE HICON GetIcon() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (HICON)::SendMessage(m_hWnd, STM_GETICON, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HICON)::SendMessage(this->m_hWnd, STM_GETICON, 0, 0L); } HICON SetIcon(HICON hIcon) { - ATLASSERT(::IsWindow(m_hWnd)); - return (HICON)::SendMessage(m_hWnd, STM_SETICON, (WPARAM)hIcon, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HICON)::SendMessage(this->m_hWnd, STM_SETICON, (WPARAM)hIcon, 0L); } HENHMETAFILE GetEnhMetaFile() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (HENHMETAFILE)::SendMessage(m_hWnd, STM_GETIMAGE, IMAGE_ENHMETAFILE, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HENHMETAFILE)::SendMessage(this->m_hWnd, STM_GETIMAGE, IMAGE_ENHMETAFILE, 0L); } HENHMETAFILE SetEnhMetaFile(HENHMETAFILE hMetaFile) { - ATLASSERT(::IsWindow(m_hWnd)); - return (HENHMETAFILE)::SendMessage(m_hWnd, STM_SETIMAGE, IMAGE_ENHMETAFILE, (LPARAM)hMetaFile); - } -#else // CE specific - HICON GetIcon() const - { - ATLASSERT(::IsWindow(m_hWnd)); - return (HICON)::SendMessage(m_hWnd, STM_GETIMAGE, IMAGE_ICON, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HENHMETAFILE)::SendMessage(this->m_hWnd, STM_SETIMAGE, IMAGE_ENHMETAFILE, (LPARAM)hMetaFile); } - HICON SetIcon(HICON hIcon) - { - ATLASSERT(::IsWindow(m_hWnd)); - return (HICON)::SendMessage(m_hWnd, STM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); - } -#endif // _WIN32_WCE - CBitmapHandle GetBitmap() const { - ATLASSERT(::IsWindow(m_hWnd)); - return CBitmapHandle((HBITMAP)::SendMessage(m_hWnd, STM_GETIMAGE, IMAGE_BITMAP, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CBitmapHandle((HBITMAP)::SendMessage(this->m_hWnd, STM_GETIMAGE, IMAGE_BITMAP, 0L)); } CBitmapHandle SetBitmap(HBITMAP hBitmap) { - ATLASSERT(::IsWindow(m_hWnd)); - return CBitmapHandle((HBITMAP)::SendMessage(m_hWnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBitmap)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CBitmapHandle((HBITMAP)::SendMessage(this->m_hWnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBitmap)); } HCURSOR GetCursor() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (HCURSOR)::SendMessage(m_hWnd, STM_GETIMAGE, IMAGE_CURSOR, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HCURSOR)::SendMessage(this->m_hWnd, STM_GETIMAGE, IMAGE_CURSOR, 0L); } HCURSOR SetCursor(HCURSOR hCursor) { - ATLASSERT(::IsWindow(m_hWnd)); - return (HCURSOR)::SendMessage(m_hWnd, STM_SETIMAGE, IMAGE_CURSOR, (LPARAM)hCursor); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HCURSOR)::SendMessage(this->m_hWnd, STM_SETIMAGE, IMAGE_CURSOR, (LPARAM)hCursor); } }; @@ -208,7 +191,7 @@ public: CButtonT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -227,161 +210,157 @@ public: UINT GetState() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (UINT)::SendMessage(m_hWnd, BM_GETSTATE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, BM_GETSTATE, 0, 0L); } void SetState(BOOL bHighlight) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, BM_SETSTATE, bHighlight, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, BM_SETSTATE, bHighlight, 0L); } int GetCheck() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, BM_GETCHECK, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, BM_GETCHECK, 0, 0L); } void SetCheck(int nCheck) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, BM_SETCHECK, nCheck, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, BM_SETCHECK, nCheck, 0L); } UINT GetButtonStyle() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (UINT)::GetWindowLong(m_hWnd, GWL_STYLE) & 0xFFFF; + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::GetWindowLong(this->m_hWnd, GWL_STYLE) & 0xFFFF; } void SetButtonStyle(UINT nStyle, BOOL bRedraw = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, BM_SETSTYLE, nStyle, (LPARAM)bRedraw); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, BM_SETSTYLE, nStyle, (LPARAM)bRedraw); } -#ifndef _WIN32_WCE HICON GetIcon() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (HICON)::SendMessage(m_hWnd, BM_GETIMAGE, IMAGE_ICON, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HICON)::SendMessage(this->m_hWnd, BM_GETIMAGE, IMAGE_ICON, 0L); } HICON SetIcon(HICON hIcon) { - ATLASSERT(::IsWindow(m_hWnd)); - return (HICON)::SendMessage(m_hWnd, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HICON)::SendMessage(this->m_hWnd, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); } CBitmapHandle GetBitmap() const { - ATLASSERT(::IsWindow(m_hWnd)); - return CBitmapHandle((HBITMAP)::SendMessage(m_hWnd, BM_GETIMAGE, IMAGE_BITMAP, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CBitmapHandle((HBITMAP)::SendMessage(this->m_hWnd, BM_GETIMAGE, IMAGE_BITMAP, 0L)); } CBitmapHandle SetBitmap(HBITMAP hBitmap) { - ATLASSERT(::IsWindow(m_hWnd)); - return CBitmapHandle((HBITMAP)::SendMessage(m_hWnd, BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBitmap)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CBitmapHandle((HBITMAP)::SendMessage(this->m_hWnd, BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBitmap)); } -#endif // !_WIN32_WCE -#if (_WIN32_WINNT >= 0x0501) BOOL GetIdealSize(LPSIZE lpSize) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, BCM_GETIDEALSIZE, 0, (LPARAM)lpSize); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, BCM_GETIDEALSIZE, 0, (LPARAM)lpSize); } BOOL GetImageList(PBUTTON_IMAGELIST pButtonImagelist) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, BCM_GETIMAGELIST, 0, (LPARAM)pButtonImagelist); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, BCM_GETIMAGELIST, 0, (LPARAM)pButtonImagelist); } BOOL SetImageList(PBUTTON_IMAGELIST pButtonImagelist) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, BCM_SETIMAGELIST, 0, (LPARAM)pButtonImagelist); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, BCM_SETIMAGELIST, 0, (LPARAM)pButtonImagelist); } BOOL GetTextMargin(LPRECT lpRect) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, BCM_GETTEXTMARGIN, 0, (LPARAM)lpRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, BCM_GETTEXTMARGIN, 0, (LPARAM)lpRect); } BOOL SetTextMargin(LPRECT lpRect) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, BCM_SETTEXTMARGIN, 0, (LPARAM)lpRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, BCM_SETTEXTMARGIN, 0, (LPARAM)lpRect); } -#endif // (_WIN32_WINNT >= 0x0501) #if (WINVER >= 0x0600) void SetDontClick(BOOL bDontClick) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, BM_SETDONTCLICK, (WPARAM)bDontClick, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, BM_SETDONTCLICK, (WPARAM)bDontClick, 0L); } #endif // (WINVER >= 0x0600) #if (_WIN32_WINNT >= 0x0600) BOOL SetDropDownState(BOOL bDropDown) { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT((GetStyle() & (BS_SPLITBUTTON | BS_DEFSPLITBUTTON)) != 0); - return (BOOL)::SendMessage(m_hWnd, BCM_SETDROPDOWNSTATE, (WPARAM)bDropDown, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & (BS_SPLITBUTTON | BS_DEFSPLITBUTTON)) != 0); + return (BOOL)::SendMessage(this->m_hWnd, BCM_SETDROPDOWNSTATE, (WPARAM)bDropDown, 0L); } BOOL GetSplitInfo(PBUTTON_SPLITINFO pSplitInfo) const { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT((GetStyle() & (BS_SPLITBUTTON | BS_DEFSPLITBUTTON)) != 0); - return (BOOL)::SendMessage(m_hWnd, BCM_GETSPLITINFO, 0, (LPARAM)pSplitInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & (BS_SPLITBUTTON | BS_DEFSPLITBUTTON)) != 0); + return (BOOL)::SendMessage(this->m_hWnd, BCM_GETSPLITINFO, 0, (LPARAM)pSplitInfo); } BOOL SetSplitInfo(PBUTTON_SPLITINFO pSplitInfo) { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT((GetStyle() & (BS_SPLITBUTTON | BS_DEFSPLITBUTTON)) != 0); - return (BOOL)::SendMessage(m_hWnd, BCM_SETSPLITINFO, 0, (LPARAM)pSplitInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & (BS_SPLITBUTTON | BS_DEFSPLITBUTTON)) != 0); + return (BOOL)::SendMessage(this->m_hWnd, BCM_SETSPLITINFO, 0, (LPARAM)pSplitInfo); } int GetNoteLength() const { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT((GetStyle() & (BS_COMMANDLINK | BS_DEFCOMMANDLINK)) != 0); - return (int)::SendMessage(m_hWnd, BCM_GETNOTELENGTH, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & (BS_COMMANDLINK | BS_DEFCOMMANDLINK)) != 0); + return (int)::SendMessage(this->m_hWnd, BCM_GETNOTELENGTH, 0, 0L); } BOOL GetNote(LPWSTR lpstrNoteText, int cchNoteText) const { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT((GetStyle() & (BS_COMMANDLINK | BS_DEFCOMMANDLINK)) != 0); - return (BOOL)::SendMessage(m_hWnd, BCM_GETNOTE, cchNoteText, (LPARAM)lpstrNoteText); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & (BS_COMMANDLINK | BS_DEFCOMMANDLINK)) != 0); + return (BOOL)::SendMessage(this->m_hWnd, BCM_GETNOTE, cchNoteText, (LPARAM)lpstrNoteText); } BOOL SetNote(LPCWSTR lpstrNoteText) { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT((GetStyle() & (BS_COMMANDLINK | BS_DEFCOMMANDLINK)) != 0); - return (BOOL)::SendMessage(m_hWnd, BCM_SETNOTE, 0, (LPARAM)lpstrNoteText); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & (BS_COMMANDLINK | BS_DEFCOMMANDLINK)) != 0); + return (BOOL)::SendMessage(this->m_hWnd, BCM_SETNOTE, 0, (LPARAM)lpstrNoteText); } LRESULT SetElevationRequiredState(BOOL bSet) { - ATLASSERT(::IsWindow(m_hWnd)); - return ::SendMessage(m_hWnd, BCM_SETSHIELD, 0, (LPARAM)bSet); + ATLASSERT(::IsWindow(this->m_hWnd)); + return ::SendMessage(this->m_hWnd, BCM_SETSHIELD, 0, (LPARAM)bSet); } #endif // (_WIN32_WINNT >= 0x0600) // Operations void Click() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, BM_CLICK, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, BM_CLICK, 0, 0L); } }; @@ -401,7 +380,7 @@ public: CListBoxT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -421,186 +400,177 @@ public: // for entire listbox int GetCount() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LB_GETCOUNT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_GETCOUNT, 0, 0L); } -#ifndef _WIN32_WCE int SetCount(int cItems) { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT(((GetStyle() & LBS_NODATA) != 0) && ((GetStyle() & LBS_HASSTRINGS) == 0)); - return (int)::SendMessage(m_hWnd, LB_SETCOUNT, cItems, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(((this->GetStyle() & LBS_NODATA) != 0) && ((this->GetStyle() & LBS_HASSTRINGS) == 0)); + return (int)::SendMessage(this->m_hWnd, LB_SETCOUNT, cItems, 0L); } -#endif // !_WIN32_WCE int GetHorizontalExtent() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LB_GETHORIZONTALEXTENT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_GETHORIZONTALEXTENT, 0, 0L); } void SetHorizontalExtent(int cxExtent) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, LB_SETHORIZONTALEXTENT, cxExtent, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, LB_SETHORIZONTALEXTENT, cxExtent, 0L); } int GetTopIndex() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LB_GETTOPINDEX, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_GETTOPINDEX, 0, 0L); } int SetTopIndex(int nIndex) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LB_SETTOPINDEX, nIndex, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_SETTOPINDEX, nIndex, 0L); } LCID GetLocale() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (LCID)::SendMessage(m_hWnd, LB_GETLOCALE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (LCID)::SendMessage(this->m_hWnd, LB_GETLOCALE, 0, 0L); } LCID SetLocale(LCID nNewLocale) { - ATLASSERT(::IsWindow(m_hWnd)); - return (LCID)::SendMessage(m_hWnd, LB_SETLOCALE, (WPARAM)nNewLocale, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (LCID)::SendMessage(this->m_hWnd, LB_SETLOCALE, (WPARAM)nNewLocale, 0L); } -#if (WINVER >= 0x0500) && !defined(_WIN32_WCE) DWORD GetListBoxInfo() const { - ATLASSERT(::IsWindow(m_hWnd)); -#if (_WIN32_WINNT >= 0x0501) - return (DWORD)::SendMessage(m_hWnd, LB_GETLISTBOXINFO, 0, 0L); -#else // !(_WIN32_WINNT >= 0x0501) - return ::GetListBoxInfo(m_hWnd); -#endif // !(_WIN32_WINNT >= 0x0501) + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, LB_GETLISTBOXINFO, 0, 0L); } -#endif // (WINVER >= 0x0500) && !defined(_WIN32_WCE) // for single-selection listboxes int GetCurSel() const { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT((GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) == 0); - return (int)::SendMessage(m_hWnd, LB_GETCURSEL, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) == 0); + return (int)::SendMessage(this->m_hWnd, LB_GETCURSEL, 0, 0L); } int SetCurSel(int nSelect) { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT((GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) == 0); - return (int)::SendMessage(m_hWnd, LB_SETCURSEL, nSelect, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) == 0); + return (int)::SendMessage(this->m_hWnd, LB_SETCURSEL, nSelect, 0L); } // for multiple-selection listboxes int GetSel(int nIndex) const // also works for single-selection { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LB_GETSEL, nIndex, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_GETSEL, nIndex, 0L); } int SetSel(int nIndex, BOOL bSelect = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT((GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != 0); - return (int)::SendMessage(m_hWnd, LB_SETSEL, bSelect, nIndex); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != 0); + return (int)::SendMessage(this->m_hWnd, LB_SETSEL, bSelect, nIndex); } int GetSelCount() const { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT((GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != 0); - return (int)::SendMessage(m_hWnd, LB_GETSELCOUNT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != 0); + return (int)::SendMessage(this->m_hWnd, LB_GETSELCOUNT, 0, 0L); } int GetSelItems(int nMaxItems, LPINT rgIndex) const { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT((GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != 0); - return (int)::SendMessage(m_hWnd, LB_GETSELITEMS, nMaxItems, (LPARAM)rgIndex); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != 0); + return (int)::SendMessage(this->m_hWnd, LB_GETSELITEMS, nMaxItems, (LPARAM)rgIndex); } int GetAnchorIndex() const { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT((GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != 0); - return (int)::SendMessage(m_hWnd, LB_GETANCHORINDEX, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != 0); + return (int)::SendMessage(this->m_hWnd, LB_GETANCHORINDEX, 0, 0L); } void SetAnchorIndex(int nIndex) { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT((GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != 0); - ::SendMessage(m_hWnd, LB_SETANCHORINDEX, nIndex, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != 0); + ::SendMessage(this->m_hWnd, LB_SETANCHORINDEX, nIndex, 0L); } int GetCaretIndex() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LB_GETCARETINDEX, 0, 0); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_GETCARETINDEX, 0, 0); } int SetCaretIndex(int nIndex, BOOL bScroll = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LB_SETCARETINDEX, nIndex, MAKELONG(bScroll, 0)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_SETCARETINDEX, nIndex, MAKELONG(bScroll, 0)); } // for listbox items DWORD_PTR GetItemData(int nIndex) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD_PTR)::SendMessage(m_hWnd, LB_GETITEMDATA, nIndex, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD_PTR)::SendMessage(this->m_hWnd, LB_GETITEMDATA, nIndex, 0L); } int SetItemData(int nIndex, DWORD_PTR dwItemData) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LB_SETITEMDATA, nIndex, (LPARAM)dwItemData); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_SETITEMDATA, nIndex, (LPARAM)dwItemData); } void* GetItemDataPtr(int nIndex) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (void*)::SendMessage(m_hWnd, LB_GETITEMDATA, nIndex, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (void*)::SendMessage(this->m_hWnd, LB_GETITEMDATA, nIndex, 0L); } int SetItemDataPtr(int nIndex, void* pData) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); return SetItemData(nIndex, (DWORD_PTR)pData); } int GetItemRect(int nIndex, LPRECT lpRect) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LB_GETITEMRECT, nIndex, (LPARAM)lpRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_GETITEMRECT, nIndex, (LPARAM)lpRect); } int GetText(int nIndex, LPTSTR lpszBuffer) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LB_GETTEXT, nIndex, (LPARAM)lpszBuffer); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_GETTEXT, nIndex, (LPARAM)lpszBuffer); } -#ifndef _ATL_NO_COM #ifdef _OLEAUTO_H_ BOOL GetTextBSTR(int nIndex, BSTR& bstrText) const { USES_CONVERSION; - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(bstrText == NULL); int nLen = GetTextLen(nIndex); if(nLen == LB_ERR) return FALSE; - CTempBuffer buff; + ATL::CTempBuffer buff; LPTSTR lpstrText = buff.Allocate(nLen + 1); if(lpstrText == NULL) return FALSE; @@ -612,12 +582,11 @@ public: return (bstrText != NULL) ? TRUE : FALSE; } #endif // _OLEAUTO_H_ -#endif // !_ATL_NO_COM -#if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) - int GetText(int nIndex, _CSTRING_NS::CString& strText) const +#ifdef __ATLSTR_H__ + int GetText(int nIndex, ATL::CString& strText) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); int cchLen = GetTextLen(nIndex); if(cchLen == LB_ERR) return LB_ERR; @@ -630,71 +599,71 @@ public: } return nRet; } -#endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) +#endif // __ATLSTR_H__ int GetTextLen(int nIndex) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LB_GETTEXTLEN, nIndex, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_GETTEXTLEN, nIndex, 0L); } int GetItemHeight(int nIndex) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LB_GETITEMHEIGHT, nIndex, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_GETITEMHEIGHT, nIndex, 0L); } int SetItemHeight(int nIndex, UINT cyItemHeight) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LB_SETITEMHEIGHT, nIndex, MAKELONG(cyItemHeight, 0)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_SETITEMHEIGHT, nIndex, MAKELONG(cyItemHeight, 0)); } // Settable only attributes void SetColumnWidth(int cxWidth) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, LB_SETCOLUMNWIDTH, cxWidth, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, LB_SETCOLUMNWIDTH, cxWidth, 0L); } BOOL SetTabStops(int nTabStops, LPINT rgTabStops) { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT((GetStyle() & LBS_USETABSTOPS) != 0); - return (BOOL)::SendMessage(m_hWnd, LB_SETTABSTOPS, nTabStops, (LPARAM)rgTabStops); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & LBS_USETABSTOPS) != 0); + return (BOOL)::SendMessage(this->m_hWnd, LB_SETTABSTOPS, nTabStops, (LPARAM)rgTabStops); } BOOL SetTabStops() { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT((GetStyle() & LBS_USETABSTOPS) != 0); - return (BOOL)::SendMessage(m_hWnd, LB_SETTABSTOPS, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & LBS_USETABSTOPS) != 0); + return (BOOL)::SendMessage(this->m_hWnd, LB_SETTABSTOPS, 0, 0L); } BOOL SetTabStops(const int& cxEachStop) // takes an 'int' { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT((GetStyle() & LBS_USETABSTOPS) != 0); - return (BOOL)::SendMessage(m_hWnd, LB_SETTABSTOPS, 1, (LPARAM)(LPINT)&cxEachStop); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & LBS_USETABSTOPS) != 0); + return (BOOL)::SendMessage(this->m_hWnd, LB_SETTABSTOPS, 1, (LPARAM)(LPINT)&cxEachStop); } // Operations int InitStorage(int nItems, UINT nBytes) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LB_INITSTORAGE, (WPARAM)nItems, nBytes); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_INITSTORAGE, (WPARAM)nItems, nBytes); } void ResetContent() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, LB_RESETCONTENT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, LB_RESETCONTENT, 0, 0L); } UINT ItemFromPoint(POINT pt, BOOL& bOutside) const { - ATLASSERT(::IsWindow(m_hWnd)); - DWORD dw = (DWORD)::SendMessage(m_hWnd, LB_ITEMFROMPOINT, 0, MAKELPARAM(pt.x, pt.y)); + ATLASSERT(::IsWindow(this->m_hWnd)); + DWORD dw = (DWORD)::SendMessage(this->m_hWnd, LB_ITEMFROMPOINT, 0, MAKELPARAM(pt.x, pt.y)); bOutside = (BOOL)HIWORD(dw); return (UINT)LOWORD(dw); } @@ -702,74 +671,60 @@ public: // manipulating listbox items int AddString(LPCTSTR lpszItem) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LB_ADDSTRING, 0, (LPARAM)lpszItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_ADDSTRING, 0, (LPARAM)lpszItem); } int DeleteString(UINT nIndex) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LB_DELETESTRING, nIndex, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_DELETESTRING, nIndex, 0L); } int InsertString(int nIndex, LPCTSTR lpszItem) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LB_INSERTSTRING, nIndex, (LPARAM)lpszItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_INSERTSTRING, nIndex, (LPARAM)lpszItem); } -#ifndef _WIN32_WCE int Dir(UINT attr, LPCTSTR lpszWildCard) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LB_DIR, attr, (LPARAM)lpszWildCard); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_DIR, attr, (LPARAM)lpszWildCard); } int AddFile(LPCTSTR lpstrFileName) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LB_ADDFILE, 0, (LPARAM)lpstrFileName); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_ADDFILE, 0, (LPARAM)lpstrFileName); } -#endif // !_WIN32_WCE // selection helpers int FindString(int nStartAfter, LPCTSTR lpszItem) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LB_FINDSTRING, nStartAfter, (LPARAM)lpszItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_FINDSTRING, nStartAfter, (LPARAM)lpszItem); } int FindStringExact(int nIndexStart, LPCTSTR lpszFind) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LB_FINDSTRINGEXACT, nIndexStart, (LPARAM)lpszFind); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_FINDSTRINGEXACT, nIndexStart, (LPARAM)lpszFind); } int SelectString(int nStartAfter, LPCTSTR lpszItem) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LB_SELECTSTRING, nStartAfter, (LPARAM)lpszItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_SELECTSTRING, nStartAfter, (LPARAM)lpszItem); } int SelItemRange(BOOL bSelect, int nFirstItem, int nLastItem) { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT((GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != 0); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != 0); ATLASSERT(nFirstItem <= nLastItem); - return bSelect ? (int)::SendMessage(m_hWnd, LB_SELITEMRANGEEX, nFirstItem, nLastItem) : (int)::SendMessage(m_hWnd, LB_SELITEMRANGEEX, nLastItem, nFirstItem); - } - -#ifdef WIN32_PLATFORM_WFSP // SmartPhone only messages - DWORD GetInputMode(BOOL bCurrentMode = TRUE) - { - return SendMessage(LB_GETINPUTMODE, 0, (LPARAM)bCurrentMode); + return bSelect ? (int)::SendMessage(this->m_hWnd, LB_SELITEMRANGEEX, nFirstItem, nLastItem) : (int)::SendMessage(this->m_hWnd, LB_SELITEMRANGEEX, nLastItem, nFirstItem); } - - BOOL SetInputMode(DWORD dwMode) - { - return SendMessage(LB_SETINPUTMODE, 0, (LPARAM)dwMode); - } -#endif // WIN32_PLATFORM_WFSP }; typedef CListBoxT CListBox; @@ -778,8 +733,6 @@ typedef CListBoxT CListBox; /////////////////////////////////////////////////////////////////////////////// // CComboBox - client side for a Windows COMBOBOX control -#ifndef WIN32_PLATFORM_WFSP // No COMBOBOX on SmartPhones - template class CComboBoxT : public TBase { @@ -790,7 +743,7 @@ public: CComboBoxT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -810,138 +763,131 @@ public: // for entire combo box int GetCount() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, CB_GETCOUNT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_GETCOUNT, 0, 0L); } int GetCurSel() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, CB_GETCURSEL, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_GETCURSEL, 0, 0L); } int SetCurSel(int nSelect) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, CB_SETCURSEL, nSelect, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_SETCURSEL, nSelect, 0L); } LCID GetLocale() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (LCID)::SendMessage(m_hWnd, CB_GETLOCALE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (LCID)::SendMessage(this->m_hWnd, CB_GETLOCALE, 0, 0L); } LCID SetLocale(LCID nNewLocale) { - ATLASSERT(::IsWindow(m_hWnd)); - return (LCID)::SendMessage(m_hWnd, CB_SETLOCALE, (WPARAM)nNewLocale, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (LCID)::SendMessage(this->m_hWnd, CB_SETLOCALE, (WPARAM)nNewLocale, 0L); } int GetTopIndex() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, CB_GETTOPINDEX, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_GETTOPINDEX, 0, 0L); } int SetTopIndex(int nIndex) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, CB_SETTOPINDEX, nIndex, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_SETTOPINDEX, nIndex, 0L); } UINT GetHorizontalExtent() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (UINT)::SendMessage(m_hWnd, CB_GETHORIZONTALEXTENT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, CB_GETHORIZONTALEXTENT, 0, 0L); } void SetHorizontalExtent(UINT nExtent) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, CB_SETHORIZONTALEXTENT, nExtent, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, CB_SETHORIZONTALEXTENT, nExtent, 0L); } int GetDroppedWidth() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, CB_GETDROPPEDWIDTH, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_GETDROPPEDWIDTH, 0, 0L); } int SetDroppedWidth(UINT nWidth) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, CB_SETDROPPEDWIDTH, nWidth, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_SETDROPPEDWIDTH, nWidth, 0L); } -#if ((WINVER >= 0x0500) && !defined(_WIN32_WCE)) || (defined(_WIN32_WCE) && (_WIN32_WCE >= 420)) BOOL GetComboBoxInfo(PCOMBOBOXINFO pComboBoxInfo) const { - ATLASSERT(::IsWindow(m_hWnd)); -#if ((_WIN32_WINNT >= 0x0501) && !defined(_WIN32_WCE)) || (defined(_WIN32_WCE) && (_WIN32_WCE >= 420)) - return (BOOL)::SendMessage(m_hWnd, CB_GETCOMBOBOXINFO, 0, (LPARAM)pComboBoxInfo); -#else // !((_WIN32_WINNT >= 0x0501) && !defined(_WIN32_WCE)) || (defined(_WIN32_WCE) && (_WIN32_WCE >= 420)) - return ::GetComboBoxInfo(m_hWnd, pComboBoxInfo); -#endif // !((_WIN32_WINNT >= 0x0501) && !defined(_WIN32_WCE)) || (defined(_WIN32_WCE) && (_WIN32_WCE >= 420)) + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, CB_GETCOMBOBOXINFO, 0, (LPARAM)pComboBoxInfo); } -#endif // ((WINVER >= 0x0500) && !defined(_WIN32_WCE)) || (defined(_WIN32_WCE) && (_WIN32_WCE >= 420)) // for edit control DWORD GetEditSel() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, CB_GETEDITSEL, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, CB_GETEDITSEL, 0, 0L); } BOOL SetEditSel(int nStartChar, int nEndChar) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, CB_SETEDITSEL, 0, MAKELONG(nStartChar, nEndChar)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, CB_SETEDITSEL, 0, MAKELONG(nStartChar, nEndChar)); } // for combobox item DWORD_PTR GetItemData(int nIndex) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD_PTR)::SendMessage(m_hWnd, CB_GETITEMDATA, nIndex, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD_PTR)::SendMessage(this->m_hWnd, CB_GETITEMDATA, nIndex, 0L); } int SetItemData(int nIndex, DWORD_PTR dwItemData) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, CB_SETITEMDATA, nIndex, (LPARAM)dwItemData); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_SETITEMDATA, nIndex, (LPARAM)dwItemData); } void* GetItemDataPtr(int nIndex) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); return (void*)GetItemData(nIndex); } int SetItemDataPtr(int nIndex, void* pData) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); return SetItemData(nIndex, (DWORD_PTR)pData); } int GetLBText(int nIndex, LPTSTR lpszText) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, CB_GETLBTEXT, nIndex, (LPARAM)lpszText); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_GETLBTEXT, nIndex, (LPARAM)lpszText); } -#ifndef _ATL_NO_COM BOOL GetLBTextBSTR(int nIndex, BSTR& bstrText) const { USES_CONVERSION; - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(bstrText == NULL); int nLen = GetLBTextLen(nIndex); if(nLen == CB_ERR) return FALSE; - CTempBuffer buff; + ATL::CTempBuffer buff; LPTSTR lpstrText = buff.Allocate(nLen + 1); if(lpstrText == NULL) return FALSE; @@ -952,12 +898,11 @@ public: bstrText = ::SysAllocString(T2OLE(lpstrText)); return (bstrText != NULL) ? TRUE : FALSE; } -#endif // !_ATL_NO_COM -#if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) - int GetLBText(int nIndex, _CSTRING_NS::CString& strText) const +#ifdef __ATLSTR_H__ + int GetLBText(int nIndex, ATL::CString& strText) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); int cchLen = GetLBTextLen(nIndex); if(cchLen == CB_ERR) return CB_ERR; @@ -970,186 +915,175 @@ public: } return nRet; } -#endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) +#endif // __ATLSTR_H__ int GetLBTextLen(int nIndex) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, CB_GETLBTEXTLEN, nIndex, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_GETLBTEXTLEN, nIndex, 0L); } int GetItemHeight(int nIndex) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, CB_GETITEMHEIGHT, nIndex, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_GETITEMHEIGHT, nIndex, 0L); } int SetItemHeight(int nIndex, UINT cyItemHeight) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, CB_SETITEMHEIGHT, nIndex, MAKELONG(cyItemHeight, 0)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_SETITEMHEIGHT, nIndex, MAKELONG(cyItemHeight, 0)); } BOOL GetExtendedUI() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, CB_GETEXTENDEDUI, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, CB_GETEXTENDEDUI, 0, 0L); } int SetExtendedUI(BOOL bExtended = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, CB_SETEXTENDEDUI, bExtended, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_SETEXTENDEDUI, bExtended, 0L); } void GetDroppedControlRect(LPRECT lprect) const { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, CB_GETDROPPEDCONTROLRECT, 0, (LPARAM)lprect); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, CB_GETDROPPEDCONTROLRECT, 0, (LPARAM)lprect); } BOOL GetDroppedState() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, CB_GETDROPPEDSTATE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, CB_GETDROPPEDSTATE, 0, 0L); } -#if (_WIN32_WINNT >= 0x0501) int GetMinVisible() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, CB_GETMINVISIBLE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_GETMINVISIBLE, 0, 0L); } BOOL SetMinVisible(int nMinVisible) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, CB_SETMINVISIBLE, nMinVisible, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, CB_SETMINVISIBLE, nMinVisible, 0L); } // Vista only BOOL GetCueBannerText(LPWSTR lpwText, int cchText) const { -#ifndef CB_GETCUEBANNER - const UINT CB_GETCUEBANNER = (CBM_FIRST + 4); -#endif - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, CB_GETCUEBANNER, (WPARAM)lpwText, cchText); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, CB_GETCUEBANNER, (WPARAM)lpwText, cchText); } // Vista only BOOL SetCueBannerText(LPCWSTR lpcwText) { -#ifndef CB_SETCUEBANNER - const UINT CB_SETCUEBANNER = (CBM_FIRST + 3); -#endif - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, CB_SETCUEBANNER, 0, (LPARAM)lpcwText); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, CB_SETCUEBANNER, 0, (LPARAM)lpcwText); } -#endif // (_WIN32_WINNT >= 0x0501) // Operations int InitStorage(int nItems, UINT nBytes) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, CB_INITSTORAGE, (WPARAM)nItems, nBytes); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_INITSTORAGE, (WPARAM)nItems, nBytes); } void ResetContent() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, CB_RESETCONTENT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, CB_RESETCONTENT, 0, 0L); } // for edit control BOOL LimitText(int nMaxChars) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, CB_LIMITTEXT, nMaxChars, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, CB_LIMITTEXT, nMaxChars, 0L); } // for drop-down combo boxes void ShowDropDown(BOOL bShowIt = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, CB_SHOWDROPDOWN, bShowIt, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, CB_SHOWDROPDOWN, bShowIt, 0L); } // manipulating listbox items int AddString(LPCTSTR lpszString) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, CB_ADDSTRING, 0, (LPARAM)lpszString); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_ADDSTRING, 0, (LPARAM)lpszString); } int DeleteString(UINT nIndex) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, CB_DELETESTRING, nIndex, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_DELETESTRING, nIndex, 0L); } int InsertString(int nIndex, LPCTSTR lpszString) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, CB_INSERTSTRING, nIndex, (LPARAM)lpszString); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_INSERTSTRING, nIndex, (LPARAM)lpszString); } -#ifndef _WIN32_WCE int Dir(UINT attr, LPCTSTR lpszWildCard) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, CB_DIR, attr, (LPARAM)lpszWildCard); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_DIR, attr, (LPARAM)lpszWildCard); } -#endif // !_WIN32_WCE // selection helpers int FindString(int nStartAfter, LPCTSTR lpszString) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, CB_FINDSTRING, nStartAfter, (LPARAM)lpszString); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_FINDSTRING, nStartAfter, (LPARAM)lpszString); } int FindStringExact(int nIndexStart, LPCTSTR lpszFind) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, CB_FINDSTRINGEXACT, nIndexStart, (LPARAM)lpszFind); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_FINDSTRINGEXACT, nIndexStart, (LPARAM)lpszFind); } int SelectString(int nStartAfter, LPCTSTR lpszString) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, CB_SELECTSTRING, nStartAfter, (LPARAM)lpszString); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_SELECTSTRING, nStartAfter, (LPARAM)lpszString); } // Clipboard operations void Clear() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, WM_CLEAR, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, WM_CLEAR, 0, 0L); } void Copy() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, WM_COPY, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, WM_COPY, 0, 0L); } void Cut() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, WM_CUT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, WM_CUT, 0, 0L); } void Paste() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, WM_PASTE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, WM_PASTE, 0, 0L); } }; typedef CComboBoxT CComboBox; -#endif // !WIN32_PLATFORM_WFSP /////////////////////////////////////////////////////////////////////////////// // CEdit - client side for a Windows EDIT control @@ -1164,7 +1098,7 @@ public: CEditT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -1183,104 +1117,102 @@ public: BOOL CanUndo() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_CANUNDO, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_CANUNDO, 0, 0L); } int GetLineCount() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, EM_GETLINECOUNT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, EM_GETLINECOUNT, 0, 0L); } BOOL GetModify() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_GETMODIFY, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_GETMODIFY, 0, 0L); } void SetModify(BOOL bModified = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_SETMODIFY, bModified, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SETMODIFY, bModified, 0L); } void GetRect(LPRECT lpRect) const { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_GETRECT, 0, (LPARAM)lpRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_GETRECT, 0, (LPARAM)lpRect); } DWORD GetSel() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, EM_GETSEL, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, EM_GETSEL, 0, 0L); } void GetSel(int& nStartChar, int& nEndChar) const { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_GETSEL, (WPARAM)&nStartChar, (LPARAM)&nEndChar); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_GETSEL, (WPARAM)&nStartChar, (LPARAM)&nEndChar); } -#ifndef _WIN32_WCE HLOCAL GetHandle() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (HLOCAL)::SendMessage(m_hWnd, EM_GETHANDLE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HLOCAL)::SendMessage(this->m_hWnd, EM_GETHANDLE, 0, 0L); } void SetHandle(HLOCAL hBuffer) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_SETHANDLE, (WPARAM)hBuffer, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SETHANDLE, (WPARAM)hBuffer, 0L); } -#endif // !_WIN32_WCE DWORD GetMargins() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, EM_GETMARGINS, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, EM_GETMARGINS, 0, 0L); } void GetMargins(UINT& nLeft, UINT& nRight) const { - ATLASSERT(::IsWindow(m_hWnd)); - DWORD dwRet = (DWORD)::SendMessage(m_hWnd, EM_GETMARGINS, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, EM_GETMARGINS, 0, 0L); nLeft = LOWORD(dwRet); nRight = HIWORD(dwRet); } void SetMargins(UINT nLeft, UINT nRight, WORD wFlags = EC_LEFTMARGIN | EC_RIGHTMARGIN) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_SETMARGINS, wFlags, MAKELONG(nLeft, nRight)); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SETMARGINS, wFlags, MAKELONG(nLeft, nRight)); } UINT GetLimitText() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (UINT)::SendMessage(m_hWnd, EM_GETLIMITTEXT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, EM_GETLIMITTEXT, 0, 0L); } void SetLimitText(UINT nMax) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_SETLIMITTEXT, nMax, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SETLIMITTEXT, nMax, 0L); } POINT PosFromChar(UINT nChar) const { - ATLASSERT(::IsWindow(m_hWnd)); - DWORD dwRet = (DWORD)::SendMessage(m_hWnd, EM_POSFROMCHAR, nChar, 0); + ATLASSERT(::IsWindow(this->m_hWnd)); + DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, EM_POSFROMCHAR, nChar, 0); POINT point = { GET_X_LPARAM(dwRet), GET_Y_LPARAM(dwRet) }; return point; } int CharFromPos(POINT pt, int* pLine = NULL) const { - ATLASSERT(::IsWindow(m_hWnd)); - DWORD dwRet = (DWORD)::SendMessage(m_hWnd, EM_CHARFROMPOS, 0, MAKELPARAM(pt.x, pt.y)); + ATLASSERT(::IsWindow(this->m_hWnd)); + DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, EM_CHARFROMPOS, 0, MAKELPARAM(pt.x, pt.y)); if(pLine != NULL) *pLine = (int)(short)HIWORD(dwRet); return (int)(short)LOWORD(dwRet); @@ -1289,168 +1221,160 @@ public: // NOTE: first word in lpszBuffer must contain the size of the buffer! int GetLine(int nIndex, LPTSTR lpszBuffer) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, EM_GETLINE, nIndex, (LPARAM)lpszBuffer); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, EM_GETLINE, nIndex, (LPARAM)lpszBuffer); } int GetLine(int nIndex, LPTSTR lpszBuffer, int nMaxLength) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); *(LPWORD)lpszBuffer = (WORD)nMaxLength; - return (int)::SendMessage(m_hWnd, EM_GETLINE, nIndex, (LPARAM)lpszBuffer); + return (int)::SendMessage(this->m_hWnd, EM_GETLINE, nIndex, (LPARAM)lpszBuffer); } TCHAR GetPasswordChar() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (TCHAR)::SendMessage(m_hWnd, EM_GETPASSWORDCHAR, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (TCHAR)::SendMessage(this->m_hWnd, EM_GETPASSWORDCHAR, 0, 0L); } void SetPasswordChar(TCHAR ch) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_SETPASSWORDCHAR, ch, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SETPASSWORDCHAR, ch, 0L); } -#ifndef _WIN32_WCE EDITWORDBREAKPROC GetWordBreakProc() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (EDITWORDBREAKPROC)::SendMessage(m_hWnd, EM_GETWORDBREAKPROC, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (EDITWORDBREAKPROC)::SendMessage(this->m_hWnd, EM_GETWORDBREAKPROC, 0, 0L); } void SetWordBreakProc(EDITWORDBREAKPROC ewbprc) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_SETWORDBREAKPROC, 0, (LPARAM)ewbprc); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SETWORDBREAKPROC, 0, (LPARAM)ewbprc); } -#endif // !_WIN32_WCE int GetFirstVisibleLine() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, EM_GETFIRSTVISIBLELINE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, EM_GETFIRSTVISIBLELINE, 0, 0L); } -#ifndef _WIN32_WCE int GetThumb() const { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT((GetStyle() & ES_MULTILINE) != 0); - return (int)::SendMessage(m_hWnd, EM_GETTHUMB, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & ES_MULTILINE) != 0); + return (int)::SendMessage(this->m_hWnd, EM_GETTHUMB, 0, 0L); } -#endif // !_WIN32_WCE BOOL SetReadOnly(BOOL bReadOnly = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_SETREADONLY, bReadOnly, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETREADONLY, bReadOnly, 0L); } -#if (WINVER >= 0x0500) && !defined(_WIN32_WCE) UINT GetImeStatus(UINT uStatus) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (UINT)::SendMessage(m_hWnd, EM_GETIMESTATUS, uStatus, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, EM_GETIMESTATUS, uStatus, 0L); } UINT SetImeStatus(UINT uStatus, UINT uData) { - ATLASSERT(::IsWindow(m_hWnd)); - return (UINT)::SendMessage(m_hWnd, EM_SETIMESTATUS, uStatus, uData); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, EM_SETIMESTATUS, uStatus, uData); } -#endif // (WINVER >= 0x0500) && !defined(_WIN32_WCE) -#if (_WIN32_WINNT >= 0x0501) BOOL GetCueBannerText(LPCWSTR lpstrText, int cchText) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_GETCUEBANNER, (WPARAM)lpstrText, cchText); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_GETCUEBANNER, (WPARAM)lpstrText, cchText); } // bKeepWithFocus - Vista only BOOL SetCueBannerText(LPCWSTR lpstrText, BOOL bKeepWithFocus = FALSE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_SETCUEBANNER, (WPARAM)bKeepWithFocus, (LPARAM)(lpstrText)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETCUEBANNER, (WPARAM)bKeepWithFocus, (LPARAM)(lpstrText)); } -#endif // (_WIN32_WINNT >= 0x0501) // Operations void EmptyUndoBuffer() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_EMPTYUNDOBUFFER, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_EMPTYUNDOBUFFER, 0, 0L); } BOOL FmtLines(BOOL bAddEOL) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_FMTLINES, bAddEOL, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_FMTLINES, bAddEOL, 0L); } void LimitText(int nChars = 0) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_LIMITTEXT, nChars, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_LIMITTEXT, nChars, 0L); } int LineFromChar(int nIndex = -1) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, EM_LINEFROMCHAR, nIndex, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, EM_LINEFROMCHAR, nIndex, 0L); } int LineIndex(int nLine = -1) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, EM_LINEINDEX, nLine, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, EM_LINEINDEX, nLine, 0L); } int LineLength(int nLine = -1) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, EM_LINELENGTH, nLine, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, EM_LINELENGTH, nLine, 0L); } void LineScroll(int nLines, int nChars = 0) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_LINESCROLL, nChars, nLines); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_LINESCROLL, nChars, nLines); } void ReplaceSel(LPCTSTR lpszNewText, BOOL bCanUndo = FALSE) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_REPLACESEL, (WPARAM) bCanUndo, (LPARAM)lpszNewText); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_REPLACESEL, (WPARAM) bCanUndo, (LPARAM)lpszNewText); } void SetRect(LPCRECT lpRect) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_SETRECT, 0, (LPARAM)lpRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SETRECT, 0, (LPARAM)lpRect); } void SetRectNP(LPCRECT lpRect) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_SETRECTNP, 0, (LPARAM)lpRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SETRECTNP, 0, (LPARAM)lpRect); } void SetSel(DWORD dwSelection, BOOL bNoScroll = FALSE) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_SETSEL, LOWORD(dwSelection), HIWORD(dwSelection)); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SETSEL, LOWORD(dwSelection), HIWORD(dwSelection)); if(!bNoScroll) - ::SendMessage(m_hWnd, EM_SCROLLCARET, 0, 0L); + ::SendMessage(this->m_hWnd, EM_SCROLLCARET, 0, 0L); } void SetSel(int nStartChar, int nEndChar, BOOL bNoScroll = FALSE) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_SETSEL, nStartChar, nEndChar); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SETSEL, nStartChar, nEndChar); if(!bNoScroll) - ::SendMessage(m_hWnd, EM_SCROLLCARET, 0, 0L); + ::SendMessage(this->m_hWnd, EM_SCROLLCARET, 0, 0L); } void SetSelAll(BOOL bNoScroll = FALSE) @@ -1465,33 +1389,33 @@ public: BOOL SetTabStops(int nTabStops, LPINT rgTabStops) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_SETTABSTOPS, nTabStops, (LPARAM)rgTabStops); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETTABSTOPS, nTabStops, (LPARAM)rgTabStops); } BOOL SetTabStops() { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_SETTABSTOPS, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETTABSTOPS, 0, 0L); } BOOL SetTabStops(const int& cxEachStop) // takes an 'int' { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_SETTABSTOPS, 1, (LPARAM)(LPINT)&cxEachStop); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETTABSTOPS, 1, (LPARAM)(LPINT)&cxEachStop); } void ScrollCaret() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_SCROLLCARET, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SCROLLCARET, 0, 0L); } int Scroll(int nScrollAction) { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT((GetStyle() & ES_MULTILINE) != 0); - LRESULT lRet = ::SendMessage(m_hWnd, EM_SCROLL, nScrollAction, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & ES_MULTILINE) != 0); + LRESULT lRet = ::SendMessage(this->m_hWnd, EM_SCROLL, nScrollAction, 0L); if(!(BOOL)HIWORD(lRet)) return -1; // failed return (int)(short)LOWORD(lRet); @@ -1506,107 +1430,190 @@ public: void AppendText(LPCTSTR lpstrText, BOOL bNoScroll = FALSE, BOOL bCanUndo = FALSE) { - InsertText(GetWindowTextLength(), lpstrText, bNoScroll, bCanUndo); + InsertText(this->GetWindowTextLength(), lpstrText, bNoScroll, bCanUndo); } -#if (_WIN32_WINNT >= 0x0501) BOOL ShowBalloonTip(PEDITBALLOONTIP pEditBaloonTip) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_SHOWBALLOONTIP, 0, (LPARAM)pEditBaloonTip); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SHOWBALLOONTIP, 0, (LPARAM)pEditBaloonTip); } BOOL HideBalloonTip() { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_HIDEBALLOONTIP, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_HIDEBALLOONTIP, 0, 0L); } -#endif // (_WIN32_WINNT >= 0x0501) #if (_WIN32_WINNT >= 0x0600) DWORD GetHilite() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, EM_GETHILITE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, EM_GETHILITE, 0, 0L); } void GetHilite(int& nStartChar, int& nEndChar) const { - ATLASSERT(::IsWindow(m_hWnd)); - DWORD dwRet = (DWORD)::SendMessage(m_hWnd, EM_GETHILITE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, EM_GETHILITE, 0, 0L); nStartChar = (int)(short)LOWORD(dwRet); nEndChar = (int)(short)HIWORD(dwRet); } void SetHilite(int nStartChar, int nEndChar) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_SETHILITE, nStartChar, nEndChar); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SETHILITE, nStartChar, nEndChar); } #endif // (_WIN32_WINNT >= 0x0600) // Clipboard operations BOOL Undo() { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_UNDO, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_UNDO, 0, 0L); } void Clear() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, WM_CLEAR, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, WM_CLEAR, 0, 0L); } void Copy() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, WM_COPY, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, WM_COPY, 0, 0L); } void Cut() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, WM_CUT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, WM_CUT, 0, 0L); } void Paste() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, WM_PASTE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, WM_PASTE, 0, 0L); + } + + // New messages added in Windows 10.0.17763 +#if defined(NTDDI_VERSION) && defined(NTDDI_WIN10_RS5) && (NTDDI_VERSION >= NTDDI_WIN10_RS5) + DWORD SetExtendedStyle(DWORD dwStyle, DWORD dwMask) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return ::SendMessage(this->m_hWnd, EM_SETEXTENDEDSTYLE, dwMask, dwStyle); + } + + DWORD GetExtendedStyle() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return ::SendMessage(this->m_hWnd, EM_GETEXTENDEDSTYLE, 0, 0L); + } + + BOOL SetEndOfLine(EC_ENDOFLINE eolType) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETENDOFLINE, eolType, 0L); + } + + EC_ENDOFLINE GetEndOfLine() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (EC_ENDOFLINE)::SendMessage(this->m_hWnd, EM_GETENDOFLINE, 0, 0L); + } + + BOOL EnableSearchWeb(BOOL bEnable) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_ENABLESEARCHWEB, (WPARAM)bEnable, 0L); + } + + void SearchWeb() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SEARCHWEB, 0, 0L); + } + + BOOL SetCaretIndex(DWORD dwCaretIndex) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETCARETINDEX, dwCaretIndex, 0L); + } + + DWORD GetCaretIndex() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return ::SendMessage(this->m_hWnd, EM_GETCARETINDEX, 0, 0L); + } + + BOOL GetZoom(int& nNum, int& nDen) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_GETZOOM, (WPARAM)&nNum, (LPARAM)&nDen); + } + + BOOL SetZoom(int nNum, int nDen) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((nNum >= 0) && (nNum <= 64)); + ATLASSERT((nDen >= 0) && (nDen <= 64)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETZOOM, nNum, nDen); } -#ifdef WIN32_PLATFORM_WFSP // SmartPhone only messages - DWORD GetExtendedStyle() + DWORD GetFileLineFromChar(DWORD dwCharIndex) const { - return SendMessage(EM_GETEXTENDEDSTYLE); + ATLASSERT(::IsWindow(this->m_hWnd)); + return ::SendMessage(this->m_hWnd, EM_FILELINEFROMCHAR, dwCharIndex, 0L); } - DWORD SetExtendedStyle(DWORD dwMask, DWORD dwExStyle) + DWORD GetFileLineIndex(DWORD dwLineNum) const { - return SendMessage(EM_SETEXTENDEDSTYLE, (WPARAM)dwMask, (LPARAM)dwExStyle); + ATLASSERT(::IsWindow(this->m_hWnd)); + return ::SendMessage(this->m_hWnd, EM_FILELINEINDEX, dwLineNum, 0L); } - DWORD GetInputMode(BOOL bCurrentMode = TRUE) + DWORD GetFileLineLength(DWORD dwCharIndex) const { - return SendMessage(EM_GETINPUTMODE, 0, (LPARAM)bCurrentMode); + ATLASSERT(::IsWindow(this->m_hWnd)); + return ::SendMessage(this->m_hWnd, EM_FILELINELENGTH, dwCharIndex, 0L); } - BOOL SetInputMode(DWORD dwMode) + DWORD GetFileLine(DWORD dwLineNum, LPTSTR lpstrLine, WORD wLen) const { - return SendMessage(EM_SETINPUTMODE, 0, (LPARAM)dwMode); + ATLASSERT(::IsWindow(this->m_hWnd)); + WORD* pw = (WORD*)lpstrLine; + *pw = wLen; + return ::SendMessage(this->m_hWnd, EM_GETFILELINE, dwLineNum, (LPARAM)lpstrLine); } - BOOL SetSymbols(LPCTSTR szSymbols) +#ifdef __ATLSTR_H__ + ATL::CString GetFileLine(DWORD dwLineNum) const { - return SendMessage(EM_SETSYMBOLS, 0, (LPARAM)szSymbols); + ATL::CString strLine; + DWORD dwCharIndex = GetFileLineIndex(dwLineNum); + if(dwCharIndex != (DWORD)-1) + { + DWORD dwLen = GetFileLineLength(dwCharIndex); + if(dwLen > 0) + { + LPTSTR lpstrLine = strLine.GetBufferSetLength(dwLen); + ATLVERIFY(GetFileLine(dwLineNum, lpstrLine, (WORD)dwLen) == dwLen); + strLine.ReleaseBuffer(); + } + } + + return strLine; } +#endif // __ATLSTR_H__ - BOOL ResetSymbols() + DWORD GetFileLineCount() const { - return SendMessage(EM_SETSYMBOLS); + ATLASSERT(::IsWindow(this->m_hWnd)); + return ::SendMessage(this->m_hWnd, EM_GETFILELINECOUNT, 0, 0L); } -#endif // WIN32_PLATFORM_WFSP +#endif // defined(NTDDI_VERSION) && defined(NTDDI_WIN10_RS5) && (NTDDI_VERSION >= NTDDI_WIN10_RS5) }; typedef CEditT CEdit; @@ -1748,7 +1755,7 @@ public: CScrollBarT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -1765,82 +1772,70 @@ public: return _T("SCROLLBAR"); } -#ifndef _WIN32_WCE int GetScrollPos() const { - ATLASSERT(::IsWindow(m_hWnd)); - return ::GetScrollPos(m_hWnd, SB_CTL); + ATLASSERT(::IsWindow(this->m_hWnd)); + return ::GetScrollPos(this->m_hWnd, SB_CTL); } -#endif // !_WIN32_WCE int SetScrollPos(int nPos, BOOL bRedraw = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return ::SetScrollPos(m_hWnd, SB_CTL, nPos, bRedraw); + ATLASSERT(::IsWindow(this->m_hWnd)); + return ::SetScrollPos(this->m_hWnd, SB_CTL, nPos, bRedraw); } -#ifndef _WIN32_WCE void GetScrollRange(LPINT lpMinPos, LPINT lpMaxPos) const { - ATLASSERT(::IsWindow(m_hWnd)); - ::GetScrollRange(m_hWnd, SB_CTL, lpMinPos, lpMaxPos); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::GetScrollRange(this->m_hWnd, SB_CTL, lpMinPos, lpMaxPos); } -#endif // !_WIN32_WCE void SetScrollRange(int nMinPos, int nMaxPos, BOOL bRedraw = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SetScrollRange(m_hWnd, SB_CTL, nMinPos, nMaxPos, bRedraw); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SetScrollRange(this->m_hWnd, SB_CTL, nMinPos, nMaxPos, bRedraw); } BOOL GetScrollInfo(LPSCROLLINFO lpScrollInfo) const { - ATLASSERT(::IsWindow(m_hWnd)); - return ::GetScrollInfo(m_hWnd, SB_CTL, lpScrollInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + return ::GetScrollInfo(this->m_hWnd, SB_CTL, lpScrollInfo); } int SetScrollInfo(LPSCROLLINFO lpScrollInfo, BOOL bRedraw = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return ::SetScrollInfo(m_hWnd, SB_CTL, lpScrollInfo, bRedraw); + ATLASSERT(::IsWindow(this->m_hWnd)); + return ::SetScrollInfo(this->m_hWnd, SB_CTL, lpScrollInfo, bRedraw); } -#ifndef _WIN32_WCE int GetScrollLimit() const { SCROLLINFO info = { sizeof(SCROLLINFO), SIF_RANGE | SIF_PAGE }; - ::GetScrollInfo(m_hWnd, SB_CTL, &info); + ::GetScrollInfo(this->m_hWnd, SB_CTL, &info); if(info.nPage > 1) info.nMax -= info.nPage - 1; return info.nMax; } -#if (WINVER >= 0x0500) BOOL GetScrollBarInfo(PSCROLLBARINFO pScrollBarInfo) const { - ATLASSERT(::IsWindow(m_hWnd)); -#if (_WIN32_WINNT >= 0x0501) - return (BOOL)::SendMessage(m_hWnd, SBM_GETSCROLLBARINFO, 0, (LPARAM)pScrollBarInfo); -#else // !(_WIN32_WINNT >= 0x0501) - return ::GetScrollBarInfo(m_hWnd, OBJID_CLIENT, pScrollBarInfo); -#endif // !(_WIN32_WINNT >= 0x0501) + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, SBM_GETSCROLLBARINFO, 0, (LPARAM)pScrollBarInfo); } -#endif // (WINVER >= 0x0500) // Operations void ShowScrollBar(BOOL bShow = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - ::ShowScrollBar(m_hWnd, SB_CTL, bShow); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::ShowScrollBar(this->m_hWnd, SB_CTL, bShow); } BOOL EnableScrollBar(UINT nArrowFlags = ESB_ENABLE_BOTH) { - ATLASSERT(::IsWindow(m_hWnd)); - return ::EnableScrollBar(m_hWnd, SB_CTL, nArrowFlags); + ATLASSERT(::IsWindow(this->m_hWnd)); + return ::EnableScrollBar(this->m_hWnd, SB_CTL, nArrowFlags); } -#endif // !_WIN32_WCE }; typedef CScrollBarT CScrollBar; @@ -1994,7 +1989,6 @@ public: return (m_hImageList != NULL) ? TRUE : FALSE; } -#ifndef _WIN32_WCE #ifdef __IStream_INTERFACE_DEFINED__ BOOL CreateFromStream(LPSTREAM lpStream) { @@ -2003,7 +1997,6 @@ public: return (m_hImageList != NULL) ? TRUE : FALSE; } #endif // __IStream_INTERFACE_DEFINED__ -#endif // !_WIN32_WCE BOOL Destroy() { @@ -2103,7 +2096,6 @@ public: } #ifdef __IStream_INTERFACE_DEFINED__ -#ifndef _WIN32_WCE static HIMAGELIST Read(LPSTREAM lpStream) { return ImageList_Read(lpStream); @@ -2114,9 +2106,7 @@ public: ATLASSERT(m_hImageList != NULL); return ImageList_Write(m_hImageList, lpStream); } -#endif // !_WIN32_WCE -#if (_WIN32_WINNT >= 0x0501) static HRESULT ReadEx(DWORD dwFlags, LPSTREAM lpStream, REFIID riid, PVOID* ppv) { return ImageList_ReadEx(dwFlags, lpStream, riid, ppv); @@ -2127,7 +2117,6 @@ public: ATLASSERT(m_hImageList != NULL); return ImageList_WriteEx(m_hImageList, dwFlags, lpStream); } -#endif // (_WIN32_WINNT >= 0x0501) #endif // __IStream_INTERFACE_DEFINED__ // Drag operations @@ -2195,7 +2184,6 @@ public: return ImageList_DragLeave(hWnd); } -#if (_WIN32_IE >= 0x0400) CImageList Duplicate() const { ATLASSERT(m_hImageList != NULL); @@ -2207,15 +2195,12 @@ public: ATLASSERT(hImageList != NULL); return CImageList(ImageList_Duplicate(hImageList)); } -#endif // (_WIN32_IE >= 0x0400) }; /////////////////////////////////////////////////////////////////////////////// // CToolTipCtrl -#ifndef _WIN32_WCE - class CToolInfo : public TOOLINFO { public: @@ -2263,7 +2248,7 @@ public: CToolTipCtrlT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -2282,32 +2267,32 @@ public: void GetText(LPTOOLINFO lpToolInfo) const { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TTM_GETTEXT, 0, (LPARAM)&lpToolInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_GETTEXT, 0, (LPARAM)&lpToolInfo); } void GetText(LPTSTR lpstrText, HWND hWnd, UINT_PTR nIDTool = 0) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(hWnd != NULL); CToolInfo ti(0, hWnd, nIDTool, NULL, lpstrText); - ::SendMessage(m_hWnd, TTM_GETTEXT, 0, ti); + ::SendMessage(this->m_hWnd, TTM_GETTEXT, 0, ti); } BOOL GetToolInfo(LPTOOLINFO lpToolInfo) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TTM_GETTOOLINFO, 0, (LPARAM)lpToolInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TTM_GETTOOLINFO, 0, (LPARAM)lpToolInfo); } BOOL GetToolInfo(HWND hWnd, UINT_PTR nIDTool, UINT* puFlags, LPRECT lpRect, LPTSTR lpstrText) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(hWnd != NULL); ATLASSERT(puFlags != NULL); ATLASSERT(lpRect != NULL); CToolInfo ti(0, hWnd, nIDTool, NULL, lpstrText); - BOOL bRet = (BOOL)::SendMessage(m_hWnd, TTM_GETTOOLINFO, 0, ti); + BOOL bRet = (BOOL)::SendMessage(this->m_hWnd, TTM_GETTOOLINFO, 0, ti); if(bRet != FALSE) { *puFlags = ti.uFlags; @@ -2318,191 +2303,188 @@ public: void SetToolInfo(LPTOOLINFO lpToolInfo) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TTM_SETTOOLINFO, 0, (LPARAM)lpToolInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_SETTOOLINFO, 0, (LPARAM)lpToolInfo); } void SetToolRect(LPTOOLINFO lpToolInfo) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TTM_NEWTOOLRECT, 0, (LPARAM)lpToolInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_NEWTOOLRECT, 0, (LPARAM)lpToolInfo); } void SetToolRect(HWND hWnd, UINT_PTR nIDTool, LPCRECT lpRect) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(hWnd != NULL); ATLASSERT(nIDTool != 0); CToolInfo ti(0, hWnd, nIDTool, (LPRECT)lpRect, NULL); - ::SendMessage(m_hWnd, TTM_NEWTOOLRECT, 0, ti); + ::SendMessage(this->m_hWnd, TTM_NEWTOOLRECT, 0, ti); } int GetToolCount() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TTM_GETTOOLCOUNT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TTM_GETTOOLCOUNT, 0, 0L); } int GetDelayTime(DWORD dwType) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TTM_GETDELAYTIME, dwType, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TTM_GETDELAYTIME, dwType, 0L); } void SetDelayTime(DWORD dwType, int nTime) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TTM_SETDELAYTIME, dwType, MAKELPARAM(nTime, 0)); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_SETDELAYTIME, dwType, MAKELPARAM(nTime, 0)); } void GetMargin(LPRECT lpRect) const { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TTM_GETMARGIN, 0, (LPARAM)lpRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_GETMARGIN, 0, (LPARAM)lpRect); } void SetMargin(LPRECT lpRect) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TTM_SETMARGIN, 0, (LPARAM)lpRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_SETMARGIN, 0, (LPARAM)lpRect); } int GetMaxTipWidth() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TTM_GETMAXTIPWIDTH, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TTM_GETMAXTIPWIDTH, 0, 0L); } int SetMaxTipWidth(int nWidth) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TTM_SETMAXTIPWIDTH, 0, nWidth); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TTM_SETMAXTIPWIDTH, 0, nWidth); } COLORREF GetTipBkColor() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, TTM_GETTIPBKCOLOR, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, TTM_GETTIPBKCOLOR, 0, 0L); } void SetTipBkColor(COLORREF clr) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TTM_SETTIPBKCOLOR, (WPARAM)clr, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_SETTIPBKCOLOR, (WPARAM)clr, 0L); } COLORREF GetTipTextColor() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, TTM_GETTIPTEXTCOLOR, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, TTM_GETTIPTEXTCOLOR, 0, 0L); } void SetTipTextColor(COLORREF clr) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TTM_SETTIPTEXTCOLOR, (WPARAM)clr, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_SETTIPTEXTCOLOR, (WPARAM)clr, 0L); } BOOL GetCurrentTool(LPTOOLINFO lpToolInfo) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TTM_GETCURRENTTOOL, 0, (LPARAM)lpToolInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TTM_GETCURRENTTOOL, 0, (LPARAM)lpToolInfo); } -#if (_WIN32_IE >= 0x0500) SIZE GetBubbleSize(LPTOOLINFO lpToolInfo) const { - ATLASSERT(::IsWindow(m_hWnd)); - DWORD dwRet = (DWORD)::SendMessage(m_hWnd, TTM_GETBUBBLESIZE, 0, (LPARAM)lpToolInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, TTM_GETBUBBLESIZE, 0, (LPARAM)lpToolInfo); SIZE size = { GET_X_LPARAM(dwRet), GET_Y_LPARAM(dwRet) }; return size; } BOOL SetTitle(UINT_PTR uIcon, LPCTSTR lpstrTitle) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TTM_SETTITLE, uIcon, (LPARAM)lpstrTitle); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TTM_SETTITLE, uIcon, (LPARAM)lpstrTitle); } + BOOL SetTitle(HICON hIcon, LPCTSTR lpstrTitle) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TTM_SETTITLE, (WPARAM)hIcon, (LPARAM)lpstrTitle); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TTM_SETTITLE, (WPARAM)hIcon, (LPARAM)lpstrTitle); } -#endif // (_WIN32_IE >= 0x0500) -#if (_WIN32_WINNT >= 0x0501) void GetTitle(PTTGETTITLE pTTGetTitle) const { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TTM_GETTITLE, 0, (LPARAM)pTTGetTitle); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_GETTITLE, 0, (LPARAM)pTTGetTitle); } void SetWindowTheme(LPCWSTR lpstrTheme) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TTM_SETWINDOWTHEME, 0, (LPARAM)lpstrTheme); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_SETWINDOWTHEME, 0, (LPARAM)lpstrTheme); } -#endif // (_WIN32_WINNT >= 0x0501) // Operations void Activate(BOOL bActivate) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TTM_ACTIVATE, bActivate, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_ACTIVATE, bActivate, 0L); } BOOL AddTool(LPTOOLINFO lpToolInfo) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TTM_ADDTOOL, 0, (LPARAM)lpToolInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TTM_ADDTOOL, 0, (LPARAM)lpToolInfo); } BOOL AddTool(HWND hWnd, ATL::_U_STRINGorID text = LPSTR_TEXTCALLBACK, LPCRECT lpRectTool = NULL, UINT_PTR nIDTool = 0) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(hWnd != NULL); // the toolrect and toolid must both be zero or both valid - ATLASSERT((lpRectTool != NULL && nIDTool != 0) || (lpRectTool == NULL && nIDTool == 0)); + ATLASSERT(((lpRectTool != NULL) && (nIDTool != 0)) || ((lpRectTool == NULL) && (nIDTool == 0))); CToolInfo ti(0, hWnd, nIDTool, (LPRECT)lpRectTool, (LPTSTR)text.m_lpstr); - return (BOOL)::SendMessage(m_hWnd, TTM_ADDTOOL, 0, ti); + return (BOOL)::SendMessage(this->m_hWnd, TTM_ADDTOOL, 0, ti); } void DelTool(LPTOOLINFO lpToolInfo) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TTM_DELTOOL, 0, (LPARAM)lpToolInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_DELTOOL, 0, (LPARAM)lpToolInfo); } void DelTool(HWND hWnd, UINT_PTR nIDTool = 0) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(hWnd != NULL); CToolInfo ti(0, hWnd, nIDTool, NULL, NULL); - ::SendMessage(m_hWnd, TTM_DELTOOL, 0, ti); + ::SendMessage(this->m_hWnd, TTM_DELTOOL, 0, ti); } BOOL HitTest(LPTTHITTESTINFO lpHitTestInfo) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TTM_HITTEST, 0, (LPARAM)lpHitTestInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TTM_HITTEST, 0, (LPARAM)lpHitTestInfo); } BOOL HitTest(HWND hWnd, POINT pt, LPTOOLINFO lpToolInfo) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(hWnd != NULL); ATLASSERT(lpToolInfo != NULL); - TTHITTESTINFO hti = { 0 }; + TTHITTESTINFO hti = {}; hti.ti.cbSize = RunTimeHelper::SizeOf_TOOLINFO(); hti.hwnd = hWnd; hti.pt.x = pt.x; hti.pt.y = pt.y; - if((BOOL)::SendMessage(m_hWnd, TTM_HITTEST, 0, (LPARAM)&hti) != FALSE) + if((BOOL)::SendMessage(this->m_hWnd, TTM_HITTEST, 0, (LPARAM)&hti) != FALSE) { *lpToolInfo = hti.ti; return TRUE; @@ -2512,87 +2494,79 @@ public: void RelayEvent(LPMSG lpMsg) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TTM_RELAYEVENT, 0, (LPARAM)lpMsg); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_RELAYEVENT, 0, (LPARAM)lpMsg); } void UpdateTipText(LPTOOLINFO lpToolInfo) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TTM_UPDATETIPTEXT, 0, (LPARAM)lpToolInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_UPDATETIPTEXT, 0, (LPARAM)lpToolInfo); } void UpdateTipText(ATL::_U_STRINGorID text, HWND hWnd, UINT_PTR nIDTool = 0) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(hWnd != NULL); CToolInfo ti(0, hWnd, nIDTool, NULL, (LPTSTR)text.m_lpstr); - ::SendMessage(m_hWnd, TTM_UPDATETIPTEXT, 0, ti); + ::SendMessage(this->m_hWnd, TTM_UPDATETIPTEXT, 0, ti); } BOOL EnumTools(UINT_PTR nTool, LPTOOLINFO lpToolInfo) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TTM_ENUMTOOLS, nTool, (LPARAM)lpToolInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TTM_ENUMTOOLS, nTool, (LPARAM)lpToolInfo); } void Pop() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TTM_POP, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_POP, 0, 0L); } void TrackActivate(LPTOOLINFO lpToolInfo, BOOL bActivate) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TTM_TRACKACTIVATE, bActivate, (LPARAM)lpToolInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_TRACKACTIVATE, bActivate, (LPARAM)lpToolInfo); } void TrackActivate(HWND hWnd, UINT_PTR nIDTool, BOOL bActivate) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(hWnd != NULL); CToolInfo ti(0, hWnd, nIDTool); - ::SendMessage(m_hWnd, TTM_TRACKACTIVATE, bActivate, ti); + ::SendMessage(this->m_hWnd, TTM_TRACKACTIVATE, bActivate, ti); } void TrackPosition(int xPos, int yPos) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TTM_TRACKPOSITION, 0, MAKELPARAM(xPos, yPos)); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_TRACKPOSITION, 0, MAKELPARAM(xPos, yPos)); } -#if (_WIN32_IE >= 0x0400) void Update() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TTM_UPDATE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_UPDATE, 0, 0L); } -#endif // (_WIN32_IE >= 0x0400) -#if (_WIN32_IE >= 0x0500) BOOL AdjustRect(LPRECT lpRect, BOOL bLarger /*= TRUE*/) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TTM_ADJUSTRECT, bLarger, (LPARAM)lpRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TTM_ADJUSTRECT, bLarger, (LPARAM)lpRect); } -#endif // (_WIN32_IE >= 0x0500) -#if (_WIN32_WINNT >= 0x0501) void Popup() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TTM_POPUP, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_POPUP, 0, 0L); } -#endif // (_WIN32_WINNT >= 0x0501) }; typedef CToolTipCtrlT CToolTipCtrl; -#endif // !_WIN32_WCE - /////////////////////////////////////////////////////////////////////////////// // CHeaderCtrl @@ -2607,7 +2581,7 @@ public: CHeaderCtrlT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -2626,123 +2600,119 @@ public: int GetItemCount() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, HDM_GETITEMCOUNT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, HDM_GETITEMCOUNT, 0, 0L); } BOOL GetItem(int nIndex, LPHDITEM pHeaderItem) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, HDM_GETITEM, nIndex, (LPARAM)pHeaderItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, HDM_GETITEM, nIndex, (LPARAM)pHeaderItem); } BOOL SetItem(int nIndex, LPHDITEM pHeaderItem) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, HDM_SETITEM, nIndex, (LPARAM)pHeaderItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, HDM_SETITEM, nIndex, (LPARAM)pHeaderItem); } CImageList GetImageList() const { - ATLASSERT(::IsWindow(m_hWnd)); - return CImageList((HIMAGELIST)::SendMessage(m_hWnd, HDM_GETIMAGELIST, 0, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, HDM_GETIMAGELIST, 0, 0L)); } CImageList SetImageList(HIMAGELIST hImageList) { - ATLASSERT(::IsWindow(m_hWnd)); - return CImageList((HIMAGELIST)::SendMessage(m_hWnd, HDM_SETIMAGELIST, 0, (LPARAM)hImageList)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, HDM_SETIMAGELIST, 0, (LPARAM)hImageList)); } BOOL GetOrderArray(int nSize, int* lpnArray) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, HDM_GETORDERARRAY, nSize, (LPARAM)lpnArray); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, HDM_GETORDERARRAY, nSize, (LPARAM)lpnArray); } BOOL SetOrderArray(int nSize, int* lpnArray) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, HDM_SETORDERARRAY, nSize, (LPARAM)lpnArray); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, HDM_SETORDERARRAY, nSize, (LPARAM)lpnArray); } BOOL GetItemRect(int nIndex, LPRECT lpItemRect) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, HDM_GETITEMRECT, nIndex, (LPARAM)lpItemRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, HDM_GETITEMRECT, nIndex, (LPARAM)lpItemRect); } int SetHotDivider(BOOL bPos, DWORD dwInputValue) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, HDM_SETHOTDIVIDER, bPos, dwInputValue); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, HDM_SETHOTDIVIDER, bPos, dwInputValue); } -#if (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) BOOL GetUnicodeFormat() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, HDM_GETUNICODEFORMAT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, HDM_GETUNICODEFORMAT, 0, 0L); } BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, HDM_SETUNICODEFORMAT, bUnicode, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, HDM_SETUNICODEFORMAT, bUnicode, 0L); } -#endif // (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) -#if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) int GetBitmapMargin() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, HDM_GETBITMAPMARGIN, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, HDM_GETBITMAPMARGIN, 0, 0L); } int SetBitmapMargin(int nWidth) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, HDM_SETBITMAPMARGIN, nWidth, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, HDM_SETBITMAPMARGIN, nWidth, 0L); } int SetFilterChangeTimeout(DWORD dwTimeOut) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, HDM_SETFILTERCHANGETIMEOUT, 0, dwTimeOut); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, HDM_SETFILTERCHANGETIMEOUT, 0, dwTimeOut); } -#endif // (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) #if (_WIN32_WINNT >= 0x0600) BOOL GetItemDropDownRect(int nIndex, LPRECT lpRect) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, HDM_GETITEMDROPDOWNRECT, nIndex, (LPARAM)lpRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, HDM_GETITEMDROPDOWNRECT, nIndex, (LPARAM)lpRect); } BOOL GetOverflowRect(LPRECT lpRect) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, HDM_GETOVERFLOWRECT, 0, (LPARAM)lpRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, HDM_GETOVERFLOWRECT, 0, (LPARAM)lpRect); } int GetFocusedItem() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, HDM_GETFOCUSEDITEM, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, HDM_GETFOCUSEDITEM, 0, 0L); } BOOL SetFocusedItem(int nIndex) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, HDM_SETFOCUSEDITEM, 0, nIndex); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, HDM_SETFOCUSEDITEM, 0, nIndex); } #endif // (_WIN32_WINNT >= 0x0600) // Operations int InsertItem(int nIndex, LPHDITEM phdi) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, HDM_INSERTITEM, nIndex, (LPARAM)phdi); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, HDM_INSERTITEM, nIndex, (LPARAM)phdi); } int AddItem(LPHDITEM phdi) @@ -2752,53 +2722,51 @@ public: BOOL DeleteItem(int nIndex) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, HDM_DELETEITEM, nIndex, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, HDM_DELETEITEM, nIndex, 0L); } BOOL Layout(HD_LAYOUT* pHeaderLayout) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, HDM_LAYOUT, 0, (LPARAM)pHeaderLayout); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, HDM_LAYOUT, 0, (LPARAM)pHeaderLayout); } int HitTest(LPHDHITTESTINFO lpHitTestInfo) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, HDM_HITTEST, 0, (LPARAM)lpHitTestInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, HDM_HITTEST, 0, (LPARAM)lpHitTestInfo); } int OrderToIndex(int nOrder) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, HDM_ORDERTOINDEX, nOrder, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, HDM_ORDERTOINDEX, nOrder, 0L); } CImageList CreateDragImage(int nIndex) { - ATLASSERT(::IsWindow(m_hWnd)); - return CImageList((HIMAGELIST)::SendMessage(m_hWnd, HDM_CREATEDRAGIMAGE, nIndex, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, HDM_CREATEDRAGIMAGE, nIndex, 0L)); } -#if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) int EditFilter(int nColumn, BOOL bDiscardChanges) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, HDM_EDITFILTER, nColumn, MAKELPARAM(bDiscardChanges, 0)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, HDM_EDITFILTER, nColumn, MAKELPARAM(bDiscardChanges, 0)); } int ClearFilter(int nColumn) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, HDM_CLEARFILTER, nColumn, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, HDM_CLEARFILTER, nColumn, 0L); } int ClearAllFilters() { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, HDM_CLEARFILTER, (WPARAM)-1, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, HDM_CLEARFILTER, (WPARAM)-1, 0L); } -#endif // (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) }; typedef CHeaderCtrlT CHeaderCtrl; @@ -2817,7 +2785,7 @@ public: CListViewCtrlT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -2836,57 +2804,57 @@ public: COLORREF GetBkColor() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, LVM_GETBKCOLOR, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, LVM_GETBKCOLOR, 0, 0L); } BOOL SetBkColor(COLORREF cr) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_SETBKCOLOR, 0, cr); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETBKCOLOR, 0, cr); } CImageList GetImageList(int nImageListType) const { - ATLASSERT(::IsWindow(m_hWnd)); - return CImageList((HIMAGELIST)::SendMessage(m_hWnd, LVM_GETIMAGELIST, nImageListType, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, LVM_GETIMAGELIST, nImageListType, 0L)); } CImageList SetImageList(HIMAGELIST hImageList, int nImageList) { - ATLASSERT(::IsWindow(m_hWnd)); - return CImageList((HIMAGELIST)::SendMessage(m_hWnd, LVM_SETIMAGELIST, nImageList, (LPARAM)hImageList)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, LVM_SETIMAGELIST, nImageList, (LPARAM)hImageList)); } int GetItemCount() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_GETITEMCOUNT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_GETITEMCOUNT, 0, 0L); } BOOL SetItemCount(int nItems) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_SETITEMCOUNT, nItems, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETITEMCOUNT, nItems, 0L); } BOOL GetItem(LPLVITEM pItem) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_GETITEM, 0, (LPARAM)pItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETITEM, 0, (LPARAM)pItem); } BOOL SetItem(const LVITEM* pItem) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_SETITEM, 0, (LPARAM)pItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETITEM, 0, (LPARAM)pItem); } BOOL SetItem(int nItem, int nSubItem, UINT nMask, LPCTSTR lpszItem, int nImage, UINT nState, UINT nStateMask, LPARAM lParam) { - ATLASSERT(::IsWindow(m_hWnd)); - LVITEM lvi = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + LVITEM lvi = {}; lvi.mask = nMask; lvi.iItem = nItem; lvi.iSubItem = nSubItem; @@ -2895,37 +2863,36 @@ public: lvi.pszText = (LPTSTR) lpszItem; lvi.iImage = nImage; lvi.lParam = lParam; - return (BOOL)::SendMessage(m_hWnd, LVM_SETITEM, 0, (LPARAM)&lvi); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETITEM, 0, (LPARAM)&lvi); } UINT GetItemState(int nItem, UINT nMask) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (UINT)::SendMessage(m_hWnd, LVM_GETITEMSTATE, nItem, nMask); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, LVM_GETITEMSTATE, nItem, nMask); } BOOL SetItemState(int nItem, UINT nState, UINT nStateMask) { - ATLASSERT(::IsWindow(m_hWnd)); - LVITEM lvi = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + LVITEM lvi = {}; lvi.state = nState; lvi.stateMask = nStateMask; - return (BOOL)::SendMessage(m_hWnd, LVM_SETITEMSTATE, nItem, (LPARAM)&lvi); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETITEMSTATE, nItem, (LPARAM)&lvi); } BOOL SetItemState(int nItem, LPLVITEM pItem) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_SETITEMSTATE, nItem, (LPARAM)pItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETITEMSTATE, nItem, (LPARAM)pItem); } -#ifndef _ATL_NO_COM BOOL GetItemText(int nItem, int nSubItem, BSTR& bstrText) const { USES_CONVERSION; - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(bstrText == NULL); - LVITEM lvi = { 0 }; + LVITEM lvi = {}; lvi.iSubItem = nSubItem; LPTSTR lpstrText = NULL; @@ -2938,7 +2905,7 @@ public: lpstrText[0] = NULL; lvi.cchTextMax = nLen; lvi.pszText = lpstrText; - nRes = (int)::SendMessage(m_hWnd, LVM_GETITEMTEXT, (WPARAM)nItem, (LPARAM)&lvi); + nRes = (int)::SendMessage(this->m_hWnd, LVM_GETITEMTEXT, (WPARAM)nItem, (LPARAM)&lvi); if(nRes < nLen - 1) break; delete [] lpstrText; @@ -2954,13 +2921,12 @@ public: return (bstrText != NULL) ? TRUE : FALSE; } -#endif // !_ATL_NO_COM -#if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) - int GetItemText(int nItem, int nSubItem, _CSTRING_NS::CString& strText) const +#ifdef __ATLSTR_H__ + int GetItemText(int nItem, int nSubItem, ATL::CString& strText) const { - ATLASSERT(::IsWindow(m_hWnd)); - LVITEM lvi = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + LVITEM lvi = {}; lvi.iSubItem = nSubItem; strText.Empty(); @@ -2974,297 +2940,287 @@ public: nRes = 0; break; } - nRes = (int)::SendMessage(m_hWnd, LVM_GETITEMTEXT, (WPARAM)nItem, (LPARAM)&lvi); + nRes = (int)::SendMessage(this->m_hWnd, LVM_GETITEMTEXT, (WPARAM)nItem, (LPARAM)&lvi); if(nRes < nLen - 1) break; } strText.ReleaseBuffer(); return nRes; } -#endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) +#endif // __ATLSTR_H__ int GetItemText(int nItem, int nSubItem, LPTSTR lpszText, int nLen) const { - ATLASSERT(::IsWindow(m_hWnd)); - LVITEM lvi = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + LVITEM lvi = {}; lvi.iSubItem = nSubItem; lvi.cchTextMax = nLen; lvi.pszText = lpszText; - return (int)::SendMessage(m_hWnd, LVM_GETITEMTEXT, (WPARAM)nItem, (LPARAM)&lvi); + return (int)::SendMessage(this->m_hWnd, LVM_GETITEMTEXT, (WPARAM)nItem, (LPARAM)&lvi); } BOOL SetItemText(int nItem, int nSubItem, LPCTSTR lpszText) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); return SetItem(nItem, nSubItem, LVIF_TEXT, lpszText, 0, 0, 0, 0); } DWORD_PTR GetItemData(int nItem) const { - ATLASSERT(::IsWindow(m_hWnd)); - LVITEM lvi = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + LVITEM lvi = {}; lvi.iItem = nItem; lvi.mask = LVIF_PARAM; - BOOL bRet = (BOOL)::SendMessage(m_hWnd, LVM_GETITEM, 0, (LPARAM)&lvi); + BOOL bRet = (BOOL)::SendMessage(this->m_hWnd, LVM_GETITEM, 0, (LPARAM)&lvi); return (DWORD_PTR)(bRet ? lvi.lParam : NULL); } BOOL SetItemData(int nItem, DWORD_PTR dwData) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); return SetItem(nItem, 0, LVIF_PARAM, NULL, 0, 0, 0, (LPARAM)dwData); } UINT GetCallbackMask() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (UINT)::SendMessage(m_hWnd, LVM_GETCALLBACKMASK, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, LVM_GETCALLBACKMASK, 0, 0L); } BOOL SetCallbackMask(UINT nMask) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_SETCALLBACKMASK, nMask, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETCALLBACKMASK, nMask, 0L); } BOOL GetItemPosition(int nItem, LPPOINT lpPoint) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_GETITEMPOSITION, nItem, (LPARAM)lpPoint); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETITEMPOSITION, nItem, (LPARAM)lpPoint); } BOOL SetItemPosition(int nItem, POINT pt) { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT(((GetStyle() & LVS_TYPEMASK) == LVS_ICON) || ((GetStyle() & LVS_TYPEMASK) == LVS_SMALLICON)); - return (BOOL)::SendMessage(m_hWnd, LVM_SETITEMPOSITION32, nItem, (LPARAM)&pt); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(((this->GetStyle() & LVS_TYPEMASK) == LVS_ICON) || ((this->GetStyle() & LVS_TYPEMASK) == LVS_SMALLICON)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETITEMPOSITION32, nItem, (LPARAM)&pt); } BOOL SetItemPosition(int nItem, int x, int y) { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT(((GetStyle() & LVS_TYPEMASK) == LVS_ICON) || ((GetStyle() & LVS_TYPEMASK) == LVS_SMALLICON)); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(((this->GetStyle() & LVS_TYPEMASK) == LVS_ICON) || ((this->GetStyle() & LVS_TYPEMASK) == LVS_SMALLICON)); POINT pt = { x, y }; - return (BOOL)::SendMessage(m_hWnd, LVM_SETITEMPOSITION32, nItem, (LPARAM)&pt); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETITEMPOSITION32, nItem, (LPARAM)&pt); } int GetStringWidth(LPCTSTR lpsz) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_GETSTRINGWIDTH, 0, (LPARAM)lpsz); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_GETSTRINGWIDTH, 0, (LPARAM)lpsz); } CEdit GetEditControl() const { - ATLASSERT(::IsWindow(m_hWnd)); - return CEdit((HWND)::SendMessage(m_hWnd, LVM_GETEDITCONTROL, 0, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CEdit((HWND)::SendMessage(this->m_hWnd, LVM_GETEDITCONTROL, 0, 0L)); } BOOL GetColumn(int nCol, LVCOLUMN* pColumn) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_GETCOLUMN, nCol, (LPARAM)pColumn); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETCOLUMN, nCol, (LPARAM)pColumn); } BOOL SetColumn(int nCol, const LVCOLUMN* pColumn) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_SETCOLUMN, nCol, (LPARAM)pColumn); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETCOLUMN, nCol, (LPARAM)pColumn); } int GetColumnWidth(int nCol) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_GETCOLUMNWIDTH, nCol, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_GETCOLUMNWIDTH, nCol, 0L); } BOOL SetColumnWidth(int nCol, int cx) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_SETCOLUMNWIDTH, nCol, MAKELPARAM(cx, 0)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETCOLUMNWIDTH, nCol, MAKELPARAM(cx, 0)); } BOOL GetViewRect(LPRECT lpRect) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_GETVIEWRECT, 0, (LPARAM)lpRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETVIEWRECT, 0, (LPARAM)lpRect); } COLORREF GetTextColor() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, LVM_GETTEXTCOLOR, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, LVM_GETTEXTCOLOR, 0, 0L); } BOOL SetTextColor(COLORREF cr) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_SETTEXTCOLOR, 0, cr); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETTEXTCOLOR, 0, cr); } COLORREF GetTextBkColor() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, LVM_GETTEXTBKCOLOR, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, LVM_GETTEXTBKCOLOR, 0, 0L); } BOOL SetTextBkColor(COLORREF cr) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_SETTEXTBKCOLOR, 0, cr); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETTEXTBKCOLOR, 0, cr); } int GetTopIndex() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_GETTOPINDEX, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_GETTOPINDEX, 0, 0L); } int GetCountPerPage() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_GETCOUNTPERPAGE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_GETCOUNTPERPAGE, 0, 0L); } BOOL GetOrigin(LPPOINT lpPoint) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_GETORIGIN, 0, (LPARAM)lpPoint); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETORIGIN, 0, (LPARAM)lpPoint); } UINT GetSelectedCount() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (UINT)::SendMessage(m_hWnd, LVM_GETSELECTEDCOUNT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, LVM_GETSELECTEDCOUNT, 0, 0L); } BOOL GetItemRect(int nItem, LPRECT lpRect, UINT nCode) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); lpRect->left = nCode; - return (BOOL)::SendMessage(m_hWnd, LVM_GETITEMRECT, (WPARAM)nItem, (LPARAM)lpRect); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETITEMRECT, (WPARAM)nItem, (LPARAM)lpRect); } -#ifndef _WIN32_WCE HCURSOR GetHotCursor() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (HCURSOR)::SendMessage(m_hWnd, LVM_GETHOTCURSOR, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HCURSOR)::SendMessage(this->m_hWnd, LVM_GETHOTCURSOR, 0, 0L); } HCURSOR SetHotCursor(HCURSOR hHotCursor) { - ATLASSERT(::IsWindow(m_hWnd)); - return (HCURSOR)::SendMessage(m_hWnd, LVM_SETHOTCURSOR, 0, (LPARAM)hHotCursor); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HCURSOR)::SendMessage(this->m_hWnd, LVM_SETHOTCURSOR, 0, (LPARAM)hHotCursor); } int GetHotItem() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_GETHOTITEM, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_GETHOTITEM, 0, 0L); } int SetHotItem(int nIndex) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_SETHOTITEM, nIndex, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_SETHOTITEM, nIndex, 0L); } -#endif // !_WIN32_WCE BOOL GetColumnOrderArray(int nCount, int* lpnArray) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_GETCOLUMNORDERARRAY, nCount, (LPARAM)lpnArray); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETCOLUMNORDERARRAY, nCount, (LPARAM)lpnArray); } BOOL SetColumnOrderArray(int nCount, int* lpnArray) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_SETCOLUMNORDERARRAY, nCount, (LPARAM)lpnArray); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETCOLUMNORDERARRAY, nCount, (LPARAM)lpnArray); } CHeaderCtrl GetHeader() const { - ATLASSERT(::IsWindow(m_hWnd)); - return CHeaderCtrl((HWND)::SendMessage(m_hWnd, LVM_GETHEADER, 0, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CHeaderCtrl((HWND)::SendMessage(this->m_hWnd, LVM_GETHEADER, 0, 0L)); } BOOL GetSubItemRect(int nItem, int nSubItem, int nFlag, LPRECT lpRect) const { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT((GetStyle() & LVS_TYPEMASK) == LVS_REPORT); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & LVS_TYPEMASK) == LVS_REPORT); ATLASSERT(lpRect != NULL); lpRect->top = nSubItem; lpRect->left = nFlag; - return (BOOL)::SendMessage(m_hWnd, LVM_GETSUBITEMRECT, nItem, (LPARAM)lpRect); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETSUBITEMRECT, nItem, (LPARAM)lpRect); } DWORD SetIconSpacing(int cx, int cy) { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT((GetStyle() & LVS_TYPEMASK) == LVS_ICON); - return (DWORD)::SendMessage(m_hWnd, LVM_SETICONSPACING, 0, MAKELPARAM(cx, cy)); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & LVS_TYPEMASK) == LVS_ICON); + return (DWORD)::SendMessage(this->m_hWnd, LVM_SETICONSPACING, 0, MAKELPARAM(cx, cy)); } int GetISearchString(LPTSTR lpstr) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_GETISEARCHSTRING, 0, (LPARAM)lpstr); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_GETISEARCHSTRING, 0, (LPARAM)lpstr); } void GetItemSpacing(SIZE& sizeSpacing, BOOL bSmallIconView = FALSE) const { - ATLASSERT(::IsWindow(m_hWnd)); - DWORD dwRet = (DWORD)::SendMessage(m_hWnd, LVM_GETITEMSPACING, bSmallIconView, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, LVM_GETITEMSPACING, bSmallIconView, 0L); sizeSpacing.cx = GET_X_LPARAM(dwRet); sizeSpacing.cy = GET_Y_LPARAM(dwRet); } -#if (_WIN32_WCE >= 410) - void SetItemSpacing(INT cySpacing) - { - ATLASSERT(::IsWindow(m_hWnd)); - ListView_SetItemSpacing(m_hWnd, cySpacing); - } -#endif // (_WIN32_WCE >= 410) - // single-selection only int GetSelectedIndex() const { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT((GetStyle() & LVS_SINGLESEL) != 0); - return (int)::SendMessage(m_hWnd, LVM_GETNEXTITEM, (WPARAM)-1, MAKELPARAM(LVNI_ALL | LVNI_SELECTED, 0)); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & LVS_SINGLESEL) != 0); + return (int)::SendMessage(this->m_hWnd, LVM_GETNEXTITEM, (WPARAM)-1, MAKELPARAM(LVNI_ALL | LVNI_SELECTED, 0)); } BOOL GetSelectedItem(LPLVITEM pItem) const { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT((GetStyle() & LVS_SINGLESEL) != 0); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & LVS_SINGLESEL) != 0); ATLASSERT(pItem != NULL); - pItem->iItem = (int)::SendMessage(m_hWnd, LVM_GETNEXTITEM, (WPARAM)-1, MAKELPARAM(LVNI_ALL | LVNI_SELECTED, 0)); + pItem->iItem = (int)::SendMessage(this->m_hWnd, LVM_GETNEXTITEM, (WPARAM)-1, MAKELPARAM(LVNI_ALL | LVNI_SELECTED, 0)); if(pItem->iItem == -1) return FALSE; - return (BOOL)::SendMessage(m_hWnd, LVM_GETITEM, 0, (LPARAM)pItem); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETITEM, 0, (LPARAM)pItem); } // extended list view styles DWORD GetExtendedListViewStyle() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0L); } // dwExMask = 0 means all styles DWORD SetExtendedListViewStyle(DWORD dwExStyle, DWORD dwExMask = 0) { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, LVM_SETEXTENDEDLISTVIEWSTYLE, dwExMask, dwExStyle); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, LVM_SETEXTENDEDLISTVIEWSTYLE, dwExMask, dwExStyle); } // checkboxes only BOOL GetCheckState(int nIndex) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT((GetExtendedListViewStyle() & LVS_EX_CHECKBOXES) != 0); UINT uRet = GetItemState(nIndex, LVIS_STATEIMAGEMASK); return (uRet >> 12) - 1; @@ -3279,304 +3235,294 @@ public: // view type DWORD GetViewType() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (GetStyle() & LVS_TYPEMASK); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (this->GetStyle() & LVS_TYPEMASK); } DWORD SetViewType(DWORD dwType) { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT(dwType == LVS_ICON || dwType == LVS_SMALLICON || dwType == LVS_LIST || dwType == LVS_REPORT); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((dwType == LVS_ICON) || (dwType == LVS_SMALLICON) || (dwType == LVS_LIST) || (dwType == LVS_REPORT)); DWORD dwOldType = GetViewType(); if(dwType != dwOldType) - ModifyStyle(LVS_TYPEMASK, (dwType & LVS_TYPEMASK)); + this->ModifyStyle(LVS_TYPEMASK, (dwType & LVS_TYPEMASK)); return dwOldType; } -#if (_WIN32_IE >= 0x0400) -#ifndef _WIN32_WCE BOOL GetBkImage(LPLVBKIMAGE plvbki) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_GETBKIMAGE, 0, (LPARAM)plvbki); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETBKIMAGE, 0, (LPARAM)plvbki); } BOOL SetBkImage(LPLVBKIMAGE plvbki) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_SETBKIMAGE, 0, (LPARAM)plvbki); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETBKIMAGE, 0, (LPARAM)plvbki); } -#endif // !_WIN32_WCE int GetSelectionMark() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_GETSELECTIONMARK, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_GETSELECTIONMARK, 0, 0L); } int SetSelectionMark(int nIndex) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_SETSELECTIONMARK, 0, nIndex); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_SETSELECTIONMARK, 0, nIndex); } -#ifndef _WIN32_WCE BOOL GetWorkAreas(int nWorkAreas, LPRECT lpRect) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_GETWORKAREAS, nWorkAreas, (LPARAM)lpRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETWORKAREAS, nWorkAreas, (LPARAM)lpRect); } BOOL SetWorkAreas(int nWorkAreas, LPRECT lpRect) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_SETWORKAREAS, nWorkAreas, (LPARAM)lpRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETWORKAREAS, nWorkAreas, (LPARAM)lpRect); } DWORD GetHoverTime() const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT((GetExtendedListViewStyle() & (LVS_EX_TRACKSELECT | LVS_EX_ONECLICKACTIVATE | LVS_EX_TWOCLICKACTIVATE)) != 0); - return (DWORD)::SendMessage(m_hWnd, LVM_GETHOVERTIME, 0, 0L); + return (DWORD)::SendMessage(this->m_hWnd, LVM_GETHOVERTIME, 0, 0L); } DWORD SetHoverTime(DWORD dwHoverTime) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT((GetExtendedListViewStyle() & (LVS_EX_TRACKSELECT | LVS_EX_ONECLICKACTIVATE | LVS_EX_TWOCLICKACTIVATE)) != 0); - return (DWORD)::SendMessage(m_hWnd, LVM_SETHOVERTIME, 0, dwHoverTime); + return (DWORD)::SendMessage(this->m_hWnd, LVM_SETHOVERTIME, 0, dwHoverTime); } BOOL GetNumberOfWorkAreas(int* pnWorkAreas) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_GETNUMBEROFWORKAREAS, 0, (LPARAM)pnWorkAreas); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETNUMBEROFWORKAREAS, 0, (LPARAM)pnWorkAreas); } -#endif // !_WIN32_WCE BOOL SetItemCountEx(int nItems, DWORD dwFlags) { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT(((GetStyle() & LVS_OWNERDATA) != 0) && (((GetStyle() & LVS_TYPEMASK) == LVS_REPORT) || ((GetStyle() & LVS_TYPEMASK) == LVS_LIST))); - return (BOOL)::SendMessage(m_hWnd, LVM_SETITEMCOUNT, nItems, dwFlags); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(((this->GetStyle() & LVS_OWNERDATA) != 0) && (((this->GetStyle() & LVS_TYPEMASK) == LVS_REPORT) || ((this->GetStyle() & LVS_TYPEMASK) == LVS_LIST))); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETITEMCOUNT, nItems, dwFlags); } -#ifndef _WIN32_WCE CToolTipCtrl GetToolTips() const { - ATLASSERT(::IsWindow(m_hWnd)); - return CToolTipCtrl((HWND)::SendMessage(m_hWnd, LVM_GETTOOLTIPS, 0, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CToolTipCtrl((HWND)::SendMessage(this->m_hWnd, LVM_GETTOOLTIPS, 0, 0L)); } CToolTipCtrl SetToolTips(HWND hWndTT) { - ATLASSERT(::IsWindow(m_hWnd)); - return CToolTipCtrl((HWND)::SendMessage(m_hWnd, LVM_SETTOOLTIPS, (WPARAM)hWndTT, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CToolTipCtrl((HWND)::SendMessage(this->m_hWnd, LVM_SETTOOLTIPS, (WPARAM)hWndTT, 0L)); } BOOL GetUnicodeFormat() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_GETUNICODEFORMAT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETUNICODEFORMAT, 0, 0L); } BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_SETUNICODEFORMAT, bUnicode, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETUNICODEFORMAT, bUnicode, 0L); } -#endif // !_WIN32_WCE -#endif // (_WIN32_IE >= 0x0400) -#if (_WIN32_WINNT >= 0x0501) int GetSelectedColumn() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_GETSELECTEDCOLUMN, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_GETSELECTEDCOLUMN, 0, 0L); } void SetSelectedColumn(int nColumn) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, LVM_SETSELECTEDCOLUMN, nColumn, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, LVM_SETSELECTEDCOLUMN, nColumn, 0L); } DWORD GetView() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, LVM_GETVIEW, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, LVM_GETVIEW, 0, 0L); } int SetView(DWORD dwView) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_SETVIEW, dwView, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_SETVIEW, dwView, 0L); } BOOL IsGroupViewEnabled() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_ISGROUPVIEWENABLED, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_ISGROUPVIEWENABLED, 0, 0L); } int GetGroupInfo(int nGroupID, PLVGROUP pGroup) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_GETGROUPINFO, nGroupID, (LPARAM)pGroup); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_GETGROUPINFO, nGroupID, (LPARAM)pGroup); } int SetGroupInfo(int nGroupID, PLVGROUP pGroup) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_SETGROUPINFO, nGroupID, (LPARAM)pGroup); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_SETGROUPINFO, nGroupID, (LPARAM)pGroup); } void GetGroupMetrics(PLVGROUPMETRICS pGroupMetrics) const { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, LVM_GETGROUPMETRICS, 0, (LPARAM)pGroupMetrics); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, LVM_GETGROUPMETRICS, 0, (LPARAM)pGroupMetrics); } void SetGroupMetrics(PLVGROUPMETRICS pGroupMetrics) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, LVM_SETGROUPMETRICS, 0, (LPARAM)pGroupMetrics); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, LVM_SETGROUPMETRICS, 0, (LPARAM)pGroupMetrics); } void GetTileViewInfo(PLVTILEVIEWINFO pTileViewInfo) const { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, LVM_GETTILEVIEWINFO, 0, (LPARAM)pTileViewInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, LVM_GETTILEVIEWINFO, 0, (LPARAM)pTileViewInfo); } BOOL SetTileViewInfo(PLVTILEVIEWINFO pTileViewInfo) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_SETTILEVIEWINFO, 0, (LPARAM)pTileViewInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETTILEVIEWINFO, 0, (LPARAM)pTileViewInfo); } void GetTileInfo(PLVTILEINFO pTileInfo) const { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, LVM_GETTILEINFO, 0, (LPARAM)pTileInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, LVM_GETTILEINFO, 0, (LPARAM)pTileInfo); } BOOL SetTileInfo(PLVTILEINFO pTileInfo) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_SETTILEINFO, 0, (LPARAM)pTileInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETTILEINFO, 0, (LPARAM)pTileInfo); } BOOL GetInsertMark(LPLVINSERTMARK pInsertMark) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_GETINSERTMARK, 0, (LPARAM)pInsertMark); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETINSERTMARK, 0, (LPARAM)pInsertMark); } BOOL SetInsertMark(LPLVINSERTMARK pInsertMark) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_SETINSERTMARK, 0, (LPARAM)pInsertMark); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETINSERTMARK, 0, (LPARAM)pInsertMark); } int GetInsertMarkRect(LPRECT lpRect) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_GETINSERTMARKRECT, 0, (LPARAM)lpRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_GETINSERTMARKRECT, 0, (LPARAM)lpRect); } COLORREF GetInsertMarkColor() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, LVM_GETINSERTMARKCOLOR, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, LVM_GETINSERTMARKCOLOR, 0, 0L); } COLORREF SetInsertMarkColor(COLORREF clr) { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, LVM_SETINSERTMARKCOLOR, 0, clr); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, LVM_SETINSERTMARKCOLOR, 0, clr); } COLORREF GetOutlineColor() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, LVM_GETOUTLINECOLOR, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, LVM_GETOUTLINECOLOR, 0, 0L); } COLORREF SetOutlineColor(COLORREF clr) { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, LVM_SETOUTLINECOLOR, 0, clr); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, LVM_SETOUTLINECOLOR, 0, clr); } -#endif // (_WIN32_WINNT >= 0x0501) #if (_WIN32_WINNT >= 0x0600) int GetGroupCount() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_GETGROUPCOUNT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_GETGROUPCOUNT, 0, 0L); } BOOL GetGroupInfoByIndex(int nIndex, PLVGROUP pGroup) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_GETGROUPINFOBYINDEX, nIndex, (LPARAM)pGroup); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETGROUPINFOBYINDEX, nIndex, (LPARAM)pGroup); } BOOL GetGroupRect(int nGroupID, int nType, LPRECT lpRect) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(lpRect != NULL); if(lpRect != NULL) lpRect->top = nType; - return (BOOL)::SendMessage(m_hWnd, LVM_GETGROUPRECT, nGroupID, (LPARAM)lpRect); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETGROUPRECT, nGroupID, (LPARAM)lpRect); } UINT GetGroupState(int nGroupID, UINT uMask) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (UINT)::SendMessage(m_hWnd, LVM_GETGROUPSTATE, nGroupID, (LPARAM)uMask); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, LVM_GETGROUPSTATE, nGroupID, (LPARAM)uMask); } int GetFocusedGroup() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_GETFOCUSEDGROUP, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_GETFOCUSEDGROUP, 0, 0L); } BOOL GetEmptyText(LPWSTR lpstrText, int cchText) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_GETEMPTYTEXT, cchText, (LPARAM)lpstrText); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETEMPTYTEXT, cchText, (LPARAM)lpstrText); } BOOL GetFooterRect(LPRECT lpRect) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_GETFOOTERRECT, 0, (LPARAM)lpRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETFOOTERRECT, 0, (LPARAM)lpRect); } BOOL GetFooterInfo(LPLVFOOTERINFO lpFooterInfo) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_GETFOOTERINFO, 0, (LPARAM)lpFooterInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETFOOTERINFO, 0, (LPARAM)lpFooterInfo); } BOOL GetFooterItemRect(int nItem, LPRECT lpRect) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_GETFOOTERITEMRECT, nItem, (LPARAM)lpRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETFOOTERITEMRECT, nItem, (LPARAM)lpRect); } BOOL GetFooterItem(int nItem, LPLVFOOTERITEM lpFooterItem) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_GETFOOTERITEM, nItem, (LPARAM)lpFooterItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETFOOTERITEM, nItem, (LPARAM)lpFooterItem); } BOOL GetItemIndexRect(PLVITEMINDEX pItemIndex, int nSubItem, int nType, LPRECT lpRect) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(pItemIndex != NULL); ATLASSERT(lpRect != NULL); if(lpRect != NULL) @@ -3584,37 +3530,37 @@ public: lpRect->top = nSubItem; lpRect->left = nType; } - return (BOOL)::SendMessage(m_hWnd, LVM_GETITEMINDEXRECT, (WPARAM)pItemIndex, (LPARAM)lpRect); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETITEMINDEXRECT, (WPARAM)pItemIndex, (LPARAM)lpRect); } BOOL SetItemIndexState(PLVITEMINDEX pItemIndex, UINT uState, UINT dwMask) { - ATLASSERT(::IsWindow(m_hWnd)); - LVITEM lvi = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + LVITEM lvi = {}; lvi.state = uState; lvi.stateMask = dwMask; - return (BOOL)::SendMessage(m_hWnd, LVM_SETITEMINDEXSTATE, (WPARAM)pItemIndex, (LPARAM)&lvi); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETITEMINDEXSTATE, (WPARAM)pItemIndex, (LPARAM)&lvi); } BOOL GetNextItemIndex(PLVITEMINDEX pItemIndex, WORD wFlags) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_GETNEXTITEMINDEX, (WPARAM)pItemIndex, MAKELPARAM(wFlags, 0)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETNEXTITEMINDEX, (WPARAM)pItemIndex, MAKELPARAM(wFlags, 0)); } #endif // (_WIN32_WINNT >= 0x0600) // Operations int InsertColumn(int nCol, const LVCOLUMN* pColumn) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_INSERTCOLUMN, nCol, (LPARAM)pColumn); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_INSERTCOLUMN, nCol, (LPARAM)pColumn); } int InsertColumn(int nCol, LPCTSTR lpszColumnHeading, int nFormat = LVCFMT_LEFT, int nWidth = -1, int nSubItem = -1, int iImage = -1, int iOrder = -1) { - LVCOLUMN column = { 0 }; - column.mask = LVCF_TEXT|LVCF_FMT; + LVCOLUMN column = {}; + column.mask = LVCF_TEXT | LVCF_FMT; column.pszText = (LPTSTR)lpszColumnHeading; column.fmt = nFormat; if (nWidth != -1) @@ -3642,14 +3588,14 @@ public: BOOL DeleteColumn(int nCol) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_DELETECOLUMN, nCol, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_DELETECOLUMN, nCol, 0L); } int InsertItem(UINT nMask, int nItem, LPCTSTR lpszItem, UINT nState, UINT nStateMask, int nImage, LPARAM lParam) { - ATLASSERT(::IsWindow(m_hWnd)); - LVITEM item = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + LVITEM item = {}; item.mask = nMask; item.iItem = nItem; item.iSubItem = 0; @@ -3663,67 +3609,67 @@ public: int InsertItem(const LVITEM* pItem) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_INSERTITEM, 0, (LPARAM)pItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_INSERTITEM, 0, (LPARAM)pItem); } int InsertItem(int nItem, LPCTSTR lpszItem) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); return InsertItem(LVIF_TEXT, nItem, lpszItem, 0, 0, 0, 0); } int InsertItem(int nItem, LPCTSTR lpszItem, int nImage) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); return InsertItem(LVIF_TEXT|LVIF_IMAGE, nItem, lpszItem, 0, 0, nImage, 0); } int GetNextItem(int nItem, int nFlags) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_GETNEXTITEM, nItem, MAKELPARAM(nFlags, 0)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_GETNEXTITEM, nItem, MAKELPARAM(nFlags, 0)); } BOOL DeleteItem(int nItem) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_DELETEITEM, nItem, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_DELETEITEM, nItem, 0L); } BOOL DeleteAllItems() { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_DELETEALLITEMS, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_DELETEALLITEMS, 0, 0L); } int FindItem(LVFINDINFO* pFindInfo, int nStart = -1) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_FINDITEM, nStart, (LPARAM)pFindInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_FINDITEM, nStart, (LPARAM)pFindInfo); } int FindItem(LPCTSTR lpstrFind, bool bPartial = true, bool bWrap = false, int nStart = -1) const { - ATLASSERT(::IsWindow(m_hWnd)); - LVFINDINFO lvfi = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + LVFINDINFO lvfi = {}; lvfi.flags = LVFI_STRING | (bWrap ? LVFI_WRAP : 0) | (bPartial ? LVFI_PARTIAL : 0); lvfi.psz = lpstrFind; - return (int)::SendMessage(m_hWnd, LVM_FINDITEM, nStart, (LPARAM)&lvfi); + return (int)::SendMessage(this->m_hWnd, LVM_FINDITEM, nStart, (LPARAM)&lvfi); } int HitTest(LVHITTESTINFO* pHitTestInfo) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_HITTEST, 0, (LPARAM)pHitTestInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_HITTEST, 0, (LPARAM)pHitTestInfo); } int HitTest(POINT pt, UINT* pFlags) const { - ATLASSERT(::IsWindow(m_hWnd)); - LVHITTESTINFO hti = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + LVHITTESTINFO hti = {}; hti.pt = pt; - int nRes = (int)::SendMessage(m_hWnd, LVM_HITTEST, 0, (LPARAM)&hti); + int nRes = (int)::SendMessage(this->m_hWnd, LVM_HITTEST, 0, (LPARAM)&hti); if (pFlags != NULL) *pFlags = hti.flags; return nRes; @@ -3731,80 +3677,86 @@ public: BOOL EnsureVisible(int nItem, BOOL bPartialOK) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_ENSUREVISIBLE, nItem, MAKELPARAM(bPartialOK, 0)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_ENSUREVISIBLE, nItem, MAKELPARAM(bPartialOK, 0)); + } + + BOOL Scroll(int cx, int cy) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SCROLL, cx, cy); } BOOL Scroll(SIZE size) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_SCROLL, size.cx, size.cy); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SCROLL, size.cx, size.cy); } BOOL RedrawItems(int nFirst, int nLast) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_REDRAWITEMS, nFirst, nLast); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_REDRAWITEMS, nFirst, nLast); } BOOL Arrange(UINT nCode) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_ARRANGE, nCode, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_ARRANGE, nCode, 0L); } CEdit EditLabel(int nItem) { - ATLASSERT(::IsWindow(m_hWnd)); - return CEdit((HWND)::SendMessage(m_hWnd, LVM_EDITLABEL, nItem, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CEdit((HWND)::SendMessage(this->m_hWnd, LVM_EDITLABEL, nItem, 0L)); } BOOL Update(int nItem) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_UPDATE, nItem, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_UPDATE, nItem, 0L); } BOOL SortItems(PFNLVCOMPARE pfnCompare, LPARAM lParamSort) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_SORTITEMS, (WPARAM)lParamSort, (LPARAM)pfnCompare); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SORTITEMS, (WPARAM)lParamSort, (LPARAM)pfnCompare); } CImageList RemoveImageList(int nImageList) { - ATLASSERT(::IsWindow(m_hWnd)); - return CImageList((HIMAGELIST)::SendMessage(m_hWnd, LVM_SETIMAGELIST, (WPARAM)nImageList, NULL)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, LVM_SETIMAGELIST, (WPARAM)nImageList, NULL)); } CImageList CreateDragImage(int nItem, LPPOINT lpPoint) { - ATLASSERT(::IsWindow(m_hWnd)); - return CImageList((HIMAGELIST)::SendMessage(m_hWnd, LVM_CREATEDRAGIMAGE, nItem, (LPARAM)lpPoint)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, LVM_CREATEDRAGIMAGE, nItem, (LPARAM)lpPoint)); } DWORD ApproximateViewRect(int cx = -1, int cy = -1, int nCount = -1) { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, LVM_APPROXIMATEVIEWRECT, nCount, MAKELPARAM(cx, cy)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, LVM_APPROXIMATEVIEWRECT, nCount, MAKELPARAM(cx, cy)); } int SubItemHitTest(LPLVHITTESTINFO lpInfo) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_SUBITEMHITTEST, 0, (LPARAM)lpInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_SUBITEMHITTEST, 0, (LPARAM)lpInfo); } - int AddColumn(LPCTSTR strItem, int nItem, int nSubItem = -1, + int AddColumn(LPCTSTR strColumn, int nItem, int nSubItem = -1, int nMask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM, int nFmt = LVCFMT_LEFT) { const int cxOffset = 15; - ATLASSERT(::IsWindow(m_hWnd)); - LVCOLUMN lvc = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + LVCOLUMN lvc = {}; lvc.mask = nMask; lvc.fmt = nFmt; - lvc.pszText = (LPTSTR)strItem; + lvc.pszText = (LPTSTR)strColumn; lvc.cx = GetStringWidth(lvc.pszText) + cxOffset; if(nMask & LVCF_SUBITEM) lvc.iSubItem = (nSubItem != -1) ? nSubItem : nItem; @@ -3813,8 +3765,8 @@ public: int AddItem(int nItem, int nSubItem, LPCTSTR strItem, int nImageIndex = -3) { - ATLASSERT(::IsWindow(m_hWnd)); - LVITEM lvItem = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + LVITEM lvItem = {}; lvItem.mask = LVIF_TEXT; lvItem.iItem = nItem; lvItem.iSubItem = nSubItem; @@ -3829,19 +3781,16 @@ public: return SetItem(&lvItem) ? nItem : -1; } -#if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) BOOL SortItemsEx(PFNLVCOMPARE pfnCompare, LPARAM lParamSort) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_SORTITEMSEX, (WPARAM)lParamSort, (LPARAM)pfnCompare); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SORTITEMSEX, (WPARAM)lParamSort, (LPARAM)pfnCompare); } -#endif // (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) -#if (_WIN32_WINNT >= 0x0501) int InsertGroup(int nItem, PLVGROUP pGroup) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_INSERTGROUP, nItem, (LPARAM)pGroup); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_INSERTGROUP, nItem, (LPARAM)pGroup); } int AddGroup(PLVGROUP pGroup) @@ -3851,96 +3800,101 @@ public: int RemoveGroup(int nGroupID) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_REMOVEGROUP, nGroupID, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_REMOVEGROUP, nGroupID, 0L); } void MoveGroup(int nGroupID, int nItem) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, LVM_MOVEGROUP, nGroupID, nItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, LVM_MOVEGROUP, nGroupID, nItem); } void MoveItemToGroup(int nItem, int nGroupID) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, LVM_MOVEITEMTOGROUP, nItem, nGroupID); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, LVM_MOVEITEMTOGROUP, nItem, nGroupID); } int EnableGroupView(BOOL bEnable) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_ENABLEGROUPVIEW, bEnable, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_ENABLEGROUPVIEW, bEnable, 0L); } int SortGroups(PFNLVGROUPCOMPARE pCompareFunc, LPVOID lpVoid = NULL) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_SORTGROUPS, (WPARAM)pCompareFunc, (LPARAM)lpVoid); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_SORTGROUPS, (WPARAM)pCompareFunc, (LPARAM)lpVoid); } void InsertGroupSorted(PLVINSERTGROUPSORTED pInsertGroupSorted) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, LVM_INSERTGROUPSORTED, (WPARAM)pInsertGroupSorted, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, LVM_INSERTGROUPSORTED, (WPARAM)pInsertGroupSorted, 0L); } void RemoveAllGroups() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, LVM_REMOVEALLGROUPS, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, LVM_REMOVEALLGROUPS, 0, 0L); } BOOL HasGroup(int nGroupID) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_HASGROUP, nGroupID, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_HASGROUP, nGroupID, 0L); } BOOL InsertMarkHitTest(LPPOINT lpPoint, LPLVINSERTMARK pInsertMark) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_INSERTMARKHITTEST, (WPARAM)lpPoint, (LPARAM)pInsertMark); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_INSERTMARKHITTEST, (WPARAM)lpPoint, (LPARAM)pInsertMark); } BOOL SetInfoTip(PLVSETINFOTIP pSetInfoTip) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LVM_SETINFOTIP, 0, (LPARAM)pSetInfoTip); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETINFOTIP, 0, (LPARAM)pSetInfoTip); } void CancelEditLabel() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, LVM_CANCELEDITLABEL, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, LVM_CANCELEDITLABEL, 0, 0L); } UINT MapIndexToID(int nIndex) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (UINT)::SendMessage(m_hWnd, LVM_MAPINDEXTOID, nIndex, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, LVM_MAPINDEXTOID, nIndex, 0L); } int MapIDToIndex(UINT uID) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_MAPIDTOINDEX, uID, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_MAPIDTOINDEX, uID, 0L); + } + + BOOL IsItemVisible(int nItem) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_ISITEMVISIBLE, nItem, 0L); } -#endif // (_WIN32_WINNT >= 0x0501) #if (_WIN32_WINNT >= 0x0600) int HitTestEx(LPLVHITTESTINFO lpHitTestInfo) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_HITTEST, (WPARAM)-1, (LPARAM)lpHitTestInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_HITTEST, (WPARAM)-1, (LPARAM)lpHitTestInfo); } int HitTestEx(POINT pt, UINT* pFlags) const { - ATLASSERT(::IsWindow(m_hWnd)); - LVHITTESTINFO hti = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + LVHITTESTINFO hti = {}; hti.pt = pt; - int nRes = (int)::SendMessage(m_hWnd, LVM_HITTEST, (WPARAM)-1, (LPARAM)&hti); + int nRes = (int)::SendMessage(this->m_hWnd, LVM_HITTEST, (WPARAM)-1, (LPARAM)&hti); if (pFlags != NULL) *pFlags = hti.flags; return nRes; @@ -3948,26 +3902,46 @@ public: int SubItemHitTestEx(LPLVHITTESTINFO lpHitTestInfo) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LVM_SUBITEMHITTEST, (WPARAM)-1, (LPARAM)lpHitTestInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_SUBITEMHITTEST, (WPARAM)-1, (LPARAM)lpHitTestInfo); } #endif // (_WIN32_WINNT >= 0x0600) // Note: selects only one item - BOOL SelectItem(int nIndex) + BOOL SelectItem(int nIndex) // -1 to select none { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); - // multi-selection only: de-select all items - if((GetStyle() & LVS_SINGLESEL) == 0) - SetItemState(-1, 0, LVIS_SELECTED); + BOOL bRet = FALSE; + if(nIndex != -1) + { + // multi-selection only: de-select all items + if((this->GetStyle() & LVS_SINGLESEL) == 0) + SetItemState(-1, 0, LVIS_SELECTED); - BOOL bRet = SetItemState(nIndex, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED); - if(bRet) - bRet = EnsureVisible(nIndex, FALSE); + bRet = SetItemState(nIndex, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED); + if(bRet) + { + SetSelectionMark(nIndex); + bRet = EnsureVisible(nIndex, FALSE); + } + } + else // no item specified, just de-select + { + bRet = SetItemState(-1, 0, LVIS_SELECTED); + } return bRet; } + + // multi-selection only + BOOL SelectAllItems(bool bSelect = true) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & LVS_SINGLESEL) == 0); + + return SetItemState(-1, bSelect ? LVIS_SELECTED : 0, LVIS_SELECTED); + } }; typedef CListViewCtrlT CListViewCtrl; @@ -3986,7 +3960,7 @@ public: CTreeViewCtrlT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -4005,51 +3979,51 @@ public: UINT GetCount() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (UINT)::SendMessage(m_hWnd, TVM_GETCOUNT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, TVM_GETCOUNT, 0, 0L); } UINT GetIndent() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (UINT)::SendMessage(m_hWnd, TVM_GETINDENT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, TVM_GETINDENT, 0, 0L); } void SetIndent(UINT nIndent) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TVM_SETINDENT, nIndent, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TVM_SETINDENT, nIndent, 0L); } CImageList GetImageList(int nImageListType = TVSIL_NORMAL) const { - ATLASSERT(::IsWindow(m_hWnd)); - return CImageList((HIMAGELIST)::SendMessage(m_hWnd, TVM_GETIMAGELIST, (WPARAM)nImageListType, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TVM_GETIMAGELIST, (WPARAM)nImageListType, 0L)); } CImageList SetImageList(HIMAGELIST hImageList, int nImageListType = TVSIL_NORMAL) { - ATLASSERT(::IsWindow(m_hWnd)); - return CImageList((HIMAGELIST)::SendMessage(m_hWnd, TVM_SETIMAGELIST, (WPARAM)nImageListType, (LPARAM)hImageList)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TVM_SETIMAGELIST, (WPARAM)nImageListType, (LPARAM)hImageList)); } BOOL GetItem(LPTVITEM pItem) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TVM_GETITEM, 0, (LPARAM)pItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_GETITEM, 0, (LPARAM)pItem); } BOOL SetItem(LPTVITEM pItem) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TVM_SETITEM, 0, (LPARAM)pItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_SETITEM, 0, (LPARAM)pItem); } BOOL SetItem(HTREEITEM hItem, UINT nMask, LPCTSTR lpszItem, int nImage, int nSelectedImage, UINT nState, UINT nStateMask, LPARAM lParam) { - ATLASSERT(::IsWindow(m_hWnd)); - TVITEM item = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + TVITEM item = {}; item.hItem = hItem; item.mask = nMask; item.pszText = (LPTSTR) lpszItem; @@ -4058,30 +4032,29 @@ public: item.state = nState; item.stateMask = nStateMask; item.lParam = lParam; - return (BOOL)::SendMessage(m_hWnd, TVM_SETITEM, 0, (LPARAM)&item); + return (BOOL)::SendMessage(this->m_hWnd, TVM_SETITEM, 0, (LPARAM)&item); } BOOL GetItemText(HTREEITEM hItem, LPTSTR lpstrText, int nLen) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(lpstrText != NULL); - TVITEM item = { 0 }; + TVITEM item = {}; item.hItem = hItem; item.mask = TVIF_TEXT; item.pszText = lpstrText; item.cchTextMax = nLen; - return (BOOL)::SendMessage(m_hWnd, TVM_GETITEM, 0, (LPARAM)&item); + return (BOOL)::SendMessage(this->m_hWnd, TVM_GETITEM, 0, (LPARAM)&item); } -#ifndef _ATL_NO_COM BOOL GetItemText(HTREEITEM hItem, BSTR& bstrText) const { USES_CONVERSION; - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(bstrText == NULL); - TVITEM item = { 0 }; + TVITEM item = {}; item.hItem = hItem; item.mask = TVIF_TEXT; @@ -4095,8 +4068,8 @@ public: lpstrText[0] = NULL; item.pszText = lpstrText; item.cchTextMax = nLen; - bRet = (BOOL)::SendMessage(m_hWnd, TVM_GETITEM, 0, (LPARAM)&item); - if(!bRet || (lstrlen(item.pszText) < nLen - 1)) + bRet = (BOOL)::SendMessage(this->m_hWnd, TVM_GETITEM, 0, (LPARAM)&item); + if(!bRet || (lstrlen(item.pszText) < (nLen - 1))) break; delete [] lpstrText; lpstrText = NULL; @@ -4111,13 +4084,12 @@ public: return (bstrText != NULL) ? TRUE : FALSE; } -#endif // !_ATL_NO_COM -#if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) - BOOL GetItemText(HTREEITEM hItem, _CSTRING_NS::CString& strText) const +#ifdef __ATLSTR_H__ + BOOL GetItemText(HTREEITEM hItem, ATL::CString& strText) const { - ATLASSERT(::IsWindow(m_hWnd)); - TVITEM item = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + TVITEM item = {}; item.hItem = hItem; item.mask = TVIF_TEXT; @@ -4132,28 +4104,28 @@ public: break; } item.cchTextMax = nLen; - bRet = (BOOL)::SendMessage(m_hWnd, TVM_GETITEM, 0, (LPARAM)&item); - if(!bRet || (lstrlen(item.pszText) < nLen - 1)) + bRet = (BOOL)::SendMessage(this->m_hWnd, TVM_GETITEM, 0, (LPARAM)&item); + if(!bRet || (lstrlen(item.pszText) < (nLen - 1))) break; } strText.ReleaseBuffer(); return bRet; } -#endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) +#endif // __ATLSTR_H__ BOOL SetItemText(HTREEITEM hItem, LPCTSTR lpszItem) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); return SetItem(hItem, TVIF_TEXT, lpszItem, 0, 0, 0, 0, NULL); } BOOL GetItemImage(HTREEITEM hItem, int& nImage, int& nSelectedImage) const { - ATLASSERT(::IsWindow(m_hWnd)); - TVITEM item = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + TVITEM item = {}; item.hItem = hItem; item.mask = TVIF_IMAGE|TVIF_SELECTEDIMAGE; - BOOL bRes = (BOOL)::SendMessage(m_hWnd, TVM_GETITEM, 0, (LPARAM)&item); + BOOL bRes = (BOOL)::SendMessage(this->m_hWnd, TVM_GETITEM, 0, (LPARAM)&item); if (bRes) { nImage = item.iImage; @@ -4164,270 +4136,265 @@ public: BOOL SetItemImage(HTREEITEM hItem, int nImage, int nSelectedImage) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); return SetItem(hItem, TVIF_IMAGE|TVIF_SELECTEDIMAGE, NULL, nImage, nSelectedImage, 0, 0, NULL); } UINT GetItemState(HTREEITEM hItem, UINT nStateMask) const { - ATLASSERT(::IsWindow(m_hWnd)); -#if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) - return (((UINT)::SendMessage(m_hWnd, TVM_GETITEMSTATE, (WPARAM)hItem, (LPARAM)nStateMask)) & nStateMask); -#else // !((_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE)) - TVITEM item = { 0 }; - item.hItem = hItem; - item.mask = TVIF_STATE; - item.state = 0; - item.stateMask = nStateMask; - ::SendMessage(m_hWnd, TVM_GETITEM, 0, (LPARAM)&item); - return (item.state & nStateMask); -#endif // !((_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE)) + ATLASSERT(::IsWindow(this->m_hWnd)); + return (((UINT)::SendMessage(this->m_hWnd, TVM_GETITEMSTATE, (WPARAM)hItem, (LPARAM)nStateMask)) & nStateMask); } BOOL SetItemState(HTREEITEM hItem, UINT nState, UINT nStateMask) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); return SetItem(hItem, TVIF_STATE, NULL, 0, 0, nState, nStateMask, NULL); } DWORD_PTR GetItemData(HTREEITEM hItem) const { - ATLASSERT(::IsWindow(m_hWnd)); - TVITEM item = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + TVITEM item = {}; item.hItem = hItem; item.mask = TVIF_PARAM; - BOOL bRet = (BOOL)::SendMessage(m_hWnd, TVM_GETITEM, 0, (LPARAM)&item); + BOOL bRet = (BOOL)::SendMessage(this->m_hWnd, TVM_GETITEM, 0, (LPARAM)&item); return (DWORD_PTR)(bRet ? item.lParam : NULL); } BOOL SetItemData(HTREEITEM hItem, DWORD_PTR dwData) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); return SetItem(hItem, TVIF_PARAM, NULL, 0, 0, 0, 0, (LPARAM)dwData); } CEdit GetEditControl() const { - ATLASSERT(::IsWindow(m_hWnd)); - return CEdit((HWND)::SendMessage(m_hWnd, TVM_GETEDITCONTROL, 0, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CEdit((HWND)::SendMessage(this->m_hWnd, TVM_GETEDITCONTROL, 0, 0L)); } UINT GetVisibleCount() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (UINT)::SendMessage(m_hWnd, TVM_GETVISIBLECOUNT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, TVM_GETVISIBLECOUNT, 0, 0L); } BOOL GetItemRect(HTREEITEM hItem, LPRECT lpRect, BOOL bTextOnly) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); *(HTREEITEM*)lpRect = hItem; - return (BOOL)::SendMessage(m_hWnd, TVM_GETITEMRECT, (WPARAM)bTextOnly, (LPARAM)lpRect); + return (BOOL)::SendMessage(this->m_hWnd, TVM_GETITEMRECT, (WPARAM)bTextOnly, (LPARAM)lpRect); } BOOL ItemHasChildren(HTREEITEM hItem) const { - ATLASSERT(::IsWindow(m_hWnd)); - TVITEM item = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + TVITEM item = {}; item.hItem = hItem; item.mask = TVIF_CHILDREN; - ::SendMessage(m_hWnd, TVM_GETITEM, 0, (LPARAM)&item); + ::SendMessage(this->m_hWnd, TVM_GETITEM, 0, (LPARAM)&item); return item.cChildren; } -#ifndef _WIN32_WCE CToolTipCtrl GetToolTips() const { - ATLASSERT(::IsWindow(m_hWnd)); - return CToolTipCtrl((HWND)::SendMessage(m_hWnd, TVM_GETTOOLTIPS, 0, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CToolTipCtrl((HWND)::SendMessage(this->m_hWnd, TVM_GETTOOLTIPS, 0, 0L)); } CToolTipCtrl SetToolTips(HWND hWndTT) { - ATLASSERT(::IsWindow(m_hWnd)); - return CToolTipCtrl((HWND)::SendMessage(m_hWnd, TVM_SETTOOLTIPS, (WPARAM)hWndTT, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CToolTipCtrl((HWND)::SendMessage(this->m_hWnd, TVM_SETTOOLTIPS, (WPARAM)hWndTT, 0L)); } -#endif // !_WIN32_WCE int GetISearchString(LPTSTR lpstr) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TVM_GETISEARCHSTRING, 0, (LPARAM)lpstr); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TVM_GETISEARCHSTRING, 0, (LPARAM)lpstr); } // checkboxes only BOOL GetCheckState(HTREEITEM hItem) const { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT((GetStyle() & TVS_CHECKBOXES) != 0); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & TVS_CHECKBOXES) != 0); UINT uRet = GetItemState(hItem, TVIS_STATEIMAGEMASK); return (uRet >> 12) - 1; } BOOL SetCheckState(HTREEITEM hItem, BOOL bCheck) { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & TVS_CHECKBOXES) != 0); int nCheck = bCheck ? 2 : 1; // one based index return SetItemState(hItem, INDEXTOSTATEIMAGEMASK(nCheck), TVIS_STATEIMAGEMASK); } -#if (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) + // for standard and extended checkboxes (0 = no checkbox, 1 = unchecked, 2 = checked, >2 = optional extended check states) + UINT GetCheckStateEx(HTREEITEM hItem) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(this->GetImageList(TVSIL_STATE) != NULL); + UINT uRet = GetItemState(hItem, TVIS_STATEIMAGEMASK); + return (uRet >> 12); + } + + BOOL SetCheckStateEx(HTREEITEM hItem, UINT uCheckState) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(this->GetImageList(TVSIL_STATE) != NULL); + ATLASSERT(uCheckState < (UINT)::ImageList_GetImageCount(this->GetImageList(TVSIL_STATE))); + return SetItemState(hItem, INDEXTOSTATEIMAGEMASK(uCheckState), TVIS_STATEIMAGEMASK); + } + COLORREF GetBkColor() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, TVM_GETBKCOLOR, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, TVM_GETBKCOLOR, 0, 0L); } COLORREF SetBkColor(COLORREF clr) { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, TVM_SETBKCOLOR, 0, (LPARAM)clr); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, TVM_SETBKCOLOR, 0, (LPARAM)clr); } COLORREF GetInsertMarkColor() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, TVM_GETINSERTMARKCOLOR, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, TVM_GETINSERTMARKCOLOR, 0, 0L); } COLORREF SetInsertMarkColor(COLORREF clr) { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, TVM_SETINSERTMARKCOLOR, 0, (LPARAM)clr); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, TVM_SETINSERTMARKCOLOR, 0, (LPARAM)clr); } int GetItemHeight() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TVM_GETITEMHEIGHT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TVM_GETITEMHEIGHT, 0, 0L); } int SetItemHeight(int cyHeight) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TVM_SETITEMHEIGHT, cyHeight, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TVM_SETITEMHEIGHT, cyHeight, 0L); } int GetScrollTime() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TVM_GETSCROLLTIME, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TVM_GETSCROLLTIME, 0, 0L); } int SetScrollTime(int nScrollTime) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TVM_SETSCROLLTIME, nScrollTime, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TVM_SETSCROLLTIME, nScrollTime, 0L); } COLORREF GetTextColor() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, TVM_GETTEXTCOLOR, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, TVM_GETTEXTCOLOR, 0, 0L); } COLORREF SetTextColor(COLORREF clr) { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, TVM_SETTEXTCOLOR, 0, (LPARAM)clr); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, TVM_SETTEXTCOLOR, 0, (LPARAM)clr); } BOOL GetUnicodeFormat() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TVM_GETUNICODEFORMAT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_GETUNICODEFORMAT, 0, 0L); } BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TVM_SETUNICODEFORMAT, bUnicode, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_SETUNICODEFORMAT, bUnicode, 0L); } -#endif // (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) -#if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) COLORREF GetLineColor() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, TVM_GETLINECOLOR, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, TVM_GETLINECOLOR, 0, 0L); } COLORREF SetLineColor(COLORREF clrNew /*= CLR_DEFAULT*/) { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, TVM_SETLINECOLOR, 0, (LPARAM)clrNew); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, TVM_SETLINECOLOR, 0, (LPARAM)clrNew); } -#endif // (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) -#if (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) BOOL GetItem(LPTVITEMEX pItem) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TVM_GETITEM, 0, (LPARAM)pItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_GETITEM, 0, (LPARAM)pItem); } BOOL SetItem(LPTVITEMEX pItem) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TVM_SETITEM, 0, (LPARAM)pItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_SETITEM, 0, (LPARAM)pItem); } -#endif // (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) DWORD GetExtendedStyle() const { -#ifndef TVM_GETEXTENDEDSTYLE - const UINT TVM_GETEXTENDEDSTYLE = (TV_FIRST + 45); -#endif - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, TVM_GETEXTENDEDSTYLE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, TVM_GETEXTENDEDSTYLE, 0, 0L); } DWORD SetExtendedStyle(DWORD dwStyle, DWORD dwMask) { -#ifndef TVM_SETEXTENDEDSTYLE - const UINT TVM_SETEXTENDEDSTYLE = (TV_FIRST + 44); -#endif - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, TVM_SETEXTENDEDSTYLE, dwMask, dwStyle); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, TVM_SETEXTENDEDSTYLE, dwMask, dwStyle); } #if (_WIN32_WINNT >= 0x0600) BOOL SetAutoScrollInfo(UINT uPixPerSec, UINT uUpdateTime) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TVM_SETAUTOSCROLLINFO, (WPARAM)uPixPerSec, (LPARAM)uUpdateTime); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_SETAUTOSCROLLINFO, (WPARAM)uPixPerSec, (LPARAM)uUpdateTime); } DWORD GetSelectedCount() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, TVM_GETSELECTEDCOUNT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, TVM_GETSELECTEDCOUNT, 0, 0L); } BOOL GetItemPartRect(HTREEITEM hItem, TVITEMPART partID, LPRECT lpRect) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); TVGETITEMPARTRECTINFO gipri = { hItem, lpRect, partID }; - return (BOOL)::SendMessage(m_hWnd, TVM_GETITEMPARTRECT, 0, (LPARAM)&gipri); + return (BOOL)::SendMessage(this->m_hWnd, TVM_GETITEMPARTRECT, 0, (LPARAM)&gipri); } #endif // (_WIN32_WINNT >= 0x0600) // Operations HTREEITEM InsertItem(LPTVINSERTSTRUCT lpInsertStruct) { - ATLASSERT(::IsWindow(m_hWnd)); - return (HTREEITEM)::SendMessage(m_hWnd, TVM_INSERTITEM, 0, (LPARAM)lpInsertStruct); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_INSERTITEM, 0, (LPARAM)lpInsertStruct); } HTREEITEM InsertItem(LPCTSTR lpszItem, int nImage, int nSelectedImage, HTREEITEM hParent, HTREEITEM hInsertAfter) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); return InsertItem(TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE, lpszItem, nImage, nSelectedImage, 0, 0, 0, hParent, hInsertAfter); } HTREEITEM InsertItem(LPCTSTR lpszItem, HTREEITEM hParent, HTREEITEM hInsertAfter) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); return InsertItem(TVIF_TEXT, lpszItem, 0, 0, 0, 0, 0, hParent, hInsertAfter); } @@ -4435,8 +4402,8 @@ public: int nSelectedImage, UINT nState, UINT nStateMask, LPARAM lParam, HTREEITEM hParent, HTREEITEM hInsertAfter) { - ATLASSERT(::IsWindow(m_hWnd)); - TVINSERTSTRUCT tvis = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + TVINSERTSTRUCT tvis = {}; tvis.hParent = hParent; tvis.hInsertAfter = hInsertAfter; tvis.item.mask = nMask; @@ -4446,160 +4413,153 @@ public: tvis.item.state = nState; tvis.item.stateMask = nStateMask; tvis.item.lParam = lParam; - return (HTREEITEM)::SendMessage(m_hWnd, TVM_INSERTITEM, 0, (LPARAM)&tvis); + return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_INSERTITEM, 0, (LPARAM)&tvis); } BOOL DeleteItem(HTREEITEM hItem) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TVM_DELETEITEM, 0, (LPARAM)hItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_DELETEITEM, 0, (LPARAM)hItem); } BOOL DeleteAllItems() { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TVM_DELETEITEM, 0, (LPARAM)TVI_ROOT); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_DELETEITEM, 0, (LPARAM)TVI_ROOT); } BOOL Expand(HTREEITEM hItem, UINT nCode = TVE_EXPAND) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TVM_EXPAND, nCode, (LPARAM)hItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_EXPAND, nCode, (LPARAM)hItem); } HTREEITEM GetNextItem(HTREEITEM hItem, UINT nCode) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, nCode, (LPARAM)hItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, nCode, (LPARAM)hItem); } HTREEITEM GetChildItem(HTREEITEM hItem) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_CHILD, (LPARAM)hItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_CHILD, (LPARAM)hItem); } HTREEITEM GetNextSiblingItem(HTREEITEM hItem) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_NEXT, (LPARAM)hItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_NEXT, (LPARAM)hItem); } HTREEITEM GetPrevSiblingItem(HTREEITEM hItem) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_PREVIOUS, (LPARAM)hItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_PREVIOUS, (LPARAM)hItem); } HTREEITEM GetParentItem(HTREEITEM hItem) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_PARENT, (LPARAM)hItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_PARENT, (LPARAM)hItem); } HTREEITEM GetFirstVisibleItem() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_FIRSTVISIBLE, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_FIRSTVISIBLE, 0L); } HTREEITEM GetNextVisibleItem(HTREEITEM hItem) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_NEXTVISIBLE, (LPARAM)hItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_NEXTVISIBLE, (LPARAM)hItem); } HTREEITEM GetPrevVisibleItem(HTREEITEM hItem) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_PREVIOUSVISIBLE, (LPARAM)hItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_PREVIOUSVISIBLE, (LPARAM)hItem); } HTREEITEM GetSelectedItem() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_CARET, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_CARET, 0L); } HTREEITEM GetDropHilightItem() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_DROPHILITE, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_DROPHILITE, 0L); } HTREEITEM GetRootItem() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_ROOT, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_ROOT, 0L); } -#if !defined(_WIN32_WCE) && (_WIN32_IE >= 0x0400) HTREEITEM GetLastVisibleItem() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_LASTVISIBLE, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_LASTVISIBLE, 0L); } -#endif // !defined(_WIN32_WCE) && (_WIN32_IE >= 0x0400) -#if (_WIN32_IE >= 0x0600) - HTREEITEM GetNextSelectedItem() const + HTREEITEM GetNextSelectedItem(HTREEITEM hItem) const { -#ifndef TVGN_NEXTSELECTED - const WORD TVGN_NEXTSELECTED = 0x000B; -#endif - ATLASSERT(::IsWindow(m_hWnd)); - return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_NEXTSELECTED, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_NEXTSELECTED, (LPARAM)hItem); } -#endif // (_WIN32_IE >= 0x0600) BOOL Select(HTREEITEM hItem, UINT nCode) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TVM_SELECTITEM, nCode, (LPARAM)hItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_SELECTITEM, nCode, (LPARAM)hItem); } BOOL SelectItem(HTREEITEM hItem) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TVM_SELECTITEM, TVGN_CARET, (LPARAM)hItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_SELECTITEM, TVGN_CARET, (LPARAM)hItem); } BOOL SelectDropTarget(HTREEITEM hItem) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TVM_SELECTITEM, TVGN_DROPHILITE, (LPARAM)hItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_SELECTITEM, TVGN_DROPHILITE, (LPARAM)hItem); } BOOL SelectSetFirstVisible(HTREEITEM hItem) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TVM_SELECTITEM, TVGN_FIRSTVISIBLE, (LPARAM)hItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_SELECTITEM, TVGN_FIRSTVISIBLE, (LPARAM)hItem); } CEdit EditLabel(HTREEITEM hItem) { - ATLASSERT(::IsWindow(m_hWnd)); - return CEdit((HWND)::SendMessage(m_hWnd, TVM_EDITLABEL, 0, (LPARAM)hItem)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CEdit((HWND)::SendMessage(this->m_hWnd, TVM_EDITLABEL, 0, (LPARAM)hItem)); } BOOL EndEditLabelNow(BOOL bCancel) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TVM_ENDEDITLABELNOW, bCancel, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_ENDEDITLABELNOW, bCancel, 0L); } HTREEITEM HitTest(TVHITTESTINFO* pHitTestInfo) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (HTREEITEM)::SendMessage(m_hWnd, TVM_HITTEST, 0, (LPARAM)pHitTestInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_HITTEST, 0, (LPARAM)pHitTestInfo); } HTREEITEM HitTest(POINT pt, UINT* pFlags) const { - ATLASSERT(::IsWindow(m_hWnd)); - TVHITTESTINFO hti = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + TVHITTESTINFO hti = {}; hti.pt = pt; - HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_HITTEST, 0, (LPARAM)&hti); + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_HITTEST, 0, (LPARAM)&hti); if (pFlags != NULL) *pFlags = hti.flags; return hTreeItem; @@ -4607,67 +4567,63 @@ public: BOOL SortChildren(HTREEITEM hItem, BOOL bRecurse = FALSE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TVM_SORTCHILDREN, (WPARAM)bRecurse, (LPARAM)hItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_SORTCHILDREN, (WPARAM)bRecurse, (LPARAM)hItem); } BOOL EnsureVisible(HTREEITEM hItem) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TVM_ENSUREVISIBLE, 0, (LPARAM)hItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_ENSUREVISIBLE, 0, (LPARAM)hItem); } BOOL SortChildrenCB(LPTVSORTCB pSort, BOOL bRecurse = FALSE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TVM_SORTCHILDRENCB, (WPARAM)bRecurse, (LPARAM)pSort); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_SORTCHILDRENCB, (WPARAM)bRecurse, (LPARAM)pSort); } CImageList RemoveImageList(int nImageList) { - ATLASSERT(::IsWindow(m_hWnd)); - return CImageList((HIMAGELIST)::SendMessage(m_hWnd, TVM_SETIMAGELIST, (WPARAM)nImageList, NULL)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TVM_SETIMAGELIST, (WPARAM)nImageList, NULL)); } CImageList CreateDragImage(HTREEITEM hItem) { - ATLASSERT(::IsWindow(m_hWnd)); - return CImageList((HIMAGELIST)::SendMessage(m_hWnd, TVM_CREATEDRAGIMAGE, 0, (LPARAM)hItem)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TVM_CREATEDRAGIMAGE, 0, (LPARAM)hItem)); } -#if (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) BOOL SetInsertMark(HTREEITEM hTreeItem, BOOL bAfter) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TVM_SETINSERTMARK, bAfter, (LPARAM)hTreeItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_SETINSERTMARK, bAfter, (LPARAM)hTreeItem); } BOOL RemoveInsertMark() { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TVM_SETINSERTMARK, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_SETINSERTMARK, 0, 0L); } -#endif // (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) -#if (_WIN32_WINNT >= 0x0501) HTREEITEM MapAccIDToHTREEITEM(UINT uID) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (HTREEITEM)::SendMessage(m_hWnd, TVM_MAPACCIDTOHTREEITEM, uID, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_MAPACCIDTOHTREEITEM, uID, 0L); } UINT MapHTREEITEMToAccID(HTREEITEM hTreeItem) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (UINT)::SendMessage(m_hWnd, TVM_MAPHTREEITEMTOACCID, (WPARAM)hTreeItem, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, TVM_MAPHTREEITEMTOACCID, (WPARAM)hTreeItem, 0L); } -#endif // (_WIN32_WINNT >= 0x0501) #if (_WIN32_WINNT >= 0x0600) void ShowInfoTip(HTREEITEM hItem) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TVM_SHOWINFOTIP, 0, (LPARAM)hItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TVM_SHOWINFOTIP, 0, (LPARAM)hItem); } #endif // (_WIN32_WINNT >= 0x0600) }; @@ -4716,12 +4672,10 @@ public: BOOL GetRect(LPRECT lpRect, BOOL bTextOnly) const; BOOL GetText(LPTSTR lpstrText, int nLen) const; -#ifndef _ATL_NO_COM BOOL GetText(BSTR& bstrText) const; -#endif // !_ATL_NO_COM -#if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) - BOOL GetText(_CSTRING_NS::CString& strText) const; -#endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) +#ifdef __ATLSTR_H__ + BOOL GetText(ATL::CString& strText) const; +#endif // __ATLSTR_H__ BOOL SetText(LPCTSTR lpszItem); BOOL GetImage(int& nImage, int& nSelectedImage) const; BOOL SetImage(int nImage, int nSelectedImage); @@ -4758,12 +4712,8 @@ public: CTreeItemT GetSelected() const; CTreeItemT GetDropHilight() const; CTreeItemT GetRoot() const; -#if !defined(_WIN32_WCE) && (_WIN32_IE >= 0x0400) CTreeItemT GetLastVisible() const; -#endif // !defined(_WIN32_WCE) && (_WIN32_IE >= 0x0400) -#if (_WIN32_IE >= 0x0600) CTreeItemT GetNextSelected() const; -#endif // (_WIN32_IE >= 0x0600) BOOL HasChildren() const; BOOL Delete(); BOOL Expand(UINT nCode = TVE_EXPAND); @@ -4777,12 +4727,8 @@ public: BOOL EnsureVisible(); CTreeItemT _Insert(LPCTSTR lpstrItem, int nImageIndex, HTREEITEM hItemAfter); int GetImageIndex() const; -#if (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) BOOL SetInsertMark(BOOL bAfter); -#endif // (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) -#if (_WIN32_WINNT >= 0x0501) UINT MapHTREEITEMToAccID() const; -#endif // (_WIN32_WINNT >= 0x0501) #if (_WIN32_WINNT >= 0x0600) void ShowInfoTip(); BOOL GetPartRect(TVITEMPART partID, LPRECT lpRect) const; @@ -4802,133 +4748,126 @@ public: CTreeViewCtrlExT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } // Operations (overides that return CTreeItem) CTreeItemT InsertItem(LPTVINSERTSTRUCT lpInsertStruct) { - ATLASSERT(::IsWindow(m_hWnd)); - HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_INSERTITEM, 0, (LPARAM)lpInsertStruct); + ATLASSERT(::IsWindow(this->m_hWnd)); + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_INSERTITEM, 0, (LPARAM)lpInsertStruct); return CTreeItemT(hTreeItem, this); } CTreeItemT InsertItem(LPCTSTR lpszItem, int nImage, int nSelectedImage, HTREEITEM hParent, HTREEITEM hInsertAfter) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); return InsertItem(TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE, lpszItem, nImage, nSelectedImage, 0, 0, 0, hParent, hInsertAfter); } CTreeItemT InsertItem(LPCTSTR lpszItem, HTREEITEM hParent, HTREEITEM hInsertAfter) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); return InsertItem(TVIF_TEXT, lpszItem, 0, 0, 0, 0, 0, hParent, hInsertAfter); } CTreeItemT GetNextItem(HTREEITEM hItem, UINT nCode) const { - ATLASSERT(::IsWindow(m_hWnd)); - HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, nCode, (LPARAM)hItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, nCode, (LPARAM)hItem); return CTreeItemT(hTreeItem, (CTreeViewCtrlExT*)this); } CTreeItemT GetChildItem(HTREEITEM hItem) const { - ATLASSERT(::IsWindow(m_hWnd)); - HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_CHILD, (LPARAM)hItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_CHILD, (LPARAM)hItem); return CTreeItemT(hTreeItem, (CTreeViewCtrlExT*)this); } CTreeItemT GetNextSiblingItem(HTREEITEM hItem) const { - ATLASSERT(::IsWindow(m_hWnd)); - HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_NEXT, (LPARAM)hItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_NEXT, (LPARAM)hItem); return CTreeItemT(hTreeItem, (CTreeViewCtrlExT*)this); } CTreeItemT GetPrevSiblingItem(HTREEITEM hItem) const { - ATLASSERT(::IsWindow(m_hWnd)); - HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_PREVIOUS, (LPARAM)hItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_PREVIOUS, (LPARAM)hItem); return CTreeItemT(hTreeItem, (CTreeViewCtrlExT*)this); } CTreeItemT GetParentItem(HTREEITEM hItem) const { - ATLASSERT(::IsWindow(m_hWnd)); - HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_PARENT, (LPARAM)hItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_PARENT, (LPARAM)hItem); return CTreeItemT(hTreeItem, (CTreeViewCtrlExT*)this); } CTreeItemT GetFirstVisibleItem() const { - ATLASSERT(::IsWindow(m_hWnd)); - HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_FIRSTVISIBLE, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_FIRSTVISIBLE, 0L); return CTreeItemT(hTreeItem, (CTreeViewCtrlExT*)this); } CTreeItemT GetNextVisibleItem(HTREEITEM hItem) const { - ATLASSERT(::IsWindow(m_hWnd)); - HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_NEXTVISIBLE, (LPARAM)hItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_NEXTVISIBLE, (LPARAM)hItem); return CTreeItemT(hTreeItem, (CTreeViewCtrlExT*)this); } CTreeItemT GetPrevVisibleItem(HTREEITEM hItem) const { - ATLASSERT(::IsWindow(m_hWnd)); - HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_PREVIOUSVISIBLE, (LPARAM)hItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_PREVIOUSVISIBLE, (LPARAM)hItem); return CTreeItemT(hTreeItem, (CTreeViewCtrlExT*)this); } CTreeItemT GetSelectedItem() const { - ATLASSERT(::IsWindow(m_hWnd)); - HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_CARET, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_CARET, 0L); return CTreeItemT(hTreeItem, (CTreeViewCtrlExT*)this); } CTreeItemT GetDropHilightItem() const { - ATLASSERT(::IsWindow(m_hWnd)); - HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_DROPHILITE, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_DROPHILITE, 0L); return CTreeItemT(hTreeItem, (CTreeViewCtrlExT*)this); } CTreeItemT GetRootItem() const { - ATLASSERT(::IsWindow(m_hWnd)); - HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_ROOT, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_ROOT, 0L); return CTreeItemT(hTreeItem, (CTreeViewCtrlExT*)this); } -#if !defined(_WIN32_WCE) && (_WIN32_IE >= 0x0400) CTreeItemT GetLastVisibleItem() const { - ATLASSERT(::IsWindow(m_hWnd)); - HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_LASTVISIBLE, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_LASTVISIBLE, 0L); return CTreeItemT(hTreeItem, (CTreeViewCtrlExT*)this); } -#endif // !defined(_WIN32_WCE) && (_WIN32_IE >= 0x0400) -#if (_WIN32_IE >= 0x0600) - CTreeItemT GetNextSelectedItem() const + CTreeItemT GetNextSelectedItem(HTREEITEM hItem) const { -#ifndef TVGN_NEXTSELECTED - const WORD TVGN_NEXTSELECTED = 0x000B; -#endif - ATLASSERT(::IsWindow(m_hWnd)); - HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_NEXTSELECTED, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_NEXTSELECTED, (LPARAM)hItem); return CTreeItemT(hTreeItem, (CTreeViewCtrlExT*)this); } -#endif // (_WIN32_IE >= 0x0600) CTreeItemT HitTest(TVHITTESTINFO* pHitTestInfo) const { - ATLASSERT(::IsWindow(m_hWnd)); - HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_HITTEST, 0, (LPARAM)pHitTestInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_HITTEST, 0, (LPARAM)pHitTestInfo); return CTreeItemT(hTreeItem, (CTreeViewCtrlExT*)this); } @@ -4936,8 +4875,8 @@ public: int nSelectedImage, UINT nState, UINT nStateMask, LPARAM lParam, HTREEITEM hParent, HTREEITEM hInsertAfter) { - ATLASSERT(::IsWindow(m_hWnd)); - TVINSERTSTRUCT tvis = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + TVINSERTSTRUCT tvis = {}; tvis.hParent = hParent; tvis.hInsertAfter = hInsertAfter; tvis.item.mask = nMask; @@ -4947,29 +4886,27 @@ public: tvis.item.state = nState; tvis.item.stateMask = nStateMask; tvis.item.lParam = lParam; - HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_INSERTITEM, 0, (LPARAM)&tvis); + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_INSERTITEM, 0, (LPARAM)&tvis); return CTreeItemT(hTreeItem, this); } CTreeItemT HitTest(POINT pt, UINT* pFlags) const { - ATLASSERT(::IsWindow(m_hWnd)); - TVHITTESTINFO hti = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + TVHITTESTINFO hti = {}; hti.pt = pt; - HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_HITTEST, 0, (LPARAM)&hti); + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_HITTEST, 0, (LPARAM)&hti); if (pFlags != NULL) *pFlags = hti.flags; return CTreeItemT(hTreeItem, (CTreeViewCtrlExT*)this); } -#if (_WIN32_WINNT >= 0x0501) CTreeItemT MapAccIDToHTREEITEM(UINT uID) const { - ATLASSERT(::IsWindow(m_hWnd)); - HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_MAPACCIDTOHTREEITEM, uID, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_MAPACCIDTOHTREEITEM, uID, 0L); return CTreeItemT(hTreeItem, (CTreeViewCtrlExT*)this); } -#endif // (_WIN32_WINNT >= 0x0501) }; typedef CTreeViewCtrlExT CTreeViewCtrlEx; @@ -5060,23 +4997,19 @@ inline CTreeItemT CTreeItemT::GetRoot() const return m_pTreeView->GetRootItem(); } -#if !defined(_WIN32_WCE) && (_WIN32_IE >= 0x0400) template inline CTreeItemT CTreeItemT::GetLastVisible() const { ATLASSERT(m_pTreeView != NULL); return m_pTreeView->GetLastVisibleItem(); } -#endif // !defined(_WIN32_WCE) && (_WIN32_IE >= 0x0400) -#if (_WIN32_IE >= 0x0600) template inline CTreeItemT CTreeItemT::GetNextSelected() const { ATLASSERT(m_pTreeView != NULL); - return m_pTreeView->GetNextSelectedItem(); + return m_pTreeView->GetNextSelectedItem(m_hTreeItem); } -#endif // (_WIN32_IE >= 0x0600) template inline BOOL CTreeItemT::GetText(LPTSTR lpstrText, int nLen) const @@ -5085,7 +5018,6 @@ inline BOOL CTreeItemT::GetText(LPTSTR lpstrText, int nLen) const return m_pTreeView->GetItemText(m_hTreeItem, lpstrText, nLen); } -#ifndef _ATL_NO_COM #ifdef _OLEAUTO_H_ template inline BOOL CTreeItemT::GetText(BSTR& bstrText) const @@ -5094,16 +5026,15 @@ inline BOOL CTreeItemT::GetText(BSTR& bstrText) const return m_pTreeView->GetItemText(m_hTreeItem, bstrText); } #endif // _OLEAUTO_H_ -#endif // !_ATL_NO_COM -#if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) +#ifdef __ATLSTR_H__ template -inline BOOL CTreeItemT::GetText(_CSTRING_NS::CString& strText) const +inline BOOL CTreeItemT::GetText(ATL::CString& strText) const { ATLASSERT(m_pTreeView != NULL); return m_pTreeView->GetItemText(m_hTreeItem, strText); } -#endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) +#endif // __ATLSTR_H__ template inline BOOL CTreeItemT::GetImage(int& nImage, int& nSelectedImage) const @@ -5243,7 +5174,7 @@ template inline CTreeItemT CTreeItemT::_Insert(LPCTSTR lpstrItem, int nImageIndex, HTREEITEM hItemAfter) { ATLASSERT(m_pTreeView != NULL); - TVINSERTSTRUCT ins = { 0 }; + TVINSERTSTRUCT ins = {}; ins.hParent = m_hTreeItem; ins.hInsertAfter = hItemAfter; ins.item.mask = TVIF_TEXT; @@ -5261,30 +5192,26 @@ template inline int CTreeItemT::GetImageIndex() const { ATLASSERT(m_pTreeView != NULL); - TVITEM item = { 0 }; + TVITEM item = {}; item.mask = TVIF_HANDLE | TVIF_IMAGE; item.hItem = m_hTreeItem; m_pTreeView->GetItem(&item); return item.iImage; } -#if (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) template inline BOOL CTreeItemT::SetInsertMark(BOOL bAfter) { ATLASSERT(m_pTreeView != NULL); return m_pTreeView->SetInsertMark(m_hTreeItem, bAfter); } -#endif // (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) -#if (_WIN32_WINNT >= 0x0501) template inline UINT CTreeItemT::MapHTREEITEMToAccID() const { ATLASSERT(m_pTreeView != NULL); return m_pTreeView->MapHTREEITEMToAccID(m_hTreeItem); } -#endif // (_WIN32_WINNT >= 0x0501) #if (_WIN32_WINNT >= 0x0600) template @@ -5316,7 +5243,7 @@ public: CToolBarCtrlT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -5335,282 +5262,275 @@ public: BOOL IsButtonEnabled(int nID) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_ISBUTTONENABLED, nID, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_ISBUTTONENABLED, nID, 0L); } BOOL IsButtonChecked(int nID) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_ISBUTTONCHECKED, nID, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_ISBUTTONCHECKED, nID, 0L); } BOOL IsButtonPressed(int nID) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_ISBUTTONPRESSED, nID, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_ISBUTTONPRESSED, nID, 0L); } BOOL IsButtonHidden(int nID) const { - ATLASSERT(::IsWindow(m_hWnd)); - return(BOOL) ::SendMessage(m_hWnd, TB_ISBUTTONHIDDEN, nID, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return(BOOL) ::SendMessage(this->m_hWnd, TB_ISBUTTONHIDDEN, nID, 0L); } BOOL IsButtonIndeterminate(int nID) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_ISBUTTONINDETERMINATE, nID, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_ISBUTTONINDETERMINATE, nID, 0L); } int GetState(int nID) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TB_GETSTATE, nID, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TB_GETSTATE, nID, 0L); } BOOL SetState(int nID, UINT nState) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_SETSTATE, nID, MAKELPARAM(nState, 0)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_SETSTATE, nID, MAKELPARAM(nState, 0)); } BOOL GetButton(int nIndex, LPTBBUTTON lpButton) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_GETBUTTON, nIndex, (LPARAM)lpButton); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_GETBUTTON, nIndex, (LPARAM)lpButton); } int GetButtonCount() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TB_BUTTONCOUNT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TB_BUTTONCOUNT, 0, 0L); } BOOL GetItemRect(int nIndex, LPRECT lpRect) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_GETITEMRECT, nIndex, (LPARAM)lpRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_GETITEMRECT, nIndex, (LPARAM)lpRect); } void SetButtonStructSize(int nSize = sizeof(TBBUTTON)) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TB_BUTTONSTRUCTSIZE, nSize, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TB_BUTTONSTRUCTSIZE, nSize, 0L); } BOOL SetButtonSize(SIZE size) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_SETBUTTONSIZE, 0, MAKELPARAM(size.cx, size.cy)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_SETBUTTONSIZE, 0, MAKELPARAM(size.cx, size.cy)); } BOOL SetButtonSize(int cx, int cy) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_SETBUTTONSIZE, 0, MAKELPARAM(cx, cy)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_SETBUTTONSIZE, 0, MAKELPARAM(cx, cy)); } BOOL SetBitmapSize(SIZE size) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_SETBITMAPSIZE, 0, MAKELPARAM(size.cx, size.cy)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_SETBITMAPSIZE, 0, MAKELPARAM(size.cx, size.cy)); } BOOL SetBitmapSize(int cx, int cy) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_SETBITMAPSIZE, 0, MAKELPARAM(cx, cy)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_SETBITMAPSIZE, 0, MAKELPARAM(cx, cy)); } -#ifndef _WIN32_WCE CToolTipCtrl GetToolTips() const { - ATLASSERT(::IsWindow(m_hWnd)); - return CToolTipCtrl((HWND)::SendMessage(m_hWnd, TB_GETTOOLTIPS, 0, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CToolTipCtrl((HWND)::SendMessage(this->m_hWnd, TB_GETTOOLTIPS, 0, 0L)); } void SetToolTips(HWND hWndToolTip) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TB_SETTOOLTIPS, (WPARAM)hWndToolTip, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TB_SETTOOLTIPS, (WPARAM)hWndToolTip, 0L); } -#endif // !_WIN32_WCE void SetNotifyWnd(HWND hWnd) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TB_SETPARENT, (WPARAM)hWnd, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TB_SETPARENT, (WPARAM)hWnd, 0L); } int GetRows() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TB_GETROWS, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TB_GETROWS, 0, 0L); } void SetRows(int nRows, BOOL bLarger, LPRECT lpRect) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TB_SETROWS, MAKELPARAM(nRows, bLarger), (LPARAM)lpRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TB_SETROWS, MAKELPARAM(nRows, bLarger), (LPARAM)lpRect); } BOOL SetCmdID(int nIndex, UINT nID) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_SETCMDID, nIndex, nID); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_SETCMDID, nIndex, nID); } DWORD GetBitmapFlags() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, TB_GETBITMAPFLAGS, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, TB_GETBITMAPFLAGS, 0, 0L); } int GetBitmap(int nID) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TB_GETBITMAP, nID, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TB_GETBITMAP, nID, 0L); } int GetButtonText(int nID, LPTSTR lpstrText) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TB_GETBUTTONTEXT, nID, (LPARAM)lpstrText); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TB_GETBUTTONTEXT, nID, (LPARAM)lpstrText); } // nIndex - IE5 or higher only CImageList GetImageList(int nIndex = 0) const { - ATLASSERT(::IsWindow(m_hWnd)); - return CImageList((HIMAGELIST)::SendMessage(m_hWnd, TB_GETIMAGELIST, nIndex, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TB_GETIMAGELIST, nIndex, 0L)); } // nIndex - IE5 or higher only CImageList SetImageList(HIMAGELIST hImageList, int nIndex = 0) { - ATLASSERT(::IsWindow(m_hWnd)); - return CImageList((HIMAGELIST)::SendMessage(m_hWnd, TB_SETIMAGELIST, nIndex, (LPARAM)hImageList)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TB_SETIMAGELIST, nIndex, (LPARAM)hImageList)); } // nIndex - IE5 or higher only CImageList GetDisabledImageList(int nIndex = 0) const { - ATLASSERT(::IsWindow(m_hWnd)); - return CImageList((HIMAGELIST)::SendMessage(m_hWnd, TB_GETDISABLEDIMAGELIST, nIndex, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TB_GETDISABLEDIMAGELIST, nIndex, 0L)); } // nIndex - IE5 or higher only CImageList SetDisabledImageList(HIMAGELIST hImageList, int nIndex = 0) { - ATLASSERT(::IsWindow(m_hWnd)); - return CImageList((HIMAGELIST)::SendMessage(m_hWnd, TB_SETDISABLEDIMAGELIST, nIndex, (LPARAM)hImageList)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TB_SETDISABLEDIMAGELIST, nIndex, (LPARAM)hImageList)); } -#ifndef _WIN32_WCE // nIndex - IE5 or higher only CImageList GetHotImageList(int nIndex = 0) const { - ATLASSERT(::IsWindow(m_hWnd)); - return CImageList((HIMAGELIST)::SendMessage(m_hWnd, TB_GETHOTIMAGELIST, nIndex, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TB_GETHOTIMAGELIST, nIndex, 0L)); } // nIndex - IE5 or higher only CImageList SetHotImageList(HIMAGELIST hImageList, int nIndex = 0) { - ATLASSERT(::IsWindow(m_hWnd)); - return CImageList((HIMAGELIST)::SendMessage(m_hWnd, TB_SETHOTIMAGELIST, nIndex, (LPARAM)hImageList)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TB_SETHOTIMAGELIST, nIndex, (LPARAM)hImageList)); } -#endif // !_WIN32_WCE DWORD GetStyle() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, TB_GETSTYLE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, TB_GETSTYLE, 0, 0L); } void SetStyle(DWORD dwStyle) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TB_SETSTYLE, 0, dwStyle); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TB_SETSTYLE, 0, dwStyle); } DWORD GetButtonSize() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, TB_GETBUTTONSIZE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, TB_GETBUTTONSIZE, 0, 0L); } void GetButtonSize(SIZE& size) const { - ATLASSERT(::IsWindow(m_hWnd)); - DWORD dwRet = (DWORD)::SendMessage(m_hWnd, TB_GETBUTTONSIZE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, TB_GETBUTTONSIZE, 0, 0L); size.cx = LOWORD(dwRet); size.cy = HIWORD(dwRet); } BOOL GetRect(int nID, LPRECT lpRect) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_GETRECT, nID, (LPARAM)lpRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_GETRECT, nID, (LPARAM)lpRect); } int GetTextRows() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TB_GETTEXTROWS, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TB_GETTEXTROWS, 0, 0L); } BOOL SetButtonWidth(int cxMin, int cxMax) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_SETBUTTONWIDTH, 0, MAKELPARAM(cxMin, cxMax)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_SETBUTTONWIDTH, 0, MAKELPARAM(cxMin, cxMax)); } BOOL SetIndent(int nIndent) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_SETINDENT, nIndent, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_SETINDENT, nIndent, 0L); } BOOL SetMaxTextRows(int nMaxTextRows) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_SETMAXTEXTROWS, nMaxTextRows, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_SETMAXTEXTROWS, nMaxTextRows, 0L); } -#if (_WIN32_IE >= 0x0400) -#ifndef _WIN32_WCE BOOL GetAnchorHighlight() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_GETANCHORHIGHLIGHT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_GETANCHORHIGHLIGHT, 0, 0L); } BOOL SetAnchorHighlight(BOOL bEnable = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_SETANCHORHIGHLIGHT, bEnable, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_SETANCHORHIGHLIGHT, bEnable, 0L); } -#endif // !_WIN32_WCE int GetButtonInfo(int nID, LPTBBUTTONINFO lptbbi) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TB_GETBUTTONINFO, nID, (LPARAM)lptbbi); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TB_GETBUTTONINFO, nID, (LPARAM)lptbbi); } BOOL SetButtonInfo(int nID, LPTBBUTTONINFO lptbbi) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_SETBUTTONINFO, nID, (LPARAM)lptbbi); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_SETBUTTONINFO, nID, (LPARAM)lptbbi); } BOOL SetButtonInfo(int nID, DWORD dwMask, BYTE Style, BYTE State, LPCTSTR lpszItem, int iImage, WORD cx, int iCommand, DWORD_PTR lParam) { - ATLASSERT(::IsWindow(m_hWnd)); - TBBUTTONINFO tbbi = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + TBBUTTONINFO tbbi = {}; tbbi.cbSize = sizeof(TBBUTTONINFO); tbbi.dwMask = dwMask; tbbi.idCommand = iCommand; @@ -5620,103 +5540,100 @@ public: tbbi.cx = cx; tbbi.pszText = (LPTSTR) lpszItem; tbbi.lParam = lParam; - return (BOOL)::SendMessage(m_hWnd, TB_SETBUTTONINFO, nID, (LPARAM)&tbbi); + return (BOOL)::SendMessage(this->m_hWnd, TB_SETBUTTONINFO, nID, (LPARAM)&tbbi); } -#ifndef _WIN32_WCE int GetHotItem() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TB_GETHOTITEM, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TB_GETHOTITEM, 0, 0L); } int SetHotItem(int nItem) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TB_SETHOTITEM, nItem, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TB_SETHOTITEM, nItem, 0L); } -#endif // !_WIN32_WCE BOOL IsButtonHighlighted(int nButtonID) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_ISBUTTONHIGHLIGHTED, nButtonID, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_ISBUTTONHIGHLIGHTED, nButtonID, 0L); } DWORD SetDrawTextFlags(DWORD dwMask, DWORD dwFlags) { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, TB_SETDRAWTEXTFLAGS, dwMask, dwFlags); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, TB_SETDRAWTEXTFLAGS, dwMask, dwFlags); } -#ifndef _WIN32_WCE BOOL GetColorScheme(LPCOLORSCHEME lpcs) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_GETCOLORSCHEME, 0, (LPARAM)lpcs); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_GETCOLORSCHEME, 0, (LPARAM)lpcs); } void SetColorScheme(LPCOLORSCHEME lpcs) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TB_SETCOLORSCHEME, 0, (LPARAM)lpcs); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TB_SETCOLORSCHEME, 0, (LPARAM)lpcs); } DWORD GetExtendedStyle() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, TB_GETEXTENDEDSTYLE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, TB_GETEXTENDEDSTYLE, 0, 0L); } DWORD SetExtendedStyle(DWORD dwStyle) { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, TB_SETEXTENDEDSTYLE, 0, dwStyle); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, TB_SETEXTENDEDSTYLE, 0, dwStyle); } void GetInsertMark(LPTBINSERTMARK lptbim) const { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TB_GETINSERTMARK, 0, (LPARAM)lptbim); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TB_GETINSERTMARK, 0, (LPARAM)lptbim); } void SetInsertMark(LPTBINSERTMARK lptbim) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TB_SETINSERTMARK, 0, (LPARAM)lptbim); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TB_SETINSERTMARK, 0, (LPARAM)lptbim); } COLORREF GetInsertMarkColor() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, TB_GETINSERTMARKCOLOR, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, TB_GETINSERTMARKCOLOR, 0, 0L); } COLORREF SetInsertMarkColor(COLORREF clr) { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, TB_SETINSERTMARKCOLOR, 0, (LPARAM)clr); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, TB_SETINSERTMARKCOLOR, 0, (LPARAM)clr); } BOOL GetMaxSize(LPSIZE lpSize) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_GETMAXSIZE, 0, (LPARAM)lpSize); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_GETMAXSIZE, 0, (LPARAM)lpSize); } void GetPadding(LPSIZE lpSizePadding) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(lpSizePadding != NULL); - DWORD dwRet = (DWORD)::SendMessage(m_hWnd, TB_GETPADDING, 0, 0L); + DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, TB_GETPADDING, 0, 0L); lpSizePadding->cx = GET_X_LPARAM(dwRet); lpSizePadding->cy = GET_Y_LPARAM(dwRet); } void SetPadding(int cx, int cy, LPSIZE lpSizePadding = NULL) { - ATLASSERT(::IsWindow(m_hWnd)); - DWORD dwRet = (DWORD)::SendMessage(m_hWnd, TB_SETPADDING, 0, MAKELPARAM(cx, cy)); + ATLASSERT(::IsWindow(this->m_hWnd)); + DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, TB_SETPADDING, 0, MAKELPARAM(cx, cy)); if(lpSizePadding != NULL) { lpSizePadding->cx = GET_X_LPARAM(dwRet); @@ -5726,38 +5643,35 @@ public: BOOL GetUnicodeFormat() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_GETUNICODEFORMAT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_GETUNICODEFORMAT, 0, 0L); } BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_SETUNICODEFORMAT, bUnicode, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_SETUNICODEFORMAT, bUnicode, 0L); } -#endif // !_WIN32_WCE -#endif // (_WIN32_IE >= 0x0400) -#if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) int GetString(int nString, LPTSTR lpstrString, int cchMaxLen) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TB_GETSTRING, MAKEWPARAM(cchMaxLen, nString), (LPARAM)lpstrString); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TB_GETSTRING, MAKEWPARAM(cchMaxLen, nString), (LPARAM)lpstrString); } int GetStringBSTR(int nString, BSTR& bstrString) const { USES_CONVERSION; - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(bstrString == NULL); - int nLength = (int)(short)LOWORD(::SendMessage(m_hWnd, TB_GETSTRING, MAKEWPARAM(0, nString), NULL)); + int nLength = (int)(short)LOWORD(::SendMessage(this->m_hWnd, TB_GETSTRING, MAKEWPARAM(0, nString), NULL)); if(nLength != -1) { - CTempBuffer buff; + ATL::CTempBuffer buff; LPTSTR lpstrText = buff.Allocate(nLength + 1); if(lpstrText != NULL) { - nLength = (int)::SendMessage(m_hWnd, TB_GETSTRING, MAKEWPARAM(nLength + 1, nString), (LPARAM)lpstrText); + nLength = (int)::SendMessage(this->m_hWnd, TB_GETSTRING, MAKEWPARAM(nLength + 1, nString), (LPARAM)lpstrText); if(nLength != -1) bstrString = ::SysAllocString(T2OLE(lpstrText)); } @@ -5770,56 +5684,53 @@ public: return nLength; } -#if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) - int GetString(int nString, _CSTRING_NS::CString& str) const +#ifdef __ATLSTR_H__ + int GetString(int nString, ATL::CString& str) const { - ATLASSERT(::IsWindow(m_hWnd)); - int nLength = (int)(short)LOWORD(::SendMessage(m_hWnd, TB_GETSTRING, MAKEWPARAM(0, nString), NULL)); + ATLASSERT(::IsWindow(this->m_hWnd)); + int nLength = (int)(short)LOWORD(::SendMessage(this->m_hWnd, TB_GETSTRING, MAKEWPARAM(0, nString), NULL)); if(nLength != -1) { LPTSTR lpstr = str.GetBufferSetLength(nLength + 1); if(lpstr != NULL) - nLength = (int)::SendMessage(m_hWnd, TB_GETSTRING, MAKEWPARAM(nLength + 1, nString), (LPARAM)lpstr); + nLength = (int)::SendMessage(this->m_hWnd, TB_GETSTRING, MAKEWPARAM(nLength + 1, nString), (LPARAM)lpstr); else nLength = -1; str.ReleaseBuffer(); } return nLength; } -#endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) -#endif // (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) +#endif // __ATLSTR_H__ -#if (_WIN32_WINNT >= 0x0501) void GetMetrics(LPTBMETRICS lptbm) const { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TB_GETMETRICS, 0, (LPARAM)lptbm); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TB_GETMETRICS, 0, (LPARAM)lptbm); } void SetMetrics(LPTBMETRICS lptbm) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TB_SETMETRICS, 0, (LPARAM)lptbm); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TB_SETMETRICS, 0, (LPARAM)lptbm); } void SetWindowTheme(LPCWSTR lpstrTheme) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TB_SETWINDOWTHEME, 0, (LPARAM)lpstrTheme); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TB_SETWINDOWTHEME, 0, (LPARAM)lpstrTheme); } -#endif // (_WIN32_WINNT >= 0x0501) #if (_WIN32_WINNT >= 0x0600) CImageList GetPressedImageList(int nIndex = 0) const { - ATLASSERT(::IsWindow(m_hWnd)); - return CImageList((HIMAGELIST)::SendMessage(m_hWnd, TB_GETPRESSEDIMAGELIST, nIndex, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TB_GETPRESSEDIMAGELIST, nIndex, 0L)); } CImageList SetPressedImageList(HIMAGELIST hImageList, int nIndex = 0) { - ATLASSERT(::IsWindow(m_hWnd)); - return CImageList((HIMAGELIST)::SendMessage(m_hWnd, TB_SETPRESSEDIMAGELIST, nIndex, (LPARAM)hImageList)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TB_SETPRESSEDIMAGELIST, nIndex, (LPARAM)hImageList)); } void GetItemDropDownRect(int nIndex, LPRECT lpRect) const @@ -5827,9 +5738,9 @@ public: #ifndef TB_GETITEMDROPDOWNRECT const int TB_GETITEMDROPDOWNRECT = WM_USER + 103; #endif - ATLASSERT(::IsWindow(m_hWnd)); - BOOL bRet = (BOOL)::SendMessage(m_hWnd, TB_GETITEMDROPDOWNRECT, nIndex, (LPARAM)lpRect); - bRet; // avoid level 4 warning + ATLASSERT(::IsWindow(this->m_hWnd)); + BOOL bRet = (BOOL)::SendMessage(this->m_hWnd, TB_GETITEMDROPDOWNRECT, nIndex, (LPARAM)lpRect); + (void)bRet; // avoid level 4 warning ATLASSERT(bRet != FALSE); } #endif // (_WIN32_WINNT >= 0x0600) @@ -5837,77 +5748,77 @@ public: // Operations BOOL EnableButton(int nID, BOOL bEnable = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_ENABLEBUTTON, nID, MAKELPARAM(bEnable, 0)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_ENABLEBUTTON, nID, MAKELPARAM(bEnable, 0)); } BOOL CheckButton(int nID, BOOL bCheck = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_CHECKBUTTON, nID, MAKELPARAM(bCheck, 0)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_CHECKBUTTON, nID, MAKELPARAM(bCheck, 0)); } BOOL PressButton(int nID, BOOL bPress = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_PRESSBUTTON, nID, MAKELPARAM(bPress, 0)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_PRESSBUTTON, nID, MAKELPARAM(bPress, 0)); } BOOL HideButton(int nID, BOOL bHide = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_HIDEBUTTON, nID, MAKELPARAM(bHide, 0)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_HIDEBUTTON, nID, MAKELPARAM(bHide, 0)); } BOOL Indeterminate(int nID, BOOL bIndeterminate = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_INDETERMINATE, nID, MAKELPARAM(bIndeterminate, 0)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_INDETERMINATE, nID, MAKELPARAM(bIndeterminate, 0)); } int AddBitmap(int nNumButtons, UINT nBitmapID) { - ATLASSERT(::IsWindow(m_hWnd)); - TBADDBITMAP tbab = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + TBADDBITMAP tbab = {}; tbab.hInst = ModuleHelper::GetResourceInstance(); ATLASSERT(tbab.hInst != NULL); tbab.nID = nBitmapID; - return (int)::SendMessage(m_hWnd, TB_ADDBITMAP, (WPARAM)nNumButtons, (LPARAM)&tbab); + return (int)::SendMessage(this->m_hWnd, TB_ADDBITMAP, (WPARAM)nNumButtons, (LPARAM)&tbab); } int AddBitmap(int nNumButtons, HBITMAP hBitmap) { - ATLASSERT(::IsWindow(m_hWnd)); - TBADDBITMAP tbab = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + TBADDBITMAP tbab = {}; tbab.hInst = NULL; tbab.nID = (UINT_PTR)hBitmap; - return (int)::SendMessage(m_hWnd, TB_ADDBITMAP, (WPARAM)nNumButtons, (LPARAM)&tbab); + return (int)::SendMessage(this->m_hWnd, TB_ADDBITMAP, (WPARAM)nNumButtons, (LPARAM)&tbab); } - BOOL AddButtons(int nNumButtons, LPTBBUTTON lpButtons) + BOOL AddButtons(int nNumButtons, LPCTBBUTTON lpButtons) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_ADDBUTTONS, nNumButtons, (LPARAM)lpButtons); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_ADDBUTTONS, nNumButtons, (LPARAM)lpButtons); } - BOOL InsertButton(int nIndex, LPTBBUTTON lpButton) + BOOL InsertButton(int nIndex, LPCTBBUTTON lpButton) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_INSERTBUTTON, nIndex, (LPARAM)lpButton); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_INSERTBUTTON, nIndex, (LPARAM)lpButton); } BOOL InsertButton(int nIndex, int iCommand, BYTE Style, BYTE State, int iBitmap, INT_PTR iString, DWORD_PTR lParam) { - ATLASSERT(::IsWindow(m_hWnd)); - TBBUTTON tbb = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + TBBUTTON tbb = {}; tbb.fsStyle = Style; tbb.fsState = State; tbb.idCommand = iCommand; tbb.iBitmap = iBitmap; tbb.iString = iString; tbb.dwData = lParam; - return (BOOL)::SendMessage(m_hWnd, TB_INSERTBUTTON, nIndex, (LPARAM)&tbb); + return (BOOL)::SendMessage(this->m_hWnd, TB_INSERTBUTTON, nIndex, (LPARAM)&tbb); } BOOL InsertButton(int nIndex, int iCommand, BYTE Style, BYTE State, int iBitmap, @@ -5933,8 +5844,8 @@ public: BOOL DeleteButton(int nIndex) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_DELETEBUTTON, nIndex, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_DELETEBUTTON, nIndex, 0L); } BOOL InsertSeparator(int nIndex, int cxWidth = 8) @@ -5949,126 +5860,120 @@ public: int CommandToIndex(UINT nID) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TB_COMMANDTOINDEX, nID, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TB_COMMANDTOINDEX, nID, 0L); } -#ifndef _WIN32_WCE void SaveState(HKEY hKeyRoot, LPCTSTR lpszSubKey, LPCTSTR lpszValueName) { - ATLASSERT(::IsWindow(m_hWnd)); - TBSAVEPARAMS tbs = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + TBSAVEPARAMS tbs = {}; tbs.hkr = hKeyRoot; tbs.pszSubKey = lpszSubKey; tbs.pszValueName = lpszValueName; - ::SendMessage(m_hWnd, TB_SAVERESTORE, (WPARAM)TRUE, (LPARAM)&tbs); + ::SendMessage(this->m_hWnd, TB_SAVERESTORE, (WPARAM)TRUE, (LPARAM)&tbs); } void RestoreState(HKEY hKeyRoot, LPCTSTR lpszSubKey, LPCTSTR lpszValueName) { - ATLASSERT(::IsWindow(m_hWnd)); - TBSAVEPARAMS tbs = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + TBSAVEPARAMS tbs = {}; tbs.hkr = hKeyRoot; tbs.pszSubKey = lpszSubKey; tbs.pszValueName = lpszValueName; - ::SendMessage(m_hWnd, TB_SAVERESTORE, (WPARAM)FALSE, (LPARAM)&tbs); + ::SendMessage(this->m_hWnd, TB_SAVERESTORE, (WPARAM)FALSE, (LPARAM)&tbs); } void Customize() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TB_CUSTOMIZE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TB_CUSTOMIZE, 0, 0L); } -#endif // !_WIN32_WCE int AddString(UINT nStringID) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TB_ADDSTRING, (WPARAM)ModuleHelper::GetResourceInstance(), (LPARAM)nStringID); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TB_ADDSTRING, (WPARAM)ModuleHelper::GetResourceInstance(), (LPARAM)nStringID); } int AddStrings(LPCTSTR lpszStrings) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TB_ADDSTRING, 0, (LPARAM)lpszStrings); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TB_ADDSTRING, 0, (LPARAM)lpszStrings); } void AutoSize() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TB_AUTOSIZE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TB_AUTOSIZE, 0, 0L); } BOOL ChangeBitmap(int nID, int nBitmap) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_CHANGEBITMAP, nID, MAKELPARAM(nBitmap, 0)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_CHANGEBITMAP, nID, MAKELPARAM(nBitmap, 0)); } int LoadImages(int nBitmapID) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TB_LOADIMAGES, nBitmapID, (LPARAM)ModuleHelper::GetResourceInstance()); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TB_LOADIMAGES, nBitmapID, (LPARAM)ModuleHelper::GetResourceInstance()); } int LoadStdImages(int nBitmapID) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TB_LOADIMAGES, nBitmapID, (LPARAM)HINST_COMMCTRL); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TB_LOADIMAGES, nBitmapID, (LPARAM)HINST_COMMCTRL); } BOOL ReplaceBitmap(LPTBREPLACEBITMAP ptbrb) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_REPLACEBITMAP, 0, (LPARAM)ptbrb); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_REPLACEBITMAP, 0, (LPARAM)ptbrb); } -#if (_WIN32_IE >= 0x0400) int HitTest(LPPOINT lpPoint) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TB_HITTEST, 0, (LPARAM)lpPoint); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TB_HITTEST, 0, (LPARAM)lpPoint); } -#ifndef _WIN32_WCE BOOL InsertMarkHitTest(LPPOINT lpPoint, LPTBINSERTMARK lptbim) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_INSERTMARKHITTEST, (WPARAM)lpPoint, (LPARAM)lptbim); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_INSERTMARKHITTEST, (WPARAM)lpPoint, (LPARAM)lptbim); } BOOL InsertMarkHitTest(int x, int y, LPTBINSERTMARK lptbim) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); POINT pt = { x, y }; - return (BOOL)::SendMessage(m_hWnd, TB_INSERTMARKHITTEST, (WPARAM)&pt, (LPARAM)lptbim); + return (BOOL)::SendMessage(this->m_hWnd, TB_INSERTMARKHITTEST, (WPARAM)&pt, (LPARAM)lptbim); } BOOL MapAccelerator(TCHAR chAccel, int& nID) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_MAPACCELERATOR, (WPARAM)chAccel, (LPARAM)&nID); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_MAPACCELERATOR, (WPARAM)chAccel, (LPARAM)&nID); } BOOL MarkButton(int nID, BOOL bHighlight = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_MARKBUTTON, nID, MAKELPARAM(bHighlight, 0)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_MARKBUTTON, nID, MAKELPARAM(bHighlight, 0)); } BOOL MoveButton(int nOldPos, int nNewPos) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TB_MOVEBUTTON, nOldPos, nNewPos); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_MOVEBUTTON, nOldPos, nNewPos); } HRESULT GetObject(REFIID iid, LPVOID* ppvObject) { - ATLASSERT(::IsWindow(m_hWnd)); - return (HRESULT)::SendMessage(m_hWnd, TB_GETOBJECT, (WPARAM)&iid, (LPARAM)ppvObject); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HRESULT)::SendMessage(this->m_hWnd, TB_GETOBJECT, (WPARAM)&iid, (LPARAM)ppvObject); } -#endif // !_WIN32_WCE -#endif // (_WIN32_IE >= 0x0400) }; typedef CToolBarCtrlT CToolBarCtrl; @@ -6087,7 +5992,7 @@ public: CStatusBarCtrlT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -6106,21 +6011,21 @@ public: int GetParts(int nParts, int* pParts) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, SB_GETPARTS, nParts, (LPARAM)pParts); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, SB_GETPARTS, nParts, (LPARAM)pParts); } BOOL SetParts(int nParts, int* pWidths) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, SB_SETPARTS, nParts, (LPARAM)pWidths); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, SB_SETPARTS, nParts, (LPARAM)pWidths); } int GetTextLength(int nPane, int* pType = NULL) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(nPane < 256); - DWORD dwRet = (DWORD)::SendMessage(m_hWnd, SB_GETTEXTLENGTH, (WPARAM)nPane, 0L); + DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, SB_GETTEXTLENGTH, (WPARAM)nPane, 0L); if (pType != NULL) *pType = (int)(short)HIWORD(dwRet); return (int)(short)LOWORD(dwRet); @@ -6128,26 +6033,25 @@ public: int GetText(int nPane, LPTSTR lpszText, int* pType = NULL) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(nPane < 256); - DWORD dwRet = (DWORD)::SendMessage(m_hWnd, SB_GETTEXT, (WPARAM)nPane, (LPARAM)lpszText); + DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, SB_GETTEXT, (WPARAM)nPane, (LPARAM)lpszText); if(pType != NULL) *pType = (int)(short)HIWORD(dwRet); return (int)(short)LOWORD(dwRet); } -#ifndef _ATL_NO_COM BOOL GetTextBSTR(int nPane, BSTR& bstrText, int* pType = NULL) const { USES_CONVERSION; - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(nPane < 256); ATLASSERT(bstrText == NULL); - int nLength = (int)(short)LOWORD(::SendMessage(m_hWnd, SB_GETTEXTLENGTH, (WPARAM)nPane, 0L)); + int nLength = (int)(short)LOWORD(::SendMessage(this->m_hWnd, SB_GETTEXTLENGTH, (WPARAM)nPane, 0L)); if(nLength == 0) return FALSE; - CTempBuffer buff; + ATL::CTempBuffer buff; LPTSTR lpstrText = buff.Allocate(nLength + 1); if(lpstrText == NULL) return FALSE; @@ -6158,14 +6062,13 @@ public: bstrText = ::SysAllocString(T2OLE(lpstrText)); return (bstrText != NULL) ? TRUE : FALSE; } -#endif // !_ATL_NO_COM -#if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) - int GetText(int nPane, _CSTRING_NS::CString& strText, int* pType = NULL) const +#ifdef __ATLSTR_H__ + int GetText(int nPane, ATL::CString& strText, int* pType = NULL) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(nPane < 256); - int nLength = (int)(short)LOWORD(::SendMessage(m_hWnd, SB_GETTEXTLENGTH, (WPARAM)nPane, 0L)); + int nLength = (int)(short)LOWORD(::SendMessage(this->m_hWnd, SB_GETTEXTLENGTH, (WPARAM)nPane, 0L)); if(nLength == 0) return 0; @@ -6174,33 +6077,33 @@ public: return 0; return GetText(nPane, lpstr, pType); } -#endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) +#endif // __ATLSTR_H__ BOOL SetText(int nPane, LPCTSTR lpszText, int nType = 0) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(nPane < 256); - return (BOOL)::SendMessage(m_hWnd, SB_SETTEXT, (nPane | nType), (LPARAM)lpszText); + return (BOOL)::SendMessage(this->m_hWnd, SB_SETTEXT, (nPane | nType), (LPARAM)lpszText); } BOOL GetRect(int nPane, LPRECT lpRect) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(nPane < 256); - return (BOOL)::SendMessage(m_hWnd, SB_GETRECT, nPane, (LPARAM)lpRect); + return (BOOL)::SendMessage(this->m_hWnd, SB_GETRECT, nPane, (LPARAM)lpRect); } BOOL GetBorders(int* pBorders) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, SB_GETBORDERS, 0, (LPARAM)pBorders); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, SB_GETBORDERS, 0, (LPARAM)pBorders); } BOOL GetBorders(int& nHorz, int& nVert, int& nSpacing) const { - ATLASSERT(::IsWindow(m_hWnd)); - int borders[3] = { 0, 0, 0 }; - BOOL bResult = (BOOL)::SendMessage(m_hWnd, SB_GETBORDERS, 0, (LPARAM)&borders); + ATLASSERT(::IsWindow(this->m_hWnd)); + int borders[3] = {}; + BOOL bResult = (BOOL)::SendMessage(this->m_hWnd, SB_GETBORDERS, 0, (LPARAM)&borders); if(bResult) { nHorz = borders[0]; @@ -6212,71 +6115,67 @@ public: void SetMinHeight(int nMin) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, SB_SETMINHEIGHT, nMin, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, SB_SETMINHEIGHT, nMin, 0L); } BOOL SetSimple(BOOL bSimple = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, SB_SIMPLE, bSimple, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, SB_SIMPLE, bSimple, 0L); } BOOL IsSimple() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, SB_ISSIMPLE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, SB_ISSIMPLE, 0, 0L); } -#if (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) BOOL GetUnicodeFormat() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, SB_GETUNICODEFORMAT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, SB_GETUNICODEFORMAT, 0, 0L); } BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, SB_SETUNICODEFORMAT, bUnicode, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, SB_SETUNICODEFORMAT, bUnicode, 0L); } void GetTipText(int nPane, LPTSTR lpstrText, int nSize) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(nPane < 256); - ::SendMessage(m_hWnd, SB_GETTIPTEXT, MAKEWPARAM(nPane, nSize), (LPARAM)lpstrText); + ::SendMessage(this->m_hWnd, SB_GETTIPTEXT, MAKEWPARAM(nPane, nSize), (LPARAM)lpstrText); } void SetTipText(int nPane, LPCTSTR lpstrText) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(nPane < 256); - ::SendMessage(m_hWnd, SB_SETTIPTEXT, nPane, (LPARAM)lpstrText); + ::SendMessage(this->m_hWnd, SB_SETTIPTEXT, nPane, (LPARAM)lpstrText); } -#endif // (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) -#if ((_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE)) || (defined(_WIN32_WCE) && (_WIN32_WCE >= 0x0500)) COLORREF SetBkColor(COLORREF clrBk) { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, SB_SETBKCOLOR, 0, (LPARAM)clrBk); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, SB_SETBKCOLOR, 0, (LPARAM)clrBk); } HICON GetIcon(int nPane) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(nPane < 256); - return (HICON)::SendMessage(m_hWnd, SB_GETICON, nPane, 0L); + return (HICON)::SendMessage(this->m_hWnd, SB_GETICON, nPane, 0L); } BOOL SetIcon(int nPane, HICON hIcon) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(nPane < 256); - return (BOOL)::SendMessage(m_hWnd, SB_SETICON, nPane, (LPARAM)hIcon); + return (BOOL)::SendMessage(this->m_hWnd, SB_SETICON, nPane, (LPARAM)hIcon); } -#endif // ((_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE)) || (defined(_WIN32_WCE) && (_WIN32_WCE >= 0x0500)) }; typedef CStatusBarCtrlT CStatusBarCtrl; @@ -6295,7 +6194,7 @@ public: CTabCtrlT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -6314,96 +6213,95 @@ public: CImageList GetImageList() const { - ATLASSERT(::IsWindow(m_hWnd)); - return CImageList((HIMAGELIST)::SendMessage(m_hWnd, TCM_GETIMAGELIST, 0, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TCM_GETIMAGELIST, 0, 0L)); } CImageList SetImageList(HIMAGELIST hImageList) { - ATLASSERT(::IsWindow(m_hWnd)); - return CImageList((HIMAGELIST)::SendMessage(m_hWnd, TCM_SETIMAGELIST, 0, (LPARAM)hImageList)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TCM_SETIMAGELIST, 0, (LPARAM)hImageList)); } int GetItemCount() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TCM_GETITEMCOUNT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TCM_GETITEMCOUNT, 0, 0L); } BOOL GetItem(int nItem, LPTCITEM pTabCtrlItem) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TCM_GETITEM, nItem, (LPARAM)pTabCtrlItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TCM_GETITEM, nItem, (LPARAM)pTabCtrlItem); } BOOL SetItem(int nItem, LPTCITEM pTabCtrlItem) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TCM_SETITEM, nItem, (LPARAM)pTabCtrlItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TCM_SETITEM, nItem, (LPARAM)pTabCtrlItem); } int SetItem(int nItem, UINT mask, LPCTSTR lpszItem, DWORD dwState, DWORD dwStateMask, int iImage, LPARAM lParam) { - ATLASSERT(::IsWindow(m_hWnd)); - TCITEM tci = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + TCITEM tci = {}; tci.mask = mask; tci.pszText = (LPTSTR) lpszItem; tci.dwState = dwState; tci.dwStateMask = dwStateMask; tci.iImage = iImage; tci.lParam = lParam; - return (int)::SendMessage(m_hWnd, TCM_SETITEM, nItem, (LPARAM)&tci); + return (int)::SendMessage(this->m_hWnd, TCM_SETITEM, nItem, (LPARAM)&tci); } BOOL GetItemRect(int nItem, LPRECT lpRect) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TCM_GETITEMRECT, nItem, (LPARAM)lpRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TCM_GETITEMRECT, nItem, (LPARAM)lpRect); } int GetCurSel() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TCM_GETCURSEL, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TCM_GETCURSEL, 0, 0L); } int SetCurSel(int nItem) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TCM_SETCURSEL, nItem, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TCM_SETCURSEL, nItem, 0L); } SIZE SetItemSize(SIZE size) { - ATLASSERT(::IsWindow(m_hWnd)); - DWORD dwSize = (DWORD)::SendMessage(m_hWnd, TCM_SETITEMSIZE, 0, MAKELPARAM(size.cx, size.cy)); + ATLASSERT(::IsWindow(this->m_hWnd)); + DWORD dwSize = (DWORD)::SendMessage(this->m_hWnd, TCM_SETITEMSIZE, 0, MAKELPARAM(size.cx, size.cy)); SIZE sizeRet = { GET_X_LPARAM(dwSize), GET_Y_LPARAM(dwSize) }; return sizeRet; } void SetItemSize(int cx, int cy) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TCM_SETITEMSIZE, 0, MAKELPARAM(cx, cy)); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TCM_SETITEMSIZE, 0, MAKELPARAM(cx, cy)); } void SetPadding(SIZE size) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TCM_SETPADDING, 0, MAKELPARAM(size.cx, size.cy)); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TCM_SETPADDING, 0, MAKELPARAM(size.cx, size.cy)); } int GetRowCount() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TCM_GETROWCOUNT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TCM_GETROWCOUNT, 0, 0L); } -#ifndef _WIN32_WCE CToolTipCtrl GetToolTips() const { - ATLASSERT(::IsWindow(m_hWnd)); - return CToolTipCtrl((HWND)::SendMessage(m_hWnd, TCM_GETTOOLTIPS, 0, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CToolTipCtrl((HWND)::SendMessage(this->m_hWnd, TCM_GETTOOLTIPS, 0, 0L)); } // this method is deprecated, please use GetToolTips @@ -6411,93 +6309,87 @@ public: void SetToolTips(HWND hWndToolTip) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TCM_SETTOOLTIPS, (WPARAM)hWndToolTip, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TCM_SETTOOLTIPS, (WPARAM)hWndToolTip, 0L); } // this method is deprecated, please use SetToolTips void SetTooltips(HWND hWndToolTip) { SetToolTips(hWndToolTip); } -#endif // !_WIN32_WCE - int GetCurFocus() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TCM_GETCURFOCUS, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TCM_GETCURFOCUS, 0, 0L); } void SetCurFocus(int nItem) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TCM_SETCURFOCUS, nItem, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TCM_SETCURFOCUS, nItem, 0L); } BOOL SetItemExtra(int cbExtra) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(GetItemCount() == 0); // must be empty - return (BOOL)::SendMessage(m_hWnd, TCM_SETITEMEXTRA, cbExtra, 0L); + return (BOOL)::SendMessage(this->m_hWnd, TCM_SETITEMEXTRA, cbExtra, 0L); } int SetMinTabWidth(int nWidth = -1) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TCM_SETMINTABWIDTH, 0, nWidth); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TCM_SETMINTABWIDTH, 0, nWidth); } -#if (_WIN32_IE >= 0x0400) DWORD GetExtendedStyle() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, TCM_GETEXTENDEDSTYLE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, TCM_GETEXTENDEDSTYLE, 0, 0L); } DWORD SetExtendedStyle(DWORD dwExMask, DWORD dwExStyle) { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, TCM_SETEXTENDEDSTYLE, dwExMask, dwExStyle); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, TCM_SETEXTENDEDSTYLE, dwExMask, dwExStyle); } -#ifndef _WIN32_WCE BOOL GetUnicodeFormat() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TCM_GETUNICODEFORMAT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TCM_GETUNICODEFORMAT, 0, 0L); } BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TCM_SETUNICODEFORMAT, bUnicode, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TCM_SETUNICODEFORMAT, bUnicode, 0L); } -#endif // !_WIN32_WCE -#endif // (_WIN32_IE >= 0x0400) // Operations int InsertItem(int nItem, LPTCITEM pTabCtrlItem) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TCM_INSERTITEM, nItem, (LPARAM)pTabCtrlItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TCM_INSERTITEM, nItem, (LPARAM)pTabCtrlItem); } int InsertItem(int nItem, UINT mask, LPCTSTR lpszItem, int iImage, LPARAM lParam) { - ATLASSERT(::IsWindow(m_hWnd)); - TCITEM tci = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + TCITEM tci = {}; tci.mask = mask; tci.pszText = (LPTSTR) lpszItem; tci.iImage = iImage; tci.lParam = lParam; - return (int)::SendMessage(m_hWnd, TCM_INSERTITEM, nItem, (LPARAM)&tci); + return (int)::SendMessage(this->m_hWnd, TCM_INSERTITEM, nItem, (LPARAM)&tci); } int InsertItem(int nItem, LPCTSTR lpszItem) { - ATLASSERT(::IsWindow(m_hWnd)); - TCITEM tci = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + TCITEM tci = {}; tci.mask = TCIF_TEXT; tci.pszText = (LPTSTR) lpszItem; - return (int)::SendMessage(m_hWnd, TCM_INSERTITEM, nItem, (LPARAM)&tci); + return (int)::SendMessage(this->m_hWnd, TCM_INSERTITEM, nItem, (LPARAM)&tci); } int AddItem(LPTCITEM pTabCtrlItem) @@ -6517,47 +6409,45 @@ public: BOOL DeleteItem(int nItem) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TCM_DELETEITEM, nItem, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TCM_DELETEITEM, nItem, 0L); } BOOL DeleteAllItems() { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TCM_DELETEALLITEMS, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TCM_DELETEALLITEMS, 0, 0L); } void AdjustRect(BOOL bLarger, LPRECT lpRect) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TCM_ADJUSTRECT, bLarger, (LPARAM)lpRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TCM_ADJUSTRECT, bLarger, (LPARAM)lpRect); } void RemoveImage(int nImage) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TCM_REMOVEIMAGE, nImage, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TCM_REMOVEIMAGE, nImage, 0L); } int HitTest(TC_HITTESTINFO* pHitTestInfo) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TCM_HITTEST, 0, (LPARAM)pHitTestInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TCM_HITTEST, 0, (LPARAM)pHitTestInfo); } void DeselectAll(BOOL bExcludeFocus = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TCM_DESELECTALL, bExcludeFocus, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TCM_DESELECTALL, bExcludeFocus, 0L); } -#if (_WIN32_IE >= 0x0400) BOOL HighlightItem(int nIndex, BOOL bHighlight = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TCM_HIGHLIGHTITEM, nIndex, MAKELPARAM(bHighlight, 0)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TCM_HIGHLIGHTITEM, nIndex, MAKELPARAM(bHighlight, 0)); } -#endif // (_WIN32_IE >= 0x0400) }; typedef CTabCtrlT CTabCtrl; @@ -6576,7 +6466,7 @@ public: CTrackBarCtrlT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -6595,50 +6485,50 @@ public: int GetLineSize() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TBM_GETLINESIZE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TBM_GETLINESIZE, 0, 0L); } int SetLineSize(int nSize) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TBM_SETLINESIZE, 0, nSize); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TBM_SETLINESIZE, 0, nSize); } int GetPageSize() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TBM_GETPAGESIZE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TBM_GETPAGESIZE, 0, 0L); } int SetPageSize(int nSize) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TBM_SETPAGESIZE, 0, nSize); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TBM_SETPAGESIZE, 0, nSize); } int GetRangeMin() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TBM_GETRANGEMIN, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TBM_GETRANGEMIN, 0, 0L); } void SetRangeMin(int nMin, BOOL bRedraw = FALSE) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TBM_SETRANGEMIN, bRedraw, nMin); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TBM_SETRANGEMIN, bRedraw, nMin); } int GetRangeMax() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TBM_GETRANGEMAX, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TBM_GETRANGEMAX, 0, 0L); } void SetRangeMax(int nMax, BOOL bRedraw = FALSE) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TBM_SETRANGEMAX, bRedraw, nMax); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TBM_SETRANGEMAX, bRedraw, nMax); } void GetRange(int& nMin, int& nMax) const @@ -6649,32 +6539,32 @@ public: void SetRange(int nMin, int nMax, BOOL bRedraw = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TBM_SETRANGE, bRedraw, MAKELPARAM(nMin, nMax)); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TBM_SETRANGE, bRedraw, MAKELPARAM(nMin, nMax)); } int GetSelStart() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TBM_GETSELSTART, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TBM_GETSELSTART, 0, 0L); } void SetSelStart(int nMin, BOOL bRedraw = FALSE) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TBM_SETSELSTART, bRedraw, (LPARAM)nMin); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TBM_SETSELSTART, bRedraw, (LPARAM)nMin); } int GetSelEnd() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TBM_GETSELEND, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TBM_GETSELEND, 0, 0L); } void SetSelEnd(int nMax, BOOL bRedraw = FALSE) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TBM_SETSELEND, bRedraw, (LPARAM)nMax); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TBM_SETSELEND, bRedraw, (LPARAM)nMax); } void GetSelection(int& nMin, int& nMax) const @@ -6691,146 +6581,142 @@ public: void GetChannelRect(LPRECT lprc) const { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TBM_GETCHANNELRECT, 0, (LPARAM)lprc); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TBM_GETCHANNELRECT, 0, (LPARAM)lprc); } void GetThumbRect(LPRECT lprc) const { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TBM_GETTHUMBRECT, 0, (LPARAM)lprc); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TBM_GETTHUMBRECT, 0, (LPARAM)lprc); } int GetPos() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TBM_GETPOS, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TBM_GETPOS, 0, 0L); } void SetPos(int nPos) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TBM_SETPOS, TRUE, nPos); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TBM_SETPOS, TRUE, nPos); } UINT GetNumTics() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (UINT)::SendMessage(m_hWnd, TBM_GETNUMTICS, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, TBM_GETNUMTICS, 0, 0L); } DWORD* GetTicArray() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD*)::SendMessage(m_hWnd, TBM_GETPTICS, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD*)::SendMessage(this->m_hWnd, TBM_GETPTICS, 0, 0L); } int GetTic(int nTic) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TBM_GETTIC, nTic, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TBM_GETTIC, nTic, 0L); } BOOL SetTic(int nTic) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TBM_SETTIC, 0, nTic); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TBM_SETTIC, 0, nTic); } int GetTicPos(int nTic) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TBM_GETTICPOS, nTic, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TBM_GETTICPOS, nTic, 0L); } void SetTicFreq(int nFreq) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TBM_SETTICFREQ, nFreq, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TBM_SETTICFREQ, nFreq, 0L); } int GetThumbLength() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TBM_GETTHUMBLENGTH, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TBM_GETTHUMBLENGTH, 0, 0L); } void SetThumbLength(int nLength) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TBM_SETTHUMBLENGTH, nLength, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TBM_SETTHUMBLENGTH, nLength, 0L); } void SetSel(int nStart, int nEnd, BOOL bRedraw = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT((GetStyle() & TBS_ENABLESELRANGE) != 0); - ::SendMessage(m_hWnd, TBM_SETSEL, bRedraw, MAKELPARAM(nStart, nEnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & TBS_ENABLESELRANGE) != 0); + ::SendMessage(this->m_hWnd, TBM_SETSEL, bRedraw, MAKELPARAM(nStart, nEnd)); } ATL::CWindow GetBuddy(BOOL bLeft = TRUE) const { - ATLASSERT(::IsWindow(m_hWnd)); - return ATL::CWindow((HWND)::SendMessage(m_hWnd, TBM_GETBUDDY, bLeft, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return ATL::CWindow((HWND)::SendMessage(this->m_hWnd, TBM_GETBUDDY, bLeft, 0L)); } ATL::CWindow SetBuddy(HWND hWndBuddy, BOOL bLeft = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return ATL::CWindow((HWND)::SendMessage(m_hWnd, TBM_SETBUDDY, bLeft, (LPARAM)hWndBuddy)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return ATL::CWindow((HWND)::SendMessage(this->m_hWnd, TBM_SETBUDDY, bLeft, (LPARAM)hWndBuddy)); } -#ifndef _WIN32_WCE CToolTipCtrl GetToolTips() const { - ATLASSERT(::IsWindow(m_hWnd)); - return CToolTipCtrl((HWND)::SendMessage(m_hWnd, TBM_GETTOOLTIPS, 0, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CToolTipCtrl((HWND)::SendMessage(this->m_hWnd, TBM_GETTOOLTIPS, 0, 0L)); } void SetToolTips(HWND hWndTT) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TBM_SETTOOLTIPS, (WPARAM)hWndTT, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TBM_SETTOOLTIPS, (WPARAM)hWndTT, 0L); } int SetTipSide(int nSide) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, TBM_SETTIPSIDE, nSide, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TBM_SETTIPSIDE, nSide, 0L); } -#endif // !_WIN32_WCE -#if (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) BOOL GetUnicodeFormat() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TBM_GETUNICODEFORMAT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TBM_GETUNICODEFORMAT, 0, 0L); } BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, TBM_SETUNICODEFORMAT, bUnicode, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TBM_SETUNICODEFORMAT, bUnicode, 0L); } -#endif // (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) // Operations void ClearSel(BOOL bRedraw = FALSE) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TBM_CLEARSEL, bRedraw, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TBM_CLEARSEL, bRedraw, 0L); } void VerifyPos() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TBM_SETPOS, FALSE, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TBM_SETPOS, FALSE, 0L); } void ClearTics(BOOL bRedraw = FALSE) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, TBM_CLEARTICS, bRedraw, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TBM_CLEARTICS, bRedraw, 0L); } }; @@ -6850,7 +6736,7 @@ public: CUpDownCtrlT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -6869,44 +6755,44 @@ public: UINT GetAccel(int nAccel, UDACCEL* pAccel) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (UINT)LOWORD(::SendMessage(m_hWnd, UDM_GETACCEL, nAccel, (LPARAM)pAccel)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)LOWORD(::SendMessage(this->m_hWnd, UDM_GETACCEL, nAccel, (LPARAM)pAccel)); } BOOL SetAccel(int nAccel, UDACCEL* pAccel) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)LOWORD(::SendMessage(m_hWnd, UDM_SETACCEL, nAccel, (LPARAM)pAccel)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)LOWORD(::SendMessage(this->m_hWnd, UDM_SETACCEL, nAccel, (LPARAM)pAccel)); } UINT GetBase() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (UINT)LOWORD(::SendMessage(m_hWnd, UDM_GETBASE, 0, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)LOWORD(::SendMessage(this->m_hWnd, UDM_GETBASE, 0, 0L)); } int SetBase(int nBase) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, UDM_SETBASE, nBase, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, UDM_SETBASE, nBase, 0L); } ATL::CWindow GetBuddy() const { - ATLASSERT(::IsWindow(m_hWnd)); - return ATL::CWindow((HWND)::SendMessage(m_hWnd, UDM_GETBUDDY, 0, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return ATL::CWindow((HWND)::SendMessage(this->m_hWnd, UDM_GETBUDDY, 0, 0L)); } ATL::CWindow SetBuddy(HWND hWndBuddy) { - ATLASSERT(::IsWindow(m_hWnd)); - return ATL::CWindow((HWND)::SendMessage(m_hWnd, UDM_SETBUDDY, (WPARAM)hWndBuddy, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return ATL::CWindow((HWND)::SendMessage(this->m_hWnd, UDM_SETBUDDY, (WPARAM)hWndBuddy, 0L)); } int GetPos(LPBOOL lpbError = NULL) const { - ATLASSERT(::IsWindow(m_hWnd)); - DWORD dwRet = (DWORD)::SendMessage(m_hWnd, UDM_GETPOS, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, UDM_GETPOS, 0, 0L); // Note: Seems that Windows always sets error to TRUE if // UDS_SETBUDDYINT style is not used if(lpbError != NULL) @@ -6916,73 +6802,67 @@ public: int SetPos(int nPos) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)(short)LOWORD(::SendMessage(m_hWnd, UDM_SETPOS, 0, MAKELPARAM(nPos, 0))); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)(short)LOWORD(::SendMessage(this->m_hWnd, UDM_SETPOS, 0, MAKELPARAM(nPos, 0))); } DWORD GetRange() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, UDM_GETRANGE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, UDM_GETRANGE, 0, 0L); } void GetRange(int& nLower, int& nUpper) const { - ATLASSERT(::IsWindow(m_hWnd)); - DWORD dwRet = (DWORD)::SendMessage(m_hWnd, UDM_GETRANGE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, UDM_GETRANGE, 0, 0L); nLower = (int)(short)HIWORD(dwRet); nUpper = (int)(short)LOWORD(dwRet); } void SetRange(int nLower, int nUpper) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, UDM_SETRANGE, 0, MAKELPARAM(nUpper, nLower)); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, UDM_SETRANGE, 0, MAKELPARAM(nUpper, nLower)); } -#if (_WIN32_IE >= 0x0400) void SetRange32(int nLower, int nUpper) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, UDM_SETRANGE32, nLower, nUpper); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, UDM_SETRANGE32, nLower, nUpper); } void GetRange32(int& nLower, int& nUpper) const { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, UDM_GETRANGE32, (WPARAM)&nLower, (LPARAM)&nUpper); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, UDM_GETRANGE32, (WPARAM)&nLower, (LPARAM)&nUpper); } -#ifndef _WIN32_WCE BOOL GetUnicodeFormat() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, UDM_GETUNICODEFORMAT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, UDM_GETUNICODEFORMAT, 0, 0L); } BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, UDM_SETUNICODEFORMAT, bUnicode, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, UDM_SETUNICODEFORMAT, bUnicode, 0L); } -#endif // !_WIN32_WCE -#endif // (_WIN32_IE >= 0x0400) -#if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) int GetPos32(LPBOOL lpbError = NULL) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); // Note: Seems that Windows always sets error to TRUE if // UDS_SETBUDDYINT style is not used - return (int)::SendMessage(m_hWnd, UDM_GETPOS32, 0, (LPARAM)lpbError); + return (int)::SendMessage(this->m_hWnd, UDM_GETPOS32, 0, (LPARAM)lpbError); } int SetPos32(int nPos) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, UDM_SETPOS32, 0, (LPARAM)nPos); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, UDM_SETPOS32, 0, (LPARAM)nPos); } -#endif // (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) }; typedef CUpDownCtrlT CUpDownCtrl; @@ -7001,7 +6881,7 @@ public: CProgressBarCtrlT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -7020,121 +6900,119 @@ public: DWORD SetRange(int nLower, int nUpper) { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, PBM_SETRANGE, 0, MAKELPARAM(nLower, nUpper)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, PBM_SETRANGE, 0, MAKELPARAM(nLower, nUpper)); } int SetPos(int nPos) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)(short)LOWORD(::SendMessage(m_hWnd, PBM_SETPOS, nPos, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)(short)LOWORD(::SendMessage(this->m_hWnd, PBM_SETPOS, nPos, 0L)); } int OffsetPos(int nPos) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)(short)LOWORD(::SendMessage(m_hWnd, PBM_DELTAPOS, nPos, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)(short)LOWORD(::SendMessage(this->m_hWnd, PBM_DELTAPOS, nPos, 0L)); } int SetStep(int nStep) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)(short)LOWORD(::SendMessage(m_hWnd, PBM_SETSTEP, nStep, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)(short)LOWORD(::SendMessage(this->m_hWnd, PBM_SETSTEP, nStep, 0L)); } UINT GetPos() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (UINT)::SendMessage(m_hWnd, PBM_GETPOS, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, PBM_GETPOS, 0, 0L); } void GetRange(PPBRANGE pPBRange) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(pPBRange != NULL); - ::SendMessage(m_hWnd, PBM_GETRANGE, TRUE, (LPARAM)pPBRange); + ::SendMessage(this->m_hWnd, PBM_GETRANGE, TRUE, (LPARAM)pPBRange); } void GetRange(int& nLower, int& nUpper) const { - ATLASSERT(::IsWindow(m_hWnd)); - PBRANGE range = { 0 }; - ::SendMessage(m_hWnd, PBM_GETRANGE, TRUE, (LPARAM)&range); + ATLASSERT(::IsWindow(this->m_hWnd)); + PBRANGE range = {}; + ::SendMessage(this->m_hWnd, PBM_GETRANGE, TRUE, (LPARAM)&range); nLower = range.iLow; nUpper = range.iHigh; } int GetRangeLimit(BOOL bLowLimit) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, PBM_GETRANGE, bLowLimit, (LPARAM)NULL); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, PBM_GETRANGE, bLowLimit, (LPARAM)NULL); } DWORD SetRange32(int nMin, int nMax) { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, PBM_SETRANGE32, nMin, nMax); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, PBM_SETRANGE32, nMin, nMax); } -#if (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) COLORREF SetBarColor(COLORREF clr) { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, PBM_SETBARCOLOR, 0, (LPARAM)clr); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, PBM_SETBARCOLOR, 0, (LPARAM)clr); } COLORREF SetBkColor(COLORREF clr) { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, PBM_SETBKCOLOR, 0, (LPARAM)clr); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, PBM_SETBKCOLOR, 0, (LPARAM)clr); } -#endif // (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) -#if (_WIN32_WINNT >= 0x0501) && defined(PBM_SETMARQUEE) +#ifdef PBM_SETMARQUEE BOOL SetMarquee(BOOL bMarquee, UINT uUpdateTime = 0U) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, PBM_SETMARQUEE, (WPARAM)bMarquee, (LPARAM)uUpdateTime); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, PBM_SETMARQUEE, (WPARAM)bMarquee, (LPARAM)uUpdateTime); } -#endif // (_WIN32_WINNT >= 0x0501) && defined(PBM_SETMARQUEE) +#endif #if (_WIN32_WINNT >= 0x0600) int GetStep() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, PBM_GETSTEP, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, PBM_GETSTEP, 0, 0L); } COLORREF GetBkColor() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, PBM_GETBKCOLOR, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, PBM_GETBKCOLOR, 0, 0L); } COLORREF GetBarColor() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, PBM_GETBARCOLOR, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, PBM_GETBARCOLOR, 0, 0L); } int GetState() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, PBM_GETSTATE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, PBM_GETSTATE, 0, 0L); } int SetState(int nState) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, PBM_SETSTATE, nState, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, PBM_SETSTATE, nState, 0L); } #endif // (_WIN32_WINNT >= 0x0600) // Operations int StepIt() { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)(short)LOWORD(::SendMessage(m_hWnd, PBM_STEPIT, 0, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)(short)LOWORD(::SendMessage(this->m_hWnd, PBM_STEPIT, 0, 0L)); } }; @@ -7144,8 +7022,6 @@ typedef CProgressBarCtrlT CProgressBarCtrl; /////////////////////////////////////////////////////////////////////////////// // CHotKeyCtrl -#ifndef _WIN32_WCE - template class CHotKeyCtrlT : public TBase { @@ -7156,7 +7032,7 @@ public: CHotKeyCtrlT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -7175,41 +7051,37 @@ public: DWORD GetHotKey() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, HKM_GETHOTKEY, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, HKM_GETHOTKEY, 0, 0L); } void GetHotKey(WORD &wVirtualKeyCode, WORD &wModifiers) const { - ATLASSERT(::IsWindow(m_hWnd)); - DWORD dw = (DWORD)::SendMessage(m_hWnd, HKM_GETHOTKEY, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + DWORD dw = (DWORD)::SendMessage(this->m_hWnd, HKM_GETHOTKEY, 0, 0L); wVirtualKeyCode = LOBYTE(LOWORD(dw)); wModifiers = HIBYTE(LOWORD(dw)); } void SetHotKey(WORD wVirtualKeyCode, WORD wModifiers) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, HKM_SETHOTKEY, MAKEWORD(wVirtualKeyCode, wModifiers), 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, HKM_SETHOTKEY, MAKEWORD(wVirtualKeyCode, wModifiers), 0L); } void SetRules(WORD wInvalidComb, WORD wModifiers) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, HKM_SETRULES, wInvalidComb, MAKELPARAM(wModifiers, 0)); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, HKM_SETRULES, wInvalidComb, MAKELPARAM(wModifiers, 0)); } }; typedef CHotKeyCtrlT CHotKeyCtrl; -#endif // !_WIN32_WCE - /////////////////////////////////////////////////////////////////////////////// // CAnimateCtrl -#ifndef _WIN32_WCE - template class CAnimateCtrlT : public TBase { @@ -7220,7 +7092,7 @@ public: CAnimateCtrlT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -7240,60 +7112,48 @@ public: // Operations BOOL Open(ATL::_U_STRINGorID FileName) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, ACM_OPEN, 0, (LPARAM)FileName.m_lpstr); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, ACM_OPEN, 0, (LPARAM)FileName.m_lpstr); } BOOL Play(UINT nFrom, UINT nTo, UINT nRep) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, ACM_PLAY, nRep, MAKELPARAM(nFrom, nTo)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, ACM_PLAY, nRep, MAKELPARAM(nFrom, nTo)); } BOOL Stop() { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, ACM_STOP, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, ACM_STOP, 0, 0L); } BOOL Close() { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, ACM_OPEN, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, ACM_OPEN, 0, 0L); } BOOL Seek(UINT nTo) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, ACM_PLAY, 0, MAKELPARAM(nTo, nTo)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, ACM_PLAY, 0, MAKELPARAM(nTo, nTo)); } // Vista only BOOL IsPlaying() const { -#ifndef ACM_ISPLAYING - const UINT ACM_ISPLAYING = (WM_USER+104); -#endif - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, ACM_ISPLAYING, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, ACM_ISPLAYING, 0, 0L); } }; typedef CAnimateCtrlT CAnimateCtrl; -#endif // !_WIN32_WCE - /////////////////////////////////////////////////////////////////////////////// // CRichEditCtrl -#ifndef _WIN32_WCE - -#if defined(_UNICODE) && (_RICHEDIT_VER == 0x0100) - #undef RICHEDIT_CLASS - #define RICHEDIT_CLASS L"RICHEDIT" -#endif - #if !defined(_UNICODE) && (_RICHEDIT_VER >= 0x0500) #undef MSFTEDIT_CLASS #define MSFTEDIT_CLASS "RICHEDIT50W" @@ -7309,7 +7169,7 @@ public: CRichEditCtrlT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -7334,101 +7194,99 @@ public: { #if (_RICHEDIT_VER >= 0x0500) return _T("MSFTEDIT.DLL"); -#elif (_RICHEDIT_VER >= 0x0200) - return _T("RICHED20.DLL"); #else - return _T("RICHED32.DLL"); + return _T("RICHED20.DLL"); #endif } int GetLineCount() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, EM_GETLINECOUNT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, EM_GETLINECOUNT, 0, 0L); } BOOL GetModify() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_GETMODIFY, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_GETMODIFY, 0, 0L); } void SetModify(BOOL bModified = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_SETMODIFY, bModified, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SETMODIFY, bModified, 0L); } void GetRect(LPRECT lpRect) const { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_GETRECT, 0, (LPARAM)lpRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_GETRECT, 0, (LPARAM)lpRect); } DWORD GetOptions() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, EM_GETOPTIONS, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, EM_GETOPTIONS, 0, 0L); } DWORD SetOptions(WORD wOperation, DWORD dwOptions) { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, EM_SETOPTIONS, wOperation, dwOptions); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, EM_SETOPTIONS, wOperation, dwOptions); } // NOTE: first word in lpszBuffer must contain the size of the buffer! int GetLine(int nIndex, LPTSTR lpszBuffer) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, EM_GETLINE, nIndex, (LPARAM)lpszBuffer); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, EM_GETLINE, nIndex, (LPARAM)lpszBuffer); } int GetLine(int nIndex, LPTSTR lpszBuffer, int nMaxLength) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); *(LPWORD)lpszBuffer = (WORD)nMaxLength; - return (int)::SendMessage(m_hWnd, EM_GETLINE, nIndex, (LPARAM)lpszBuffer); + return (int)::SendMessage(this->m_hWnd, EM_GETLINE, nIndex, (LPARAM)lpszBuffer); } BOOL CanUndo() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_CANUNDO, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_CANUNDO, 0, 0L); } BOOL CanPaste(UINT nFormat = 0) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_CANPASTE, nFormat, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_CANPASTE, nFormat, 0L); } void GetSel(LONG& nStartChar, LONG& nEndChar) const { - ATLASSERT(::IsWindow(m_hWnd)); - CHARRANGE cr = { 0, 0 }; - ::SendMessage(m_hWnd, EM_EXGETSEL, 0, (LPARAM)&cr); + ATLASSERT(::IsWindow(this->m_hWnd)); + CHARRANGE cr = {}; + ::SendMessage(this->m_hWnd, EM_EXGETSEL, 0, (LPARAM)&cr); nStartChar = cr.cpMin; nEndChar = cr.cpMax; } void GetSel(CHARRANGE &cr) const { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_EXGETSEL, 0, (LPARAM)&cr); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_EXGETSEL, 0, (LPARAM)&cr); } int SetSel(LONG nStartChar, LONG nEndChar) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); CHARRANGE cr = { nStartChar, nEndChar }; - return (int)::SendMessage(m_hWnd, EM_EXSETSEL, 0, (LPARAM)&cr); + return (int)::SendMessage(this->m_hWnd, EM_EXSETSEL, 0, (LPARAM)&cr); } int SetSel(CHARRANGE &cr) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, EM_EXSETSEL, 0, (LPARAM)&cr); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, EM_EXSETSEL, 0, (LPARAM)&cr); } int SetSelAll() @@ -7443,341 +7301,279 @@ public: DWORD GetDefaultCharFormat(CHARFORMAT& cf) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); cf.cbSize = sizeof(CHARFORMAT); - return (DWORD)::SendMessage(m_hWnd, EM_GETCHARFORMAT, 0, (LPARAM)&cf); + return (DWORD)::SendMessage(this->m_hWnd, EM_GETCHARFORMAT, 0, (LPARAM)&cf); } DWORD GetSelectionCharFormat(CHARFORMAT& cf) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); cf.cbSize = sizeof(CHARFORMAT); - return (DWORD)::SendMessage(m_hWnd, EM_GETCHARFORMAT, 1, (LPARAM)&cf); + return (DWORD)::SendMessage(this->m_hWnd, EM_GETCHARFORMAT, 1, (LPARAM)&cf); } DWORD GetEventMask() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, EM_GETEVENTMASK, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, EM_GETEVENTMASK, 0, 0L); } LONG GetLimitText() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (LONG)::SendMessage(m_hWnd, EM_GETLIMITTEXT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (LONG)::SendMessage(this->m_hWnd, EM_GETLIMITTEXT, 0, 0L); } DWORD GetParaFormat(PARAFORMAT& pf) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); pf.cbSize = sizeof(PARAFORMAT); - return (DWORD)::SendMessage(m_hWnd, EM_GETPARAFORMAT, 0, (LPARAM)&pf); + return (DWORD)::SendMessage(this->m_hWnd, EM_GETPARAFORMAT, 0, (LPARAM)&pf); } -#if (_RICHEDIT_VER >= 0x0200) LONG GetSelText(LPTSTR lpstrBuff) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (LONG)::SendMessage(m_hWnd, EM_GETSELTEXT, 0, (LPARAM)lpstrBuff); - } -#else // !(_RICHEDIT_VER >= 0x0200) - // RichEdit 1.0 EM_GETSELTEXT is ANSI only - LONG GetSelText(LPSTR lpstrBuff) const - { - ATLASSERT(::IsWindow(m_hWnd)); - return (LONG)::SendMessage(m_hWnd, EM_GETSELTEXT, 0, (LPARAM)lpstrBuff); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (LONG)::SendMessage(this->m_hWnd, EM_GETSELTEXT, 0, (LPARAM)lpstrBuff); } -#endif // !(_RICHEDIT_VER >= 0x0200) -#ifndef _ATL_NO_COM BOOL GetSelTextBSTR(BSTR& bstrText) const { USES_CONVERSION; - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(bstrText == NULL); - CHARRANGE cr = { 0, 0 }; - ::SendMessage(m_hWnd, EM_EXGETSEL, 0, (LPARAM)&cr); + CHARRANGE cr = {}; + ::SendMessage(this->m_hWnd, EM_EXGETSEL, 0, (LPARAM)&cr); -#if (_RICHEDIT_VER >= 0x0200) - CTempBuffer buff; + ATL::CTempBuffer buff; LPTSTR lpstrText = buff.Allocate(cr.cpMax - cr.cpMin + 1); if(lpstrText == NULL) return FALSE; - if(::SendMessage(m_hWnd, EM_GETSELTEXT, 0, (LPARAM)lpstrText) == 0) + if(::SendMessage(this->m_hWnd, EM_GETSELTEXT, 0, (LPARAM)lpstrText) == 0) return FALSE; bstrText = ::SysAllocString(T2W(lpstrText)); -#else // !(_RICHEDIT_VER >= 0x0200) - CTempBuffer buff; - LPSTR lpstrText = buff.Allocate(cr.cpMax - cr.cpMin + 1); - if(lpstrText == NULL) - return FALSE; - if(::SendMessage(m_hWnd, EM_GETSELTEXT, 0, (LPARAM)lpstrText) == 0) - return FALSE; - - bstrText = ::SysAllocString(A2W(lpstrText)); -#endif // !(_RICHEDIT_VER >= 0x0200) return (bstrText != NULL) ? TRUE : FALSE; } -#endif // !_ATL_NO_COM -#if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) - LONG GetSelText(_CSTRING_NS::CString& strText) const +#ifdef __ATLSTR_H__ + LONG GetSelText(ATL::CString& strText) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); - CHARRANGE cr = { 0, 0 }; - ::SendMessage(m_hWnd, EM_EXGETSEL, 0, (LPARAM)&cr); + CHARRANGE cr = {}; + ::SendMessage(this->m_hWnd, EM_EXGETSEL, 0, (LPARAM)&cr); -#if (_RICHEDIT_VER >= 0x0200) LONG lLen = 0; LPTSTR lpstrText = strText.GetBufferSetLength(cr.cpMax - cr.cpMin); if(lpstrText != NULL) { - lLen = (LONG)::SendMessage(m_hWnd, EM_GETSELTEXT, 0, (LPARAM)lpstrText); + lLen = (LONG)::SendMessage(this->m_hWnd, EM_GETSELTEXT, 0, (LPARAM)lpstrText); strText.ReleaseBuffer(); } -#else // !(_RICHEDIT_VER >= 0x0200) - CTempBuffer buff; - LPSTR lpstrText = buff.Allocate(cr.cpMax - cr.cpMin + 1); - if(lpstrText == NULL) - return 0; - LONG lLen = (LONG)::SendMessage(m_hWnd, EM_GETSELTEXT, 0, (LPARAM)lpstrText); - if(lLen == 0) - return 0; - - USES_CONVERSION; - strText = A2T(lpstrText); -#endif // !(_RICHEDIT_VER >= 0x0200) return lLen; } -#endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) +#endif // __ATLSTR_H__ WORD GetSelectionType() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (WORD)::SendMessage(m_hWnd, EM_SELECTIONTYPE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (WORD)::SendMessage(this->m_hWnd, EM_SELECTIONTYPE, 0, 0L); } COLORREF SetBackgroundColor(COLORREF cr) { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, EM_SETBKGNDCOLOR, 0, cr); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, EM_SETBKGNDCOLOR, 0, cr); } COLORREF SetBackgroundColor() // sets to system background { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, EM_SETBKGNDCOLOR, 1, 0); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, EM_SETBKGNDCOLOR, 1, 0); } BOOL SetCharFormat(CHARFORMAT& cf, WORD wFlags) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); cf.cbSize = sizeof(CHARFORMAT); - return (BOOL)::SendMessage(m_hWnd, EM_SETCHARFORMAT, (WPARAM)wFlags, (LPARAM)&cf); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETCHARFORMAT, (WPARAM)wFlags, (LPARAM)&cf); } BOOL SetDefaultCharFormat(CHARFORMAT& cf) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); cf.cbSize = sizeof(CHARFORMAT); - return (BOOL)::SendMessage(m_hWnd, EM_SETCHARFORMAT, 0, (LPARAM)&cf); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETCHARFORMAT, 0, (LPARAM)&cf); } BOOL SetSelectionCharFormat(CHARFORMAT& cf) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); cf.cbSize = sizeof(CHARFORMAT); - return (BOOL)::SendMessage(m_hWnd, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf); } BOOL SetWordCharFormat(CHARFORMAT& cf) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); cf.cbSize = sizeof(CHARFORMAT); - return (BOOL)::SendMessage(m_hWnd, EM_SETCHARFORMAT, SCF_SELECTION | SCF_WORD, (LPARAM)&cf); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETCHARFORMAT, SCF_SELECTION | SCF_WORD, (LPARAM)&cf); } DWORD SetEventMask(DWORD dwEventMask) { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, EM_SETEVENTMASK, 0, dwEventMask); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, EM_SETEVENTMASK, 0, dwEventMask); } BOOL SetParaFormat(PARAFORMAT& pf) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); pf.cbSize = sizeof(PARAFORMAT); - return (BOOL)::SendMessage(m_hWnd, EM_SETPARAFORMAT, 0, (LPARAM)&pf); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETPARAFORMAT, 0, (LPARAM)&pf); } BOOL SetTargetDevice(HDC hDC, int cxLineWidth) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_SETTARGETDEVICE, (WPARAM)hDC, cxLineWidth); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETTARGETDEVICE, (WPARAM)hDC, cxLineWidth); } int GetTextLength() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, WM_GETTEXTLENGTH, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, WM_GETTEXTLENGTH, 0, 0L); } BOOL SetReadOnly(BOOL bReadOnly = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_SETREADONLY, bReadOnly, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETREADONLY, bReadOnly, 0L); } int GetFirstVisibleLine() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, EM_GETFIRSTVISIBLELINE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, EM_GETFIRSTVISIBLELINE, 0, 0L); } int GetTextRange(TEXTRANGE* pTextRange) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, EM_GETTEXTRANGE, 0, (LPARAM)pTextRange); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, EM_GETTEXTRANGE, 0, (LPARAM)pTextRange); } -#if (_RICHEDIT_VER < 0x0200) - EDITWORDBREAKPROCEX GetWordBreakProcEx() const - { - ATLASSERT(::IsWindow(m_hWnd)); - return (EDITWORDBREAKPROCEX)::SendMessage(m_hWnd, EM_GETWORDBREAKPROCEX, 0, 0L); - } - - EDITWORDBREAKPROCEX SetWordBreakProcEx(EDITWORDBREAKPROCEX pfnEditWordBreakProcEx) - { - ATLASSERT(::IsWindow(m_hWnd)); - return (EDITWORDBREAKPROCEX)::SendMessage(m_hWnd, EM_SETWORDBREAKPROCEX, 0, (LPARAM)pfnEditWordBreakProcEx); - } -#endif // (_RICHEDIT_VER < 0x0200) - -#if (_RICHEDIT_VER >= 0x0200) int GetTextRange(LONG nStartChar, LONG nEndChar, LPTSTR lpstrText) const { - ATLASSERT(::IsWindow(m_hWnd)); - TEXTRANGE tr = { 0 }; - tr.chrg.cpMin = nStartChar; - tr.chrg.cpMax = nEndChar; - tr.lpstrText = lpstrText; - return (int)::SendMessage(m_hWnd, EM_GETTEXTRANGE, 0, (LPARAM)&tr); - } -#else // !(_RICHEDIT_VER >= 0x0200) - int GetTextRange(LONG nStartChar, LONG nEndChar, LPSTR lpstrText) const - { - ATLASSERT(::IsWindow(m_hWnd)); - TEXTRANGE tr = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + TEXTRANGE tr = {}; tr.chrg.cpMin = nStartChar; tr.chrg.cpMax = nEndChar; tr.lpstrText = lpstrText; - return (int)::SendMessage(m_hWnd, EM_GETTEXTRANGE, 0, (LPARAM)&tr); + return (int)::SendMessage(this->m_hWnd, EM_GETTEXTRANGE, 0, (LPARAM)&tr); } -#endif // !(_RICHEDIT_VER >= 0x0200) -#if (_RICHEDIT_VER >= 0x0200) DWORD GetDefaultCharFormat(CHARFORMAT2& cf) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); cf.cbSize = sizeof(CHARFORMAT2); - return (DWORD)::SendMessage(m_hWnd, EM_GETCHARFORMAT, 0, (LPARAM)&cf); + return (DWORD)::SendMessage(this->m_hWnd, EM_GETCHARFORMAT, 0, (LPARAM)&cf); } BOOL SetCharFormat(CHARFORMAT2& cf, WORD wFlags) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); cf.cbSize = sizeof(CHARFORMAT2); - return (BOOL)::SendMessage(m_hWnd, EM_SETCHARFORMAT, (WPARAM)wFlags, (LPARAM)&cf); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETCHARFORMAT, (WPARAM)wFlags, (LPARAM)&cf); } BOOL SetDefaultCharFormat(CHARFORMAT2& cf) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); cf.cbSize = sizeof(CHARFORMAT2); - return (BOOL)::SendMessage(m_hWnd, EM_SETCHARFORMAT, 0, (LPARAM)&cf); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETCHARFORMAT, 0, (LPARAM)&cf); } DWORD GetSelectionCharFormat(CHARFORMAT2& cf) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); cf.cbSize = sizeof(CHARFORMAT2); - return (DWORD)::SendMessage(m_hWnd, EM_GETCHARFORMAT, 1, (LPARAM)&cf); + return (DWORD)::SendMessage(this->m_hWnd, EM_GETCHARFORMAT, 1, (LPARAM)&cf); } BOOL SetSelectionCharFormat(CHARFORMAT2& cf) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); cf.cbSize = sizeof(CHARFORMAT2); - return (BOOL)::SendMessage(m_hWnd, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf); } BOOL SetWordCharFormat(CHARFORMAT2& cf) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); cf.cbSize = sizeof(CHARFORMAT2); - return (BOOL)::SendMessage(m_hWnd, EM_SETCHARFORMAT, SCF_SELECTION | SCF_WORD, (LPARAM)&cf); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETCHARFORMAT, SCF_SELECTION | SCF_WORD, (LPARAM)&cf); } DWORD GetParaFormat(PARAFORMAT2& pf) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); pf.cbSize = sizeof(PARAFORMAT2); - return (DWORD)::SendMessage(m_hWnd, EM_GETPARAFORMAT, 0, (LPARAM)&pf); + return (DWORD)::SendMessage(this->m_hWnd, EM_GETPARAFORMAT, 0, (LPARAM)&pf); } BOOL SetParaFormat(PARAFORMAT2& pf) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); pf.cbSize = sizeof(PARAFORMAT2); - return (BOOL)::SendMessage(m_hWnd, EM_SETPARAFORMAT, 0, (LPARAM)&pf); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETPARAFORMAT, 0, (LPARAM)&pf); } TEXTMODE GetTextMode() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (TEXTMODE)::SendMessage(m_hWnd, EM_GETTEXTMODE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (TEXTMODE)::SendMessage(this->m_hWnd, EM_GETTEXTMODE, 0, 0L); } BOOL SetTextMode(TEXTMODE enumTextMode) { - ATLASSERT(::IsWindow(m_hWnd)); - return !(BOOL)::SendMessage(m_hWnd, EM_SETTEXTMODE, enumTextMode, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return !(BOOL)::SendMessage(this->m_hWnd, EM_SETTEXTMODE, enumTextMode, 0L); } UNDONAMEID GetUndoName() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (UNDONAMEID)::SendMessage(m_hWnd, EM_GETUNDONAME, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UNDONAMEID)::SendMessage(this->m_hWnd, EM_GETUNDONAME, 0, 0L); } UNDONAMEID GetRedoName() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (UNDONAMEID)::SendMessage(m_hWnd, EM_GETREDONAME, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UNDONAMEID)::SendMessage(this->m_hWnd, EM_GETREDONAME, 0, 0L); } BOOL CanRedo() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_CANREDO, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_CANREDO, 0, 0L); } BOOL GetAutoURLDetect() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_GETAUTOURLDETECT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_GETAUTOURLDETECT, 0, 0L); } BOOL SetAutoURLDetect(BOOL bAutoDetect = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return !(BOOL)::SendMessage(m_hWnd, EM_AUTOURLDETECT, bAutoDetect, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return !(BOOL)::SendMessage(this->m_hWnd, EM_AUTOURLDETECT, bAutoDetect, 0L); } // this method is deprecated, please use SetAutoURLDetect @@ -7785,284 +7581,293 @@ public: UINT SetUndoLimit(UINT uUndoLimit) { - ATLASSERT(::IsWindow(m_hWnd)); - return (UINT)::SendMessage(m_hWnd, EM_SETUNDOLIMIT, uUndoLimit, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, EM_SETUNDOLIMIT, uUndoLimit, 0L); } void SetPalette(HPALETTE hPalette) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_SETPALETTE, (WPARAM)hPalette, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SETPALETTE, (WPARAM)hPalette, 0L); } int GetTextEx(GETTEXTEX* pGetTextEx, LPTSTR lpstrText) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, EM_GETTEXTEX, (WPARAM)pGetTextEx, (LPARAM)lpstrText); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, EM_GETTEXTEX, (WPARAM)pGetTextEx, (LPARAM)lpstrText); } int GetTextEx(LPTSTR lpstrText, int nTextLen, DWORD dwFlags = GT_DEFAULT, UINT uCodePage = CP_ACP, LPCSTR lpDefaultChar = NULL, LPBOOL lpUsedDefChar = NULL) const { - ATLASSERT(::IsWindow(m_hWnd)); - GETTEXTEX gte = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + GETTEXTEX gte = {}; gte.cb = nTextLen * sizeof(TCHAR); gte.codepage = uCodePage; gte.flags = dwFlags; gte.lpDefaultChar = lpDefaultChar; gte.lpUsedDefChar = lpUsedDefChar; - return (int)::SendMessage(m_hWnd, EM_GETTEXTEX, (WPARAM)>e, (LPARAM)lpstrText); + return (int)::SendMessage(this->m_hWnd, EM_GETTEXTEX, (WPARAM)>e, (LPARAM)lpstrText); } int GetTextLengthEx(GETTEXTLENGTHEX* pGetTextLengthEx) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, EM_GETTEXTLENGTHEX, (WPARAM)pGetTextLengthEx, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, EM_GETTEXTLENGTHEX, (WPARAM)pGetTextLengthEx, 0L); } int GetTextLengthEx(DWORD dwFlags = GTL_DEFAULT, UINT uCodePage = CP_ACP) const { - ATLASSERT(::IsWindow(m_hWnd)); - GETTEXTLENGTHEX gtle = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + GETTEXTLENGTHEX gtle = {}; gtle.codepage = uCodePage; gtle.flags = dwFlags; - return (int)::SendMessage(m_hWnd, EM_GETTEXTLENGTHEX, (WPARAM)>le, 0L); + return (int)::SendMessage(this->m_hWnd, EM_GETTEXTLENGTHEX, (WPARAM)>le, 0L); } EDITWORDBREAKPROC GetWordBreakProc() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (EDITWORDBREAKPROC)::SendMessage(m_hWnd, EM_GETWORDBREAKPROC, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (EDITWORDBREAKPROC)::SendMessage(this->m_hWnd, EM_GETWORDBREAKPROC, 0, 0L); } void SetWordBreakProc(EDITWORDBREAKPROC ewbprc) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_SETWORDBREAKPROC, 0, (LPARAM)ewbprc); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SETWORDBREAKPROC, 0, (LPARAM)ewbprc); } -#endif // (_RICHEDIT_VER >= 0x0200) -#if (_RICHEDIT_VER >= 0x0300) int SetTextEx(SETTEXTEX* pSetTextEx, LPCTSTR lpstrText) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, EM_SETTEXTEX, (WPARAM)pSetTextEx, (LPARAM)lpstrText); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, EM_SETTEXTEX, (WPARAM)pSetTextEx, (LPARAM)lpstrText); } int SetTextEx(LPCTSTR lpstrText, DWORD dwFlags = ST_DEFAULT, UINT uCodePage = CP_ACP) { - ATLASSERT(::IsWindow(m_hWnd)); - SETTEXTEX ste = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + SETTEXTEX ste = {}; ste.flags = dwFlags; ste.codepage = uCodePage; - return (int)::SendMessage(m_hWnd, EM_SETTEXTEX, (WPARAM)&ste, (LPARAM)lpstrText); + return (int)::SendMessage(this->m_hWnd, EM_SETTEXTEX, (WPARAM)&ste, (LPARAM)lpstrText); } int GetEditStyle() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, EM_GETEDITSTYLE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, EM_GETEDITSTYLE, 0, 0L); } int SetEditStyle(int nStyle, int nMask = -1) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); if(nMask == -1) nMask = nStyle; // set everything specified - return (int)::SendMessage(m_hWnd, EM_SETEDITSTYLE, nStyle, nMask); + return (int)::SendMessage(this->m_hWnd, EM_SETEDITSTYLE, nStyle, nMask); } BOOL SetFontSize(int nFontSizeDelta) { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT(nFontSizeDelta >= -1637 && nFontSizeDelta <= 1638); - return (BOOL)::SendMessage(m_hWnd, EM_SETFONTSIZE, nFontSizeDelta, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((nFontSizeDelta >= -1637) && (nFontSizeDelta <= 1638)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETFONTSIZE, nFontSizeDelta, 0L); } void GetScrollPos(LPPOINT lpPoint) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(lpPoint != NULL); - ::SendMessage(m_hWnd, EM_GETSCROLLPOS, 0, (LPARAM)lpPoint); + ::SendMessage(this->m_hWnd, EM_GETSCROLLPOS, 0, (LPARAM)lpPoint); } void SetScrollPos(LPPOINT lpPoint) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(lpPoint != NULL); - ::SendMessage(m_hWnd, EM_SETSCROLLPOS, 0, (LPARAM)lpPoint); + ::SendMessage(this->m_hWnd, EM_SETSCROLLPOS, 0, (LPARAM)lpPoint); } BOOL GetZoom(int& nNum, int& nDen) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_GETZOOM, (WPARAM)&nNum, (LPARAM)&nDen); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_GETZOOM, (WPARAM)&nNum, (LPARAM)&nDen); } BOOL SetZoom(int nNum, int nDen) { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT(nNum >= 0 && nNum <= 64); - ATLASSERT(nDen >= 0 && nDen <= 64); - return (BOOL)::SendMessage(m_hWnd, EM_SETZOOM, nNum, nDen); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((nNum >= 0) && (nNum <= 64)); + ATLASSERT((nDen >= 0) && (nDen <= 64)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETZOOM, nNum, nDen); } BOOL SetZoomOff() { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_SETZOOM, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETZOOM, 0, 0L); } void SetMargins(UINT nLeft, UINT nRight, WORD wFlags = EC_LEFTMARGIN | EC_RIGHTMARGIN) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_SETMARGINS, wFlags, MAKELONG(nLeft, nRight)); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SETMARGINS, wFlags, MAKELONG(nLeft, nRight)); + } + + WORD GetTypographyOptions() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (WORD)::SendMessage(this->m_hWnd, EM_GETTYPOGRAPHYOPTIONS, 0, 0L); + } + + BOOL SetTypographyOptions(WORD wOptions, WORD wMask) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETTYPOGRAPHYOPTIONS, wOptions, wMask); } -#endif // (_RICHEDIT_VER >= 0x0300) // Operations void LimitText(LONG nChars = 0) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_EXLIMITTEXT, 0, nChars); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_EXLIMITTEXT, 0, nChars); } int LineFromChar(LONG nIndex) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, EM_EXLINEFROMCHAR, 0, nIndex); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, EM_EXLINEFROMCHAR, 0, nIndex); } POINT PosFromChar(LONG nChar) const { - ATLASSERT(::IsWindow(m_hWnd)); - POINT point = { 0, 0 }; - ::SendMessage(m_hWnd, EM_POSFROMCHAR, (WPARAM)&point, nChar); + ATLASSERT(::IsWindow(this->m_hWnd)); + POINT point = {}; + ::SendMessage(this->m_hWnd, EM_POSFROMCHAR, (WPARAM)&point, nChar); return point; } int CharFromPos(POINT pt) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); POINTL ptl = { pt.x, pt.y }; - return (int)::SendMessage(m_hWnd, EM_CHARFROMPOS, 0, (LPARAM)&ptl); + return (int)::SendMessage(this->m_hWnd, EM_CHARFROMPOS, 0, (LPARAM)&ptl); } void EmptyUndoBuffer() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_EMPTYUNDOBUFFER, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_EMPTYUNDOBUFFER, 0, 0L); } int LineIndex(int nLine = -1) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, EM_LINEINDEX, nLine, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, EM_LINEINDEX, nLine, 0L); } int LineLength(int nLine = -1) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, EM_LINELENGTH, nLine, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, EM_LINELENGTH, nLine, 0L); } BOOL LineScroll(int nLines) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_LINESCROLL, 0, nLines); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_LINESCROLL, 0, nLines); } void ReplaceSel(LPCTSTR lpszNewText, BOOL bCanUndo = FALSE) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_REPLACESEL, (WPARAM) bCanUndo, (LPARAM)lpszNewText); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_REPLACESEL, (WPARAM) bCanUndo, (LPARAM)lpszNewText); } void SetRect(LPCRECT lpRect) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_SETRECT, 0, (LPARAM)lpRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SETRECT, 0, (LPARAM)lpRect); } BOOL DisplayBand(LPRECT pDisplayRect) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_DISPLAYBAND, 0, (LPARAM)pDisplayRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_DISPLAYBAND, 0, (LPARAM)pDisplayRect); } LONG FindText(DWORD dwFlags, FINDTEXT& ft) const { - ATLASSERT(::IsWindow(m_hWnd)); -#if (_RICHEDIT_VER >= 0x0200) && defined(_UNICODE) - return (LONG)::SendMessage(m_hWnd, EM_FINDTEXTW, dwFlags, (LPARAM)&ft); + ATLASSERT(::IsWindow(this->m_hWnd)); +#ifdef _UNICODE + return (LONG)::SendMessage(this->m_hWnd, EM_FINDTEXTW, dwFlags, (LPARAM)&ft); #else - return (LONG)::SendMessage(m_hWnd, EM_FINDTEXT, dwFlags, (LPARAM)&ft); + return (LONG)::SendMessage(this->m_hWnd, EM_FINDTEXT, dwFlags, (LPARAM)&ft); #endif } LONG FindText(DWORD dwFlags, FINDTEXTEX& ft) const { - ATLASSERT(::IsWindow(m_hWnd)); -#if (_RICHEDIT_VER >= 0x0200) && defined(_UNICODE) - return (LONG)::SendMessage(m_hWnd, EM_FINDTEXTEXW, dwFlags, (LPARAM)&ft); + ATLASSERT(::IsWindow(this->m_hWnd)); +#ifdef _UNICODE + return (LONG)::SendMessage(this->m_hWnd, EM_FINDTEXTEXW, dwFlags, (LPARAM)&ft); #else - return (LONG)::SendMessage(m_hWnd, EM_FINDTEXTEX, dwFlags, (LPARAM)&ft); + return (LONG)::SendMessage(this->m_hWnd, EM_FINDTEXTEX, dwFlags, (LPARAM)&ft); #endif } LONG FormatRange(FORMATRANGE& fr, BOOL bDisplay = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (LONG)::SendMessage(m_hWnd, EM_FORMATRANGE, bDisplay, (LPARAM)&fr); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (LONG)::SendMessage(this->m_hWnd, EM_FORMATRANGE, bDisplay, (LPARAM)&fr); } LONG FormatRange(FORMATRANGE* pFormatRange, BOOL bDisplay = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (LONG)::SendMessage(m_hWnd, EM_FORMATRANGE, bDisplay, (LPARAM)pFormatRange); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (LONG)::SendMessage(this->m_hWnd, EM_FORMATRANGE, bDisplay, (LPARAM)pFormatRange); } void HideSelection(BOOL bHide = TRUE, BOOL bChangeStyle = FALSE) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_HIDESELECTION, bHide, bChangeStyle); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_HIDESELECTION, bHide, bChangeStyle); } void PasteSpecial(UINT uClipFormat, DWORD dwAspect = 0, HMETAFILE hMF = 0) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); REPASTESPECIAL reps = { dwAspect, (DWORD_PTR)hMF }; - ::SendMessage(m_hWnd, EM_PASTESPECIAL, uClipFormat, (LPARAM)&reps); + ::SendMessage(this->m_hWnd, EM_PASTESPECIAL, uClipFormat, (LPARAM)&reps); } void RequestResize() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_REQUESTRESIZE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_REQUESTRESIZE, 0, 0L); } LONG StreamIn(UINT uFormat, EDITSTREAM& es) { - ATLASSERT(::IsWindow(m_hWnd)); - return (LONG)::SendMessage(m_hWnd, EM_STREAMIN, uFormat, (LPARAM)&es); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (LONG)::SendMessage(this->m_hWnd, EM_STREAMIN, uFormat, (LPARAM)&es); } LONG StreamOut(UINT uFormat, EDITSTREAM& es) { - ATLASSERT(::IsWindow(m_hWnd)); - return (LONG)::SendMessage(m_hWnd, EM_STREAMOUT, uFormat, (LPARAM)&es); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (LONG)::SendMessage(this->m_hWnd, EM_STREAMOUT, uFormat, (LPARAM)&es); } DWORD FindWordBreak(int nCode, LONG nStartChar) { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, EM_FINDWORDBREAK, nCode, nStartChar); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, EM_FINDWORDBREAK, nCode, nStartChar); } // Additional operations void ScrollCaret() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_SCROLLCARET, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SCROLLCARET, 0, 0L); } int InsertText(long nInsertAfterChar, LPCTSTR lpstrText, BOOL bCanUndo = FALSE) @@ -8074,145 +7879,141 @@ public: int AppendText(LPCTSTR lpstrText, BOOL bCanUndo = FALSE) { - return InsertText(GetWindowTextLength(), lpstrText, bCanUndo); + return InsertText(this->GetWindowTextLength(), lpstrText, bCanUndo); } // Clipboard operations BOOL Undo() { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_UNDO, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_UNDO, 0, 0L); } void Clear() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, WM_CLEAR, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, WM_CLEAR, 0, 0L); } void Copy() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, WM_COPY, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, WM_COPY, 0, 0L); } void Cut() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, WM_CUT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, WM_CUT, 0, 0L); } void Paste() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, WM_PASTE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, WM_PASTE, 0, 0L); } // OLE support IRichEditOle* GetOleInterface() const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); IRichEditOle *pRichEditOle = NULL; - ::SendMessage(m_hWnd, EM_GETOLEINTERFACE, 0, (LPARAM)&pRichEditOle); + ::SendMessage(this->m_hWnd, EM_GETOLEINTERFACE, 0, (LPARAM)&pRichEditOle); return pRichEditOle; } BOOL SetOleCallback(IRichEditOleCallback* pCallback) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_SETOLECALLBACK, 0, (LPARAM)pCallback); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETOLECALLBACK, 0, (LPARAM)pCallback); } -#if (_RICHEDIT_VER >= 0x0200) BOOL Redo() { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_REDO, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_REDO, 0, 0L); } void StopGroupTyping() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_STOPGROUPTYPING, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_STOPGROUPTYPING, 0, 0L); } void ShowScrollBar(int nBarType, BOOL bVisible = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_SHOWSCROLLBAR, nBarType, bVisible); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SHOWSCROLLBAR, nBarType, bVisible); } -#endif // (_RICHEDIT_VER >= 0x0200) -#if (_RICHEDIT_VER >= 0x0300) BOOL SetTabStops(int nTabStops, LPINT rgTabStops) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_SETTABSTOPS, nTabStops, (LPARAM)rgTabStops); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETTABSTOPS, nTabStops, (LPARAM)rgTabStops); } BOOL SetTabStops() { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_SETTABSTOPS, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETTABSTOPS, 0, 0L); } BOOL SetTabStops(const int& cxEachStop) // takes an 'int' { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_SETTABSTOPS, 1, (LPARAM)(LPINT)&cxEachStop); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETTABSTOPS, 1, (LPARAM)(LPINT)&cxEachStop); } -#endif // (_RICHEDIT_VER >= 0x0300) #if (_RICHEDIT_VER >= 0x0800) AutoCorrectProc GetAutoCorrectProc() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (AutoCorrectProc)::SendMessage(m_hWnd, EM_GETAUTOCORRECTPROC, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (AutoCorrectProc)::SendMessage(this->m_hWnd, EM_GETAUTOCORRECTPROC, 0, 0L); } BOOL SetAutoCorrectProc(AutoCorrectProc pfn) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_SETAUTOCORRECTPROC, (WPARAM)pfn, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETAUTOCORRECTPROC, (WPARAM)pfn, 0L); } BOOL CallAutoCorrectProc(WCHAR ch) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_CALLAUTOCORRECTPROC, (WPARAM)ch, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_CALLAUTOCORRECTPROC, (WPARAM)ch, 0L); } DWORD GetEditStyleEx() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, EM_GETEDITSTYLEEX, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, EM_GETEDITSTYLEEX, 0, 0L); } DWORD SetEditStyleEx(DWORD dwStyleEx, DWORD dwMask) { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, EM_SETEDITSTYLEEX, dwStyleEx, dwMask); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, EM_SETEDITSTYLEEX, dwStyleEx, dwMask); } DWORD GetStoryType(int nStoryIndex) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, EM_GETSTORYTYPE, nStoryIndex, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, EM_GETSTORYTYPE, nStoryIndex, 0L); } DWORD SetStoryType(int nStoryIndex, DWORD dwStoryType) { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, EM_SETSTORYTYPE, nStoryIndex, dwStoryType); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, EM_SETSTORYTYPE, nStoryIndex, dwStoryType); } DWORD GetEllipsisMode() const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); DWORD dwMode = 0; - BOOL bRet = (BOOL)::SendMessage(m_hWnd, EM_GETELLIPSISMODE, 0, (LPARAM)&dwMode); - bRet; // avoid level 4 warning + BOOL bRet = (BOOL)::SendMessage(this->m_hWnd, EM_GETELLIPSISMODE, 0, (LPARAM)&dwMode); + (void)bRet; // avoid level 4 warning ATLASSERT(bRet != FALSE); return dwMode; @@ -8220,70 +8021,66 @@ public: BOOL SetEllipsisMode(DWORD dwEllipsisMode) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_SETELLIPSISMODE, 0, dwEllipsisMode); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETELLIPSISMODE, 0, dwEllipsisMode); } BOOL GetEllipsisState() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_GETELLIPSISSTATE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_GETELLIPSISSTATE, 0, 0L); } BOOL GetTouchOptions(int nTouchOptions) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_GETTOUCHOPTIONS, nTouchOptions, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_GETTOUCHOPTIONS, nTouchOptions, 0L); } void SetTouchOptions(int nTouchOptions, BOOL bEnable) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, EM_SETTOUCHOPTIONS, nTouchOptions, bEnable); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SETTOUCHOPTIONS, nTouchOptions, bEnable); } HRESULT InsertTable(TABLEROWPARMS* pRowParams, TABLECELLPARMS* pCellParams) { - ATLASSERT(::IsWindow(m_hWnd)); - return (HRESULT)::SendMessage(m_hWnd, EM_INSERTTABLE, (WPARAM)pRowParams, (LPARAM)pCellParams); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HRESULT)::SendMessage(this->m_hWnd, EM_INSERTTABLE, (WPARAM)pRowParams, (LPARAM)pCellParams); } HRESULT GetTableParams(TABLEROWPARMS* pRowParams, TABLECELLPARMS* pCellParams) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (HRESULT)::SendMessage(m_hWnd, EM_GETTABLEPARMS, (WPARAM)pRowParams, (LPARAM)pCellParams); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HRESULT)::SendMessage(this->m_hWnd, EM_GETTABLEPARMS, (WPARAM)pRowParams, (LPARAM)pCellParams); } HRESULT SetTableParams(TABLEROWPARMS* pRowParams, TABLECELLPARMS* pCellParams) { - ATLASSERT(::IsWindow(m_hWnd)); - return (HRESULT)::SendMessage(m_hWnd, EM_SETTABLEPARMS, (WPARAM)pRowParams, (LPARAM)pCellParams); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HRESULT)::SendMessage(this->m_hWnd, EM_SETTABLEPARMS, (WPARAM)pRowParams, (LPARAM)pCellParams); } HRESULT InsertImage(RICHEDIT_IMAGE_PARAMETERS* pParams) { - ATLASSERT(::IsWindow(m_hWnd)); - return (HRESULT)::SendMessage(m_hWnd, EM_INSERTIMAGE, 0, (LPARAM)pParams); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HRESULT)::SendMessage(this->m_hWnd, EM_INSERTIMAGE, 0, (LPARAM)pParams); } BOOL SetUiaName(LPCTSTR lpstrName) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, EM_SETUIANAME, 0, (LPARAM)lpstrName); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETUIANAME, 0, (LPARAM)lpstrName); } #endif // (_RICHEDIT_VER >= 0x0800) }; typedef CRichEditCtrlT CRichEditCtrl; -#endif // !_WIN32_WCE - /////////////////////////////////////////////////////////////////////////////// // CRichEditCommands - message handlers for standard EDIT commands -#ifndef _WIN32_WCE - // Chain to CRichEditCommands message map. Your class must also derive from CRichEditCtrl. // Example: // class CMyRichEdit : public CWindowImpl, @@ -8310,19 +8107,15 @@ public: COMMAND_ID_HANDLER(ID_EDIT_PASTE, CEditCommands< T >::OnEditPaste) COMMAND_ID_HANDLER(ID_EDIT_SELECT_ALL, CEditCommands< T >::OnEditSelectAll) COMMAND_ID_HANDLER(ID_EDIT_UNDO, CEditCommands< T >::OnEditUndo) -#if (_RICHEDIT_VER >= 0x0200) COMMAND_ID_HANDLER(ID_EDIT_REDO, OnEditRedo) -#endif // (_RICHEDIT_VER >= 0x0200) END_MSG_MAP() -#if (_RICHEDIT_VER >= 0x0200) LRESULT OnEditRedo(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { T* pT = static_cast(this); pT->Redo(); return 0; } -#endif // (_RICHEDIT_VER >= 0x0200) // State (update UI) helpers BOOL CanCut() const @@ -8342,14 +8135,10 @@ public: } }; -#endif // _WIN32_WCE - /////////////////////////////////////////////////////////////////////////////// // CDragListBox -#ifndef _WIN32_WCE - template class CDragListBoxT : public CListBoxT< TBase > { @@ -8360,7 +8149,7 @@ public: CDragListBoxT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -8368,7 +8157,7 @@ public: DWORD dwStyle = 0, DWORD dwExStyle = 0, ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) { - HWND hWnd = TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); + HWND hWnd = TBase::Create(TBase::GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); if(hWnd != NULL) MakeDragList(); return hWnd; @@ -8377,21 +8166,21 @@ public: // Operations BOOL MakeDragList() { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT((GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) == 0); - return ::MakeDragList(m_hWnd); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) == 0); + return ::MakeDragList(this->m_hWnd); } int LBItemFromPt(POINT pt, BOOL bAutoScroll = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return ::LBItemFromPt(m_hWnd, pt, bAutoScroll); + ATLASSERT(::IsWindow(this->m_hWnd)); + return ::LBItemFromPt(this->m_hWnd, pt, bAutoScroll); } void DrawInsert(int nItem) { - ATLASSERT(::IsWindow(m_hWnd)); - ::DrawInsert(GetParent(), m_hWnd, nItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::DrawInsert(this->GetParent(), this->m_hWnd, nItem); } static UINT GetDragListMessage() @@ -8429,7 +8218,7 @@ public: LRESULT OnDragListNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { - uMsg; // avoid level 4 warning + (void)uMsg; // avoid level 4 warning ATLASSERT(uMsg == CDragListBox::GetDragListMessage()); T* pT = static_cast(this); LPDRAGLISTINFO lpDragListInfo = (LPDRAGLISTINFO)lParam; @@ -8478,8 +8267,6 @@ public: } }; -#endif // _WIN32_WCE - /////////////////////////////////////////////////////////////////////////////// // CReBarCtrl @@ -8494,7 +8281,7 @@ public: CReBarCtrlT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -8513,208 +8300,192 @@ public: UINT GetBandCount() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (UINT)::SendMessage(m_hWnd, RB_GETBANDCOUNT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, RB_GETBANDCOUNT, 0, 0L); } BOOL GetBandInfo(int nBand, LPREBARBANDINFO lprbbi) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, RB_GETBANDINFO, nBand, (LPARAM)lprbbi); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, RB_GETBANDINFO, nBand, (LPARAM)lprbbi); } BOOL SetBandInfo(int nBand, LPREBARBANDINFO lprbbi) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, RB_SETBANDINFO, nBand, (LPARAM)lprbbi); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, RB_SETBANDINFO, nBand, (LPARAM)lprbbi); } BOOL GetBarInfo(LPREBARINFO lprbi) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, RB_GETBARINFO, 0, (LPARAM)lprbi); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, RB_GETBARINFO, 0, (LPARAM)lprbi); } BOOL SetBarInfo(LPREBARINFO lprbi) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, RB_SETBARINFO, 0, (LPARAM)lprbi); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, RB_SETBARINFO, 0, (LPARAM)lprbi); } CImageList GetImageList() const { - ATLASSERT(::IsWindow(m_hWnd)); - REBARINFO rbi = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + REBARINFO rbi = {}; rbi.cbSize = sizeof(REBARINFO); rbi.fMask = RBIM_IMAGELIST; - BOOL bRet = (BOOL)::SendMessage(m_hWnd, RB_GETBARINFO, 0, (LPARAM)&rbi); + BOOL bRet = (BOOL)::SendMessage(this->m_hWnd, RB_GETBARINFO, 0, (LPARAM)&rbi); return CImageList((bRet != FALSE) ? rbi.himl : NULL); } BOOL SetImageList(HIMAGELIST hImageList) { - ATLASSERT(::IsWindow(m_hWnd)); - REBARINFO rbi = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + REBARINFO rbi = {}; rbi.cbSize = sizeof(REBARINFO); rbi.fMask = RBIM_IMAGELIST; rbi.himl = hImageList; - return (BOOL)::SendMessage(m_hWnd, RB_SETBARINFO, 0, (LPARAM)&rbi); + return (BOOL)::SendMessage(this->m_hWnd, RB_SETBARINFO, 0, (LPARAM)&rbi); } UINT GetRowCount() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (UINT)::SendMessage(m_hWnd, RB_GETROWCOUNT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, RB_GETROWCOUNT, 0, 0L); } UINT GetRowHeight(int nBand) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (UINT)::SendMessage(m_hWnd, RB_GETROWHEIGHT, nBand, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, RB_GETROWHEIGHT, nBand, 0L); } -#if (_WIN32_IE >= 0x0400) COLORREF GetTextColor() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, RB_GETTEXTCOLOR, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, RB_GETTEXTCOLOR, 0, 0L); } COLORREF SetTextColor(COLORREF clr) { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, RB_SETTEXTCOLOR, 0, (LPARAM)clr); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, RB_SETTEXTCOLOR, 0, (LPARAM)clr); } COLORREF GetBkColor() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, RB_GETBKCOLOR, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, RB_GETBKCOLOR, 0, 0L); } COLORREF SetBkColor(COLORREF clr) { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, RB_SETBKCOLOR, 0, (LPARAM)clr); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, RB_SETBKCOLOR, 0, (LPARAM)clr); } UINT GetBarHeight() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (UINT)::SendMessage(m_hWnd, RB_GETBARHEIGHT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, RB_GETBARHEIGHT, 0, 0L); } BOOL GetRect(int nBand, LPRECT lpRect) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, RB_GETRECT, nBand, (LPARAM)lpRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, RB_GETRECT, nBand, (LPARAM)lpRect); } -#ifndef _WIN32_WCE CToolTipCtrl GetToolTips() const { - ATLASSERT(::IsWindow(m_hWnd)); - return CToolTipCtrl((HWND)::SendMessage(m_hWnd, RB_GETTOOLTIPS, 0, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CToolTipCtrl((HWND)::SendMessage(this->m_hWnd, RB_GETTOOLTIPS, 0, 0L)); } void SetToolTips(HWND hwndToolTip) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, RB_SETTOOLTIPS, (WPARAM)hwndToolTip, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, RB_SETTOOLTIPS, (WPARAM)hwndToolTip, 0L); } -#endif // !_WIN32_WCE void GetBandBorders(int nBand, LPRECT lpRect) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(lpRect != NULL); - ::SendMessage(m_hWnd, RB_GETBANDBORDERS, nBand, (LPARAM)lpRect); + ::SendMessage(this->m_hWnd, RB_GETBANDBORDERS, nBand, (LPARAM)lpRect); } -#ifndef _WIN32_WCE BOOL GetColorScheme(LPCOLORSCHEME lpColorScheme) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(lpColorScheme != NULL); - return (BOOL)::SendMessage(m_hWnd, RB_GETCOLORSCHEME, 0, (LPARAM)lpColorScheme); + return (BOOL)::SendMessage(this->m_hWnd, RB_GETCOLORSCHEME, 0, (LPARAM)lpColorScheme); } void SetColorScheme(LPCOLORSCHEME lpColorScheme) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(lpColorScheme != NULL); - ::SendMessage(m_hWnd, RB_SETCOLORSCHEME, 0, (LPARAM)lpColorScheme); + ::SendMessage(this->m_hWnd, RB_SETCOLORSCHEME, 0, (LPARAM)lpColorScheme); } HPALETTE GetPalette() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (HPALETTE)::SendMessage(m_hWnd, RB_GETPALETTE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HPALETTE)::SendMessage(this->m_hWnd, RB_GETPALETTE, 0, 0L); } HPALETTE SetPalette(HPALETTE hPalette) { - ATLASSERT(::IsWindow(m_hWnd)); - return (HPALETTE)::SendMessage(m_hWnd, RB_SETPALETTE, 0, (LPARAM)hPalette); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HPALETTE)::SendMessage(this->m_hWnd, RB_SETPALETTE, 0, (LPARAM)hPalette); } BOOL GetUnicodeFormat() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, RB_GETUNICODEFORMAT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, RB_GETUNICODEFORMAT, 0, 0L); } BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, RB_SETUNICODEFORMAT, bUnicode, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, RB_SETUNICODEFORMAT, bUnicode, 0L); } -#endif // !_WIN32_WCE -#endif // (_WIN32_IE >= 0x0400) -#if (_WIN32_WINNT >= 0x0501) // requires uxtheme.h to be included to use MARGINS struct #ifndef _UXTHEME_H_ typedef struct _MARGINS* PMARGINS; #endif // !_UXTHEME_H_ void GetBandMargins(PMARGINS pMargins) const { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, RB_GETBANDMARGINS, 0, (LPARAM)pMargins); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, RB_GETBANDMARGINS, 0, (LPARAM)pMargins); } void SetWindowTheme(LPCWSTR lpstrTheme) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, RB_SETWINDOWTHEME, 0, (LPARAM)lpstrTheme); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, RB_SETWINDOWTHEME, 0, (LPARAM)lpstrTheme); } -#endif // (_WIN32_WINNT >= 0x0501) -#if (_WIN32_IE >= 0x0600) DWORD GetExtendedStyle() const { -#ifndef RB_GETEXTENDEDSTYLE - const UINT RB_GETEXTENDEDSTYLE = WM_USER + 42; -#endif - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, RB_GETEXTENDEDSTYLE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, RB_GETEXTENDEDSTYLE, 0, 0L); } DWORD SetExtendedStyle(DWORD dwStyle, DWORD dwMask) { -#ifndef RB_SETEXTENDEDSTYLE - const UINT RB_SETEXTENDEDSTYLE = WM_USER + 41; -#endif - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, RB_SETEXTENDEDSTYLE, dwMask, dwStyle); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, RB_SETEXTENDEDSTYLE, dwMask, dwStyle); } -#endif // (_WIN32_IE >= 0x0600) // Operations BOOL InsertBand(int nBand, LPREBARBANDINFO lprbbi) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, RB_INSERTBAND, nBand, (LPARAM)lprbbi); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, RB_INSERTBAND, nBand, (LPARAM)lprbbi); } BOOL AddBand(LPREBARBANDINFO lprbbi) @@ -8724,111 +8495,102 @@ public: BOOL DeleteBand(int nBand) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, RB_DELETEBAND, nBand, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, RB_DELETEBAND, nBand, 0L); } ATL::CWindow SetNotifyWnd(HWND hWnd) { - ATLASSERT(::IsWindow(m_hWnd)); - return ATL::CWindow((HWND)::SendMessage(m_hWnd, RB_SETPARENT, (WPARAM)hWnd, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return ATL::CWindow((HWND)::SendMessage(this->m_hWnd, RB_SETPARENT, (WPARAM)hWnd, 0L)); } -#if (_WIN32_IE >= 0x0400) void BeginDrag(int nBand, DWORD dwPos) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, RB_BEGINDRAG, nBand, dwPos); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, RB_BEGINDRAG, nBand, dwPos); } void BeginDrag(int nBand, int xPos, int yPos) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, RB_BEGINDRAG, nBand, MAKELPARAM(xPos, yPos)); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, RB_BEGINDRAG, nBand, MAKELPARAM(xPos, yPos)); } void EndDrag() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, RB_ENDDRAG, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, RB_ENDDRAG, 0, 0L); } void DragMove(DWORD dwPos) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, RB_DRAGMOVE, 0, dwPos); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, RB_DRAGMOVE, 0, dwPos); } void DragMove(int xPos, int yPos) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, RB_DRAGMOVE, 0, MAKELPARAM(xPos, yPos)); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, RB_DRAGMOVE, 0, MAKELPARAM(xPos, yPos)); } -#ifndef _WIN32_WCE void GetDropTarget(IDropTarget** ppDropTarget) const { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, RB_GETDROPTARGET, 0, (LPARAM)ppDropTarget); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, RB_GETDROPTARGET, 0, (LPARAM)ppDropTarget); } -#endif // !_WIN32_WCE void MaximizeBand(int nBand, BOOL bIdeal = FALSE) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, RB_MAXIMIZEBAND, nBand, bIdeal); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, RB_MAXIMIZEBAND, nBand, bIdeal); } void MinimizeBand(int nBand) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, RB_MINIMIZEBAND, nBand, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, RB_MINIMIZEBAND, nBand, 0L); } BOOL SizeToRect(LPRECT lpRect) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, RB_SIZETORECT, 0, (LPARAM)lpRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, RB_SIZETORECT, 0, (LPARAM)lpRect); } int IdToIndex(UINT uBandID) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, RB_IDTOINDEX, uBandID, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, RB_IDTOINDEX, uBandID, 0L); } int HitTest(LPRBHITTESTINFO lprbht) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, RB_HITTEST, 0, (LPARAM)lprbht); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, RB_HITTEST, 0, (LPARAM)lprbht); } BOOL ShowBand(int nBand, BOOL bShow) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, RB_SHOWBAND, nBand, bShow); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, RB_SHOWBAND, nBand, bShow); } -#ifndef _WIN32_WCE BOOL MoveBand(int nBand, int nNewPos) { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT(nNewPos >= 0 && nNewPos <= ((int)GetBandCount() - 1)); - return (BOOL)::SendMessage(m_hWnd, RB_MOVEBAND, nBand, nNewPos); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((nNewPos >= 0) && (nNewPos <= ((int)GetBandCount() - 1))); + return (BOOL)::SendMessage(this->m_hWnd, RB_MOVEBAND, nBand, nNewPos); } -#endif // !_WIN32_WCE -#endif // (_WIN32_IE >= 0x0400) -#if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) void PushChevron(int nBand, LPARAM lAppValue) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, RB_PUSHCHEVRON, nBand, lAppValue); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, RB_PUSHCHEVRON, nBand, lAppValue); } -#endif // (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) // Extra operations -#if (_WIN32_IE >= 0x0400) void LockBands(bool bLock) { int nBandCount = GetBandCount(); @@ -8856,13 +8618,12 @@ public: ATLASSERT(bRet); } } -#endif // (_WIN32_IE >= 0x0400) #if (_WIN32_WINNT >= 0x0600) BOOL SetBandWidth(int nBand, int cxWidth) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, RB_SETBANDWIDTH, nBand, cxWidth); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, RB_SETBANDWIDTH, nBand, cxWidth); } #endif // (_WIN32_WINNT >= 0x0600) }; @@ -8873,8 +8634,6 @@ typedef CReBarCtrlT CReBarCtrl; /////////////////////////////////////////////////////////////////////////////// // CComboBoxEx -#ifndef _WIN32_WCE - template class CComboBoxExT : public CComboBoxT< TBase > { @@ -8885,7 +8644,7 @@ public: CComboBoxExT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -8904,62 +8663,58 @@ public: CImageList GetImageList() const { - ATLASSERT(::IsWindow(m_hWnd)); - return CImageList((HIMAGELIST)::SendMessage(m_hWnd, CBEM_GETIMAGELIST, 0, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, CBEM_GETIMAGELIST, 0, 0L)); } CImageList SetImageList(HIMAGELIST hImageList) { - ATLASSERT(::IsWindow(m_hWnd)); - return CImageList((HIMAGELIST)::SendMessage(m_hWnd, CBEM_SETIMAGELIST, 0, (LPARAM)hImageList)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, CBEM_SETIMAGELIST, 0, (LPARAM)hImageList)); } -#if (_WIN32_IE >= 0x0400) DWORD GetExtendedStyle() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, CBEM_GETEXTENDEDSTYLE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, CBEM_GETEXTENDEDSTYLE, 0, 0L); } DWORD SetExtendedStyle(DWORD dwExMask, DWORD dwExStyle) { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, CBEM_SETEXTENDEDSTYLE, dwExMask, dwExStyle); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, CBEM_SETEXTENDEDSTYLE, dwExMask, dwExStyle); } BOOL GetUnicodeFormat() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, CBEM_GETUNICODEFORMAT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, CBEM_GETUNICODEFORMAT, 0, 0L); } BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, CBEM_SETUNICODEFORMAT, bUnicode, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, CBEM_SETUNICODEFORMAT, bUnicode, 0L); } -#endif // (_WIN32_IE >= 0x0400) -#if (_WIN32_WINNT >= 0x0501) void SetWindowTheme(LPCWSTR lpstrTheme) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, CBEM_SETWINDOWTHEME, 0, (LPARAM)lpstrTheme); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, CBEM_SETWINDOWTHEME, 0, (LPARAM)lpstrTheme); } -#endif // (_WIN32_WINNT >= 0x0501) // Operations int InsertItem(const COMBOBOXEXITEM* lpcCBItem) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, CBEM_INSERTITEM, 0, (LPARAM)lpcCBItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CBEM_INSERTITEM, 0, (LPARAM)lpcCBItem); } int InsertItem(UINT nMask, int nIndex, LPCTSTR lpszItem, int nImage, int nSelImage, int iIndent, int iOverlay, LPARAM lParam) { - ATLASSERT(::IsWindow(m_hWnd)); - COMBOBOXEXITEM cbex = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + COMBOBOXEXITEM cbex = {}; cbex.mask = nMask; cbex.iItem = nIndex; cbex.pszText = (LPTSTR) lpszItem; @@ -8968,13 +8723,13 @@ public: cbex.iIndent = iIndent; cbex.iOverlay = iOverlay; cbex.lParam = lParam; - return (int)::SendMessage(m_hWnd, CBEM_INSERTITEM, 0, (LPARAM)&cbex); + return (int)::SendMessage(this->m_hWnd, CBEM_INSERTITEM, 0, (LPARAM)&cbex); } int InsertItem(int nIndex, LPCTSTR lpszItem, int nImage, int nSelImage, int iIndent, LPARAM lParam = 0) { - ATLASSERT(::IsWindow(m_hWnd)); - COMBOBOXEXITEM cbex = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + COMBOBOXEXITEM cbex = {}; cbex.mask = CBEIF_TEXT | CBEIF_IMAGE | CBEIF_SELECTEDIMAGE | CBEIF_INDENT | CBEIF_LPARAM; cbex.iItem = nIndex; cbex.pszText = (LPTSTR) lpszItem; @@ -8982,7 +8737,7 @@ public: cbex.iSelectedImage = nSelImage; cbex.iIndent = iIndent; cbex.lParam = lParam; - return (int)::SendMessage(m_hWnd, CBEM_INSERTITEM, 0, (LPARAM)&cbex); + return (int)::SendMessage(this->m_hWnd, CBEM_INSERTITEM, 0, (LPARAM)&cbex); } int AddItem(UINT nMask, LPCTSTR lpszItem, int nImage, int nSelImage, int iIndent, int iOverlay, LPARAM lParam) @@ -8997,27 +8752,27 @@ public: int DeleteItem(int nIndex) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, CBEM_DELETEITEM, nIndex, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CBEM_DELETEITEM, nIndex, 0L); } BOOL GetItem(PCOMBOBOXEXITEM pCBItem) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, CBEM_GETITEM, 0, (LPARAM)pCBItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, CBEM_GETITEM, 0, (LPARAM)pCBItem); } BOOL SetItem(const COMBOBOXEXITEM* lpcCBItem) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, CBEM_SETITEM, 0, (LPARAM)lpcCBItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, CBEM_SETITEM, 0, (LPARAM)lpcCBItem); } int SetItem(int nIndex, UINT nMask, LPCTSTR lpszItem, int nImage, int nSelImage, int iIndent, int iOverlay, LPARAM lParam) { - ATLASSERT(::IsWindow(m_hWnd)); - COMBOBOXEXITEM cbex = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + COMBOBOXEXITEM cbex = {}; cbex.mask = nMask; cbex.iItem = nIndex; cbex.pszText = (LPTSTR) lpszItem; @@ -9026,31 +8781,30 @@ public: cbex.iIndent = iIndent; cbex.iOverlay = iOverlay; cbex.lParam = lParam; - return (int)::SendMessage(m_hWnd, CBEM_SETITEM, 0, (LPARAM)&cbex); + return (int)::SendMessage(this->m_hWnd, CBEM_SETITEM, 0, (LPARAM)&cbex); } BOOL GetItemText(int nIndex, LPTSTR lpszItem, int nLen) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(lpszItem != NULL); - COMBOBOXEXITEM cbex = { 0 }; + COMBOBOXEXITEM cbex = {}; cbex.mask = CBEIF_TEXT; cbex.iItem = nIndex; cbex.pszText = lpszItem; cbex.cchTextMax = nLen; - return (BOOL)::SendMessage(m_hWnd, CBEM_GETITEM, 0, (LPARAM)&cbex); + return (BOOL)::SendMessage(this->m_hWnd, CBEM_GETITEM, 0, (LPARAM)&cbex); } -#ifndef _ATL_NO_COM BOOL GetItemText(int nIndex, BSTR& bstrText) const { USES_CONVERSION; - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(bstrText == NULL); - COMBOBOXEXITEM cbex = { 0 }; + COMBOBOXEXITEM cbex = {}; cbex.mask = CBEIF_TEXT; cbex.iItem = nIndex; @@ -9064,8 +8818,8 @@ public: lpstrText[0] = NULL; cbex.pszText = lpstrText; cbex.cchTextMax = nLen; - bRet = (BOOL)::SendMessage(m_hWnd, CBEM_GETITEM, 0, (LPARAM)&cbex); - if(!bRet || (lstrlen(cbex.pszText) < nLen - 1)) + bRet = (BOOL)::SendMessage(this->m_hWnd, CBEM_GETITEM, 0, (LPARAM)&cbex); + if(!bRet || (lstrlen(cbex.pszText) < (nLen - 1))) break; delete [] lpstrText; lpstrText = NULL; @@ -9080,14 +8834,13 @@ public: return (bstrText != NULL) ? TRUE : FALSE; } -#endif // !_ATL_NO_COM -#if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) - BOOL GetItemText(int nIndex, _CSTRING_NS::CString& strText) const +#ifdef __ATLSTR_H__ + BOOL GetItemText(int nIndex, ATL::CString& strText) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); - COMBOBOXEXITEM cbex = { 0 }; + COMBOBOXEXITEM cbex = {}; cbex.mask = CBEIF_TEXT; cbex.iItem = nIndex; @@ -9102,37 +8855,37 @@ public: break; } cbex.cchTextMax = nLen; - bRet = (BOOL)::SendMessage(m_hWnd, CBEM_GETITEM, 0, (LPARAM)&cbex); - if(!bRet || (lstrlen(cbex.pszText) < nLen - 1)) + bRet = (BOOL)::SendMessage(this->m_hWnd, CBEM_GETITEM, 0, (LPARAM)&cbex); + if(!bRet || (lstrlen(cbex.pszText) < (nLen - 1))) break; } strText.ReleaseBuffer(); return bRet; } -#endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) +#endif // __ATLSTR_H__ BOOL SetItemText(int nIndex, LPCTSTR lpszItem) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); return SetItem(nIndex, CBEIF_TEXT, lpszItem, 0, 0, 0, 0, 0); } CComboBox GetComboCtrl() const { - ATLASSERT(::IsWindow(m_hWnd)); - return CComboBox((HWND)::SendMessage(m_hWnd, CBEM_GETCOMBOCONTROL, 0, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CComboBox((HWND)::SendMessage(this->m_hWnd, CBEM_GETCOMBOCONTROL, 0, 0L)); } CEdit GetEditCtrl() const { - ATLASSERT(::IsWindow(m_hWnd)); - return CEdit((HWND)::SendMessage(m_hWnd, CBEM_GETEDITCONTROL, 0, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CEdit((HWND)::SendMessage(this->m_hWnd, CBEM_GETEDITCONTROL, 0, 0L)); } BOOL HasEditChanged() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, CBEM_HASEDITCHANGED, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, CBEM_HASEDITCHANGED, 0, 0L); } // Non-functional @@ -9163,8 +8916,6 @@ public: typedef CComboBoxExT CComboBoxEx; -#endif // !_WIN32_WCE - /////////////////////////////////////////////////////////////////////////////// // CMonthCalendarCtrl @@ -9179,7 +8930,7 @@ public: CMonthCalendarCtrlT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -9198,32 +8949,32 @@ public: COLORREF GetColor(int nColorType) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, MCM_GETCOLOR, nColorType, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, MCM_GETCOLOR, nColorType, 0L); } COLORREF SetColor(int nColorType, COLORREF clr) { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, MCM_SETCOLOR, nColorType, clr); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, MCM_SETCOLOR, nColorType, clr); } BOOL GetCurSel(LPSYSTEMTIME lpSysTime) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, MCM_GETCURSEL, 0, (LPARAM)lpSysTime); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, MCM_GETCURSEL, 0, (LPARAM)lpSysTime); } BOOL SetCurSel(LPSYSTEMTIME lpSysTime) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, MCM_SETCURSEL, 0, (LPARAM)lpSysTime); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, MCM_SETCURSEL, 0, (LPARAM)lpSysTime); } int GetFirstDayOfWeek(BOOL* pbLocaleVal = NULL) const { - ATLASSERT(::IsWindow(m_hWnd)); - DWORD dwRet = (DWORD)::SendMessage(m_hWnd, MCM_GETFIRSTDAYOFWEEK, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, MCM_GETFIRSTDAYOFWEEK, 0, 0L); if(pbLocaleVal != NULL) *pbLocaleVal = (BOOL)HIWORD(dwRet); return (int)(short)LOWORD(dwRet); @@ -9231,8 +8982,8 @@ public: int SetFirstDayOfWeek(int nDay, BOOL* pbLocaleVal = NULL) { - ATLASSERT(::IsWindow(m_hWnd)); - DWORD dwRet = (DWORD)::SendMessage(m_hWnd, MCM_SETFIRSTDAYOFWEEK, 0, nDay); + ATLASSERT(::IsWindow(this->m_hWnd)); + DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, MCM_SETFIRSTDAYOFWEEK, 0, nDay); if(pbLocaleVal != NULL) *pbLocaleVal = (BOOL)HIWORD(dwRet); return (int)(short)LOWORD(dwRet); @@ -9240,164 +8991,162 @@ public: int GetMaxSelCount() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, MCM_GETMAXSELCOUNT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, MCM_GETMAXSELCOUNT, 0, 0L); } BOOL SetMaxSelCount(int nMax) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, MCM_SETMAXSELCOUNT, nMax, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, MCM_SETMAXSELCOUNT, nMax, 0L); } int GetMonthDelta() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, MCM_GETMONTHDELTA, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, MCM_GETMONTHDELTA, 0, 0L); } int SetMonthDelta(int nDelta) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, MCM_SETMONTHDELTA, nDelta, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, MCM_SETMONTHDELTA, nDelta, 0L); } DWORD GetRange(LPSYSTEMTIME lprgSysTimeArray) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, MCM_GETRANGE, 0, (LPARAM)lprgSysTimeArray); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, MCM_GETRANGE, 0, (LPARAM)lprgSysTimeArray); } BOOL SetRange(DWORD dwFlags, LPSYSTEMTIME lprgSysTimeArray) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, MCM_SETRANGE, dwFlags, (LPARAM)lprgSysTimeArray); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, MCM_SETRANGE, dwFlags, (LPARAM)lprgSysTimeArray); } BOOL GetSelRange(LPSYSTEMTIME lprgSysTimeArray) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, MCM_GETSELRANGE, 0, (LPARAM)lprgSysTimeArray); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, MCM_GETSELRANGE, 0, (LPARAM)lprgSysTimeArray); } BOOL SetSelRange(LPSYSTEMTIME lprgSysTimeArray) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, MCM_SETSELRANGE, 0, (LPARAM)lprgSysTimeArray); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, MCM_SETSELRANGE, 0, (LPARAM)lprgSysTimeArray); } BOOL GetToday(LPSYSTEMTIME lpSysTime) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, MCM_GETTODAY, 0, (LPARAM)lpSysTime); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, MCM_GETTODAY, 0, (LPARAM)lpSysTime); } void SetToday(LPSYSTEMTIME lpSysTime) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, MCM_SETTODAY, 0, (LPARAM)lpSysTime); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, MCM_SETTODAY, 0, (LPARAM)lpSysTime); } BOOL GetMinReqRect(LPRECT lpRectInfo) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, MCM_GETMINREQRECT, 0, (LPARAM)lpRectInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, MCM_GETMINREQRECT, 0, (LPARAM)lpRectInfo); } int GetMaxTodayWidth() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, MCM_GETMAXTODAYWIDTH, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, MCM_GETMAXTODAYWIDTH, 0, 0L); } -#if (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) BOOL GetUnicodeFormat() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, MCM_GETUNICODEFORMAT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, MCM_GETUNICODEFORMAT, 0, 0L); } BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, MCM_SETUNICODEFORMAT, bUnicode, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, MCM_SETUNICODEFORMAT, bUnicode, 0L); } -#endif // (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) #if defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_LONGHORN) DWORD GetCurrentView() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, MCM_GETCURRENTVIEW, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, MCM_GETCURRENTVIEW, 0, 0L); } BOOL SetCurrentView(DWORD dwView) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, MCM_SETCURRENTVIEW, 0, dwView); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, MCM_SETCURRENTVIEW, 0, dwView); } DWORD GetCalendarCount() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, MCM_GETCALENDARCOUNT, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, MCM_GETCALENDARCOUNT, 0, 0L); } BOOL GetCalendarGridInfo(PMCGRIDINFO pGridInfo) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, MCM_GETCALENDARGRIDINFO, 0, (LPARAM)pGridInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, MCM_GETCALENDARGRIDINFO, 0, (LPARAM)pGridInfo); } CALID GetCALID() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (CALID)::SendMessage(m_hWnd, MCM_GETCALID, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (CALID)::SendMessage(this->m_hWnd, MCM_GETCALID, 0, 0L); } void SetCALID(CALID calid) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, MCM_SETCALID, (LPARAM)calid, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, MCM_SETCALID, (LPARAM)calid, 0L); } int GetCalendarBorder() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, MCM_GETCALENDARBORDER, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, MCM_GETCALENDARBORDER, 0, 0L); } void SetCalendarBorder(int cxyBorder, BOOL bSet = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, MCM_SETCALENDARBORDER, (WPARAM)bSet, (LPARAM)cxyBorder); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, MCM_SETCALENDARBORDER, (WPARAM)bSet, (LPARAM)cxyBorder); } #endif // defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_LONGHORN) // Operations int GetMonthRange(DWORD dwFlags, LPSYSTEMTIME lprgSysTimeArray) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, MCM_GETMONTHRANGE, dwFlags, (LPARAM)lprgSysTimeArray); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, MCM_GETMONTHRANGE, dwFlags, (LPARAM)lprgSysTimeArray); } BOOL SetDayState(int nMonths, LPMONTHDAYSTATE lpDayStateArray) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, MCM_SETDAYSTATE, nMonths, (LPARAM)lpDayStateArray); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, MCM_SETDAYSTATE, nMonths, (LPARAM)lpDayStateArray); } DWORD HitTest(PMCHITTESTINFO pMCHitTest) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, MCM_HITTEST, 0, (LPARAM)pMCHitTest); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, MCM_HITTEST, 0, (LPARAM)pMCHitTest); } #if defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_LONGHORN) void SizeRectToMin(LPRECT lpRect) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, MCM_SIZERECTTOMIN, 0, (LPARAM)lpRect); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, MCM_SIZERECTTOMIN, 0, (LPARAM)lpRect); } #endif // defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_LONGHORN) }; @@ -9418,7 +9167,7 @@ public: CDateTimePickerCtrlT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -9437,95 +9186,93 @@ public: BOOL SetFormat(LPCTSTR lpszFormat) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, DTM_SETFORMAT, 0, (LPARAM)lpszFormat); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, DTM_SETFORMAT, 0, (LPARAM)lpszFormat); } COLORREF GetMonthCalColor(int nColorType) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, DTM_GETMCCOLOR, nColorType, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, DTM_GETMCCOLOR, nColorType, 0L); } COLORREF SetMonthCalColor(int nColorType, COLORREF clr) { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, DTM_SETMCCOLOR, nColorType, clr); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, DTM_SETMCCOLOR, nColorType, clr); } DWORD GetRange(LPSYSTEMTIME lpSysTimeArray) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, DTM_GETRANGE, 0, (LPARAM)lpSysTimeArray); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, DTM_GETRANGE, 0, (LPARAM)lpSysTimeArray); } BOOL SetRange(DWORD dwFlags, LPSYSTEMTIME lpSysTimeArray) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, DTM_SETRANGE, dwFlags, (LPARAM)lpSysTimeArray); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, DTM_SETRANGE, dwFlags, (LPARAM)lpSysTimeArray); } DWORD GetSystemTime(LPSYSTEMTIME lpSysTime) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, DTM_GETSYSTEMTIME, 0, (LPARAM)lpSysTime); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, DTM_GETSYSTEMTIME, 0, (LPARAM)lpSysTime); } BOOL SetSystemTime(DWORD dwFlags, LPSYSTEMTIME lpSysTime) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, DTM_SETSYSTEMTIME, dwFlags, (LPARAM)lpSysTime); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, DTM_SETSYSTEMTIME, dwFlags, (LPARAM)lpSysTime); } CMonthCalendarCtrl GetMonthCal() const { - ATLASSERT(::IsWindow(m_hWnd)); - return CMonthCalendarCtrl((HWND)::SendMessage(m_hWnd, DTM_GETMONTHCAL, 0, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CMonthCalendarCtrl((HWND)::SendMessage(this->m_hWnd, DTM_GETMONTHCAL, 0, 0L)); } -#if (_WIN32_IE >= 0x0400) CFontHandle GetMonthCalFont() const { - ATLASSERT(::IsWindow(m_hWnd)); - return CFontHandle((HFONT)::SendMessage(m_hWnd, DTM_GETMCFONT, 0, 0L)); + ATLASSERT(::IsWindow(this->m_hWnd)); + return CFontHandle((HFONT)::SendMessage(this->m_hWnd, DTM_GETMCFONT, 0, 0L)); } void SetMonthCalFont(HFONT hFont, BOOL bRedraw = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, DTM_SETMCFONT, (WPARAM)hFont, MAKELPARAM(bRedraw, 0)); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, DTM_SETMCFONT, (WPARAM)hFont, MAKELPARAM(bRedraw, 0)); } -#endif // (_WIN32_IE >= 0x0400) #if defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_LONGHORN) DWORD GetMonthCalStyle() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, DTM_GETMCSTYLE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, DTM_GETMCSTYLE, 0, 0L); } DWORD SetMonthCalStyle(DWORD dwStyle) { - ATLASSERT(::IsWindow(m_hWnd)); - return (DWORD)::SendMessage(m_hWnd, DTM_SETMCSTYLE, 0, (LPARAM)dwStyle); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, DTM_SETMCSTYLE, 0, (LPARAM)dwStyle); } void GetDateTimePickerInfo(LPDATETIMEPICKERINFO lpPickerInfo) const { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, DTM_GETDATETIMEPICKERINFO, 0, (LPARAM)lpPickerInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, DTM_GETDATETIMEPICKERINFO, 0, (LPARAM)lpPickerInfo); } BOOL GetIdealSize(LPSIZE lpSize) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, DTM_GETIDEALSIZE, 0, (LPARAM)lpSize); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, DTM_GETIDEALSIZE, 0, (LPARAM)lpSize); } void CloseMonthCal() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, DTM_CLOSEMONTHCAL, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, DTM_CLOSEMONTHCAL, 0, 0L); } #endif // defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_LONGHORN) }; @@ -9536,8 +9283,6 @@ typedef CDateTimePickerCtrlT CDateTimePickerCtrl; /////////////////////////////////////////////////////////////////////////////// // CFlatScrollBarImpl - support for flat scroll bars -#if (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) - template class CFlatScrollBarImpl { @@ -9640,21 +9385,17 @@ public: CFlatScrollBarT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } }; typedef CFlatScrollBarT CFlatScrollBar; -#endif // (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) - /////////////////////////////////////////////////////////////////////////////// // CIPAddressCtrl -#if (_WIN32_IE >= 0x0400) - template class CIPAddressCtrlT : public TBase { @@ -9665,7 +9406,7 @@ public: CIPAddressCtrlT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -9684,57 +9425,53 @@ public: BOOL IsBlank() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, IPM_ISBLANK, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, IPM_ISBLANK, 0, 0L); } int GetAddress(LPDWORD lpdwAddress) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, IPM_GETADDRESS, 0, (LPARAM)lpdwAddress); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, IPM_GETADDRESS, 0, (LPARAM)lpdwAddress); } void SetAddress(DWORD dwAddress) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, IPM_SETADDRESS, 0, dwAddress); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, IPM_SETADDRESS, 0, dwAddress); } void ClearAddress() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, IPM_CLEARADDRESS, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, IPM_CLEARADDRESS, 0, 0L); } void SetRange(int nField, WORD wRange) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, IPM_SETRANGE, nField, wRange); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, IPM_SETRANGE, nField, wRange); } void SetRange(int nField, BYTE nMin, BYTE nMax) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, IPM_SETRANGE, nField, MAKEIPRANGE(nMin, nMax)); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, IPM_SETRANGE, nField, MAKEIPRANGE(nMin, nMax)); } void SetFocus(int nField) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, IPM_SETFOCUS, nField, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, IPM_SETFOCUS, nField, 0L); } }; typedef CIPAddressCtrlT CIPAddressCtrl; -#endif // (_WIN32_IE >= 0x0400) - /////////////////////////////////////////////////////////////////////////////// // CPagerCtrl -#if (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) - template class CPagerCtrlT : public TBase { @@ -9745,7 +9482,7 @@ public: CPagerCtrlT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -9764,96 +9501,92 @@ public: int GetButtonSize() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, PGM_GETBUTTONSIZE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, PGM_GETBUTTONSIZE, 0, 0L); } int SetButtonSize(int nButtonSize) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, PGM_SETBUTTONSIZE, 0, nButtonSize); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, PGM_SETBUTTONSIZE, 0, nButtonSize); } DWORD GetButtonState(int nButton) const { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT(nButton == PGB_TOPORLEFT || nButton == PGB_BOTTOMORRIGHT); - return (DWORD)::SendMessage(m_hWnd, PGM_GETBUTTONSTATE, 0, nButton); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((nButton == PGB_TOPORLEFT) || (nButton == PGB_BOTTOMORRIGHT)); + return (DWORD)::SendMessage(this->m_hWnd, PGM_GETBUTTONSTATE, 0, nButton); } COLORREF GetBkColor() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, PGM_GETBKCOLOR, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, PGM_GETBKCOLOR, 0, 0L); } COLORREF SetBkColor(COLORREF clrBk) { - ATLASSERT(::IsWindow(m_hWnd)); - return (COLORREF)::SendMessage(m_hWnd, PGM_SETBKCOLOR, 0, (LPARAM)clrBk); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, PGM_SETBKCOLOR, 0, (LPARAM)clrBk); } int GetBorder() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, PGM_GETBORDER, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, PGM_GETBORDER, 0, 0L); } int SetBorder(int nBorderSize) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, PGM_SETBORDER, 0, nBorderSize); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, PGM_SETBORDER, 0, nBorderSize); } int GetPos() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, PGM_GETPOS, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, PGM_GETPOS, 0, 0L); } int SetPos(int nPos) { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, PGM_SETPOS, 0, nPos); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, PGM_SETPOS, 0, nPos); } // Operations void SetChild(HWND hWndChild) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, PGM_SETCHILD, 0, (LPARAM)hWndChild); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, PGM_SETCHILD, 0, (LPARAM)hWndChild); } void ForwardMouse(BOOL bForward = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, PGM_FORWARDMOUSE, bForward, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, PGM_FORWARDMOUSE, bForward, 0L); } void RecalcSize() { - ATLASSERT(::IsWindow(m_hWnd)); - ::SendMessage(m_hWnd, PGM_RECALCSIZE, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, PGM_RECALCSIZE, 0, 0L); } void GetDropTarget(IDropTarget** ppDropTarget) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(ppDropTarget != NULL); - ::SendMessage(m_hWnd, PGM_GETDROPTARGET, 0, (LPARAM)ppDropTarget); + ::SendMessage(this->m_hWnd, PGM_GETDROPTARGET, 0, (LPARAM)ppDropTarget); } }; typedef CPagerCtrlT CPagerCtrl; -#endif // (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) - /////////////////////////////////////////////////////////////////////////////// // CLinkCtrl - Windows SYSLINK control -#if (_WIN32_WINNT >= 0x0501) && !defined(_WIN32_WCE) - template class CLinkCtrlT : public TBase { @@ -9864,7 +9597,7 @@ public: CLinkCtrlT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -9887,44 +9620,39 @@ public: int GetIdealHeight(int cxMaxWidth = 0) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LM_GETIDEALHEIGHT, cxMaxWidth, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LM_GETIDEALHEIGHT, cxMaxWidth, 0L); } BOOL GetItem(PLITEM pLItem) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LM_GETITEM, 0, (LPARAM)pLItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LM_GETITEM, 0, (LPARAM)pLItem); } BOOL SetItem(PLITEM pLItem) { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LM_SETITEM, 0, (LPARAM)pLItem); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LM_SETITEM, 0, (LPARAM)pLItem); } // Vista only int GetIdealSize(SIZE& size, int cxMaxWidth = 0) const { -#ifndef LM_GETIDEALSIZE - const UINT LM_GETIDEALSIZE = LM_GETIDEALHEIGHT; -#endif - ATLASSERT(::IsWindow(m_hWnd)); - return (int)::SendMessage(m_hWnd, LM_GETIDEALSIZE, cxMaxWidth, (LPARAM)&size); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LM_GETIDEALSIZE, cxMaxWidth, (LPARAM)&size); } // Operations BOOL HitTest(PLHITTESTINFO pLHitTestInfo) const { - ATLASSERT(::IsWindow(m_hWnd)); - return (BOOL)::SendMessage(m_hWnd, LM_HITTEST, 0, (LPARAM)pLHitTestInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LM_HITTEST, 0, (LPARAM)pLHitTestInfo); } }; typedef CLinkCtrlT CLinkCtrl; -#endif // (_WIN32_WINNT >= 0x0501) && !defined(_WIN32_WCE) - /////////////////////////////////////////////////////////////////////////////// // CCustomDraw - MI class for custom-draw support @@ -9933,20 +9661,6 @@ template class CCustomDraw { public: -#if (_ATL_VER < 0x0700) - BOOL m_bHandledCD; - - BOOL IsMsgHandled() const - { - return m_bHandledCD; - } - - void SetMsgHandled(BOOL bHandled) - { - m_bHandledCD = bHandled; - } -#endif // !(_ATL_VER < 0x0700) - // Message map and handlers BEGIN_MSG_MAP(CCustomDraw< T >) NOTIFY_CODE_HANDLER(NM_CUSTOMDRAW, OnCustomDraw) @@ -9987,11 +9701,9 @@ public: case CDDS_ITEMPOSTERASE: dwRet = pT->OnItemPostErase(idCtrl, lpNMCustomDraw); break; -#if (_WIN32_IE >= 0x0400) case (CDDS_ITEMPREPAINT | CDDS_SUBITEM): dwRet = pT->OnSubItemPrePaint(idCtrl, lpNMCustomDraw); break; -#endif // (_WIN32_IE >= 0x0400) default: pT->SetMsgHandled(FALSE); break; @@ -10041,212 +9753,12 @@ public: return CDRF_DODEFAULT; } -#if (_WIN32_IE >= 0x0400) DWORD OnSubItemPrePaint(int /*idCtrl*/, LPNMCUSTOMDRAW /*lpNMCustomDraw*/) { return CDRF_DODEFAULT; } -#endif // (_WIN32_IE >= 0x0400) }; - -// --- Windows CE common controls --- - -#ifdef _WIN32_WCE - -/////////////////////////////////////////////////////////////////////////////// -// CCECommandBarCtrl - -template -class CCECommandBarCtrlT : public TBase -{ -public: -// Constructors - CCECommandBarCtrlT(HWND hWnd = NULL) : TBase(hWnd) { } - - CCECommandBarCtrlT< TBase >& operator=(HWND hWnd) - { - m_hWnd = hWnd; - return *this; - } - -// Attributes - BOOL IsVisible() const - { - return IsWindowVisible(); - } - - int GetHeight() const - { - ATLASSERT(::IsWindow(m_hWnd)); - return ::CommandBar_Height(m_hWnd); - } - - HMENU GetMenu(WORD wButton) const - { - ATLASSERT(::IsWindow(m_hWnd)); - return ::CommandBar_GetMenu(m_hWnd, wButton); - } - -// Operations - HWND Create(HWND hWndParent, int nCmdBarID) - { - m_hWnd = ::CommandBar_Create(ModuleHelper::GetModuleInstance(), hWndParent, nCmdBarID); - ATLASSERT(::IsWindow(m_hWnd)); - return m_hWnd; - } - - void Destroy() - { - DestroyWindow(); - } - - BOOL Show(BOOL bShow = TRUE) - { - ATLASSERT(::IsWindow(m_hWnd)); - return ::CommandBar_Show(m_hWnd, bShow); - } - - BOOL DrawMenuBar(WORD wButton) - { - ATLASSERT(::IsWindow(m_hWnd)); - return ::CommandBar_DrawMenuBar(m_hWnd, wButton); - } - - BOOL AddAdornments(DWORD dwFlags = 0) - { - ATLASSERT(::IsWindow(m_hWnd)); - return ::CommandBar_AddAdornments(m_hWnd, dwFlags, 0); - } - - int AddBitmap(int nBitmapID, int nNumImages) - { - ATLASSERT(::IsWindow(m_hWnd)); - return ::CommandBar_AddBitmap(m_hWnd, ModuleHelper::GetResourceInstance(), nBitmapID, nNumImages, 16, 16); - } - - BOOL AddButtons(UINT uNumButtons, LPTBBUTTON lpButtons) - { - ATLASSERT(::IsWindow(m_hWnd)); - return CommandBar_AddButtons(m_hWnd, uNumButtons, lpButtons); - } - - BOOL AddToolTips(UINT uNumToolTips, LPTSTR lpToolTips) - { - ATLASSERT(::IsWindow(m_hWnd)); - return CommandBar_AddToolTips(m_hWnd, uNumToolTips, lpToolTips); - } - - BOOL InsertButton(int nButton, LPTBBUTTON lpButton) - { - ATLASSERT(::IsWindow(m_hWnd)); - return CommandBar_InsertButton(m_hWnd, nButton, lpButton); - } - - HWND InsertComboBox(int nWidth, UINT dwStyle, WORD wComboBoxID, WORD wButton) - { - ATLASSERT(::IsWindow(m_hWnd)); - return ::CommandBar_InsertComboBox(m_hWnd, ModuleHelper::GetModuleInstance(), nWidth, dwStyle, wComboBoxID, wButton); - } - - BOOL InsertMenubar(WORD wMenuID, WORD wButton) - { - ATLASSERT(::IsWindow(m_hWnd)); - return ::CommandBar_InsertMenubar(m_hWnd, ModuleHelper::GetResourceInstance(), wMenuID, wButton); - } - - BOOL InsertMenubarEx(ATL::_U_STRINGorID menu, WORD wButton) - { - ATLASSERT(::IsWindow(m_hWnd)); - return ::CommandBar_InsertMenubarEx(m_hWnd, ModuleHelper::GetResourceInstance(), (LPTSTR)menu.m_lpstr, wButton); - } - - BOOL IsCommandBarMessage(LPMSG lpMsg) - { - ATLASSERT(::IsWindow(m_hWnd)); - return ::IsCommandBarMessage(m_hWnd, lpMsg); - } -}; - -#if defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) // PPC MenuBar - typedef CCECommandBarCtrlT CMenuBarCtrl; -#else - typedef CCECommandBarCtrlT CCECommandBarCtrl; -#endif // defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) - -/////////////////////////////////////////////////////////////////////////////// -// CCECommandBandsCtrl - -template -class CCECommandBandsCtrlT : public TBase -{ -public: -// Constructors - CCECommandBandsCtrlT(HWND hWnd = NULL) : TBase(hWnd) { } - - CCECommandBandsCtrlT< TBase >& operator=(HWND hWnd) - { - m_hWnd = hWnd; - return *this; - } - -// Attributes - BOOL IsVisible() const - { - return IsWindowVisible(); - } - -#if (_WIN32_IE >= 0x0400) - UINT GetHeight() const - { - ATLASSERT(::IsWindow(m_hWnd)); - return CommandBands_Height(m_hWnd); - } -#endif // (_WIN32_IE >= 0x0400) - - HWND GetCommandBar(UINT uBand) const - { - ATLASSERT(::IsWindow(m_hWnd)); - return ::CommandBands_GetCommandBar(m_hWnd, uBand); - } - - BOOL GetRestoreInformation(UINT uBand, LPCOMMANDBANDSRESTOREINFO pcbr) const - { - ATLASSERT(::IsWindow(m_hWnd)); - return ::CommandBands_GetRestoreInformation(m_hWnd, uBand, pcbr); - } - -// Operations - HWND Create(HWND hWndParent, UINT wID, DWORD dwStyles, HIMAGELIST hImageList = NULL) - { - m_hWnd = ::CommandBands_Create(ModuleHelper::GetModuleInstance(), hWndParent, wID, dwStyles, hImageList); - ATLASSERT(::IsWindow(m_hWnd)); - return m_hWnd; - } - - BOOL AddAdornments(DWORD dwFlags = 0, LPREBARBANDINFO prbbi = NULL) - { - ATLASSERT(::IsWindow(m_hWnd)); - return ::CommandBands_AddAdornments(m_hWnd, ModuleHelper::GetModuleInstance(), dwFlags, prbbi); - } - - BOOL AddBands(UINT uBandCount, LPREBARBANDINFO prbbi) - { - ATLASSERT(::IsWindow(m_hWnd)); - return ::CommandBands_AddBands(m_hWnd, ModuleHelper::GetModuleInstance(), uBandCount, prbbi); - } - - BOOL Show(BOOL bShow = TRUE) - { - ATLASSERT(::IsWindow(m_hWnd)); - return ::CommandBands_Show(m_hWnd, bShow); - } -}; - -typedef CCECommandBandsCtrlT CCECommandBandsCtrl; - -#endif // _WIN32_WCE - -}; // namespace WTL +} // namespace WTL #endif // __ATLCTRLS_H__ diff --git a/ZbaSDK/SampleCode/PluginWinExe/WTL/atlctrlw.h b/ZbaSDK/SampleCode/PluginWinExe/WTL/atlctrlw.h index 0984551fed49c69a126b59fa8981df7190c358ec..73cac9f50324e52bb4139f46627b9ab25cde2600 100644 --- a/ZbaSDK/SampleCode/PluginWinExe/WTL/atlctrlw.h +++ b/ZbaSDK/SampleCode/PluginWinExe/WTL/atlctrlw.h @@ -1,4 +1,4 @@ -// Windows Template Library - WTL version 9.10 +// Windows Template Library - WTL version 10.0 // Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. // // This file is a part of the Windows Template Library. @@ -11,10 +11,6 @@ #pragma once -#ifdef _WIN32_WCE - #error atlctrlw.h is not supported on Windows CE -#endif - #ifndef __ATLAPP_H__ #error atlctrlw.h requires atlapp.h to be included first #endif @@ -23,21 +19,11 @@ #error atlctrlw.h requires atlctrls.h to be included first #endif -#if (_WIN32_IE < 0x0400) - #error atlctrlw.h requires _WIN32_IE >= 0x0400 -#endif - // Define _WTL_CMDBAR_VISTA_MENUS as 0 to exclude Vista menus support -#if !defined(_WTL_CMDBAR_VISTA_MENUS) && (WINVER >= 0x0500) && (_WIN32_WINNT >= 0x0501) && (_WIN32_IE >= 0x0501) +#ifndef _WTL_CMDBAR_VISTA_MENUS #define _WTL_CMDBAR_VISTA_MENUS 1 #endif -#if _WTL_CMDBAR_VISTA_MENUS - #if !((_WIN32_WINNT >= 0x0501) && (_WIN32_IE >= 0x0501)) - #error _WTL_CMDBAR_VISTA_MENUS requires (_WIN32_WINNT >= 0x0501) && (_WIN32_IE >= 0x0501) - #endif -#endif - // Note: Define _WTL_CMDBAR_VISTA_STD_MENUBAR to use Vista standard menubar look with Vista menus @@ -99,29 +85,29 @@ public: #ifdef _CMDBAR_EXTRA_TRACE ATLTRACE2(atlTraceUI, 0, _T("CmdBar - STACK-PUSH (%8.8X) size = %i\n"), t, GetSize()); #endif - return Add(t); + return this->Add(t); } T Pop() { - int nLast = GetSize() - 1; + int nLast = this->GetSize() - 1; if(nLast < 0) return NULL; // must be able to convert to NULL - T t = m_aT[nLast]; + T t = this->m_aT[nLast]; #ifdef _CMDBAR_EXTRA_TRACE ATLTRACE2(atlTraceUI, 0, _T("CmdBar - STACK-POP (%8.8X) size = %i\n"), t, GetSize()); #endif - if(!RemoveAt(nLast)) + if(!this->RemoveAt(nLast)) return NULL; return t; } T GetCurrent() { - int nLast = GetSize() - 1; + int nLast = this->GetSize() - 1; if(nLast < 0) return NULL; // must be able to convert to NULL - return m_aT[nLast]; + return this->m_aT[nLast]; } }; @@ -145,7 +131,6 @@ public: static CMsgHookMap* s_pmapMsgHook; static HHOOK s_hCreateHook; - static bool s_bW2K; // For animation flag static CCommandBarCtrlBase* s_pCurrentBar; static bool s_bStaticInit; @@ -173,8 +158,6 @@ public: { // Just in case... AtlInitCommonControls(ICC_COOL_CLASSES | ICC_BAR_CLASSES); - // Animation on Win2000 only - s_bW2K = !AtlIsOldWindows(); // done s_bStaticInit = true; } @@ -189,7 +172,6 @@ public: __declspec(selectany) CCommandBarCtrlBase::CMsgHookMap* CCommandBarCtrlBase::s_pmapMsgHook = NULL; __declspec(selectany) HHOOK CCommandBarCtrlBase::s_hCreateHook = NULL; __declspec(selectany) CCommandBarCtrlBase* CCommandBarCtrlBase::s_pCurrentBar = NULL; -__declspec(selectany) bool CCommandBarCtrlBase::s_bW2K = false; __declspec(selectany) bool CCommandBarCtrlBase::s_bStaticInit = false; @@ -200,7 +182,7 @@ template { public: - DECLARE_WND_SUPERCLASS(NULL, TBase::GetWndClassName()) + DECLARE_WND_SUPERCLASS2(NULL, T, TBase::GetWndClassName()) // Declarations struct _MenuItemData // menu item data @@ -211,7 +193,9 @@ public: UINT fState; int iButton; - _MenuItemData() { dwMagic = 0x1313; } + _MenuItemData() : dwMagic(0x1313), lpstrText(NULL), fType(0U), fState(0U), iButton(0) + { } + bool IsCmdBarMenuItem() { return (dwMagic == 0x1313); } }; @@ -242,10 +226,6 @@ public: _chChevronShortcut = _T('/') }; -#ifndef DT_HIDEPREFIX - enum { DT_HIDEPREFIX = 0x00100000 }; -#endif // !DT_HIDEPREFIX - // Data members HMENU m_hMenu; HIMAGELIST m_hImageList; @@ -296,31 +276,31 @@ public: CCommandBarCtrlImpl() : m_hMenu(NULL), m_hImageList(NULL), - m_wndParent(this, 1), + m_dwExtendedStyle(CBR_EX_TRANSPARENT | CBR_EX_SHAREMENU | CBR_EX_TRACKALWAYS), + m_wndParent(this, 1), m_bMenuActive(false), m_bAttachedMenu(false), - m_nPopBtn(-1), - m_nNextPopBtn(-1), - m_bPopupItem(false), m_bImagesVisible(true), - m_bSkipMsg(false), - m_uSysKey(0), - m_hWndFocus(NULL), + m_bPopupItem(false), m_bContextMenu(false), m_bEscapePressed(false), - m_clrMask(RGB(192, 192, 192)), - m_dwExtendedStyle(CBR_EX_TRANSPARENT | CBR_EX_SHAREMENU | CBR_EX_TRACKALWAYS), + m_bSkipMsg(false), m_bParentActive(true), m_bFlatMenus(false), m_bUseKeyboardCues(false), m_bShowKeyboardCues(false), m_bAllowKeyboardCues(true), m_bKeyboardInput(false), - m_cxExtraSpacing(0), m_bAlphaImages(false), m_bLayoutRTL(false), m_bSkipPostDown(false), - m_bVistaMenus(false) + m_bVistaMenus(false), + m_nPopBtn(-1), + m_nNextPopBtn(-1), + m_clrMask(RGB(192, 192, 192)), + m_uSysKey(0), + m_hWndFocus(NULL), + m_cxExtraSpacing(0) { SetImageSize(16, 15); // default } @@ -330,7 +310,7 @@ public: if(m_wndParent.IsWindow()) /*scary!*/ m_wndParent.UnsubclassWindow(); - if(m_hMenu != NULL && (m_dwExtendedStyle & CBR_EX_SHAREMENU) == 0) + if((m_hMenu != NULL) && ((m_dwExtendedStyle & CBR_EX_SHAREMENU) == 0)) ::DestroyMenu(m_hMenu); if(m_hImageList != NULL) @@ -355,7 +335,7 @@ public: CMenuHandle GetMenu() const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); return m_hMenu; } @@ -408,7 +388,7 @@ public: } } - if(cx == 0 || cy == 0) + if((cx == 0) || (cy == 0)) return false; m_szBitmap.cx = cx; @@ -445,8 +425,8 @@ public: HWND GetCmdBar() const { - ATLASSERT(::IsWindow(m_hWnd)); - return (HWND)::SendMessage(m_hWnd, CBRM_GETCMDBAR, 0, 0L); + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HWND)::SendMessage(this->m_hWnd, CBRM_GETCMDBAR, 0, 0L); } // Methods @@ -456,19 +436,14 @@ public: { // These styles are required for command bars dwStyle |= TBSTYLE_LIST | TBSTYLE_FLAT; -#if (_MSC_VER >= 1300) return ATL::CWindowImpl< T, TBase, TWinTraits >::Create(hWndParent, rcPos, szWindowName, dwStyle, dwExStyle, nID, lpCreateParam); -#else // !(_MSC_VER >= 1300) - typedef ATL::CWindowImpl< T, TBase, TWinTraits > _baseClass; - return _baseClass::Create(hWndParent, rcPos, szWindowName, dwStyle, dwExStyle, nID, lpCreateParam); -#endif // !(_MSC_VER >= 1300) } BOOL AttachToWindow(HWND hWnd) { - ATLASSERT(m_hWnd == NULL); + ATLASSERT(this->m_hWnd == NULL); ATLASSERT(::IsWindow(hWnd)); - BOOL bRet = SubclassWindow(hWnd); + BOOL bRet = this->SubclassWindow(hWnd); if(bRet) { m_bAttachedMenu = true; @@ -480,7 +455,7 @@ public: BOOL LoadMenu(ATL::_U_STRINGorID menu) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); if(m_bAttachedMenu) // doesn't work in this mode return FALSE; @@ -496,9 +471,9 @@ public: BOOL AttachMenu(HMENU hMenu) { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT(hMenu == NULL || ::IsMenu(hMenu)); - if(hMenu != NULL && !::IsMenu(hMenu)) + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((hMenu == NULL) || ::IsMenu(hMenu)); + if((hMenu != NULL) && !::IsMenu(hMenu)) return FALSE; #if _WTL_CMDBAR_VISTA_MENUS @@ -511,7 +486,7 @@ public: #endif // _WTL_CMDBAR_VISTA_MENUS // destroy old menu, if needed, and set new one - if(m_hMenu != NULL && (m_dwExtendedStyle & CBR_EX_SHAREMENU) == 0) + if((m_hMenu != NULL) && ((m_dwExtendedStyle & CBR_EX_SHAREMENU) == 0)) ::DestroyMenu(m_hMenu); m_hMenu = hMenu; @@ -520,12 +495,12 @@ public: return TRUE; // Build buttons according to menu - SetRedraw(FALSE); + this->SetRedraw(FALSE); // Clear all buttons - int nCount = GetButtonCount(); + int nCount = this->GetButtonCount(); for(int i = 0; i < nCount; i++) - ATLVERIFY(DeleteButton(0) != FALSE); + ATLVERIFY(this->DeleteButton(0) != FALSE); // Add buttons for each menu item if(m_hMenu != NULL) @@ -533,8 +508,8 @@ public: int nItems = ::GetMenuItemCount(m_hMenu); T* pT = static_cast(this); - pT; // avoid level 4 warning - TCHAR szString[pT->_nMaxMenuItemTextLength] = { 0 }; + (void)pT; // avoid level 4 warning + TCHAR szString[pT->_nMaxMenuItemTextLength] = {}; for(int i = 0; i < nItems; i++) { CMenuItemInfo mii; @@ -555,7 +530,7 @@ public: // NOTE: Command Bar currently supports only drop-down menu items ATLASSERT(mii.hSubMenu != NULL); - TBBUTTON btn = { 0 }; + TBBUTTON btn = {}; btn.iBitmap = 0; btn.idCommand = i; btn.fsState = (BYTE)(((mii.fState & MFS_DISABLED) == 0) ? TBSTATE_ENABLED : 0); @@ -563,22 +538,22 @@ public: btn.dwData = 0; btn.iString = 0; - bRet = InsertButton(-1, &btn); + bRet = this->InsertButton(-1, &btn); ATLASSERT(bRet); - TBBUTTONINFO bi = { 0 }; + TBBUTTONINFO bi = {}; bi.cbSize = sizeof(TBBUTTONINFO); bi.dwMask = TBIF_TEXT; bi.pszText = szString; - bRet = SetButtonInfo(i, &bi); + bRet = this->SetButtonInfo(i, &bi); ATLASSERT(bRet); } } - SetRedraw(TRUE); - Invalidate(); - UpdateWindow(); + this->SetRedraw(TRUE); + this->Invalidate(); + this->UpdateWindow(); return TRUE; } @@ -595,7 +570,7 @@ public: BOOL _LoadImagesHelper(ATL::_U_STRINGorID image, bool bMapped, UINT nFlags = 0, LPCOLORMAP lpColorMap = NULL, int nMapSize = 0) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); HINSTANCE hInstance = ModuleHelper::GetResourceInstance(); HRSRC hRsrc = ::FindResource(hInstance, image.m_lpstr, (LPTSTR)RT_TOOLBAR); @@ -679,7 +654,7 @@ public: BOOL AddBitmap(ATL::_U_STRINGorID bitmap, int nCommandID) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); CBitmap bmp; bmp.LoadBitmap(bitmap.m_lpstr); if(bmp.m_hBitmap == NULL) @@ -689,7 +664,7 @@ public: BOOL AddBitmap(HBITMAP hBitmap, UINT nCommandID) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); T* pT = static_cast(this); // Create image list if it doesn't exist if(m_hImageList == NULL) @@ -699,9 +674,9 @@ public: } // check bitmap size CBitmapHandle bmp = hBitmap; - SIZE size = { 0, 0 }; + SIZE size = {}; bmp.GetSize(size); - if(size.cx != m_szBitmap.cx || size.cy != m_szBitmap.cy) + if((size.cx != m_szBitmap.cx) || (size.cy != m_szBitmap.cy)) { ATLASSERT(FALSE); // must match size! return FALSE; @@ -724,7 +699,7 @@ public: BOOL AddIcon(ATL::_U_STRINGorID icon, UINT nCommandID) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); HICON hIcon = ::LoadIcon(ModuleHelper::GetResourceInstance(), icon.m_lpstr); if(hIcon == NULL) return FALSE; @@ -733,7 +708,7 @@ public: BOOL AddIcon(HICON hIcon, UINT nCommandID) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); T* pT = static_cast(this); // create image list if it doesn't exist if(m_hImageList == NULL) @@ -759,7 +734,7 @@ public: BOOL ReplaceBitmap(ATL::_U_STRINGorID bitmap, int nCommandID) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); CBitmap bmp; bmp.LoadBitmap(bitmap.m_lpstr); if(bmp.m_hBitmap == NULL) @@ -769,7 +744,7 @@ public: BOOL ReplaceBitmap(HBITMAP hBitmap, UINT nCommandID) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); BOOL bRet = FALSE; for(int i = 0; i < m_arrCommand.GetSize(); i++) { @@ -798,7 +773,7 @@ public: BOOL ReplaceIcon(ATL::_U_STRINGorID icon, UINT nCommandID) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); HICON hIcon = ::LoadIcon(ModuleHelper::GetResourceInstance(), icon.m_lpstr); if(hIcon == NULL) return FALSE; @@ -807,7 +782,7 @@ public: BOOL ReplaceIcon(HICON hIcon, UINT nCommandID) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); BOOL bRet = FALSE; for(int i = 0; i < m_arrCommand.GetSize(); i++) { @@ -815,7 +790,7 @@ public: { bRet = (::ImageList_ReplaceIcon(m_hImageList, i, hIcon) != -1); #if _WTL_CMDBAR_VISTA_MENUS - if(RunTimeHelper::IsVista() && bRet != FALSE) + if(RunTimeHelper::IsVista() && (bRet != FALSE)) { T* pT = static_cast(this); pT->_ReplaceVistaBitmapFromImageList(i); @@ -829,7 +804,7 @@ public: BOOL RemoveImage(int nCommandID) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); BOOL bRet = FALSE; for(int i = 0; i < m_arrCommand.GetSize(); i++) @@ -857,7 +832,7 @@ public: BOOL RemoveAllImages() { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLTRACE2(atlTraceUI, 0, _T("CmdBar - Removing all images\n")); BOOL bRet = ::ImageList_RemoveAll(m_hImageList); @@ -878,7 +853,7 @@ public: BOOL TrackPopupMenu(HMENU hMenu, UINT uFlags, int x, int y, LPTPMPARAMS lpParams = NULL) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(::IsMenu(hMenu)); if(!::IsMenu(hMenu)) return FALSE; @@ -957,9 +932,9 @@ public: LRESULT OnForwardMsg(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/) { LPMSG pMsg = (LPMSG)lParam; - if(pMsg->message >= WM_MOUSEFIRST && pMsg->message <= WM_MOUSELAST) + if((pMsg->message >= WM_MOUSEFIRST) && (pMsg->message <= WM_MOUSELAST)) m_bKeyboardInput = false; - else if(pMsg->message >= WM_KEYFIRST && pMsg->message <= WM_KEYLAST) + else if((pMsg->message >= WM_KEYFIRST) && (pMsg->message <= WM_KEYLAST)) m_bKeyboardInput = true; LRESULT lRet = 0; ProcessWindowMessage(pMsg->hwnd, pMsg->message, pMsg->wParam, pMsg->lParam, lRet, 3); @@ -969,17 +944,17 @@ public: LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) { // Let the toolbar initialize itself - LRESULT lRet = DefWindowProc(uMsg, wParam, lParam); + LRESULT lRet = this->DefWindowProc(uMsg, wParam, lParam); // get and use system settings T* pT = static_cast(this); pT->GetSystemSettings(); // Parent init - ATL::CWindow wndParent = GetParent(); + ATL::CWindow wndParent = this->GetParent(); ATL::CWindow wndTopLevelParent = wndParent.GetTopLevelParent(); m_wndParent.SubclassWindow(wndTopLevelParent); // Toolbar Init - SetButtonStructSize(); - SetImageList(NULL); + this->SetButtonStructSize(); + this->SetImageList(NULL); // Create message hook if needed CWindowCreateCriticalSectionLock lock; @@ -990,28 +965,28 @@ public: return -1; } - if(s_pmapMsgHook == NULL) + if(this->s_pmapMsgHook == NULL) { - ATLTRY(s_pmapMsgHook = new CMsgHookMap); - ATLASSERT(s_pmapMsgHook != NULL); + ATLTRY(this->s_pmapMsgHook = new CCommandBarCtrlBase::CMsgHookMap); + ATLASSERT(this->s_pmapMsgHook != NULL); } - if(s_pmapMsgHook != NULL) + if(this->s_pmapMsgHook != NULL) { DWORD dwThreadID = ::GetCurrentThreadId(); - _MsgHookData* pData = s_pmapMsgHook->Lookup(dwThreadID); + CCommandBarCtrlBase::_MsgHookData* pData = this->s_pmapMsgHook->Lookup(dwThreadID); if(pData == NULL) { - ATLTRY(pData = new _MsgHookData); + ATLTRY(pData = new CCommandBarCtrlBase::_MsgHookData); ATLASSERT(pData != NULL); HHOOK hMsgHook = ::SetWindowsHookEx(WH_GETMESSAGE, MessageHookProc, ModuleHelper::GetModuleInstance(), dwThreadID); ATLASSERT(hMsgHook != NULL); - if(pData != NULL && hMsgHook != NULL) + if((pData != NULL) && (hMsgHook != NULL)) { pData->hMsgHook = hMsgHook; pData->dwUsage = 1; - BOOL bRet = s_pmapMsgHook->Add(dwThreadID, pData); - bRet; + BOOL bRet = this->s_pmapMsgHook->Add(dwThreadID, pData); + (void)bRet; // avoid level 4 warning ATLASSERT(bRet); } } @@ -1023,16 +998,14 @@ public: lock.Unlock(); // Get layout -#if (WINVER >= 0x0500) - m_bLayoutRTL = ((GetExStyle() & WS_EX_LAYOUTRTL) != 0); -#endif // (WINVER >= 0x0500) + m_bLayoutRTL = ((this->GetExStyle() & WS_EX_LAYOUTRTL) != 0); return lRet; } LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) { - LRESULT lRet = DefWindowProc(uMsg, wParam, lParam); + LRESULT lRet = this->DefWindowProc(uMsg, wParam, lParam); #if _WTL_CMDBAR_VISTA_MENUS if(m_bVistaMenus && (m_hMenu != NULL)) @@ -1059,10 +1032,10 @@ public: return lRet; } - if(s_pmapMsgHook != NULL) + if(this->s_pmapMsgHook != NULL) { DWORD dwThreadID = ::GetCurrentThreadId(); - _MsgHookData* pData = s_pmapMsgHook->Lookup(dwThreadID); + CCommandBarCtrlBase::_MsgHookData* pData = this->s_pmapMsgHook->Lookup(dwThreadID); if(pData != NULL) { (pData->dwUsage)--; @@ -1070,16 +1043,16 @@ public: { BOOL bRet = ::UnhookWindowsHookEx(pData->hMsgHook); ATLASSERT(bRet); - bRet = s_pmapMsgHook->Remove(dwThreadID); + bRet = this->s_pmapMsgHook->Remove(dwThreadID); ATLASSERT(bRet); if(bRet) delete pData; } - if(s_pmapMsgHook->GetSize() == 0) + if(this->s_pmapMsgHook->GetSize() == 0) { - delete s_pmapMsgHook; - s_pmapMsgHook = NULL; + delete this->s_pmapMsgHook; + this->s_pmapMsgHook = NULL; } } } @@ -1107,25 +1080,23 @@ public: m_wndParent.PostMessage(WM_SYSKEYDOWN, wParam, lParam | (1 << 29)); bHandled = TRUE; } -#if (_WIN32_IE >= 0x0500) - else if(wParam == VK_LEFT || wParam == VK_RIGHT) + else if((wParam == VK_LEFT) || (wParam == VK_RIGHT)) { WPARAM wpNext = m_bLayoutRTL ? VK_LEFT : VK_RIGHT; if(!m_bMenuActive) { T* pT = static_cast(this); - int nBtn = GetHotItem(); + int nBtn = this->GetHotItem(); int nNextBtn = (wParam == wpNext) ? pT->GetNextMenuItem(nBtn) : pT->GetPreviousMenuItem(nBtn); if(nNextBtn == -2) { - SetHotItem(-1); + this->SetHotItem(-1); if(pT->DisplayChevronMenu()) bHandled = TRUE; } } } -#endif // (_WIN32_IE >= 0x0500) return 0; } @@ -1162,41 +1133,35 @@ public: else return 0; // Security - if(!m_wndParent.IsWindowEnabled() || ::GetFocus() != m_hWnd) + if(!m_wndParent.IsWindowEnabled() || (::GetFocus() != this->m_hWnd)) return 0; // Handle mnemonic press when we have focus int nBtn = 0; - if(wParam != VK_RETURN && !MapAccelerator((TCHAR)LOWORD(wParam), nBtn)) + if((wParam != VK_RETURN) && !this->MapAccelerator((TCHAR)LOWORD(wParam), nBtn)) { -#if (_WIN32_IE >= 0x0500) if((TCHAR)LOWORD(wParam) != _chChevronShortcut) -#endif // (_WIN32_IE >= 0x0500) ::MessageBeep(0); } else { -#if (_WIN32_IE >= 0x0500) - RECT rcClient = { 0 }; - GetClientRect(&rcClient); - RECT rcBtn = { 0 }; - GetItemRect(nBtn, &rcBtn); - TBBUTTON tbb = { 0 }; - GetButton(nBtn, &tbb); - if((tbb.fsState & TBSTATE_ENABLED) != 0 && (tbb.fsState & TBSTATE_HIDDEN) == 0 && rcBtn.right <= rcClient.right) + RECT rcClient = {}; + this->GetClientRect(&rcClient); + RECT rcBtn = {}; + this->GetItemRect(nBtn, &rcBtn); + TBBUTTON tbb = {}; + this->GetButton(nBtn, &tbb); + if(((tbb.fsState & TBSTATE_ENABLED) != 0) && ((tbb.fsState & TBSTATE_HIDDEN) == 0) && (rcBtn.right <= rcClient.right)) { -#endif // (_WIN32_IE >= 0x0500) - PostMessage(WM_KEYDOWN, VK_DOWN, 0L); + this->PostMessage(WM_KEYDOWN, VK_DOWN, 0L); if(wParam != VK_RETURN) - SetHotItem(nBtn); -#if (_WIN32_IE >= 0x0500) + this->SetHotItem(nBtn); } else { ::MessageBeep(0); bHandled = TRUE; } -#endif // (_WIN32_IE >= 0x0500) } return 0; } @@ -1237,8 +1202,8 @@ public: } CDCHandle dc = (HDC)wParam; - RECT rect = { 0 }; - GetClientRect(&rect); + RECT rect = {}; + this->GetClientRect(&rect); dc.FillRect(&rect, COLOR_MENU); return 1; // don't do the default erase @@ -1246,8 +1211,8 @@ public: LRESULT OnInitMenu(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) { - int nIndex = GetHotItem(); - SendMessage(WM_MENUSELECT, MAKEWPARAM(nIndex, MF_POPUP|MF_HILITE), (LPARAM)m_hMenu); + int nIndex = this->GetHotItem(); + this->SendMessage(WM_MENUSELECT, MAKEWPARAM(nIndex, MF_POPUP|MF_HILITE), (LPARAM)m_hMenu); bHandled = FALSE; return 1; } @@ -1272,9 +1237,9 @@ public: // forward to the parent or subclassed window, so it can handle update UI LRESULT lRet = 0; if(m_bAttachedMenu) - lRet = DefWindowProc(uMsg, wParam, (lParam || m_bContextMenu) ? lParam : GetHotItem()); + lRet = this->DefWindowProc(uMsg, wParam, (lParam || m_bContextMenu) ? lParam : this->GetHotItem()); else - lRet = m_wndParent.DefWindowProc(uMsg, wParam, (lParam || m_bContextMenu) ? lParam : GetHotItem()); + lRet = m_wndParent.DefWindowProc(uMsg, wParam, (lParam || m_bContextMenu) ? lParam : this->GetHotItem()); #if _WTL_CMDBAR_VISTA_MENUS // If Vista menus are active, just set bitmaps and return @@ -1305,8 +1270,8 @@ public: ATLASSERT(menuPopup.m_hMenu != NULL); T* pT = static_cast(this); - pT; // avoid level 4 warning - TCHAR szString[pT->_nMaxMenuItemTextLength] = { 0 }; + (void)pT; // avoid level 4 warning + TCHAR szString[pT->_nMaxMenuItemTextLength] = {}; BOOL bRet = FALSE; for(int i = 0; i < menuPopup.GetMenuItemCount(); i++) { @@ -1342,7 +1307,7 @@ public: ATLTRY(pMI->lpstrText = new TCHAR[cchLen]); ATLASSERT(pMI->lpstrText != NULL); if(pMI->lpstrText != NULL) - SecureHelper::strcpy_x(pMI->lpstrText, cchLen, szString); + ATL::Checked::tcscpy_s(pMI->lpstrText, cchLen, szString); mii.dwItemData = (ULONG_PTR)pMI; bRet = menuPopup.SetMenuItemInfo(i, TRUE, &mii); ATLASSERT(bRet); @@ -1351,7 +1316,7 @@ public: } // Add it to the list - m_stackMenuHandle.Push(menuPopup.m_hMenu); + this->m_stackMenuHandle.Push(menuPopup.m_hMenu); } return lRet; @@ -1369,17 +1334,17 @@ public: } // Check if a menu is closing, do a cleanup - if(HIWORD(wParam) == 0xFFFF && lParam == NULL) // Menu closing + if((HIWORD(wParam) == 0xFFFF) && (lParam == NULL)) // Menu closing { #ifdef _CMDBAR_EXTRA_TRACE ATLTRACE2(atlTraceUI, 0, _T("CmdBar - OnMenuSelect - CLOSING!!!!\n")); #endif - ATLASSERT(m_stackMenuWnd.GetSize() == 0); + ATLASSERT(this->m_stackMenuWnd.GetSize() == 0); // Restore the menu items to the previous state for all menus that were converted if(m_bImagesVisible) { HMENU hMenu = NULL; - while((hMenu = m_stackMenuHandle.Pop()) != NULL) + while((hMenu = this->m_stackMenuHandle.Pop()) != NULL) { CMenuHandle menuPopup = hMenu; ATLASSERT(menuPopup.m_hMenu != NULL); @@ -1393,7 +1358,7 @@ public: ATLASSERT(bRet); _MenuItemData* pMI = (_MenuItemData*)mii.dwItemData; - if(pMI != NULL && pMI->IsCmdBarMenuItem()) + if(_IsValidMem(pMI) && pMI->IsCmdBarMenuItem()) { mii.fMask = MIIM_DATA | MIIM_TYPE | MIIM_STATE; mii.fType = pMI->fType; @@ -1430,7 +1395,7 @@ public: // Let's make sure we're not embedded in another process if((LPVOID)wParam != NULL) *((DWORD*)wParam) = GetCurrentProcessId(); - if(IsWindowVisible()) + if(this->IsWindowVisible()) return (LRESULT)static_cast(this); else return NULL; @@ -1438,14 +1403,7 @@ public: LRESULT OnSettingChange(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) { -#ifndef SPI_SETKEYBOARDCUES - const UINT SPI_SETKEYBOARDCUES = 0x100B; -#endif // !SPI_SETKEYBOARDCUES -#ifndef SPI_GETFLATMENU - const UINT SPI_SETFLATMENU = 0x1023; -#endif // !SPI_GETFLATMENU - - if(wParam == SPI_SETNONCLIENTMETRICS || wParam == SPI_SETKEYBOARDCUES || wParam == SPI_SETFLATMENU) + if((wParam == SPI_SETNONCLIENTMETRICS) || (wParam == SPI_SETKEYBOARDCUES) || (wParam == SPI_SETFLATMENU)) { T* pT = static_cast(this); pT->GetSystemSettings(); @@ -1456,7 +1414,7 @@ public: LRESULT OnWindowPosChanging(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) { - LRESULT lRet = DefWindowProc(uMsg, wParam, lParam); + LRESULT lRet = this->DefWindowProc(uMsg, wParam, lParam); LPWINDOWPOS lpWP = (LPWINDOWPOS)lParam; int cyMin = ::GetSystemMetrics(SM_CYMENU); @@ -1475,12 +1433,12 @@ public: T* pT = static_cast(this); LRESULT lRet; - if(m_bMenuActive && LOWORD(wParam) != 0x0D) + if(m_bMenuActive && (LOWORD(wParam) != 0x0D)) lRet = 0; else lRet = MAKELRESULT(1, 1); - if(m_bMenuActive && HIWORD(wParam) == MF_POPUP) + if(m_bMenuActive && (HIWORD(wParam) == MF_POPUP)) { // Convert character to lower/uppercase and possibly Unicode, using current keyboard layout TCHAR ch = (TCHAR)LOWORD(wParam); @@ -1488,7 +1446,7 @@ public: int nCount = ::GetMenuItemCount(menu); int nRetCode = MNC_EXECUTE; BOOL bRet = FALSE; - TCHAR szString[pT->_nMaxMenuItemTextLength] = { 0 }; + TCHAR szString[pT->_nMaxMenuItemTextLength] = {}; WORD wMnem = 0; bool bFound = false; for(int i = 0; i < nCount; i++) @@ -1501,15 +1459,15 @@ public: if(!bRet || (mii.fType & MFT_SEPARATOR)) continue; _MenuItemData* pmd = (_MenuItemData*)mii.dwItemData; - if(pmd != NULL && pmd->IsCmdBarMenuItem()) + if(_IsValidMem(pmd) && pmd->IsCmdBarMenuItem()) { LPTSTR p = pmd->lpstrText; if(p != NULL) { - while(*p && *p != _T('&')) + while(*p && (*p != _T('&'))) p = ::CharNext(p); - if(p != NULL && *p) + if((p != NULL) && *p) { DWORD dwP = MAKELONG(*(++p), 0); DWORD dwC = MAKELONG(ch, 0); @@ -1534,7 +1492,7 @@ public: { if(nRetCode == MNC_EXECUTE) { - PostMessage(TB_SETHOTITEM, (WPARAM)-1, 0L); + this->PostMessage(TB_SETHOTITEM, (WPARAM)-1, 0L); pT->GiveFocusBack(); } bHandled = TRUE; @@ -1544,48 +1502,42 @@ public: else if(!m_bMenuActive) { int nBtn = 0; - if(!MapAccelerator((TCHAR)LOWORD(wParam), nBtn)) + if(!this->MapAccelerator((TCHAR)LOWORD(wParam), nBtn)) { bHandled = FALSE; - PostMessage(TB_SETHOTITEM, (WPARAM)-1, 0L); + this->PostMessage(TB_SETHOTITEM, (WPARAM)-1, 0L); pT->GiveFocusBack(); -#if (_WIN32_IE >= 0x0500) // check if we should display chevron menu if((TCHAR)LOWORD(wParam) == pT->_chChevronShortcut) { if(pT->DisplayChevronMenu()) bHandled = TRUE; } -#endif // (_WIN32_IE >= 0x0500) } else if(m_wndParent.IsWindowEnabled()) { -#if (_WIN32_IE >= 0x0500) - RECT rcClient = { 0 }; - GetClientRect(&rcClient); - RECT rcBtn = { 0 }; - GetItemRect(nBtn, &rcBtn); - TBBUTTON tbb = { 0 }; - GetButton(nBtn, &tbb); - if((tbb.fsState & TBSTATE_ENABLED) != 0 && (tbb.fsState & TBSTATE_HIDDEN) == 0 && rcBtn.right <= rcClient.right) + RECT rcClient = {}; + this->GetClientRect(&rcClient); + RECT rcBtn = {}; + this->GetItemRect(nBtn, &rcBtn); + TBBUTTON tbb = {}; + this->GetButton(nBtn, &tbb); + if(((tbb.fsState & TBSTATE_ENABLED) != 0) && ((tbb.fsState & TBSTATE_HIDDEN) == 0) && (rcBtn.right <= rcClient.right)) { -#endif // (_WIN32_IE >= 0x0500) if(m_bUseKeyboardCues && !m_bShowKeyboardCues) { m_bAllowKeyboardCues = true; ShowKeyboardCues(true); } pT->TakeFocus(); - PostMessage(WM_KEYDOWN, VK_DOWN, 0L); - SetHotItem(nBtn); -#if (_WIN32_IE >= 0x0500) + this->PostMessage(WM_KEYDOWN, VK_DOWN, 0L); + this->SetHotItem(nBtn); } else { ::MessageBeep(0); } -#endif // (_WIN32_IE >= 0x0500) } } @@ -1605,7 +1557,7 @@ public: { LPDRAWITEMSTRUCT lpDrawItemStruct = (LPDRAWITEMSTRUCT)lParam; _MenuItemData* pmd = (_MenuItemData*)lpDrawItemStruct->itemData; - if(lpDrawItemStruct->CtlType == ODT_MENU && pmd != NULL && pmd->IsCmdBarMenuItem()) + if((lpDrawItemStruct->CtlType == ODT_MENU) && _IsValidMem(pmd) && pmd->IsCmdBarMenuItem()) { T* pT = static_cast(this); pT->DrawItem(lpDrawItemStruct); @@ -1621,7 +1573,7 @@ public: { LPMEASUREITEMSTRUCT lpMeasureItemStruct = (LPMEASUREITEMSTRUCT)lParam; _MenuItemData* pmd = (_MenuItemData*)lpMeasureItemStruct->itemData; - if(lpMeasureItemStruct->CtlType == ODT_MENU && pmd != NULL && pmd->IsCmdBarMenuItem()) + if((lpMeasureItemStruct->CtlType == ODT_MENU) && _IsValidMem(pmd) && pmd->IsCmdBarMenuItem()) { T* pT = static_cast(this); pT->MeasureItem(lpMeasureItemStruct); @@ -1653,7 +1605,7 @@ public: LRESULT OnAPIGetCmdBar(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { - return (LRESULT)m_hWnd; + return (LRESULT)this->m_hWnd; } // Parent window message handlers @@ -1662,7 +1614,7 @@ public: LPNMTBHOTITEM lpNMHT = (LPNMTBHOTITEM)pnmh; // Check if this comes from us - if(pnmh->hwndFrom != m_hWnd) + if(pnmh->hwndFrom != this->m_hWnd) { bHandled = FALSE; return 0; @@ -1677,45 +1629,36 @@ public: } if((!m_wndParent.IsWindowEnabled() || bBlockTracking) && (lpNMHT->dwFlags & HICF_MOUSE)) - { return 1; - } - else - { -#ifndef HICF_LMOUSE - const DWORD HICF_LMOUSE = 0x00000080; // left mouse button selected -#endif - bHandled = FALSE; - // Send WM_MENUSELECT to the app if it needs to display a status text - if(!(lpNMHT->dwFlags & HICF_MOUSE) - && !(lpNMHT->dwFlags & HICF_ACCELERATOR) - && !(lpNMHT->dwFlags & HICF_LMOUSE)) - { - if(lpNMHT->dwFlags & HICF_ENTERING) - m_wndParent.SendMessage(WM_MENUSELECT, 0, (LPARAM)m_hMenu); - if(lpNMHT->dwFlags & HICF_LEAVING) - m_wndParent.SendMessage(WM_MENUSELECT, MAKEWPARAM(0, 0xFFFF), NULL); - } + bHandled = FALSE; - return 0; + // Send WM_MENUSELECT to the app if it needs to display a status text + if(!(lpNMHT->dwFlags & HICF_MOUSE) && !(lpNMHT->dwFlags & HICF_ACCELERATOR) && !(lpNMHT->dwFlags & HICF_LMOUSE)) + { + if(lpNMHT->dwFlags & HICF_ENTERING) + m_wndParent.SendMessage(WM_MENUSELECT, 0, (LPARAM)m_hMenu); + if(lpNMHT->dwFlags & HICF_LEAVING) + m_wndParent.SendMessage(WM_MENUSELECT, MAKEWPARAM(0, 0xFFFF), NULL); } + + return 0; } LRESULT OnParentDropDown(int /*idCtrl*/, LPNMHDR pnmh, BOOL& bHandled) { // Check if this comes from us - if(pnmh->hwndFrom != m_hWnd) + if(pnmh->hwndFrom != this->m_hWnd) { bHandled = FALSE; return 1; } T* pT = static_cast(this); - if(::GetFocus() != m_hWnd) + if(::GetFocus() != this->m_hWnd) pT->TakeFocus(); LPNMTOOLBAR pNMToolBar = (LPNMTOOLBAR)pnmh; - int nIndex = CommandToIndex(pNMToolBar->iItem); + int nIndex = this->CommandToIndex(pNMToolBar->iItem); m_bContextMenu = false; m_bEscapePressed = false; pT->DoPopupMenu(nIndex, true); @@ -1736,18 +1679,18 @@ public: LRESULT OnParentSysCommand(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) { bHandled = FALSE; - if((m_uSysKey == VK_MENU - || (m_uSysKey == VK_F10 && !(::GetKeyState(VK_SHIFT) & 0x80)) - || m_uSysKey == VK_SPACE) - && wParam == SC_KEYMENU) + if(((m_uSysKey == VK_MENU) + || ((m_uSysKey == VK_F10) && !(::GetKeyState(VK_SHIFT) & 0x80)) + || (m_uSysKey == VK_SPACE)) + && (wParam == SC_KEYMENU)) { T* pT = static_cast(this); - if(::GetFocus() == m_hWnd) + if(::GetFocus() == this->m_hWnd) { pT->GiveFocusBack(); // exit menu "loop" - PostMessage(TB_SETHOTITEM, (WPARAM)-1, 0L); + this->PostMessage(TB_SETHOTITEM, (WPARAM)-1, 0L); } - else if(m_uSysKey != VK_SPACE && !m_bSkipMsg) + else if((m_uSysKey != VK_SPACE) && !m_bSkipMsg) { if(m_bUseKeyboardCues && !m_bShowKeyboardCues && m_bAllowKeyboardCues) ShowKeyboardCues(true); @@ -1810,8 +1753,8 @@ public: } else { - Invalidate(); - UpdateWindow(); + this->Invalidate(); + this->UpdateWindow(); } bHandled = FALSE; return 1; @@ -1821,7 +1764,7 @@ public: { LRESULT lRet = CDRF_DODEFAULT; bHandled = FALSE; - if(pnmh->hwndFrom == m_hWnd) + if(pnmh->hwndFrom == this->m_hWnd) { LPNMTBCUSTOMDRAW lpTBCustomDraw = (LPNMTBCUSTOMDRAW)pnmh; if(lpTBCustomDraw->nmcd.dwDrawStage == CDDS_PREPAINT) @@ -1843,11 +1786,8 @@ public: { if(m_bFlatMenus) { -#ifndef COLOR_MENUHILIGHT - const int COLOR_MENUHILIGHT = 29; -#endif // !COLOR_MENUHILIGHT bool bDisabled = ((lpTBCustomDraw->nmcd.uItemState & CDIS_DISABLED) == CDIS_DISABLED); - if(!bDisabled && ((lpTBCustomDraw->nmcd.uItemState & CDIS_HOT) == CDIS_HOT || + if(!bDisabled && (((lpTBCustomDraw->nmcd.uItemState & CDIS_HOT) == CDIS_HOT) || (lpTBCustomDraw->nmcd.uItemState & CDIS_SELECTED) == CDIS_SELECTED)) { ::FillRect(lpTBCustomDraw->nmcd.hdc, &lpTBCustomDraw->nmcd.rc, ::GetSysColorBrush(COLOR_MENUHILIGHT)); @@ -1894,19 +1834,19 @@ public: dc.SetTextColor(lpTBCustomDraw->clrText); dc.SetBkMode(lpTBCustomDraw->nStringBkMode); - HFONT hFont = GetFont(); + HFONT hFont = this->GetFont(); HFONT hFontOld = NULL; if(hFont != NULL) hFontOld = dc.SelectFont(hFont); const int cchText = 200; - TCHAR szText[cchText] = { 0 }; - TBBUTTONINFO tbbi = { 0 }; + TCHAR szText[cchText] = {}; + TBBUTTONINFO tbbi = {}; tbbi.cbSize = sizeof(TBBUTTONINFO); tbbi.dwMask = TBIF_TEXT; tbbi.pszText = szText; tbbi.cchText = cchText; - GetButtonInfo((int)lpTBCustomDraw->nmcd.dwItemSpec, &tbbi); + this->GetButtonInfo((int)lpTBCustomDraw->nmcd.dwItemSpec, &tbbi); dc.DrawText(szText, -1, &lpTBCustomDraw->nmcd.rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER | (m_bShowKeyboardCues ? 0 : DT_HIDEPREFIX)); @@ -1924,19 +1864,19 @@ public: bHandled = FALSE; if(m_bMenuActive) { - if(::WindowFromPoint(point) == m_hWnd) + if(::WindowFromPoint(point) == this->m_hWnd) { - ScreenToClient(&point); - int nHit = HitTest(&point); + this->ScreenToClient(&point); + int nHit = this->HitTest(&point); - if((point.x != s_point.x || point.y != s_point.y) && nHit >= 0 && nHit < ::GetMenuItemCount(m_hMenu) && nHit != m_nPopBtn && m_nPopBtn != -1) + if(((point.x != s_point.x) || (point.y != s_point.y)) && (nHit >= 0) && (nHit < ::GetMenuItemCount(m_hMenu)) && (nHit != m_nPopBtn) && (m_nPopBtn != -1)) { - TBBUTTON tbb = { 0 }; - GetButton(nHit, &tbb); + TBBUTTON tbb = {}; + this->GetButton(nHit, &tbb); if((tbb.fsState & TBSTATE_ENABLED) != 0) { m_nNextPopBtn = nHit | 0xFFFF0000; - HWND hWndMenu = m_stackMenuWnd.GetCurrent(); + HWND hWndMenu = this->m_stackMenuWnd.GetCurrent(); ATLASSERT(hWndMenu != NULL); // this one is needed to close a menu if mouse button was down @@ -1951,7 +1891,7 @@ public: } else { - ScreenToClient(&point); + this->ScreenToClient(&point); } s_point = point; @@ -1965,20 +1905,20 @@ public: ATLTRACE2(atlTraceUI, 0, _T("CmdBar - Hook WM_SYSKEYDOWN (0x%2.2X)\n"), wParam); #endif - if(wParam == VK_MENU && m_bParentActive && m_bUseKeyboardCues && !m_bShowKeyboardCues && m_bAllowKeyboardCues) + if((wParam == VK_MENU) && m_bParentActive && m_bUseKeyboardCues && !m_bShowKeyboardCues && m_bAllowKeyboardCues) ShowKeyboardCues(true); - if(wParam != VK_SPACE && !m_bMenuActive && ::GetFocus() == m_hWnd) + if((wParam != VK_SPACE) && !m_bMenuActive && (::GetFocus() == this->m_hWnd)) { m_bAllowKeyboardCues = false; - PostMessage(TB_SETHOTITEM, (WPARAM)-1, 0L); + this->PostMessage(TB_SETHOTITEM, (WPARAM)-1, 0L); T* pT = static_cast(this); pT->GiveFocusBack(); m_bSkipMsg = true; } else { - if(wParam == VK_SPACE && m_bUseKeyboardCues && m_bShowKeyboardCues) + if((wParam == VK_SPACE) && m_bUseKeyboardCues && m_bShowKeyboardCues) { m_bAllowKeyboardCues = true; ShowKeyboardCues(false); @@ -1993,7 +1933,7 @@ public: if(!m_bAllowKeyboardCues) m_bAllowKeyboardCues = true; bHandled = FALSE; - wParam; + (void)wParam; // avoid level 4 warning #ifdef _CMDBAR_EXTRA_TRACE ATLTRACE2(atlTraceUI, 0, _T("CmdBar - Hook WM_SYSKEYUP (0x%2.2X)\n"), wParam); #endif @@ -2007,7 +1947,7 @@ public: ATLTRACE2(atlTraceUI, 0, _T("CmdBar - Hook WM_SYSCHAR (0x%2.2X)\n"), wParam); #endif - if(!m_bMenuActive && m_hWndHook != m_hWnd && wParam != VK_SPACE) + if(!m_bMenuActive && (this->m_hWndHook != this->m_hWnd) && (wParam != VK_SPACE)) bHandled = TRUE; return 0; } @@ -2020,51 +1960,40 @@ public: bHandled = FALSE; T* pT = static_cast(this); - if(wParam == VK_ESCAPE && m_stackMenuWnd.GetSize() <= 1) + if((wParam == VK_ESCAPE) && (this->m_stackMenuWnd.GetSize() <= 1)) { if(m_bMenuActive && !m_bContextMenu) { - int nHot = GetHotItem(); + int nHot = this->GetHotItem(); if(nHot == -1) nHot = m_nPopBtn; if(nHot == -1) nHot = 0; - SetHotItem(nHot); + this->SetHotItem(nHot); bHandled = TRUE; pT->TakeFocus(); m_bEscapePressed = true; // To keep focus m_bSkipPostDown = false; } - else if(::GetFocus() == m_hWnd && m_wndParent.IsWindow()) + else if((::GetFocus() == this->m_hWnd) && m_wndParent.IsWindow()) { - SetHotItem(-1); + this->SetHotItem(-1); pT->GiveFocusBack(); bHandled = TRUE; } } - else if(wParam == VK_RETURN || wParam == VK_UP || wParam == VK_DOWN) + else if((wParam == VK_RETURN) || (wParam == VK_UP) || (wParam == VK_DOWN)) { - if(!m_bMenuActive && ::GetFocus() == m_hWnd && m_wndParent.IsWindow()) + if(!m_bMenuActive && (::GetFocus() == this->m_hWnd) && m_wndParent.IsWindow()) { - int nHot = GetHotItem(); + int nHot = this->GetHotItem(); if(nHot != -1) { if(wParam != VK_RETURN) { if(!m_bSkipPostDown) { -// IE4 only: WM_KEYDOWN doesn't generate TBN_DROPDOWN, we need to simulate a mouse click -#if (_WIN32_IE < 0x0500) - DWORD dwMajor = 0, dwMinor = 0; - ATL::AtlGetCommCtrlVersion(&dwMajor, &dwMinor); - if(dwMajor <= 4 || (dwMajor == 5 && dwMinor < 80)) - { - RECT rect = { 0 }; - GetItemRect(nHot, &rect); - PostMessage(WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(rect.left, rect.top)); - } -#endif // (_WIN32_IE < 0x0500) - PostMessage(WM_KEYDOWN, VK_DOWN, 0L); + this->PostMessage(WM_KEYDOWN, VK_DOWN, 0L); m_bSkipPostDown = true; } else @@ -2079,22 +2008,22 @@ public: ATLTRACE2(atlTraceUI, 0, _T("CmdBar - Can't find hot button\n")); } } - if(wParam == VK_RETURN && m_bMenuActive) + if((wParam == VK_RETURN) && m_bMenuActive) { - PostMessage(TB_SETHOTITEM, (WPARAM)-1, 0L); + this->PostMessage(TB_SETHOTITEM, (WPARAM)-1, 0L); m_nNextPopBtn = -1; pT->GiveFocusBack(); } } - else if(wParam == VK_LEFT || wParam == VK_RIGHT) + else if((wParam == VK_LEFT) || (wParam == VK_RIGHT)) { WPARAM wpNext = m_bLayoutRTL ? VK_LEFT : VK_RIGHT; WPARAM wpPrev = m_bLayoutRTL ? VK_RIGHT : VK_LEFT; - if(m_bMenuActive && !m_bContextMenu && !(wParam == wpNext && m_bPopupItem)) + if(m_bMenuActive && !m_bContextMenu && !((wParam == wpNext) && m_bPopupItem)) { bool bAction = false; - if(wParam == wpPrev && s_pCurrentBar->m_stackMenuWnd.GetSize() == 1) + if((wParam == wpPrev) && (this->s_pCurrentBar->m_stackMenuWnd.GetSize() == 1)) { m_nNextPopBtn = pT->GetPreviousMenuItem(m_nPopBtn); if(m_nNextPopBtn != -1) @@ -2106,7 +2035,7 @@ public: if(m_nNextPopBtn != -1) bAction = true; } - HWND hWndMenu = m_stackMenuWnd.GetCurrent(); + HWND hWndMenu = this->m_stackMenuWnd.GetCurrent(); ATLASSERT(hWndMenu != NULL); // Close the popup menu @@ -2115,22 +2044,20 @@ public: ::PostMessage(hWndMenu, WM_KEYDOWN, VK_ESCAPE, 0L); if(wParam == wpNext) { - int cItem = m_stackMenuWnd.GetSize() - 1; + int cItem = this->m_stackMenuWnd.GetSize() - 1; while(cItem >= 0) { - hWndMenu = m_stackMenuWnd[cItem]; + hWndMenu = this->m_stackMenuWnd[cItem]; if(hWndMenu != NULL) ::PostMessage(hWndMenu, WM_KEYDOWN, VK_ESCAPE, 0L); cItem--; } } -#if (_WIN32_IE >= 0x0500) if(m_nNextPopBtn == -2) { m_nNextPopBtn = -1; pT->DisplayChevronMenu(); } -#endif // (_WIN32_IE >= 0x0500) bHandled = TRUE; } } @@ -2247,7 +2174,7 @@ public: CMenuItemInfo info; info.fMask = MIIM_CHECKMARKS | MIIM_TYPE; ::GetMenuItemInfo((HMENU)lpDrawItemStruct->hwndItem, lpDrawItemStruct->itemID, MF_BYCOMMAND, &info); - if(bChecked || info.hbmpUnchecked != NULL) + if(bChecked || (info.hbmpUnchecked != NULL)) { BOOL bRadio = ((info.fType & MFT_RADIOCHECK) != 0); bHasImage = pT->DrawCheckmark(dc, rcButn, bSelected, bDisabled, bRadio, bChecked ? info.hbmpChecked : info.hbmpUnchecked); @@ -2257,7 +2184,7 @@ public: // draw item text int cxButn = m_szButton.cx; COLORREF colorBG = ::GetSysColor(bSelected ? COLOR_HIGHLIGHT : COLOR_MENU); - if(bSelected || lpDrawItemStruct->itemAction == ODA_SELECT) + if(bSelected || (lpDrawItemStruct->itemAction == ODA_SELECT)) { RECT rcBG = rcItem; if(bHasImage) @@ -2273,7 +2200,7 @@ public: COLORREF colorText = ::GetSysColor(bDisabled ? (bSelected ? COLOR_GRAYTEXT : COLOR_3DSHADOW) : (bSelected ? COLOR_HIGHLIGHTTEXT : COLOR_MENUTEXT)); // font already selected by Windows - if(bDisabled && (!bSelected || colorText == colorBG)) + if(bDisabled && (!bSelected || (colorText == colorBG))) { // disabled - draw shadow text shifted down and right 1 pixel (unles selected) RECT rcDisabled = rcText; @@ -2291,16 +2218,12 @@ public: const RECT& rcItem = lpDrawItemStruct->rcItem; T* pT = static_cast(this); -#ifndef COLOR_MENUHILIGHT - const int COLOR_MENUHILIGHT = 29; -#endif // !COLOR_MENUHILIGHT - BOOL bDisabled = lpDrawItemStruct->itemState & ODS_GRAYED; BOOL bSelected = lpDrawItemStruct->itemState & ODS_SELECTED; BOOL bChecked = lpDrawItemStruct->itemState & ODS_CHECKED; // paint background - if(bSelected || lpDrawItemStruct->itemAction == ODA_SELECT) + if(bSelected || (lpDrawItemStruct->itemAction == ODA_SELECT)) { if(bSelected) { @@ -2353,7 +2276,7 @@ public: } else { - HBRUSH hBrushBackground = ::GetSysColorBrush((bSelected && !(bDisabled && bChecked)) ? COLOR_MENUHILIGHT : COLOR_MENU); + HBRUSH hBrushBackground = ::GetSysColorBrush((bSelected && !bChecked) ? COLOR_MENUHILIGHT : COLOR_MENU); HBRUSH hBrushDisabledImage = ::GetSysColorBrush(COLOR_3DSHADOW); pT->DrawBitmapDisabled(dc, iButton, point, hBrushBackground, hBrushBackground, hBrushDisabledImage); } @@ -2364,7 +2287,7 @@ public: CMenuItemInfo info; info.fMask = MIIM_CHECKMARKS | MIIM_TYPE; ::GetMenuItemInfo((HMENU)lpDrawItemStruct->hwndItem, lpDrawItemStruct->itemID, MF_BYCOMMAND, &info); - if(bChecked || info.hbmpUnchecked != NULL) + if(bChecked || (info.hbmpUnchecked != NULL)) { BOOL bRadio = ((info.fType & MFT_RADIOCHECK) != 0); pT->DrawCheckmark(dc, rcButn, bSelected, bDisabled, bRadio, bChecked ? info.hbmpChecked : info.hbmpUnchecked); @@ -2407,10 +2330,9 @@ public: HBRUSH hBrush3DEffect = ::GetSysColorBrush(COLOR_3DHILIGHT), HBRUSH hBrushDisabledImage = ::GetSysColorBrush(COLOR_3DSHADOW)) { -#if (_WIN32_WINNT >= 0x0501) && (_WIN32_IE >= 0x0501) if(m_bAlphaImages) { - IMAGELISTDRAWPARAMS ildp = { 0 }; + IMAGELISTDRAWPARAMS ildp = {}; ildp.cbSize = sizeof(IMAGELISTDRAWPARAMS); ildp.himl = m_hImageList; ildp.i = nImage; @@ -2427,7 +2349,6 @@ public: ::ImageList_DrawIndirect(&ildp); } else -#endif // (_WIN32_WINNT >= 0x0501) && (_WIN32_IE >= 0x0501) { // create memory DC CDC dcMem; @@ -2457,7 +2378,7 @@ public: BOOL DrawCheckmark(CDCHandle& dc, const RECT& rc, BOOL bSelected, BOOL bDisabled, BOOL bRadio, HBITMAP hBmpCheck) { // get checkmark bitmap, if none, use Windows standard - SIZE size = { 0, 0 }; + SIZE size = {}; CBitmapHandle bmp = hBmpCheck; if(hBmpCheck != NULL) { @@ -2630,7 +2551,7 @@ public: if(pmd->fState & MFS_DEFAULT) { // need bold version of font - LOGFONT lf = { 0 }; + LOGFONT lf = {}; m_fontMenu.GetLogFont(lf); lf.lfWeight += 200; fontBold.CreateFontIndirect(&lf); @@ -2642,12 +2563,12 @@ public: hOldFont = dc.SelectFont(m_fontMenu); } - RECT rcText = { 0 }; + RECT rcText = {}; dc.DrawText(pmd->lpstrText, -1, &rcText, DT_SINGLELINE | DT_LEFT | DT_VCENTER | DT_CALCRECT); int cx = rcText.right - rcText.left; dc.SelectFont(hOldFont); - LOGFONT lf = { 0 }; + LOGFONT lf = {}; m_fontMenu.GetLogFont(lf); int cy = lf.lfHeight; if(cy < 0) @@ -2674,7 +2595,7 @@ public: static LRESULT CALLBACK CreateHookProc(int nCode, WPARAM wParam, LPARAM lParam) { const int cchClassName = 7; - TCHAR szClassName[cchClassName] = { 0 }; + TCHAR szClassName[cchClassName] = {}; if(nCode == HCBT_CREATEWND) { @@ -2685,7 +2606,7 @@ public: ::GetClassName(hWndMenu, szClassName, cchClassName); if(!lstrcmp(_T("#32768"), szClassName)) - s_pCurrentBar->m_stackMenuWnd.Push(hWndMenu); + CCommandBarCtrlBase::s_pCurrentBar->m_stackMenuWnd.Push(hWndMenu); } else if(nCode == HCBT_DESTROYWND) { @@ -2697,30 +2618,30 @@ public: ::GetClassName(hWndMenu, szClassName, cchClassName); if(!lstrcmp(_T("#32768"), szClassName)) { - ATLASSERT(hWndMenu == s_pCurrentBar->m_stackMenuWnd.GetCurrent()); - s_pCurrentBar->m_stackMenuWnd.Pop(); + ATLASSERT(hWndMenu == CCommandBarCtrlBase::s_pCurrentBar->m_stackMenuWnd.GetCurrent()); + CCommandBarCtrlBase::s_pCurrentBar->m_stackMenuWnd.Pop(); } } - return ::CallNextHookEx(s_hCreateHook, nCode, wParam, lParam); + return ::CallNextHookEx(CCommandBarCtrlBase::s_hCreateHook, nCode, wParam, lParam); } static LRESULT CALLBACK MessageHookProc(int nCode, WPARAM wParam, LPARAM lParam) { LPMSG pMsg = (LPMSG)lParam; - if(nCode == HC_ACTION && wParam == PM_REMOVE && pMsg->message != GetGetBarMessage() && pMsg->message != WM_FORWARDMSG) + if((nCode == HC_ACTION) && (wParam == PM_REMOVE) && (pMsg->message != GetGetBarMessage()) && (pMsg->message != WM_FORWARDMSG)) { CCommandBarCtrlBase* pCmdBar = NULL; HWND hWnd = pMsg->hwnd; DWORD dwPID = 0; - while(pCmdBar == NULL && hWnd != NULL) + while((pCmdBar == NULL) && (hWnd != NULL)) { pCmdBar = (CCommandBarCtrlBase*)::SendMessage(hWnd, GetGetBarMessage(), (WPARAM)&dwPID, 0L); hWnd = ::GetParent(hWnd); } - if(pCmdBar != NULL && dwPID == GetCurrentProcessId()) + if((pCmdBar != NULL) && (dwPID == GetCurrentProcessId())) { pCmdBar->m_hWndHook = pMsg->hwnd; ATLASSERT(pCmdBar->IsCommandBarBase()); @@ -2733,11 +2654,11 @@ public: } LRESULT lRet = 0; - ATLASSERT(s_pmapMsgHook != NULL); - if(s_pmapMsgHook != NULL) + ATLASSERT(CCommandBarCtrlBase::s_pmapMsgHook != NULL); + if(CCommandBarCtrlBase::s_pmapMsgHook != NULL) { DWORD dwThreadID = ::GetCurrentThreadId(); - _MsgHookData* pData = s_pmapMsgHook->Lookup(dwThreadID); + CCommandBarCtrlBase::_MsgHookData* pData = CCommandBarCtrlBase::s_pmapMsgHook->Lookup(dwThreadID); if(pData != NULL) { lRet = ::CallNextHookEx(pData->hMsgHook, nCode, wParam, lParam); @@ -2752,57 +2673,49 @@ public: #ifdef _CMDBAR_EXTRA_TRACE ATLTRACE2(atlTraceUI, 0, _T("CmdBar - DoPopupMenu, bAnimate = %s\n"), bAnimate ? "true" : "false"); #endif - - // Menu animation flags -#ifndef TPM_VERPOSANIMATION - const UINT TPM_VERPOSANIMATION = 0x1000L; -#endif -#ifndef TPM_NOANIMATION - const UINT TPM_NOANIMATION = 0x4000L; -#endif T* pT = static_cast(this); // get popup menu and it's position - RECT rect = { 0 }; - GetItemRect(nIndex, &rect); + RECT rect = {}; + this->GetItemRect(nIndex, &rect); POINT pt = { rect.left, rect.bottom }; - MapWindowPoints(NULL, &pt, 1); - MapWindowPoints(NULL, &rect); - TPMPARAMS TPMParams = { 0 }; + this->MapWindowPoints(NULL, &pt, 1); + this->MapWindowPoints(NULL, &rect); + TPMPARAMS TPMParams = {}; TPMParams.cbSize = sizeof(TPMPARAMS); TPMParams.rcExclude = rect; HMENU hMenuPopup = ::GetSubMenu(m_hMenu, nIndex); ATLASSERT(hMenuPopup != NULL); // get button ID - TBBUTTON tbb = { 0 }; - GetButton(nIndex, &tbb); + TBBUTTON tbb = {}; + this->GetButton(nIndex, &tbb); int nCmdID = tbb.idCommand; m_nPopBtn = nIndex; // remember current button's index // press button and display popup menu - PressButton(nCmdID, TRUE); - SetHotItem(nCmdID); + this->PressButton(nCmdID, TRUE); + this->SetHotItem(nCmdID); pT->DoTrackPopupMenu(hMenuPopup, TPM_LEFTBUTTON | TPM_VERTICAL | TPM_LEFTALIGN | TPM_TOPALIGN | - (s_bW2K ? (bAnimate ? TPM_VERPOSANIMATION : TPM_NOANIMATION) : 0), pt.x, pt.y, &TPMParams); - PressButton(nCmdID, FALSE); - if(::GetFocus() != m_hWnd) - SetHotItem(-1); + (bAnimate ? TPM_VERPOSANIMATION : TPM_NOANIMATION), pt.x, pt.y, &TPMParams); + this->PressButton(nCmdID, FALSE); + if(::GetFocus() != this->m_hWnd) + this->SetHotItem(-1); m_nPopBtn = -1; // restore // eat next message if click is on the same button - MSG msg = { 0 }; - if(::PeekMessage(&msg, m_hWnd, WM_LBUTTONDOWN, WM_LBUTTONDOWN, PM_NOREMOVE) && ::PtInRect(&rect, msg.pt)) - ::PeekMessage(&msg, m_hWnd, WM_LBUTTONDOWN, WM_LBUTTONDOWN, PM_REMOVE); + MSG msg = {}; + if(::PeekMessage(&msg, this->m_hWnd, WM_LBUTTONDOWN, WM_LBUTTONDOWN, PM_NOREMOVE) && ::PtInRect(&rect, msg.pt)) + ::PeekMessage(&msg, this->m_hWnd, WM_LBUTTONDOWN, WM_LBUTTONDOWN, PM_REMOVE); // check if another popup menu should be displayed if(m_nNextPopBtn != -1) { - PostMessage(GetAutoPopupMessage(), m_nNextPopBtn & 0xFFFF); + this->PostMessage(GetAutoPopupMessage(), m_nNextPopBtn & 0xFFFF); if(!(m_nNextPopBtn & 0xFFFF0000) && !m_bPopupItem) - PostMessage(WM_KEYDOWN, VK_DOWN, 0); + this->PostMessage(WM_KEYDOWN, VK_DOWN, 0); m_nNextPopBtn = -1; } else @@ -2817,8 +2730,8 @@ public: } else { - SetHotItem(nCmdID); - SetAnchorHighlight(TRUE); + this->SetHotItem(nCmdID); + this->SetAnchorHighlight(TRUE); } } } @@ -2835,23 +2748,23 @@ public: return FALSE; } - ATLASSERT(s_hCreateHook == NULL); + ATLASSERT(this->s_hCreateHook == NULL); - s_pCurrentBar = static_cast(this); + this->s_pCurrentBar = static_cast(this); - s_hCreateHook = ::SetWindowsHookEx(WH_CBT, CreateHookProc, ModuleHelper::GetModuleInstance(), GetCurrentThreadId()); - ATLASSERT(s_hCreateHook != NULL); + this->s_hCreateHook = ::SetWindowsHookEx(WH_CBT, CreateHookProc, ModuleHelper::GetModuleInstance(), GetCurrentThreadId()); + ATLASSERT(this->s_hCreateHook != NULL); m_bPopupItem = false; m_bMenuActive = true; - BOOL bTrackRet = menuPopup.TrackPopupMenuEx(uFlags, x, y, m_hWnd, lpParams); + BOOL bTrackRet = menuPopup.TrackPopupMenuEx(uFlags, x, y, this->m_hWnd, lpParams); m_bMenuActive = false; - ::UnhookWindowsHookEx(s_hCreateHook); + ::UnhookWindowsHookEx(this->s_hCreateHook); - s_hCreateHook = NULL; - s_pCurrentBar = NULL; + this->s_hCreateHook = NULL; + this->s_pCurrentBar = NULL; lock.Unlock(); @@ -2860,17 +2773,17 @@ public: ATLTRACE2(atlTraceUI, 0, _T("CmdBar - TrackPopupMenu - cleanup\n")); #endif - ATLASSERT(m_stackMenuWnd.GetSize() == 0); + ATLASSERT(this->m_stackMenuWnd.GetSize() == 0); - UpdateWindow(); - ATL::CWindow wndTL = GetTopLevelParent(); + this->UpdateWindow(); + ATL::CWindow wndTL = this->GetTopLevelParent(); wndTL.UpdateWindow(); // restore the menu items to the previous state for all menus that were converted if(m_bImagesVisible) { HMENU hMenuSav = NULL; - while((hMenuSav = m_stackMenuHandle.Pop()) != NULL) + while((hMenuSav = this->m_stackMenuHandle.Pop()) != NULL) { menuPopup = hMenuSav; BOOL bRet = FALSE; @@ -2883,7 +2796,7 @@ public: ATLASSERT(bRet); _MenuItemData* pMI = (_MenuItemData*)mii.dwItemData; - if(pMI != NULL && pMI->IsCmdBarMenuItem()) + if(_IsValidMem(pMI) && pMI->IsCmdBarMenuItem()) { mii.fMask = MIIM_DATA | MIIM_TYPE | MIIM_STATE; mii.fType = pMI->fType; @@ -2910,27 +2823,23 @@ public: { if(nBtn == -1) return -1; -#if (_WIN32_IE >= 0x0500) - RECT rcClient = { 0 }; - GetClientRect(&rcClient); -#endif // (_WIN32_IE >= 0x0500) + RECT rcClient = {}; + this->GetClientRect(&rcClient); int nNextBtn; for(nNextBtn = nBtn - 1; nNextBtn != nBtn; nNextBtn--) { if(nNextBtn < 0) nNextBtn = ::GetMenuItemCount(m_hMenu) - 1; - TBBUTTON tbb = { 0 }; - GetButton(nNextBtn, &tbb); -#if (_WIN32_IE >= 0x0500) - RECT rcBtn = { 0 }; - GetItemRect(nNextBtn, &rcBtn); + TBBUTTON tbb = {}; + this->GetButton(nNextBtn, &tbb); + RECT rcBtn = {}; + this->GetItemRect(nNextBtn, &rcBtn); if(rcBtn.right > rcClient.right) { nNextBtn = -2; // chevron break; } -#endif // (_WIN32_IE >= 0x0500) - if((tbb.fsState & TBSTATE_ENABLED) != 0 && (tbb.fsState & TBSTATE_HIDDEN) == 0) + if(((tbb.fsState & TBSTATE_ENABLED) != 0) && ((tbb.fsState & TBSTATE_HIDDEN) == 0)) break; } return (nNextBtn != nBtn) ? nNextBtn : -1; @@ -2940,50 +2849,45 @@ public: { if(nBtn == -1) return -1; -#if (_WIN32_IE >= 0x0500) - RECT rcClient = { 0 }; - GetClientRect(&rcClient); -#endif // (_WIN32_IE >= 0x0500) + RECT rcClient = {}; + this->GetClientRect(&rcClient); int nNextBtn = 0; int nCount = ::GetMenuItemCount(m_hMenu); for(nNextBtn = nBtn + 1; nNextBtn != nBtn; nNextBtn++) { if(nNextBtn >= nCount) nNextBtn = 0; - TBBUTTON tbb = { 0 }; - GetButton(nNextBtn, &tbb); -#if (_WIN32_IE >= 0x0500) - RECT rcBtn = { 0 }; - GetItemRect(nNextBtn, &rcBtn); + TBBUTTON tbb = {}; + this->GetButton(nNextBtn, &tbb); + RECT rcBtn = {}; + this->GetItemRect(nNextBtn, &rcBtn); if(rcBtn.right > rcClient.right) { nNextBtn = -2; // chevron break; } -#endif // (_WIN32_IE >= 0x0500) - if((tbb.fsState & TBSTATE_ENABLED) != 0 && (tbb.fsState & TBSTATE_HIDDEN) == 0) + if(((tbb.fsState & TBSTATE_ENABLED) != 0) && ((tbb.fsState & TBSTATE_HIDDEN) == 0)) break; } return (nNextBtn != nBtn) ? nNextBtn : -1; } -#if (_WIN32_IE >= 0x0500) bool DisplayChevronMenu() { // assume we are in a rebar - HWND hWndReBar = GetParent(); + HWND hWndReBar = this->GetParent(); int nCount = (int)::SendMessage(hWndReBar, RB_GETBANDCOUNT, 0, 0L); bool bRet = false; for(int i = 0; i < nCount; i++) { REBARBANDINFO rbbi = { RunTimeHelper::SizeOf_REBARBANDINFO(), RBBIM_CHILD | RBBIM_STYLE }; BOOL bRetBandInfo = (BOOL)::SendMessage(hWndReBar, RB_GETBANDINFO, i, (LPARAM)&rbbi); - if(bRetBandInfo && rbbi.hwndChild == m_hWnd) + if(bRetBandInfo && (rbbi.hwndChild == this->m_hWnd)) { if((rbbi.fStyle & RBBS_USECHEVRON) != 0) { ::PostMessage(hWndReBar, RB_PUSHCHEVRON, i, 0L); - PostMessage(WM_KEYDOWN, VK_DOWN, 0L); + this->PostMessage(WM_KEYDOWN, VK_DOWN, 0L); bRet = true; } break; @@ -2991,7 +2895,6 @@ public: } return bRet; } -#endif // (_WIN32_IE >= 0x0500) void GetSystemSettings() { @@ -3001,23 +2904,23 @@ public: ATLASSERT(bRet); if(bRet) { - LOGFONT logfont = { 0 }; + LOGFONT logfont = {}; if(m_fontMenu.m_hFont != NULL) m_fontMenu.GetLogFont(logfont); - if(logfont.lfHeight != info.lfMenuFont.lfHeight || - logfont.lfWidth != info.lfMenuFont.lfWidth || - logfont.lfEscapement != info.lfMenuFont.lfEscapement || - logfont.lfOrientation != info.lfMenuFont.lfOrientation || - logfont.lfWeight != info.lfMenuFont.lfWeight || - logfont.lfItalic != info.lfMenuFont.lfItalic || - logfont.lfUnderline != info.lfMenuFont.lfUnderline || - logfont.lfStrikeOut != info.lfMenuFont.lfStrikeOut || - logfont.lfCharSet != info.lfMenuFont.lfCharSet || - logfont.lfOutPrecision != info.lfMenuFont.lfOutPrecision || - logfont.lfClipPrecision != info.lfMenuFont.lfClipPrecision || - logfont.lfQuality != info.lfMenuFont.lfQuality || - logfont.lfPitchAndFamily != info.lfMenuFont.lfPitchAndFamily || - lstrcmp(logfont.lfFaceName, info.lfMenuFont.lfFaceName) != 0) + if((logfont.lfHeight != info.lfMenuFont.lfHeight) || + (logfont.lfWidth != info.lfMenuFont.lfWidth) || + (logfont.lfEscapement != info.lfMenuFont.lfEscapement) || + (logfont.lfOrientation != info.lfMenuFont.lfOrientation) || + (logfont.lfWeight != info.lfMenuFont.lfWeight) || + (logfont.lfItalic != info.lfMenuFont.lfItalic) || + (logfont.lfUnderline != info.lfMenuFont.lfUnderline) || + (logfont.lfStrikeOut != info.lfMenuFont.lfStrikeOut) || + (logfont.lfCharSet != info.lfMenuFont.lfCharSet) || + (logfont.lfOutPrecision != info.lfMenuFont.lfOutPrecision) || + (logfont.lfClipPrecision != info.lfMenuFont.lfClipPrecision) || + (logfont.lfQuality != info.lfMenuFont.lfQuality) || + (logfont.lfPitchAndFamily != info.lfMenuFont.lfPitchAndFamily) || + (lstrcmp(logfont.lfFaceName, info.lfMenuFont.lfFaceName) != 0)) { HFONT hFontMenu = ::CreateFontIndirect(&info.lfMenuFont); ATLASSERT(hFontMenu != NULL); @@ -3026,17 +2929,17 @@ public: if(m_fontMenu.m_hFont != NULL) m_fontMenu.DeleteObject(); m_fontMenu.Attach(hFontMenu); - SetFont(m_fontMenu); - AddStrings(_T("NS\0")); // for proper item height - AutoSize(); + this->SetFont(m_fontMenu); + this->AddStrings(_T("NS\0")); // for proper item height + this->AutoSize(); } } } // check if we need extra spacing for menu item text - CWindowDC dc(m_hWnd); + CWindowDC dc(this->m_hWnd); HFONT hFontOld = dc.SelectFont(m_fontMenu); - RECT rcText = { 0 }; + RECT rcText = {}; dc.DrawText(_T("\t"), -1, &rcText, DT_SINGLELINE | DT_LEFT | DT_VCENTER | DT_CALCRECT); if((rcText.right - rcText.left) < 4) { @@ -3063,9 +2966,6 @@ public: if (ovi.dwMajorVersion >= 5) #endif // _versionhelpers_H_INCLUDED_ { -#ifndef SPI_GETKEYBOARDCUES - const UINT SPI_GETKEYBOARDCUES = 0x100A; -#endif // !SPI_GETKEYBOARDCUES BOOL bRetVal = TRUE; bRet = ::SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, &bRetVal, 0); m_bUseKeyboardCues = (bRet && !bRetVal); @@ -3077,12 +2977,9 @@ public: #ifdef _versionhelpers_H_INCLUDED_ if(::IsWindowsXPOrGreater()) #else // !_versionhelpers_H_INCLUDED_ - if ((ovi.dwMajorVersion == 5 && ovi.dwMinorVersion >= 1) || (ovi.dwMajorVersion > 5)) + if (((ovi.dwMajorVersion == 5) && (ovi.dwMinorVersion >= 1)) || (ovi.dwMajorVersion > 5)) #endif // _versionhelpers_H_INCLUDED_ { -#ifndef SPI_GETFLATMENU - const UINT SPI_GETFLATMENU = 0x1022; -#endif // !SPI_GETFLATMENU BOOL bRetVal = FALSE; bRet = ::SystemParametersInfo(SPI_GETFLATMENU, 0, &bRetVal, 0); m_bFlatMenus = (bRet && bRetVal); @@ -3109,9 +3006,9 @@ public: // Implementation - alternate focus mode support void TakeFocus() { - if((m_dwExtendedStyle & CBR_EX_ALTFOCUSMODE) && m_hWndFocus == NULL) + if((m_dwExtendedStyle & CBR_EX_ALTFOCUSMODE) && (m_hWndFocus == NULL)) m_hWndFocus = ::GetFocus(); - SetFocus(); + this->SetFocus(); } void GiveFocusBack() @@ -3124,18 +3021,18 @@ public: m_wndParent.SetFocus(); } m_hWndFocus = NULL; - SetAnchorHighlight(FALSE); + this->SetAnchorHighlight(FALSE); if(m_bUseKeyboardCues && m_bShowKeyboardCues) - ShowKeyboardCues(false); + this->ShowKeyboardCues(false); m_bSkipPostDown = false; } void ShowKeyboardCues(bool bShow) { m_bShowKeyboardCues = bShow; - SetDrawTextFlags(DT_HIDEPREFIX, m_bShowKeyboardCues ? 0 : DT_HIDEPREFIX); - Invalidate(); - UpdateWindow(); + this->SetDrawTextFlags(DT_HIDEPREFIX, m_bShowKeyboardCues ? 0 : DT_HIDEPREFIX); + this->Invalidate(); + this->UpdateWindow(); } // Implementation - internal message helpers @@ -3253,7 +3150,7 @@ public: HBITMAP _CreateVistaBitmapHelper(int nIndex, HDC hDCSource, HDC hDCTarget) { // Create 32-bit bitmap - BITMAPINFO bi = { 0 }; + BITMAPINFO bi = {}; bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); bi.bmiHeader.biWidth = m_szBitmap.cx; bi.bmiHeader.biHeight = m_szBitmap.cy; @@ -3273,7 +3170,7 @@ public: { ::SelectObject(hDCTarget, hBitmap); - IMAGELISTDRAWPARAMS ildp = { 0 }; + IMAGELISTDRAWPARAMS ildp = {}; ildp.cbSize = sizeof(IMAGELISTDRAWPARAMS); ildp.himl = m_hImageList; ildp.i = nIndex; @@ -3305,6 +3202,20 @@ public: } } #endif // _WTL_CMDBAR_VISTA_MENUS + +// Implementation helper + static bool _IsValidMem(void* pMem) + { + bool bRet = false; + if(pMem != NULL) + { + MEMORY_BASIC_INFORMATION mbi = {}; + ::VirtualQuery(pMem, &mbi, sizeof(MEMORY_BASIC_INFORMATION)); + bRet = (mbi.BaseAddress != NULL) && ((mbi.Protect & (PAGE_READONLY | PAGE_READWRITE)) != 0); + } + + return bRet; + } }; @@ -3338,34 +3249,18 @@ public: int m_cxLeft; // left nonclient area width int m_cxRight; // right nonclient area width -// Theme declarations and data members -#ifndef _WTL_NO_AUTO_THEME -#ifndef _UXTHEME_H_ - typedef HANDLE HTHEME; -#endif // !_UXTHEME_H_ - typedef HTHEME (STDAPICALLTYPE *PFN_OpenThemeData)(HWND hwnd, LPCWSTR pszClassList); - typedef HRESULT (STDAPICALLTYPE *PFN_CloseThemeData)(HTHEME hTheme); - typedef HRESULT (STDAPICALLTYPE *PFN_DrawThemeBackground)(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, OPTIONAL const RECT *pClipRect); - typedef HRESULT (STDAPICALLTYPE *PFN_DrawThemeParentBackground)(HWND hwnd, HDC hdc, OPTIONAL RECT* prc); - - HMODULE m_hThemeDLL; HTHEME m_hTheme; - PFN_DrawThemeBackground m_pfnDrawThemeBackground; - PFN_DrawThemeParentBackground m_pfnDrawThemeParentBackground; -#endif // !_WTL_NO_AUTO_THEME // Constructor/destructor CMDICommandBarCtrlImpl() : m_wndMDIClient(this, 2), m_bChildMaximized(false), m_hWndChildMaximized(NULL), m_hIconChildMaximized(NULL), m_nBtnPressed(-1), m_nBtnWasPressed(-1), -#ifndef _WTL_NO_AUTO_THEME - m_hThemeDLL(NULL), m_hTheme(NULL), m_pfnDrawThemeBackground(NULL), m_pfnDrawThemeParentBackground(NULL), -#endif // !_WTL_NO_AUTO_THEME m_cxyOffset(2), m_cxIconWidth(16), m_cyIconHeight(16), m_cxBtnWidth(16), m_cyBtnHeight(14), - m_cxLeft(20), m_cxRight(55) + m_cxLeft(20), m_cxRight(55), + m_hTheme(NULL) { } ~CMDICommandBarCtrlImpl() @@ -3377,7 +3272,7 @@ public: // Operations BOOL SetMDIClient(HWND hWndMDIClient) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(::IsWindow(hWndMDIClient)); if(!::IsWindow(hWndMDIClient)) return FALSE; @@ -3387,7 +3282,7 @@ public: { LPCTSTR lpszMDIClientClass = _T("MDICLIENT"); const int nNameLen = 9 + 1; // "MDICLIENT" + NULL - TCHAR szClassName[nNameLen] = { 0 }; + TCHAR szClassName[nNameLen] = {}; ::GetClassName(hWndMDIClient, szClassName, nNameLen); ATLASSERT(lstrcmpi(szClassName, lpszMDIClientClass) == 0); } @@ -3404,9 +3299,7 @@ public: BEGIN_MSG_MAP(CMDICommandBarCtrlImpl) MESSAGE_HANDLER(WM_CREATE, OnCreate) MESSAGE_HANDLER(WM_DESTROY, OnDestroy) -#ifndef _WTL_NO_AUTO_THEME - MESSAGE_HANDLER(_GetThemeChangedMsg(), OnThemeChanged) -#endif // !_WTL_NO_AUTO_THEME + MESSAGE_HANDLER(WM_THEMECHANGED, OnThemeChanged) MESSAGE_HANDLER(WM_SIZE, OnSize) MESSAGE_HANDLER(WM_NCCALCSIZE, OnNcCalcSize) MESSAGE_HANDLER(WM_NCPAINT, OnNcPaint) @@ -3435,27 +3328,8 @@ public: if(lRet == (LRESULT)-1) return lRet; -#ifndef _WTL_NO_AUTO_THEME - // this will fail if theming is not supported - m_hThemeDLL = ::LoadLibrary(_T("uxtheme.dll")); - if(m_hThemeDLL != NULL) - { - m_pfnDrawThemeBackground = (PFN_DrawThemeBackground)::GetProcAddress(m_hThemeDLL, "DrawThemeBackground"); - ATLASSERT(m_pfnDrawThemeBackground != NULL); - if(m_pfnDrawThemeBackground != NULL) - { - T* pT = static_cast(this); - pT->_OpenThemeData(); - } - else - { - ::FreeLibrary(m_hThemeDLL); - m_hThemeDLL = NULL; - } - m_pfnDrawThemeParentBackground = (PFN_DrawThemeParentBackground)::GetProcAddress(m_hThemeDLL, "DrawThemeParentBackground"); - ATLASSERT(m_pfnDrawThemeParentBackground != NULL); - } -#endif // !_WTL_NO_AUTO_THEME + T* pT = static_cast(this); + pT->_OpenThemeData(); return lRet; } @@ -3464,35 +3338,24 @@ public: { LRESULT lRet = _baseClass::OnDestroy(uMsg, wParam, lParam, bHandled); -#ifndef _WTL_NO_AUTO_THEME - if(m_hThemeDLL != NULL) - { - T* pT = static_cast(this); - pT->_CloseThemeData(); - ::FreeLibrary(m_hThemeDLL); - m_hThemeDLL = NULL; - } -#endif // !_WTL_NO_AUTO_THEME + T* pT = static_cast(this); + pT->_CloseThemeData(); return lRet; } -#ifndef _WTL_NO_AUTO_THEME LRESULT OnThemeChanged(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { - if(m_hThemeDLL != NULL) - { - T* pT = static_cast(this); - pT->_CloseThemeData(); - pT->_OpenThemeData(); - } + T* pT = static_cast(this); + pT->_CloseThemeData(); + pT->_OpenThemeData(); + return 0; } -#endif // !_WTL_NO_AUTO_THEME LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) { - LRESULT lRet = DefWindowProc(uMsg, wParam, lParam); + LRESULT lRet = this->DefWindowProc(uMsg, wParam, lParam); T* pT = static_cast(this); pT->_AdjustBtnSize(GET_Y_LPARAM(lParam)); return lRet; @@ -3500,12 +3363,12 @@ public: LRESULT OnNcCalcSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) { - LRESULT lRet = DefWindowProc(uMsg, wParam, lParam); + LRESULT lRet = this->DefWindowProc(uMsg, wParam, lParam); if(m_bChildMaximized && (BOOL)wParam) { LPNCCALCSIZE_PARAMS lpParams = (LPNCCALCSIZE_PARAMS)lParam; - if(m_bLayoutRTL) + if(this->m_bLayoutRTL) { lpParams->rgrc[0].left += m_cxRight; lpParams->rgrc[0].right -= m_cxLeft; @@ -3522,79 +3385,65 @@ public: LRESULT OnNcPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) { - LRESULT lRet = DefWindowProc(uMsg, wParam, lParam); + LRESULT lRet = this->DefWindowProc(uMsg, wParam, lParam); if(!m_bChildMaximized) return lRet; - ATLASSERT(m_hWndChildMaximized != NULL && m_hIconChildMaximized != NULL); + ATLASSERT((m_hWndChildMaximized != NULL) && (m_hIconChildMaximized != NULL)); // get DC and window rectangle - CWindowDC dc(m_hWnd); - RECT rect = { 0 }; - GetWindowRect(&rect); + CWindowDC dc(this->m_hWnd); + RECT rect = {}; + this->GetWindowRect(&rect); int cxWidth = rect.right - rect.left; int cyHeight = rect.bottom - rect.top; // paint left side nonclient background and draw icon ::SetRect(&rect, 0, 0, m_cxLeft, cyHeight); -#ifndef _WTL_NO_AUTO_THEME if(m_hTheme != NULL) { - if(m_pfnDrawThemeParentBackground != NULL) - m_pfnDrawThemeParentBackground(m_hWnd, dc, &rect); - else - dc.FillRect(&rect, COLOR_WINDOW); + ::DrawThemeParentBackground(this->m_hWnd, dc, &rect); } else -#endif // !_WTL_NO_AUTO_THEME { - if((m_dwExtendedStyle & CBR_EX_TRANSPARENT) != 0) + if((this->m_dwExtendedStyle & CBR_EX_TRANSPARENT) != 0) dc.FillRect(&rect, COLOR_3DFACE); else dc.FillRect(&rect, COLOR_MENU); } - RECT rcIcon = { 0 }; + RECT rcIcon = {}; T* pT = static_cast(this); pT->_CalcIconRect(cxWidth, cyHeight, rcIcon); dc.DrawIconEx(rcIcon.left, rcIcon.top, m_hIconChildMaximized, m_cxIconWidth, m_cyIconHeight); // paint right side nonclient background ::SetRect(&rect, cxWidth - m_cxRight, 0, cxWidth, cyHeight); -#ifndef _WTL_NO_AUTO_THEME if(m_hTheme != NULL) { - if(m_pfnDrawThemeParentBackground != NULL) - { - // this is to account for the left non-client area - POINT ptOrg = { 0, 0 }; - dc.GetViewportOrg(&ptOrg); - dc.SetViewportOrg(ptOrg.x + m_cxLeft, ptOrg.y); - ::OffsetRect(&rect, -m_cxLeft, 0); + // this is to account for the left non-client area + POINT ptOrg = {}; + dc.GetViewportOrg(&ptOrg); + dc.SetViewportOrg(ptOrg.x + m_cxLeft, ptOrg.y); + ::OffsetRect(&rect, -m_cxLeft, 0); - m_pfnDrawThemeParentBackground(m_hWnd, dc, &rect); + ::DrawThemeParentBackground(this->m_hWnd, dc, &rect); - // restore - dc.SetViewportOrg(ptOrg); - ::OffsetRect(&rect, m_cxLeft, 0); - } - else - { - dc.FillRect(&rect, COLOR_3DFACE); - } + // restore + dc.SetViewportOrg(ptOrg); + ::OffsetRect(&rect, m_cxLeft, 0); } else -#endif // !_WTL_NO_AUTO_THEME { - if((m_dwExtendedStyle & CBR_EX_TRANSPARENT) != 0) + if((this->m_dwExtendedStyle & CBR_EX_TRANSPARENT) != 0) dc.FillRect(&rect, COLOR_3DFACE); else dc.FillRect(&rect, COLOR_MENU); } // draw buttons - RECT arrRect[3] = { 0 }; + RECT arrRect[3] = {}; pT->_CalcBtnRects(cxWidth, cyHeight, arrRect); pT->_DrawMDIButton(dc, arrRect, -1); // draw all buttons @@ -3603,13 +3452,13 @@ public: LRESULT OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) { - LRESULT lRet = DefWindowProc(uMsg, wParam, lParam); + LRESULT lRet = this->DefWindowProc(uMsg, wParam, lParam); if(m_bChildMaximized) { - RECT rect = { 0 }; - GetWindowRect(&rect); + RECT rect = {}; + this->GetWindowRect(&rect); POINT pt = { GET_X_LPARAM(lParam) - rect.left, GET_Y_LPARAM(lParam) - rect.top }; - if(m_bLayoutRTL) + if(this->m_bLayoutRTL) { if((pt.x < m_cxRight) || (pt.x > ((rect.right - rect.left) - m_cxLeft))) lRet = HTBORDER; @@ -3634,34 +3483,31 @@ public: ATLASSERT(_DebugCheckChild()); POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; - RECT rect = { 0 }; - GetWindowRect(&rect); + RECT rect = {}; + this->GetWindowRect(&rect); pt.x -= rect.left; pt.y -= rect.top; - RECT rcIcon = { 0 }; + RECT rcIcon = {}; T* pT = static_cast(this); - pT->_CalcIconRect(rect.right - rect.left, rect.bottom - rect.top, rcIcon, m_bLayoutRTL); - RECT arrRect[3] = { 0 }; - pT->_CalcBtnRects(rect.right - rect.left, rect.bottom - rect.top, arrRect, m_bLayoutRTL); + pT->_CalcIconRect(rect.right - rect.left, rect.bottom - rect.top, rcIcon, this->m_bLayoutRTL); + RECT arrRect[3] = {}; + pT->_CalcBtnRects(rect.right - rect.left, rect.bottom - rect.top, arrRect, this->m_bLayoutRTL); if(::PtInRect(&rcIcon, pt)) { #ifdef _CMDBAR_EXTRA_TRACE ATLTRACE2(atlTraceUI, 0, _T("MDI CmdBar - LButtonDown: icon\n")); -#endif -#ifndef TPM_VERPOSANIMATION - const UINT TPM_VERPOSANIMATION = 0x1000L; // Menu animation flag #endif CMenuHandle menu = ::GetSystemMenu(m_hWndChildMaximized, FALSE); UINT uRet = (UINT)menu.TrackPopupMenu(TPM_LEFTBUTTON | TPM_VERTICAL | TPM_LEFTALIGN | TPM_TOPALIGN | TPM_RETURNCMD | - (s_bW2K ? TPM_VERPOSANIMATION : 0), m_bLayoutRTL ? rect.right : rect.left, rect.bottom, m_hWndChildMaximized); + TPM_VERPOSANIMATION, this->m_bLayoutRTL ? rect.right : rect.left, rect.bottom, m_hWndChildMaximized); // eat next message if click is on the same button ::OffsetRect(&rcIcon, rect.left, rect.top); - MSG msg = { 0 }; - if(::PeekMessage(&msg, m_hWnd, WM_NCLBUTTONDOWN, WM_NCLBUTTONDOWN, PM_NOREMOVE) && ::PtInRect(&rcIcon, msg.pt)) - ::PeekMessage(&msg, m_hWnd, WM_NCLBUTTONDOWN, WM_NCLBUTTONDOWN, PM_REMOVE); + MSG msg = {}; + if(::PeekMessage(&msg, this->m_hWnd, WM_NCLBUTTONDOWN, WM_NCLBUTTONDOWN, PM_NOREMOVE) && ::PtInRect(&rcIcon, msg.pt)) + ::PeekMessage(&msg, this->m_hWnd, WM_NCLBUTTONDOWN, WM_NCLBUTTONDOWN, PM_REMOVE); if(uRet != 0) ::SendMessage(m_hWndChildMaximized, WM_SYSCOMMAND, uRet, 0L); @@ -3695,8 +3541,8 @@ public: // draw the button state if it was pressed if(m_nBtnPressed != -1) { - SetCapture(); - CWindowDC dc(m_hWnd); + this->SetCapture(); + CWindowDC dc(this->m_hWnd); pT->_CalcBtnRects(rect.right - rect.left, rect.bottom - rect.top, arrRect); pT->_DrawMDIButton(dc, arrRect, m_nBtnPressed); } @@ -3706,26 +3552,26 @@ public: LRESULT OnMouseMove(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled) { - if(!m_bChildMaximized || ::GetCapture() != m_hWnd || m_nBtnWasPressed == -1) + if(!m_bChildMaximized || (::GetCapture() != this->m_hWnd) || (m_nBtnWasPressed == -1)) { bHandled = FALSE; return 1; } POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; - ClientToScreen(&pt); - RECT rect = { 0 }; - GetWindowRect(&rect); + this->ClientToScreen(&pt); + RECT rect = {}; + this->GetWindowRect(&rect); pt.x -= rect.left; pt.y -= rect.top; - RECT arrRect[3] = { 0 }; + RECT arrRect[3] = {}; T* pT = static_cast(this); - pT->_CalcBtnRects(rect.right - rect.left, rect.bottom - rect.top, arrRect, m_bLayoutRTL); + pT->_CalcBtnRects(rect.right - rect.left, rect.bottom - rect.top, arrRect, this->m_bLayoutRTL); int nOldBtnPressed = m_nBtnPressed; m_nBtnPressed = ::PtInRect(&arrRect[m_nBtnWasPressed], pt) ? m_nBtnWasPressed : -1; if(nOldBtnPressed != m_nBtnPressed) { - CWindowDC dc(m_hWnd); + CWindowDC dc(this->m_hWnd); pT->_CalcBtnRects(rect.right - rect.left, rect.bottom - rect.top, arrRect); pT->_DrawMDIButton(dc, arrRect, (m_nBtnPressed != -1) ? m_nBtnPressed : nOldBtnPressed); } @@ -3735,7 +3581,7 @@ public: LRESULT OnLButtonUp(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled) { - if(!m_bChildMaximized || ::GetCapture() != m_hWnd || m_nBtnWasPressed == -1) + if(!m_bChildMaximized || (::GetCapture() != this->m_hWnd) || (m_nBtnWasPressed == -1)) { bHandled = FALSE; return 1; @@ -3744,18 +3590,18 @@ public: ATLASSERT(_DebugCheckChild()); POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; - ClientToScreen(&pt); - RECT rect = { 0 }; - GetWindowRect(&rect); + this->ClientToScreen(&pt); + RECT rect = {}; + this->GetWindowRect(&rect); pt.x -= rect.left; pt.y -= rect.top; int nBtn = m_nBtnWasPressed; ReleaseCapture(); - RECT arrRect[3] = { 0 }; + RECT arrRect[3] = {}; T* pT = static_cast(this); - pT->_CalcBtnRects(rect.right - rect.left, rect.bottom - rect.top, arrRect, m_bLayoutRTL); + pT->_CalcBtnRects(rect.right - rect.left, rect.bottom - rect.top, arrRect, this->m_bLayoutRTL); if(::PtInRect(&arrRect[nBtn], pt)) { switch(nBtn) @@ -3788,7 +3634,7 @@ public: LRESULT OnNcLButtonDblClk(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled) { - if(!m_bChildMaximized || m_nBtnWasPressed != -1) + if(!m_bChildMaximized || (m_nBtnWasPressed != -1)) { bHandled = FALSE; return 1; @@ -3797,16 +3643,16 @@ public: ATLASSERT(_DebugCheckChild()); POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; - RECT rect = { 0 }; - GetWindowRect(&rect); + RECT rect = {}; + this->GetWindowRect(&rect); pt.x -= rect.left; pt.y -= rect.top; - RECT rcIcon = { 0 }; + RECT rcIcon = {}; T* pT = static_cast(this); - pT->_CalcIconRect(rect.right - rect.left, rect.bottom - rect.top, rcIcon, m_bLayoutRTL); - RECT arrRect[3] = { 0 }; - pT->_CalcBtnRects(rect.right - rect.left, rect.bottom - rect.top, arrRect, m_bLayoutRTL); + pT->_CalcIconRect(rect.right - rect.left, rect.bottom - rect.top, rcIcon, this->m_bLayoutRTL); + RECT arrRect[3] = {}; + pT->_CalcBtnRects(rect.right - rect.left, rect.bottom - rect.top, arrRect, this->m_bLayoutRTL); if(::PtInRect(&rcIcon, pt)) { @@ -3828,12 +3674,12 @@ public: { ATLASSERT(m_nBtnPressed == m_nBtnWasPressed); // must be m_nBtnPressed = -1; - RECT rect = { 0 }; - GetWindowRect(&rect); - RECT arrRect[3] = { 0 }; + RECT rect = {}; + this->GetWindowRect(&rect); + RECT arrRect[3] = {}; T* pT = static_cast(this); pT->_CalcBtnRects(rect.right - rect.left, rect.bottom - rect.top, arrRect); - CWindowDC dc(m_hWnd); + CWindowDC dc(this->m_hWnd); pT->_DrawMDIButton(dc, arrRect, m_nBtnWasPressed); } m_nBtnWasPressed = -1; @@ -3848,8 +3694,8 @@ public: // Parent window message handlers LRESULT OnParentActivate(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) { - m_bParentActive = (LOWORD(wParam) != WA_INACTIVE); - RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_UPDATENOW); + this->m_bParentActive = (LOWORD(wParam) != WA_INACTIVE); + this->RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_UPDATENOW); bHandled = FALSE; return 1; } @@ -3858,15 +3704,13 @@ public: LRESULT OnMDISetMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) { m_wndMDIClient.DefWindowProc(uMsg, NULL, lParam); - HMENU hOldMenu = GetMenu(); - BOOL bRet = AttachMenu((HMENU)wParam); - bRet; // avoid level 4 warning + HMENU hOldMenu = this->GetMenu(); + BOOL bRet = this->AttachMenu((HMENU)wParam); + (void)bRet; // avoid level 4 warning ATLASSERT(bRet); -#if (_WIN32_IE >= 0x0400) T* pT = static_cast(this); pT->UpdateRebarBandIdealSize(); -#endif // (_WIN32_IE >= 0x0400) return (LRESULT)hOldMenu; } @@ -3887,23 +3731,24 @@ public: { // assuming we are in a rebar, change ideal size to our size // we hope that if we are not in a rebar, nCount will be 0 - int nCount = (int)::SendMessage(GetParent(), RB_GETBANDCOUNT, 0, 0L); + ATL::CWindow wndParent = this->GetParent(); + int nCount = (int)wndParent.SendMessage(RB_GETBANDCOUNT, 0, 0L); for(int i = 0; i < nCount; i++) { REBARBANDINFO rbi = { RunTimeHelper::SizeOf_REBARBANDINFO(), RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_IDEALSIZE }; - ::SendMessage(GetParent(), RB_GETBANDINFO, i, (LPARAM)&rbi); - if(rbi.hwndChild == m_hWnd) + wndParent.SendMessage(RB_GETBANDINFO, i, (LPARAM)&rbi); + if(rbi.hwndChild == this->m_hWnd) { rbi.fMask = RBBIM_IDEALSIZE; rbi.cxIdeal = m_bChildMaximized ? m_cxLeft + m_cxRight : 0; - int nBtnCount = GetButtonCount(); + int nBtnCount = this->GetButtonCount(); if(nBtnCount > 0) { - RECT rect = { 0 }; - GetItemRect(nBtnCount - 1, &rect); + RECT rect = {}; + this->GetItemRect(nBtnCount - 1, &rect); rbi.cxIdeal += rect.right; } - ::SendMessage(GetParent(), RB_SETBANDINFO, i, (LPARAM)&rbi); + wndParent.SendMessage(RB_SETBANDINFO, i, (LPARAM)&rbi); break; } } @@ -3912,13 +3757,13 @@ public: // all hook messages - check for the maximized MDI child window change void _ProcessAllHookMessages(UINT uMsg, WPARAM /*wParam*/, LPARAM /*lParam*/) { - if(uMsg == WM_MDIGETACTIVE || uMsg == WM_MDISETMENU) + if((uMsg == WM_MDIGETACTIVE) || (uMsg == WM_MDISETMENU)) return; BOOL bMaximized = FALSE; HWND hWndChild = (HWND)::SendMessage(m_wndMDIClient, WM_MDIGETACTIVE, 0, (LPARAM)&bMaximized); bool bMaxOld = m_bChildMaximized; - m_bChildMaximized = (hWndChild != NULL && bMaximized); + m_bChildMaximized = ((hWndChild != NULL) && bMaximized); HICON hIconOld = m_hIconChildMaximized; if(m_bChildMaximized) @@ -3930,16 +3775,8 @@ public: if(m_hIconChildMaximized == NULL) { m_hIconChildMaximized = wnd.GetIcon(TRUE); - if(m_hIconChildMaximized == NULL) - { - // no icon set with WM_SETICON, get the class one -// need conditional code because types don't match in winuser.h -#ifdef _WIN64 + if(m_hIconChildMaximized == NULL) // no icon set with WM_SETICON, get the class one m_hIconChildMaximized = (HICON)::GetClassLongPtr(wnd, GCLP_HICONSM); -#else - m_hIconChildMaximized = (HICON)LongToHandle(::GetClassLongPtr(wnd, GCLP_HICONSM)); -#endif - } } } } @@ -3956,60 +3793,38 @@ public: #endif // assuming we are in a rebar, change our size to accomodate new state // we hope that if we are not in a rebar, nCount will be 0 - int nCount = (int)::SendMessage(GetParent(), RB_GETBANDCOUNT, 0, 0L); + ATL::CWindow wndParent = this->GetParent(); + int nCount = (int)wndParent.SendMessage(RB_GETBANDCOUNT, 0, 0L); int cxDiff = (m_bChildMaximized ? 1 : -1) * (m_cxLeft + m_cxRight); for(int i = 0; i < nCount; i++) { -#if (_WIN32_IE >= 0x0500) REBARBANDINFO rbi = { RunTimeHelper::SizeOf_REBARBANDINFO(), RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_IDEALSIZE | RBBIM_STYLE }; - ::SendMessage(GetParent(), RB_GETBANDINFO, i, (LPARAM)&rbi); - if(rbi.hwndChild == m_hWnd) + wndParent.SendMessage(RB_GETBANDINFO, i, (LPARAM)&rbi); + if(rbi.hwndChild == this->m_hWnd) { if((rbi.fStyle & RBBS_USECHEVRON) != 0) { rbi.fMask = RBBIM_CHILDSIZE | RBBIM_IDEALSIZE; rbi.cxMinChild += cxDiff; rbi.cxIdeal += cxDiff; - ::SendMessage(GetParent(), RB_SETBANDINFO, i, (LPARAM)&rbi); + wndParent.SendMessage(RB_SETBANDINFO, i, (LPARAM)&rbi); } break; } -#elif (_WIN32_IE >= 0x0400) - REBARBANDINFO rbi = { RunTimeHelper::SizeOf_REBARBANDINFO(), RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_IDEALSIZE }; - ::SendMessage(GetParent(), RB_GETBANDINFO, i, (LPARAM)&rbi); - if(rbi.hwndChild == m_hWnd) - { - rbi.fMask = RBBIM_CHILDSIZE | RBBIM_IDEALSIZE; - rbi.cxMinChild += cxDiff; - rbi.cxIdeal += cxDiff; - ::SendMessage(GetParent(), RB_SETBANDINFO, i, (LPARAM)&rbi); - break; - } -#else // (_WIN32_IE < 0x0400) - REBARBANDINFO rbi = { RunTimeHelper::SizeOf_REBARBANDINFO(), RBBIM_CHILD | RBBIM_CHILDSIZE }; - ::SendMessage(GetParent(), RB_GETBANDINFO, i, (LPARAM)&rbi); - if(rbi.hwndChild == m_hWnd) - { - rbi.fMask = RBBIM_CHILDSIZE; - rbi.cxMinChild += cxDiff; - ::SendMessage(GetParent(), RB_SETBANDINFO, i, (LPARAM)&rbi); - break; - } -#endif // (_WIN32_IE < 0x0400) } } - if(bMaxOld != m_bChildMaximized || hIconOld != m_hIconChildMaximized) + if((bMaxOld != m_bChildMaximized) || (hIconOld != m_hIconChildMaximized)) { // force size change and redraw everything - RECT rect = { 0 }; - GetWindowRect(&rect); - ::MapWindowPoints(NULL, GetParent(), (LPPOINT)&rect, 2); - SetRedraw(FALSE); - SetWindowPos(NULL, 0, 0, 1, 1, SWP_NOZORDER | SWP_NOMOVE); - SetWindowPos(NULL, &rect, SWP_NOZORDER | SWP_NOMOVE); - SetRedraw(TRUE); - RedrawWindow(NULL, NULL, RDW_FRAME | RDW_INVALIDATE | RDW_UPDATENOW); + RECT rect = {}; + this->GetWindowRect(&rect); + ::MapWindowPoints(NULL, this->GetParent(), (LPPOINT)&rect, 2); + this->SetRedraw(FALSE); + this->SetWindowPos(NULL, 0, 0, 1, 1, SWP_NOZORDER | SWP_NOMOVE); + this->SetWindowPos(NULL, &rect, SWP_NOZORDER | SWP_NOMOVE); + this->SetRedraw(TRUE); + this->RedrawWindow(NULL, NULL, RDW_FRAME | RDW_INVALIDATE | RDW_UPDATENOW); } } @@ -4030,7 +3845,6 @@ public: m_cyIconHeight = ::GetSystemMetrics(SM_CYSMICON); m_cxLeft = m_cxIconWidth; -#ifndef _WTL_NO_AUTO_THEME if(m_hTheme != NULL) { m_cxBtnWidth = info.iCaptionWidth - 2 * m_cxyOffset; @@ -4038,7 +3852,6 @@ public: m_cxRight = 3 * m_cxBtnWidth; } else -#endif // !_WTL_NO_AUTO_THEME { m_cxBtnWidth = info.iCaptionWidth - m_cxyOffset; m_cyBtnHeight = info.iCaptionHeight - 2 * m_cxyOffset; @@ -4046,17 +3859,16 @@ public: } } - RECT rect = { 0 }; - GetClientRect(&rect); + RECT rect = {}; + this->GetClientRect(&rect); T* pT = static_cast(this); pT->_AdjustBtnSize(rect.bottom); } void _AdjustBtnSize(int cyHeight) { - if(cyHeight > 1 && m_cyBtnHeight > cyHeight) + if((cyHeight > 1) && (m_cyBtnHeight > cyHeight)) { -#ifndef _WTL_NO_AUTO_THEME if(m_hTheme != NULL) { m_cyBtnHeight = cyHeight; @@ -4064,7 +3876,6 @@ public: m_cxRight = 3 * m_cxBtnWidth; } else -#endif // !_WTL_NO_AUTO_THEME { m_cyBtnHeight = cyHeight; m_cxBtnWidth = cyHeight + m_cxyOffset; @@ -4103,11 +3914,9 @@ public: } arrRect[0] = rcBtn; -#ifndef _WTL_NO_AUTO_THEME if(m_hTheme != NULL) ::OffsetRect(&rcBtn, nDirection * m_cxBtnWidth, 0); else -#endif // !_WTL_NO_AUTO_THEME ::OffsetRect(&rcBtn, nDirection * (m_cxBtnWidth + m_cxyOffset), 0); arrRect[1] = rcBtn; ::OffsetRect(&rcBtn, nDirection * m_cxBtnWidth, 0); @@ -4116,10 +3925,9 @@ public: void _DrawMDIButton(CWindowDC& dc, LPRECT pRects, int nBtn) { -#ifndef _WTL_NO_AUTO_THEME if(m_hTheme != NULL) { -#if !defined(TMSCHEMA_H) && !defined(__VSSYM32_H__) +#ifndef __VSSYM32_H__ const int WP_MDICLOSEBUTTON = 20; const int CBS_NORMAL = 1; const int CBS_PUSHED = 3; @@ -4132,68 +3940,46 @@ public: const int MINBS_NORMAL = 1; const int MINBS_PUSHED = 3; const int MINBS_DISABLED = 4; -#endif // !defined(TMSCHEMA_H) && !defined(__VSSYM32_H__) - if(nBtn == -1 || nBtn == 0) - m_pfnDrawThemeBackground(m_hTheme, dc, WP_MDICLOSEBUTTON, m_bParentActive ? ((m_nBtnPressed == 0) ? CBS_PUSHED : CBS_NORMAL) : CBS_DISABLED, &pRects[0], NULL); - if(nBtn == -1 || nBtn == 1) - m_pfnDrawThemeBackground(m_hTheme, dc, WP_MDIRESTOREBUTTON, m_bParentActive ? ((m_nBtnPressed == 1) ? RBS_PUSHED : RBS_NORMAL) : RBS_DISABLED, &pRects[1], NULL); - if(nBtn == -1 || nBtn == 2) - m_pfnDrawThemeBackground(m_hTheme, dc, WP_MDIMINBUTTON, m_bParentActive ? ((m_nBtnPressed == 2) ? MINBS_PUSHED : MINBS_NORMAL) : MINBS_DISABLED, &pRects[2], NULL); +#endif // __VSSYM32_H__ + if((nBtn == -1) || (nBtn == 0)) + ::DrawThemeBackground(m_hTheme, dc, WP_MDICLOSEBUTTON, this->m_bParentActive ? ((m_nBtnPressed == 0) ? CBS_PUSHED : CBS_NORMAL) : CBS_DISABLED, &pRects[0], NULL); + if((nBtn == -1) || (nBtn == 1)) + ::DrawThemeBackground(m_hTheme, dc, WP_MDIRESTOREBUTTON, this->m_bParentActive ? ((m_nBtnPressed == 1) ? RBS_PUSHED : RBS_NORMAL) : RBS_DISABLED, &pRects[1], NULL); + if((nBtn == -1) || (nBtn == 2)) + ::DrawThemeBackground(m_hTheme, dc, WP_MDIMINBUTTON, this->m_bParentActive ? ((m_nBtnPressed == 2) ? MINBS_PUSHED : MINBS_NORMAL) : MINBS_DISABLED, &pRects[2], NULL); } else -#endif // !_WTL_NO_AUTO_THEME { - if(nBtn == -1 || nBtn == 0) + if((nBtn == -1) || (nBtn == 0)) dc.DrawFrameControl(&pRects[0], DFC_CAPTION, DFCS_CAPTIONCLOSE | ((m_nBtnPressed == 0) ? DFCS_PUSHED : 0)); - if(nBtn == -1 || nBtn == 1) + if((nBtn == -1) || (nBtn == 1)) dc.DrawFrameControl(&pRects[1], DFC_CAPTION, DFCS_CAPTIONRESTORE | ((m_nBtnPressed == 1) ? DFCS_PUSHED : 0)); - if(nBtn == -1 || nBtn == 2) + if((nBtn == -1) || (nBtn == 2)) dc.DrawFrameControl(&pRects[2], DFC_CAPTION, DFCS_CAPTIONMIN | ((m_nBtnPressed == 2) ? DFCS_PUSHED : 0)); } } -#ifndef _WTL_NO_AUTO_THEME - static UINT _GetThemeChangedMsg() - { -#ifndef WM_THEMECHANGED - static const UINT WM_THEMECHANGED = 0x031A; -#endif // !WM_THEMECHANGED - return WM_THEMECHANGED; - } - void _OpenThemeData() { - ATLASSERT(m_hThemeDLL != NULL); - - PFN_OpenThemeData pfnOpenThemeData = (PFN_OpenThemeData)::GetProcAddress(m_hThemeDLL, "OpenThemeData"); - ATLASSERT(pfnOpenThemeData != NULL); - if(pfnOpenThemeData != NULL) - m_hTheme = pfnOpenThemeData(m_hWnd, L"Window"); + if(RunTimeHelper::IsThemeAvailable()) + m_hTheme = ::OpenThemeData(this->m_hWnd, L"Window"); } void _CloseThemeData() { - ATLASSERT(m_hThemeDLL != NULL); - - if(m_hTheme == NULL) - return; // nothing to do - - PFN_CloseThemeData pfnCloseThemeData = (PFN_CloseThemeData)::GetProcAddress(m_hThemeDLL, "CloseThemeData"); - ATLASSERT(pfnCloseThemeData != NULL); - if(pfnCloseThemeData != NULL) + if(m_hTheme != NULL) { - pfnCloseThemeData(m_hTheme); + ::CloseThemeData(m_hTheme); m_hTheme = NULL; } } -#endif // !_WTL_NO_AUTO_THEME bool _DebugCheckChild() { #ifdef _DEBUG BOOL bMaximized = FALSE; HWND hWndChild = (HWND)::SendMessage(m_wndMDIClient, WM_MDIGETACTIVE, 0, (LPARAM)&bMaximized); - return (bMaximized && hWndChild == m_hWndChildMaximized); + return (bMaximized && (hWndChild == m_hWndChildMaximized)); #else // !_DEBUG return true; #endif // !_DEBUG @@ -4206,6 +3992,6 @@ public: DECLARE_WND_SUPERCLASS(_T("WTL_MDICommandBar"), GetWndClassName()) }; -}; // namespace WTL +} // namespace WTL #endif // __ATLCTRLW_H__ diff --git a/ZbaSDK/SampleCode/PluginWinExe/WTL/atlctrlx.h b/ZbaSDK/SampleCode/PluginWinExe/WTL/atlctrlx.h index c0ad456388d50ab178677d2701a1d405ec43dae4..5230ed17cb98416f2ec0982510a103061cb86b50 100644 --- a/ZbaSDK/SampleCode/PluginWinExe/WTL/atlctrlx.h +++ b/ZbaSDK/SampleCode/PluginWinExe/WTL/atlctrlx.h @@ -1,4 +1,4 @@ -// Windows Template Library - WTL version 9.10 +// Windows Template Library - WTL version 10.0 // Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. // // This file is a part of the Windows Template Library. @@ -19,10 +19,6 @@ #error atlctrlx.h requires atlctrls.h to be included first #endif -#ifndef WM_UPDATEUISTATE - #define WM_UPDATEUISTATE 0x0128 -#endif // !WM_UPDATEUISTATE - /////////////////////////////////////////////////////////////////////////////// // Classes in this file: @@ -51,8 +47,6 @@ namespace WTL /////////////////////////////////////////////////////////////////////////////// // CBitmapButton - bitmap button implementation -#ifndef _WIN32_WCE - // bitmap button extended styles #define BMPBTN_HOVER 0x00000001 #define BMPBTN_AUTO3D_SINGLE 0x00000002 @@ -70,7 +64,7 @@ template { public: - DECLARE_WND_SUPERCLASS(NULL, TBase::GetWndClassName()) + DECLARE_WND_SUPERCLASS2(NULL, T, TBase::GetWndClassName()) enum { @@ -131,12 +125,7 @@ public: // overridden to provide proper initialization BOOL SubclassWindow(HWND hWnd) { -#if (_MSC_VER >= 1300) BOOL bRet = ATL::CWindowImpl< T, TBase, TWinTraits >::SubclassWindow(hWnd); -#else // !(_MSC_VER >= 1300) - typedef ATL::CWindowImpl< T, TBase, TWinTraits > _baseClass; - BOOL bRet = _baseClass::SubclassWindow(hWnd); -#endif // !(_MSC_VER >= 1300) if(bRet != FALSE) { T* pT = static_cast(this); @@ -177,7 +166,7 @@ public: { HIMAGELIST hImageListPrev = m_ImageList; m_ImageList = hImageList; - if((m_dwExtendedStyle & BMPBTN_AUTOSIZE) != 0 && ::IsWindow(m_hWnd)) + if(((m_dwExtendedStyle & BMPBTN_AUTOSIZE) != 0) && ::IsWindow(this->m_hWnd)) SizeToImage(); return hImageListPrev; @@ -194,9 +183,9 @@ public: if(m_lpstrToolTipText == NULL) return false; - errno_t nRet = SecureHelper::strncpy_x(lpstrText, nLength, m_lpstrToolTipText, _TRUNCATE); + errno_t nRet = ATL::Checked::tcsncpy_s(lpstrText, nLength, m_lpstrToolTipText, _TRUNCATE); - return (nRet == 0 || nRet == STRUNCATE); + return ((nRet == 0) || (nRet == STRUNCATE)); } bool SetToolTipText(LPCTSTR lpstrText) @@ -219,11 +208,11 @@ public: if(m_lpstrToolTipText == NULL) return false; - SecureHelper::strcpy_x(m_lpstrToolTipText, cchLen, lpstrText); + ATL::Checked::tcscpy_s(m_lpstrToolTipText, cchLen, lpstrText); if(m_tip.IsWindow()) { m_tip.Activate(TRUE); - m_tip.AddTool(m_hWnd, m_lpstrToolTipText); + m_tip.AddTool(this->m_hWnd, m_lpstrToolTipText); } return true; @@ -240,8 +229,8 @@ public: if(bUpdate) { - Invalidate(); - UpdateWindow(); + this->Invalidate(); + this->UpdateWindow(); } } @@ -260,12 +249,12 @@ public: BOOL SizeToImage() { - ATLASSERT(::IsWindow(m_hWnd) && m_ImageList.m_hImageList != NULL); + ATLASSERT(::IsWindow(this->m_hWnd) && (m_ImageList.m_hImageList != NULL)); int cx = 0; int cy = 0; if(!m_ImageList.GetIconSize(cx, cy)) return FALSE; - return ResizeClient(cx, cy); + return this->ResizeClient(cx, cy); } // Overrideables @@ -278,7 +267,7 @@ public: bool bHover = IsHoverMode(); bool bPressed = (m_fPressed == 1) || (IsCheckMode() && (m_fChecked == 1)); int nImage = -1; - if(!IsWindowEnabled()) + if(!this->IsWindowEnabled()) nImage = m_nImage[_nImageDisabled]; else if(bPressed) nImage = m_nImage[_nImagePushed]; @@ -297,8 +286,8 @@ public: // draw 3D border if required if(bAuto3D) { - RECT rect = { 0 }; - GetClientRect(&rect); + RECT rect = {}; + this->GetClientRect(&rect); if(bPressed) dc.DrawEdge(&rect, ((m_dwExtendedStyle & BMPBTN_AUTO3D_SINGLE) != 0) ? BDR_SUNKENOUTER : EDGE_SUNKEN, BF_RECT); @@ -358,7 +347,7 @@ public: LRESULT OnMouseMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { - MSG msg = { m_hWnd, uMsg, wParam, lParam }; + MSG msg = { this->m_hWnd, uMsg, wParam, lParam }; if(m_tip.IsWindow()) m_tip.RelayEvent(&msg); bHandled = FALSE; @@ -379,7 +368,7 @@ public: } else { - CPaintDC dc(m_hWnd); + CPaintDC dc(this->m_hWnd); pT->DoPaint(dc.m_hDC); } return 0; @@ -388,8 +377,8 @@ public: LRESULT OnFocus(UINT uMsg, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) { m_fFocus = (uMsg == WM_SETFOCUS) ? 1 : 0; - Invalidate(); - UpdateWindow(); + this->Invalidate(); + this->UpdateWindow(); bHandled = FALSE; return 1; } @@ -398,14 +387,14 @@ public: { LRESULT lRet = 0; if(IsHoverMode()) - SetCapture(); + this->SetCapture(); else - lRet = DefWindowProc(uMsg, wParam, lParam); - if(::GetCapture() == m_hWnd) + lRet = this->DefWindowProc(uMsg, wParam, lParam); + if(::GetCapture() == this->m_hWnd) { m_fPressed = 1; - Invalidate(); - UpdateWindow(); + this->Invalidate(); + this->UpdateWindow(); } if(((m_dwExtendedStyle & BMPBTN_AUTOFIRE) != 0) && !IsCheckMode()) { @@ -413,7 +402,7 @@ public: int nDelay = 0; if(::SystemParametersInfo(SPI_GETKEYBOARDDELAY, 0, &nDelay, 0)) nElapse += nDelay * 250; // all milli-seconds - SetTimer(ID_TIMER_FIRST, nElapse); + this->SetTimer(ID_TIMER_FIRST, nElapse); } return lRet; } @@ -422,14 +411,14 @@ public: { LRESULT lRet = 0; if(!IsHoverMode() && !IsCheckMode()) - lRet = DefWindowProc(uMsg, wParam, lParam); - if(::GetCapture() != m_hWnd) - SetCapture(); + lRet = this->DefWindowProc(uMsg, wParam, lParam); + if(::GetCapture() != this->m_hWnd) + this->SetCapture(); if(m_fPressed == 0) { m_fPressed = 1; - Invalidate(); - UpdateWindow(); + this->Invalidate(); + this->UpdateWindow(); } return lRet; } @@ -441,11 +430,11 @@ public: LRESULT lRet = 0; if(!IsHoverMode() && !IsCheckMode()) - lRet = DefWindowProc(uMsg, wParam, lParam); - if(::GetCapture() == m_hWnd) + lRet = this->DefWindowProc(uMsg, wParam, lParam); + if(::GetCapture() == this->m_hWnd) { if((IsHoverMode() || IsCheckMode()) && (m_fPressed == 1)) - ::SendMessage(GetParent(), WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(), BN_CLICKED), (LPARAM)m_hWnd); + this->GetParent().SendMessage(WM_COMMAND, MAKEWPARAM(this->GetDlgCtrlID(), BN_CLICKED), (LPARAM)this->m_hWnd); ::ReleaseCapture(); } return lRet; @@ -456,8 +445,8 @@ public: if(m_fPressed == 1) { m_fPressed = 0; - Invalidate(); - UpdateWindow(); + this->Invalidate(); + this->UpdateWindow(); } bHandled = FALSE; return 1; @@ -465,33 +454,33 @@ public: LRESULT OnEnable(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) { - Invalidate(); - UpdateWindow(); + this->Invalidate(); + this->UpdateWindow(); bHandled = FALSE; return 1; } LRESULT OnMouseMove(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled) { - if(::GetCapture() == m_hWnd) + if(::GetCapture() == this->m_hWnd) { POINT ptCursor = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; - ClientToScreen(&ptCursor); - RECT rect = { 0 }; - GetWindowRect(&rect); + this->ClientToScreen(&ptCursor); + RECT rect = {}; + this->GetWindowRect(&rect); unsigned int uPressed = ::PtInRect(&rect, ptCursor) ? 1 : 0; if(m_fPressed != uPressed) { m_fPressed = uPressed; - Invalidate(); - UpdateWindow(); + this->Invalidate(); + this->UpdateWindow(); } } else if(IsHoverMode() && m_fMouseOver == 0) { m_fMouseOver = 1; - Invalidate(); - UpdateWindow(); + this->Invalidate(); + this->UpdateWindow(); StartTrackMouseLeave(); } bHandled = FALSE; @@ -503,21 +492,21 @@ public: if(m_fMouseOver == 1) { m_fMouseOver = 0; - Invalidate(); - UpdateWindow(); + this->Invalidate(); + this->UpdateWindow(); } return 0; } LRESULT OnKeyDown(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) { - if(wParam == VK_SPACE && IsHoverMode()) + if((wParam == VK_SPACE) && IsHoverMode()) return 0; // ignore if in hover mode - if(wParam == VK_SPACE && m_fPressed == 0) + if((wParam == VK_SPACE) && (m_fPressed == 0)) { m_fPressed = 1; - Invalidate(); - UpdateWindow(); + this->Invalidate(); + this->UpdateWindow(); } bHandled = FALSE; return 1; @@ -525,15 +514,15 @@ public: LRESULT OnKeyUp(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) { - if(wParam == VK_SPACE && IsHoverMode()) + if((wParam == VK_SPACE) && IsHoverMode()) return 0; // ignore if in hover mode - if(wParam == VK_SPACE && m_fPressed == 1) + if((wParam == VK_SPACE) && (m_fPressed == 1)) { m_fPressed = 0; if((m_dwExtendedStyle & BMPBTN_AUTOCHECK) != 0) SetCheck(!GetCheck(), false); - Invalidate(); - UpdateWindow(); + this->Invalidate(); + this->UpdateWindow(); } bHandled = FALSE; return 1; @@ -545,22 +534,22 @@ public: switch(wParam) // timer ID { case ID_TIMER_FIRST: - KillTimer(ID_TIMER_FIRST); + this->KillTimer(ID_TIMER_FIRST); if(m_fPressed == 1) { - ::SendMessage(GetParent(), WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(), BN_CLICKED), (LPARAM)m_hWnd); + this->GetParent().SendMessage(WM_COMMAND, MAKEWPARAM(this->GetDlgCtrlID(), BN_CLICKED), (LPARAM)this->m_hWnd); int nElapse = 250; int nRepeat = 40; if(::SystemParametersInfo(SPI_GETKEYBOARDSPEED, 0, &nRepeat, 0)) nElapse = 10000 / (10 * nRepeat + 25); // milli-seconds, approximated - SetTimer(ID_TIMER_REPEAT, nElapse); + this->SetTimer(ID_TIMER_REPEAT, nElapse); } break; case ID_TIMER_REPEAT: if(m_fPressed == 1) - ::SendMessage(GetParent(), WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(), BN_CLICKED), (LPARAM)m_hWnd); - else if(::GetCapture() != m_hWnd) - KillTimer(ID_TIMER_REPEAT); + this->GetParent().SendMessage(WM_COMMAND, MAKEWPARAM(this->GetDlgCtrlID(), BN_CLICKED), (LPARAM)this->m_hWnd); + else if(::GetCapture() != this->m_hWnd) + this->KillTimer(ID_TIMER_REPEAT); break; default: // not our timer break; @@ -579,28 +568,28 @@ public: void Init() { // We need this style to prevent Windows from painting the button - ModifyStyle(0, BS_OWNERDRAW); + this->ModifyStyle(0, BS_OWNERDRAW); // create a tool tip - m_tip.Create(m_hWnd); + m_tip.Create(this->m_hWnd); ATLASSERT(m_tip.IsWindow()); - if(m_tip.IsWindow() && m_lpstrToolTipText != NULL) + if(m_tip.IsWindow() && (m_lpstrToolTipText != NULL)) { m_tip.Activate(TRUE); - m_tip.AddTool(m_hWnd, m_lpstrToolTipText); + m_tip.AddTool(this->m_hWnd, m_lpstrToolTipText); } - if(m_ImageList.m_hImageList != NULL && (m_dwExtendedStyle & BMPBTN_AUTOSIZE) != 0) + if((m_ImageList.m_hImageList != NULL) && ((m_dwExtendedStyle & BMPBTN_AUTOSIZE) != 0)) SizeToImage(); } BOOL StartTrackMouseLeave() { - TRACKMOUSEEVENT tme = { 0 }; + TRACKMOUSEEVENT tme = {}; tme.cbSize = sizeof(tme); tme.dwFlags = TME_LEAVE; - tme.hwndTrack = m_hWnd; - return _TrackMouseEvent(&tme); + tme.hwndTrack = this->m_hWnd; + return ::TrackMouseEvent(&tme); } bool IsHoverMode() const @@ -624,8 +613,6 @@ public: { } }; -#endif // !_WIN32_WCE - /////////////////////////////////////////////////////////////////////////////// // CCheckListCtrlView - list view control with check boxes @@ -656,7 +643,7 @@ template { public: - DECLARE_WND_SUPERCLASS(NULL, TBase::GetWndClassName()) + DECLARE_WND_SUPERCLASS2(NULL, T, TBase::GetWndClassName()) // Attributes static DWORD GetExtendedLVStyle() @@ -667,12 +654,7 @@ public: // Operations BOOL SubclassWindow(HWND hWnd) { -#if (_MSC_VER >= 1300) BOOL bRet = ATL::CWindowImpl< T, TBase, TWinTraits >::SubclassWindow(hWnd); -#else // !(_MSC_VER >= 1300) - typedef ATL::CWindowImpl< T, TBase, TWinTraits > _baseClass; - BOOL bRet = _baseClass::SubclassWindow(hWnd); -#endif // !(_MSC_VER >= 1300) if(bRet != FALSE) { T* pT = static_cast(this); @@ -685,23 +667,23 @@ public: void CheckSelectedItems(int nCurrItem) { // first check if this item is selected - LVITEM lvi = { 0 }; + LVITEM lvi = {}; lvi.iItem = nCurrItem; lvi.iSubItem = 0; lvi.mask = LVIF_STATE; lvi.stateMask = LVIS_SELECTED; - GetItem(&lvi); + this->GetItem(&lvi); // if item is not selected, don't do anything if(!(lvi.state & LVIS_SELECTED)) return; // new check state will be reverse of the current state, - BOOL bCheck = !GetCheckState(nCurrItem); + BOOL bCheck = !this->GetCheckState(nCurrItem); int nItem = -1; int nOldItem = -1; - while((nItem = GetNextItem(nOldItem, LVNI_SELECTED)) != -1) + while((nItem = this->GetNextItem(nOldItem, LVNI_SELECTED)) != -1) { if(nItem != nCurrItem) - SetCheckState(nItem, bCheck); + this->SetCheckState(nItem, bCheck); nOldItem = nItem; } } @@ -710,9 +692,9 @@ public: void Init() { T* pT = static_cast(this); - pT; // avoid level 4 warning + (void)pT; // avoid level 4 warning ATLASSERT((pT->GetExtendedLVStyle() & LVS_EX_CHECKBOXES) != 0); - SetExtendedListViewStyle(pT->GetExtendedLVStyle()); + this->SetExtendedListViewStyle(pT->GetExtendedLVStyle()); } // Message map and handlers @@ -726,7 +708,7 @@ public: LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) { // first let list view control initialize everything - LRESULT lRet = DefWindowProc(uMsg, wParam, lParam); + LRESULT lRet = this->DefWindowProc(uMsg, wParam, lParam); if(lRet == 0) { T* pT = static_cast(this); @@ -739,9 +721,9 @@ public: LRESULT OnLButtonDown(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled) { POINT ptMsg = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; - LVHITTESTINFO lvh = { 0 }; + LVHITTESTINFO lvh = {}; lvh.pt = ptMsg; - if(HitTest(&lvh) != -1 && lvh.flags == LVHT_ONITEMSTATEICON && ::GetKeyState(VK_CONTROL) >= 0) + if((this->HitTest(&lvh) != -1) && (lvh.flags == LVHT_ONITEMSTATEICON) && (::GetKeyState(VK_CONTROL) >= 0)) { T* pT = static_cast(this); pT->CheckSelectedItems(lvh.iItem); @@ -754,8 +736,8 @@ public: { if(wParam == VK_SPACE) { - int nCurrItem = GetNextItem(-1, LVNI_FOCUSED); - if(nCurrItem != -1 && ::GetKeyState(VK_CONTROL) >= 0) + int nCurrItem = this->GetNextItem(-1, LVNI_FOCUSED); + if((nCurrItem != -1) && (::GetKeyState(VK_CONTROL) >= 0)) { T* pT = static_cast(this); pT->CheckSelectedItems(nCurrItem); @@ -776,40 +758,6 @@ public: /////////////////////////////////////////////////////////////////////////////// // CHyperLink - hyper link control implementation -#if (WINVER < 0x0500) && !defined(_WIN32_WCE) -__declspec(selectany) struct -{ - enum { cxWidth = 32, cyHeight = 32 }; - int xHotSpot; - int yHotSpot; - unsigned char arrANDPlane[cxWidth * cyHeight / 8]; - unsigned char arrXORPlane[cxWidth * cyHeight / 8]; -} _AtlHyperLink_CursorData = -{ - 5, 0, - { - 0xF9, 0xFF, 0xFF, 0xFF, 0xF0, 0xFF, 0xFF, 0xFF, 0xF0, 0xFF, 0xFF, 0xFF, 0xF0, 0xFF, 0xFF, 0xFF, - 0xF0, 0xFF, 0xFF, 0xFF, 0xF0, 0x3F, 0xFF, 0xFF, 0xF0, 0x07, 0xFF, 0xFF, 0xF0, 0x01, 0xFF, 0xFF, - 0xF0, 0x00, 0xFF, 0xFF, 0x10, 0x00, 0x7F, 0xFF, 0x00, 0x00, 0x7F, 0xFF, 0x00, 0x00, 0x7F, 0xFF, - 0x80, 0x00, 0x7F, 0xFF, 0xC0, 0x00, 0x7F, 0xFF, 0xC0, 0x00, 0x7F, 0xFF, 0xE0, 0x00, 0x7F, 0xFF, - 0xE0, 0x00, 0xFF, 0xFF, 0xF0, 0x00, 0xFF, 0xFF, 0xF0, 0x00, 0xFF, 0xFF, 0xF8, 0x01, 0xFF, 0xFF, - 0xF8, 0x01, 0xFF, 0xFF, 0xF8, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF - }, - { - 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x06, 0xC0, 0x00, 0x00, 0x06, 0xD8, 0x00, 0x00, - 0x06, 0xDA, 0x00, 0x00, 0x06, 0xDB, 0x00, 0x00, 0x67, 0xFB, 0x00, 0x00, 0x77, 0xFF, 0x00, 0x00, - 0x37, 0xFF, 0x00, 0x00, 0x17, 0xFF, 0x00, 0x00, 0x1F, 0xFF, 0x00, 0x00, 0x0F, 0xFF, 0x00, 0x00, - 0x0F, 0xFE, 0x00, 0x00, 0x07, 0xFE, 0x00, 0x00, 0x07, 0xFE, 0x00, 0x00, 0x03, 0xFC, 0x00, 0x00, - 0x03, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - } -}; -#endif // (WINVER < 0x0500) && !defined(_WIN32_WCE) - #define HLINK_UNDERLINED 0x00000000 #define HLINK_NOTUNDERLINED 0x00000001 #define HLINK_UNDERLINEHOVER 0x00000002 @@ -837,9 +785,7 @@ public: HFONT m_hFontNormal; RECT m_rcLink; -#ifndef _WIN32_WCE CToolTipCtrl m_tip; -#endif // !_WIN32_WCE COLORREF m_clrLink; COLORREF m_clrVisited; @@ -869,11 +815,6 @@ public: { delete [] m_lpstrLabel; delete [] m_lpstrHyperLink; -#if (WINVER < 0x0500) && !defined(_WIN32_WCE) - // It was created, not loaded, so we have to destroy it - if(m_hCursor != NULL) - ::DestroyCursor(m_hCursor); -#endif // (WINVER < 0x0500) && !defined(_WIN32_WCE) } // Attributes @@ -900,7 +841,7 @@ public: if(nLength <= lstrlen(m_lpstrLabel)) return false; - SecureHelper::strcpy_x(lpstrBuffer, nLength, m_lpstrLabel); + ATL::Checked::tcscpy_s(lpstrBuffer, nLength, m_lpstrLabel); return true; } @@ -914,12 +855,12 @@ public: if(m_lpstrLabel == NULL) return false; - SecureHelper::strcpy_x(m_lpstrLabel, cchLen, lpstrLabel); + ATL::Checked::tcscpy_s(m_lpstrLabel, cchLen, lpstrLabel); T* pT = static_cast(this); pT->CalcLabelRect(); - if(m_hWnd != NULL) - SetWindowText(lpstrLabel); // Set this for accessibility + if(this->m_hWnd != NULL) + this->SetWindowText(lpstrLabel); // Set this for accessibility return true; } @@ -932,7 +873,7 @@ public: if(nLength <= lstrlen(m_lpstrHyperLink)) return false; - SecureHelper::strcpy_x(lpstrBuffer, nLength, m_lpstrHyperLink); + ATL::Checked::tcscpy_s(lpstrBuffer, nLength, m_lpstrHyperLink); return true; } @@ -946,19 +887,19 @@ public: if(m_lpstrHyperLink == NULL) return false; - SecureHelper::strcpy_x(m_lpstrHyperLink, cchLen, lpstrLink); + ATL::Checked::tcscpy_s(m_lpstrHyperLink, cchLen, lpstrLink); if(m_lpstrLabel == NULL) { T* pT = static_cast(this); pT->CalcLabelRect(); } -#ifndef _WIN32_WCE + if(m_tip.IsWindow()) { m_tip.Activate(TRUE); - m_tip.AddTool(m_hWnd, m_lpstrHyperLink, &m_rcLink, 1); + m_tip.AddTool(this->m_hWnd, m_lpstrHyperLink, &m_rcLink, 1); } -#endif // !_WIN32_WCE + return true; } @@ -983,17 +924,17 @@ public: int GetIdealHeight() const { - ATLASSERT(::IsWindow(m_hWnd)); - if(m_lpstrLabel == NULL && m_lpstrHyperLink == NULL) + ATLASSERT(::IsWindow(this->m_hWnd)); + if((m_lpstrLabel == NULL) && (m_lpstrHyperLink == NULL)) return -1; if(!m_bPaintLabel) return -1; UINT uFormat = IsSingleLine() ? DT_SINGLELINE : DT_WORDBREAK; - CClientDC dc(m_hWnd); - RECT rect = { 0 }; - GetClientRect(&rect); + CClientDC dc(this->m_hWnd); + RECT rect = {}; + this->GetClientRect(&rect); HFONT hFontOld = dc.SelectFont(m_hFontNormal); RECT rcText = rect; dc.DrawText(_T("NS"), -1, &rcText, DT_LEFT | uFormat | DT_CALCRECT); @@ -1018,15 +959,15 @@ public: bool GetIdealSize(int& cx, int& cy) const { - ATLASSERT(::IsWindow(m_hWnd)); - if(m_lpstrLabel == NULL && m_lpstrHyperLink == NULL) + ATLASSERT(::IsWindow(this->m_hWnd)); + if((m_lpstrLabel == NULL) && (m_lpstrHyperLink == NULL)) return false; if(!m_bPaintLabel) return false; - CClientDC dc(m_hWnd); - RECT rcClient = { 0 }; - GetClientRect(&rcClient); + CClientDC dc(this->m_hWnd); + RECT rcClient = {}; + this->GetClientRect(&rcClient); RECT rcAll = rcClient; if(IsUsingTags()) @@ -1068,7 +1009,7 @@ public: if(m_hFontLink != NULL) hOldFont = dc.SelectFont(m_hFontLink); LPTSTR lpstrText = (m_lpstrLabel != NULL) ? m_lpstrLabel : m_lpstrHyperLink; - DWORD dwStyle = GetStyle(); + DWORD dwStyle = this->GetStyle(); UINT uFormat = DT_LEFT; if (dwStyle & SS_CENTER) uFormat = DT_CENTER; @@ -1112,17 +1053,12 @@ public: // Operations BOOL SubclassWindow(HWND hWnd) { - ATLASSERT(m_hWnd == NULL); + ATLASSERT(this->m_hWnd == NULL); ATLASSERT(::IsWindow(hWnd)); if(m_hFontNormal == NULL) m_hFontNormal = (HFONT)::SendMessage(hWnd, WM_GETFONT, 0, 0L); -#if (_MSC_VER >= 1300) BOOL bRet = ATL::CWindowImpl< T, TBase, TWinTraits >::SubclassWindow(hWnd); -#else // !(_MSC_VER >= 1300) - typedef ATL::CWindowImpl< T, TBase, TWinTraits > _baseClass; - BOOL bRet = _baseClass::SubclassWindow(hWnd); -#endif // !(_MSC_VER >= 1300) if(bRet != FALSE) { T* pT = static_cast(this); @@ -1134,34 +1070,27 @@ public: bool Navigate() { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); bool bRet = true; if(IsNotifyButton()) { - NMHDR nmhdr = { m_hWnd, (UINT_PTR)GetDlgCtrlID(), NM_CLICK }; - ::SendMessage(GetParent(), WM_NOTIFY, GetDlgCtrlID(), (LPARAM)&nmhdr); + NMHDR nmhdr = { this->m_hWnd, (UINT_PTR)this->GetDlgCtrlID(), NM_CLICK }; + this->GetParent().SendMessage(WM_NOTIFY, this->GetDlgCtrlID(), (LPARAM)&nmhdr); } else if(IsCommandButton()) { - ::SendMessage(GetParent(), WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(), BN_CLICKED), (LPARAM)m_hWnd); + this->GetParent().SendMessage(WM_COMMAND, MAKEWPARAM(this->GetDlgCtrlID(), BN_CLICKED), (LPARAM)this->m_hWnd); } else { ATLASSERT(m_lpstrHyperLink != NULL); -#ifndef _WIN32_WCE DWORD_PTR dwRet = (DWORD_PTR)::ShellExecute(0, _T("open"), m_lpstrHyperLink, 0, 0, SW_SHOWNORMAL); bRet = (dwRet > 32); -#else // CE specific - SHELLEXECUTEINFO shExeInfo = { sizeof(SHELLEXECUTEINFO), 0, 0, L"open", m_lpstrHyperLink, 0, 0, SW_SHOWNORMAL, 0, 0, 0, 0, 0, 0, 0 }; - ::ShellExecuteEx(&shExeInfo); - DWORD_PTR dwRet = (DWORD_PTR)shExeInfo.hInstApp; - bRet = (dwRet == 0) || (dwRet > 32); -#endif // _WIN32_WCE ATLASSERT(bRet); if(bRet) { m_bVisited = true; - Invalidate(); + this->Invalidate(); } } return bRet; @@ -1176,7 +1105,7 @@ public: } CFontHandle font = (m_hFontNormal != NULL) ? m_hFontNormal : (HFONT)::GetStockObject(SYSTEM_FONT); - LOGFONT lf = { 0 }; + LOGFONT lf = {}; font.GetLogFont(&lf); if(IsUsingTagsBold()) @@ -1192,21 +1121,15 @@ public: // Message map and handlers BEGIN_MSG_MAP(CHyperLinkImpl) MESSAGE_HANDLER(WM_CREATE, OnCreate) -#ifndef _WIN32_WCE MESSAGE_HANDLER(WM_DESTROY, OnDestroy) MESSAGE_RANGE_HANDLER(WM_MOUSEFIRST, WM_MOUSELAST, OnMouseMessage) -#endif // !_WIN32_WCE MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackground) MESSAGE_HANDLER(WM_PAINT, OnPaint) -#ifndef _WIN32_WCE MESSAGE_HANDLER(WM_PRINTCLIENT, OnPaint) -#endif // !_WIN32_WCE MESSAGE_HANDLER(WM_SETFOCUS, OnFocus) MESSAGE_HANDLER(WM_KILLFOCUS, OnFocus) MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove) -#ifndef _WIN32_WCE MESSAGE_HANDLER(WM_MOUSELEAVE, OnMouseLeave) -#endif // !_WIN32_WCE MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown) MESSAGE_HANDLER(WM_LBUTTONUP, OnLButtonUp) MESSAGE_HANDLER(WM_CHAR, OnChar) @@ -1226,7 +1149,6 @@ public: return 0; } -#ifndef _WIN32_WCE LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) { if(m_tip.IsWindow()) @@ -1255,13 +1177,12 @@ public: LRESULT OnMouseMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { - MSG msg = { m_hWnd, uMsg, wParam, lParam }; + MSG msg = { this->m_hWnd, uMsg, wParam, lParam }; if(m_tip.IsWindow() && IsUsingToolTip()) m_tip.RelayEvent(&msg); bHandled = FALSE; return 1; } -#endif // !_WIN32_WCE LRESULT OnEraseBackground(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { @@ -1284,7 +1205,7 @@ public: } else { - CPaintDC dc(m_hWnd); + CPaintDC dc(this->m_hWnd); pT->DoEraseBackground(dc.m_hDC); pT->DoPaint(dc.m_hDC); } @@ -1295,7 +1216,7 @@ public: LRESULT OnFocus(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) { if(m_bPaintLabel) - Invalidate(); + this->Invalidate(); else bHandled = FALSE; return 0; @@ -1304,7 +1225,7 @@ public: LRESULT OnMouseMove(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled) { POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; - if((m_lpstrHyperLink != NULL || IsCommandButton()) && ::PtInRect(&m_rcLink, pt)) + if(((m_lpstrHyperLink != NULL) || IsCommandButton()) && ::PtInRect(&m_rcLink, pt)) { ::SetCursor(m_hCursor); if(IsUnderlineHover()) @@ -1312,11 +1233,9 @@ public: if(!m_bHover) { m_bHover = true; - InvalidateRect(&m_rcLink); - UpdateWindow(); -#ifndef _WIN32_WCE + this->InvalidateRect(&m_rcLink); + this->UpdateWindow(); StartTrackMouseLeave(); -#endif // !_WIN32_WCE } } } @@ -1327,8 +1246,8 @@ public: if(m_bHover) { m_bHover = false; - InvalidateRect(&m_rcLink); - UpdateWindow(); + this->InvalidateRect(&m_rcLink); + this->UpdateWindow(); } } bHandled = FALSE; @@ -1336,33 +1255,31 @@ public: return 0; } -#ifndef _WIN32_WCE LRESULT OnMouseLeave(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { if(IsUnderlineHover() && m_bHover) { m_bHover = false; - InvalidateRect(&m_rcLink); - UpdateWindow(); + this->InvalidateRect(&m_rcLink); + this->UpdateWindow(); } return 0; } -#endif // !_WIN32_WCE LRESULT OnLButtonDown(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/) { POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; if(::PtInRect(&m_rcLink, pt)) { - SetFocus(); - SetCapture(); + this->SetFocus(); + this->SetCapture(); } return 0; } LRESULT OnLButtonUp(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/) { - if(GetCapture() == m_hWnd) + if(GetCapture() == this->m_hWnd) { ReleaseCapture(); POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; @@ -1377,7 +1294,7 @@ public: LRESULT OnChar(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) { - if(wParam == VK_RETURN || wParam == VK_SPACE) + if((wParam == VK_RETURN) || (wParam == VK_SPACE)) { T* pT = static_cast(this); pT->Navigate(); @@ -1392,10 +1309,10 @@ public: LRESULT OnSetCursor(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) { - POINT pt = { 0, 0 }; + POINT pt = {}; GetCursorPos(&pt); - ScreenToClient(&pt); - if((m_lpstrHyperLink != NULL || IsCommandButton()) && ::PtInRect(&m_rcLink, pt)) + this->ScreenToClient(&pt); + if(((m_lpstrHyperLink != NULL) || IsCommandButton()) && ::PtInRect(&m_rcLink, pt)) { return TRUE; } @@ -1405,8 +1322,8 @@ public: LRESULT OnEnable(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { - Invalidate(); - UpdateWindow(); + this->Invalidate(); + this->UpdateWindow(); return 0; } @@ -1435,8 +1352,8 @@ public: if((BOOL)lParam) { - Invalidate(); - UpdateWindow(); + this->Invalidate(); + this->UpdateWindow(); } return 0; @@ -1460,35 +1377,27 @@ public: // Implementation void Init() { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); // Check if we should paint a label const int cchBuff = 8; - TCHAR szBuffer[cchBuff] = { 0 }; - if(::GetClassName(m_hWnd, szBuffer, cchBuff)) + TCHAR szBuffer[cchBuff] = {}; + if(::GetClassName(this->m_hWnd, szBuffer, cchBuff)) { if(lstrcmpi(szBuffer, _T("static")) == 0) { - ModifyStyle(0, SS_NOTIFY); // we need this - DWORD dwStyle = GetStyle() & 0x000000FF; -#ifndef _WIN32_WCE - if(dwStyle == SS_ICON || dwStyle == SS_BLACKRECT || dwStyle == SS_GRAYRECT || - dwStyle == SS_WHITERECT || dwStyle == SS_BLACKFRAME || dwStyle == SS_GRAYFRAME || - dwStyle == SS_WHITEFRAME || dwStyle == SS_OWNERDRAW || - dwStyle == SS_BITMAP || dwStyle == SS_ENHMETAFILE) -#else // CE specific - if(dwStyle == SS_ICON || dwStyle == SS_BITMAP) -#endif // _WIN32_WCE + this->ModifyStyle(0, SS_NOTIFY); // we need this + DWORD dwStyle = this->GetStyle() & 0x000000FF; + if((dwStyle == SS_ICON) || (dwStyle == SS_BLACKRECT) || (dwStyle == SS_GRAYRECT) || + (dwStyle == SS_WHITERECT) || (dwStyle == SS_BLACKFRAME) || (dwStyle == SS_GRAYFRAME) || + (dwStyle == SS_WHITEFRAME) || (dwStyle == SS_OWNERDRAW) || + (dwStyle == SS_BITMAP) || (dwStyle == SS_ENHMETAFILE)) m_bPaintLabel = false; } } // create or load a cursor -#if (WINVER >= 0x0500) || defined(_WIN32_WCE) m_hCursor = ::LoadCursor(NULL, IDC_HAND); -#else - m_hCursor = ::CreateCursor(ModuleHelper::GetModuleInstance(), _AtlHyperLink_CursorData.xHotSpot, _AtlHyperLink_CursorData.yHotSpot, _AtlHyperLink_CursorData.cxWidth, _AtlHyperLink_CursorData.cyHeight, _AtlHyperLink_CursorData.arrANDPlane, _AtlHyperLink_CursorData.arrXORPlane); -#endif ATLASSERT(m_hCursor != NULL); // set fonts @@ -1504,21 +1413,19 @@ public: CreateLinkFontFromNormal(); } -#ifndef _WIN32_WCE // create a tool tip - m_tip.Create(m_hWnd); + m_tip.Create(this->m_hWnd); ATLASSERT(m_tip.IsWindow()); -#endif // !_WIN32_WCE // set label (defaults to window text) if(m_lpstrLabel == NULL) { - int nLen = GetWindowTextLength(); + int nLen = this->GetWindowTextLength(); if(nLen > 0) { ATLTRY(m_lpstrLabel = new TCHAR[nLen + 1]); if(m_lpstrLabel != NULL) - ATLVERIFY(GetWindowText(m_lpstrLabel, nLen + 1) > 0); + ATLVERIFY(this->GetWindowText(m_lpstrLabel, nLen + 1) > 0); } } @@ -1526,28 +1433,26 @@ public: pT->CalcLabelRect(); // set hyperlink (defaults to label), or just activate tool tip if already set - if(m_lpstrHyperLink == NULL && !IsCommandButton()) + if((m_lpstrHyperLink == NULL) && !IsCommandButton()) { if(m_lpstrLabel != NULL) SetHyperLink(m_lpstrLabel); } -#ifndef _WIN32_WCE else { m_tip.Activate(TRUE); - m_tip.AddTool(m_hWnd, m_lpstrHyperLink, &m_rcLink, 1); + m_tip.AddTool(this->m_hWnd, m_lpstrHyperLink, &m_rcLink, 1); } -#endif // !_WIN32_WCE // set link colors if(m_bPaintLabel) { - CRegKeyEx rk; + ATL::CRegKey rk; LONG lRet = rk.Open(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Internet Explorer\\Settings")); if(lRet == ERROR_SUCCESS) { const int cchValue = 12; - TCHAR szValue[cchValue] = { 0 }; + TCHAR szValue[cchValue] = {}; ULONG ulCount = cchValue; lRet = rk.QueryStringValue(_T("Anchor Color"), szValue, &ulCount); if(lRet == ERROR_SUCCESS) @@ -1582,7 +1487,7 @@ public: if(*p == _T(',')) { *p = _T('\0'); - c[i] = MinCrtHelper::_atoi(lpstr); + c[i] = _ttoi(lpstr); lpstr = &p[1]; break; } @@ -1592,21 +1497,21 @@ public: } if(*lpstr == _T('\0')) return CLR_INVALID; - c[2] = MinCrtHelper::_atoi(lpstr); + c[2] = _ttoi(lpstr); return RGB(c[0], c[1], c[2]); } bool CalcLabelRect() { - if(!::IsWindow(m_hWnd)) + if(!::IsWindow(this->m_hWnd)) return false; - if(m_lpstrLabel == NULL && m_lpstrHyperLink == NULL) + if((m_lpstrLabel == NULL) && (m_lpstrHyperLink == NULL)) return false; - CClientDC dc(m_hWnd); - RECT rcClient = { 0 }; - GetClientRect(&rcClient); + CClientDC dc(this->m_hWnd); + RECT rcClient = {}; + this->GetClientRect(&rcClient); m_rcLink = rcClient; if(!m_bPaintLabel) return true; @@ -1651,7 +1556,7 @@ public: if(m_hFontLink != NULL) hOldFont = dc.SelectFont(m_hFontLink); LPTSTR lpstrText = (m_lpstrLabel != NULL) ? m_lpstrLabel : m_lpstrHyperLink; - DWORD dwStyle = GetStyle(); + DWORD dwStyle = this->GetStyle(); UINT uFormat = DT_LEFT; if (dwStyle & SS_CENTER) uFormat = DT_CENTER; @@ -1725,11 +1630,11 @@ public: void DoEraseBackground(CDCHandle dc) { - HBRUSH hBrush = (HBRUSH)::SendMessage(GetParent(), WM_CTLCOLORSTATIC, (WPARAM)dc.m_hDC, (LPARAM)m_hWnd); + HBRUSH hBrush = (HBRUSH)this->GetParent().SendMessage(WM_CTLCOLORSTATIC, (WPARAM)dc.m_hDC, (LPARAM)this->m_hWnd); if(hBrush != NULL) { - RECT rect = { 0 }; - GetClientRect(&rect); + RECT rect = {}; + this->GetClientRect(&rect); dc.FillRect(&rect, hBrush); } } @@ -1750,8 +1655,8 @@ public: pT->CalcLabelParts(lpstrLeft, cchLeft, lpstrLink, cchLink, lpstrRight, cchRight); // get label part rects - RECT rcClient = { 0 }; - GetClientRect(&rcClient); + RECT rcClient = {}; + this->GetClientRect(&rcClient); dc.SetBkMode(TRANSPARENT); HFONT hFontOld = dc.SelectFont(m_hFontNormal); @@ -1761,8 +1666,8 @@ public: if(lpstrLeft != NULL) dc.DrawText(lpstrLeft, cchLeft, &rcClient, DT_LEFT | uFormat); - COLORREF clrOld = dc.SetTextColor(IsWindowEnabled() ? (m_bVisited ? m_clrVisited : m_clrLink) : (::GetSysColor(COLOR_GRAYTEXT))); - if(m_hFontLink != NULL && (!IsUnderlineHover() || (IsUnderlineHover() && m_bHover))) + COLORREF clrOld = dc.SetTextColor(this->IsWindowEnabled() ? (m_bVisited ? m_clrVisited : m_clrLink) : (::GetSysColor(COLOR_GRAYTEXT))); + if((m_hFontLink != NULL) && (!IsUnderlineHover() || (IsUnderlineHover() && m_bHover))) dc.SelectFont(m_hFontLink); else dc.SelectFont(m_hFontNormal); @@ -1777,7 +1682,7 @@ public: dc.DrawText(lpstrRight, cchRight, &rcRight, DT_LEFT | uFormat); } - if(GetFocus() == m_hWnd) + if(GetFocus() == this->m_hWnd) dc.DrawFocusRect(&m_rcLink); dc.SelectFont(hFontOld); @@ -1785,17 +1690,17 @@ public: else { dc.SetBkMode(TRANSPARENT); - COLORREF clrOld = dc.SetTextColor(IsWindowEnabled() ? (m_bVisited ? m_clrVisited : m_clrLink) : (::GetSysColor(COLOR_GRAYTEXT))); + COLORREF clrOld = dc.SetTextColor(this->IsWindowEnabled() ? (m_bVisited ? m_clrVisited : m_clrLink) : (::GetSysColor(COLOR_GRAYTEXT))); HFONT hFontOld = NULL; - if(m_hFontLink != NULL && (!IsUnderlineHover() || (IsUnderlineHover() && m_bHover))) + if((m_hFontLink != NULL) && (!IsUnderlineHover() || (IsUnderlineHover() && m_bHover))) hFontOld = dc.SelectFont(m_hFontLink); else hFontOld = dc.SelectFont(m_hFontNormal); LPTSTR lpstrText = (m_lpstrLabel != NULL) ? m_lpstrLabel : m_lpstrHyperLink; - DWORD dwStyle = GetStyle(); + DWORD dwStyle = this->GetStyle(); UINT uFormat = DT_LEFT; if (dwStyle & SS_CENTER) uFormat = DT_CENTER; @@ -1805,7 +1710,7 @@ public: dc.DrawText(lpstrText, -1, &m_rcLink, uFormat); - if(GetFocus() == m_hWnd) + if(GetFocus() == this->m_hWnd) dc.DrawFocusRect(&m_rcLink); dc.SetTextColor(clrOld); @@ -1813,16 +1718,14 @@ public: } } -#ifndef _WIN32_WCE BOOL StartTrackMouseLeave() { - TRACKMOUSEEVENT tme = { 0 }; + TRACKMOUSEEVENT tme = {}; tme.cbSize = sizeof(tme); tme.dwFlags = TME_LEAVE; - tme.hwndTrack = m_hWnd; - return _TrackMouseEvent(&tme); + tme.hwndTrack = this->m_hWnd; + return ::TrackMouseEvent(&tme); } -#endif // !_WIN32_WCE // Implementation helpers bool IsUnderlined() const @@ -1952,9 +1855,7 @@ public: ~CCustomWaitCursor() { Restore(); -#if !defined(_WIN32_WCE) || ((_WIN32_WCE >= 0x400) && !(defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP))) ::DestroyCursor(m_hWaitCursor); -#endif // !defined(_WIN32_WCE) || ((_WIN32_WCE >= 0x400) && !(defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP))) } }; @@ -1966,7 +1867,7 @@ template class ATL_NO_VTABLE CMultiPaneStatusBarCtrlImpl : public ATL::CWindowImpl< T, TBase > { public: - DECLARE_WND_SUPERCLASS(NULL, TBase::GetWndClassName()) + DECLARE_WND_SUPERCLASS2(NULL, T, TBase::GetWndClassName()) // Data enum { m_cxPaneMargin = 3 }; @@ -1986,25 +1887,20 @@ public: // Methods HWND Create(HWND hWndParent, LPCTSTR lpstrText, DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | SBARS_SIZEGRIP, UINT nID = ATL_IDW_STATUS_BAR) { -#if (_MSC_VER >= 1300) - return ATL::CWindowImpl< T, TBase >::Create(hWndParent, rcDefault, lpstrText, dwStyle, 0, nID); -#else // !(_MSC_VER >= 1300) - typedef ATL::CWindowImpl< T, TBase > _baseClass; - return _baseClass::Create(hWndParent, rcDefault, lpstrText, dwStyle, 0, nID); -#endif // !(_MSC_VER >= 1300) + return ATL::CWindowImpl< T, TBase >::Create(hWndParent, this->rcDefault, lpstrText, dwStyle, 0, nID); } HWND Create(HWND hWndParent, UINT nTextID = ATL_IDS_IDLEMESSAGE, DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | SBARS_SIZEGRIP, UINT nID = ATL_IDW_STATUS_BAR) { const int cchMax = 128; // max text length is 127 for status bars (+1 for null) - TCHAR szText[cchMax] = { 0 }; + TCHAR szText[cchMax] = {}; ::LoadString(ModuleHelper::GetResourceInstance(), nTextID, szText, cchMax); return Create(hWndParent, szText, dwStyle, nID); } BOOL SetPanes(int* pPanes, int nPanes, bool bSetText = true) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(nPanes > 0); m_nPanes = nPanes; @@ -2016,25 +1912,24 @@ public: if(m_pPane == NULL) return FALSE; - CTempBuffer buff; + ATL::CTempBuffer buff; int* pPanesPos = buff.Allocate(nPanes); ATLASSERT(pPanesPos != NULL); if(pPanesPos == NULL) return FALSE; - SecureHelper::memcpy_x(m_pPane, nPanes * sizeof(int), pPanes, nPanes * sizeof(int)); + ATL::Checked::memcpy_s(m_pPane, nPanes * sizeof(int), pPanes, nPanes * sizeof(int)); // get status bar DC and set font - CClientDC dc(m_hWnd); - HFONT hOldFont = dc.SelectFont(GetFont()); + CClientDC dc(this->m_hWnd); + HFONT hOldFont = dc.SelectFont(this->GetFont()); // get status bar borders - int arrBorders[3] = { 0 }; - GetBorders(arrBorders); + int arrBorders[3] = {}; + this->GetBorders(arrBorders); const int cchBuff = 128; - TCHAR szBuff[cchBuff] = { 0 }; - SIZE size = { 0, 0 }; + TCHAR szBuff[cchBuff] = {}; int cxLeft = arrBorders[0]; // calculate right edge of each part @@ -2048,15 +1943,16 @@ public: else { ::LoadString(ModuleHelper::GetResourceInstance(), pPanes[i], szBuff, cchBuff); + SIZE size = {}; dc.GetTextExtent(szBuff, lstrlen(szBuff), &size); T* pT = static_cast(this); - pT; + (void)pT; // avoid level 4 warning pPanesPos[i] = cxLeft + size.cx + arrBorders[2] + 2 * pT->m_cxPaneMargin; } cxLeft = pPanesPos[i]; } - BOOL bRet = SetParts(nPanes, pPanesPos); + BOOL bRet = this->SetParts(nPanes, pPanesPos); if(bRet && bSetText) { @@ -2076,12 +1972,12 @@ public: bool GetPaneTextLength(int nPaneID, int* pcchLength = NULL, int* pnType = NULL) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); int nIndex = GetPaneIndexFromID(nPaneID); if(nIndex == -1) return false; - int nLength = GetTextLength(nIndex, pnType); + int nLength = this->GetTextLength(nIndex, pnType); if(pcchLength != NULL) *pcchLength = nLength; @@ -2090,52 +1986,68 @@ public: BOOL GetPaneText(int nPaneID, LPTSTR lpstrText, int* pcchLength = NULL, int* pnType = NULL) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); + int nIndex = GetPaneIndexFromID(nPaneID); + if(nIndex == -1) + return FALSE; + + int nLength = this->GetText(nIndex, lpstrText, pnType); + if(pcchLength != NULL) + *pcchLength = nLength; + + return TRUE; + } + +#ifdef __ATLSTR_H__ + BOOL GetPaneText(int nPaneID, ATL::CString& strText, int* pcchLength = NULL, int* pnType = NULL) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); int nIndex = GetPaneIndexFromID(nPaneID); if(nIndex == -1) return FALSE; - int nLength = GetText(nIndex, lpstrText, pnType); + int nLength = this->GetText(nIndex, strText, pnType); if(pcchLength != NULL) *pcchLength = nLength; return TRUE; } +#endif // __ATLSTR_H__ BOOL SetPaneText(int nPaneID, LPCTSTR lpstrText, int nType = 0) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); int nIndex = GetPaneIndexFromID(nPaneID); if(nIndex == -1) return FALSE; - return SetText(nIndex, lpstrText, nType); + return this->SetText(nIndex, lpstrText, nType); } BOOL GetPaneRect(int nPaneID, LPRECT lpRect) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); int nIndex = GetPaneIndexFromID(nPaneID); if(nIndex == -1) return FALSE; - return GetRect(nIndex, lpRect); + return this->GetRect(nIndex, lpRect); } BOOL SetPaneWidth(int nPaneID, int cxWidth) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(nPaneID != ID_DEFAULT_PANE); // Can't resize this one int nIndex = GetPaneIndexFromID(nPaneID); if(nIndex == -1) return FALSE; // get pane positions - CTempBuffer buff; + ATL::CTempBuffer buff; int* pPanesPos = buff.Allocate(m_nPanes); if(pPanesPos == NULL) return FALSE; - GetParts(m_nPanes, pPanesPos); + this->GetParts(m_nPanes, pPanesPos); // calculate offset int cxPaneWidth = pPanesPos[nIndex] - ((nIndex == 0) ? 0 : pPanesPos[nIndex - 1]); int cxOff = cxWidth - cxPaneWidth; @@ -2162,55 +2074,51 @@ public: pPanesPos[i] -= cxOff; } // set pane postions - return SetParts(m_nPanes, pPanesPos); + return this->SetParts(m_nPanes, pPanesPos); } -#if (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) BOOL GetPaneTipText(int nPaneID, LPTSTR lpstrText, int nSize) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); int nIndex = GetPaneIndexFromID(nPaneID); if(nIndex == -1) return FALSE; - GetTipText(nIndex, lpstrText, nSize); + this->GetTipText(nIndex, lpstrText, nSize); return TRUE; } BOOL SetPaneTipText(int nPaneID, LPCTSTR lpstrText) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); int nIndex = GetPaneIndexFromID(nPaneID); if(nIndex == -1) return FALSE; - SetTipText(nIndex, lpstrText); + this->SetTipText(nIndex, lpstrText); return TRUE; } -#endif // (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) -#if ((_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE)) || (defined(_WIN32_WCE) && (_WIN32_WCE >= 0x0500)) BOOL GetPaneIcon(int nPaneID, HICON& hIcon) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); int nIndex = GetPaneIndexFromID(nPaneID); if(nIndex == -1) return FALSE; - hIcon = GetIcon(nIndex); + hIcon = this->GetIcon(nIndex); return TRUE; } BOOL SetPaneIcon(int nPaneID, HICON hIcon) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); int nIndex = GetPaneIndexFromID(nPaneID); if(nIndex == -1) return FALSE; - return SetIcon(nIndex, hIcon); + return this->SetIcon(nIndex, hIcon); } -#endif // ((_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE)) || (defined(_WIN32_WCE) && (_WIN32_WCE >= 0x0500)) // Message map and handlers BEGIN_MSG_MAP(CMultiPaneStatusBarCtrlImpl< T >) @@ -2219,8 +2127,8 @@ public: LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) { - LRESULT lRet = DefWindowProc(uMsg, wParam, lParam); - if(wParam != SIZE_MINIMIZED && m_nPanes > 0) + LRESULT lRet = this->DefWindowProc(uMsg, wParam, lParam); + if((wParam != SIZE_MINIMIZED) && (m_nPanes > 0)) { T* pT = static_cast(this); pT->UpdatePanesLayout(); @@ -2232,24 +2140,22 @@ public: BOOL UpdatePanesLayout() { // get pane positions - CTempBuffer buff; + ATL::CTempBuffer buff; int* pPanesPos = buff.Allocate(m_nPanes); ATLASSERT(pPanesPos != NULL); if(pPanesPos == NULL) return FALSE; - int nRet = GetParts(m_nPanes, pPanesPos); + int nRet = this->GetParts(m_nPanes, pPanesPos); ATLASSERT(nRet == m_nPanes); if(nRet != m_nPanes) return FALSE; // calculate offset - RECT rcClient = { 0 }; - GetClientRect(&rcClient); + RECT rcClient = {}; + this->GetClientRect(&rcClient); int cxOff = rcClient.right - pPanesPos[m_nPanes - 1]; -#ifndef _WIN32_WCE // Move panes left if size grip box is present - if((GetStyle() & SBARS_SIZEGRIP) != 0) + if((this->GetStyle() & SBARS_SIZEGRIP) != 0) cxOff -= ::GetSystemMetrics(SM_CXVSCROLL) + ::GetSystemMetrics(SM_CXEDGE); -#endif // !_WIN32_WCE // find variable width pane int i; for(i = 0; i < m_nPanes; i++) @@ -2264,7 +2170,7 @@ public: pPanesPos[i] += cxOff; } // set pane postions - return SetParts(m_nPanes, pPanesPos); + return this->SetParts(m_nPanes, pPanesPos); } int GetPaneIndexFromID(int nPaneID) const @@ -2297,13 +2203,11 @@ public: #define PANECNT_DIVIDER 0x00000010 #define PANECNT_GRADIENT 0x00000020 -// Note: PANECNT_GRADIENT doesn't work with _ATL_NO_MSIMG - template class ATL_NO_VTABLE CPaneContainerImpl : public ATL::CWindowImpl< T, TBase, TWinTraits >, public CCustomDraw< T > { public: - DECLARE_WND_CLASS_EX(NULL, 0, -1) + DECLARE_WND_CLASS_EX2(NULL, T, 0, -1) // Constants enum @@ -2357,7 +2261,7 @@ public: m_dwExtendedStyle = dwExtendedStyle; else m_dwExtendedStyle = (m_dwExtendedStyle & ~dwMask) | (dwExtendedStyle & dwMask); - if(m_hWnd != NULL) + if(this->m_hWnd != NULL) { T* pT = static_cast(this); bool bUpdate = false; @@ -2385,12 +2289,10 @@ public: bUpdate = true; } -#if (!defined(_WIN32_WCE) && !defined(_ATL_NO_MSIMG)) || (_WIN32_WCE >= 420) if((dwPrevStyle & PANECNT_GRADIENT) != (m_dwExtendedStyle & PANECNT_GRADIENT)) // change background { bUpdate = true; } -#endif // (!defined(_WIN32_WCE) && !defined(_ATL_NO_MSIMG)) || (_WIN32_WCE >= 420) if(bUpdate) pT->UpdateLayout(); @@ -2407,7 +2309,7 @@ public: { HWND hWndOldClient = m_wndClient; m_wndClient = hWndClient; - if(m_hWnd != NULL) + if(this->m_hWnd != NULL) { T* pT = static_cast(this); pT->UpdateLayout(); @@ -2419,18 +2321,18 @@ public: { ATLASSERT(lpstrTitle != NULL); - errno_t nRet = SecureHelper::strncpy_x(lpstrTitle, cchLength, m_szTitle, _TRUNCATE); + errno_t nRet = ATL::Checked::tcsncpy_s(lpstrTitle, cchLength, m_szTitle, _TRUNCATE); - return (nRet == 0 || nRet == STRUNCATE); + return ((nRet == 0) || (nRet == STRUNCATE)); } BOOL SetTitle(LPCTSTR lpstrTitle) { ATLASSERT(lpstrTitle != NULL); - errno_t nRet = SecureHelper::strncpy_x(m_szTitle, m_cchTitle, lpstrTitle, _TRUNCATE); - bool bRet = (nRet == 0 || nRet == STRUNCATE); - if(bRet && m_hWnd != NULL) + errno_t nRet = ATL::Checked::tcsncpy_s(m_szTitle, m_cchTitle, lpstrTitle, _TRUNCATE); + bool bRet = ((nRet == 0) || (nRet == STRUNCATE)); + if(bRet && (this->m_hWnd != NULL)) { T* pT = static_cast(this); pT->UpdateLayout(); @@ -2449,13 +2351,8 @@ public: DWORD dwExStyle = 0, UINT nID = 0, LPVOID lpCreateParam = NULL) { if(lpstrTitle != NULL) - SecureHelper::strncpy_x(m_szTitle, m_cchTitle, lpstrTitle, _TRUNCATE); -#if (_MSC_VER >= 1300) - return ATL::CWindowImpl< T, TBase, TWinTraits >::Create(hWndParent, rcDefault, NULL, dwStyle, dwExStyle, nID, lpCreateParam); -#else // !(_MSC_VER >= 1300) - typedef ATL::CWindowImpl< T, TBase, TWinTraits > _baseClass; - return _baseClass::Create(hWndParent, rcDefault, NULL, dwStyle, dwExStyle, nID, lpCreateParam); -#endif // !(_MSC_VER >= 1300) + ATL::Checked::tcsncpy_s(m_szTitle, m_cchTitle, lpstrTitle, _TRUNCATE); + return ATL::CWindowImpl< T, TBase, TWinTraits >::Create(hWndParent, this->rcDefault, NULL, dwStyle, dwExStyle, nID, lpCreateParam); } HWND Create(HWND hWndParent, UINT uTitleID, DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, @@ -2463,29 +2360,19 @@ public: { if(uTitleID != 0U) ::LoadString(ModuleHelper::GetResourceInstance(), uTitleID, m_szTitle, m_cchTitle); -#if (_MSC_VER >= 1300) - return ATL::CWindowImpl< T, TBase, TWinTraits >::Create(hWndParent, rcDefault, NULL, dwStyle, dwExStyle, nID, lpCreateParam); -#else // !(_MSC_VER >= 1300) - typedef ATL::CWindowImpl< T, TBase, TWinTraits > _baseClass; - return _baseClass::Create(hWndParent, rcDefault, NULL, dwStyle, dwExStyle, nID, lpCreateParam); -#endif // !(_MSC_VER >= 1300) + return ATL::CWindowImpl< T, TBase, TWinTraits >::Create(hWndParent, this->rcDefault, NULL, dwStyle, dwExStyle, nID, lpCreateParam); } BOOL SubclassWindow(HWND hWnd) { -#if (_MSC_VER >= 1300) BOOL bRet = ATL::CWindowImpl< T, TBase, TWinTraits >::SubclassWindow(hWnd); -#else // !(_MSC_VER >= 1300) - typedef ATL::CWindowImpl< T, TBase, TWinTraits > _baseClass; - BOOL bRet = _baseClass::SubclassWindow(hWnd); -#endif // !(_MSC_VER >= 1300) if(bRet != FALSE) { T* pT = static_cast(this); pT->Init(); - RECT rect = { 0 }; - GetClientRect(&rect); + RECT rect = {}; + this->GetClientRect(&rect); pT->UpdateLayout(rect.right, rect.bottom); } @@ -2494,16 +2381,16 @@ public: BOOL EnableCloseButton(BOOL bEnable) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); T* pT = static_cast(this); - pT; // avoid level 4 warning + (void)pT; // avoid level 4 warning return (m_tb.m_hWnd != NULL) ? m_tb.EnableButton(pT->m_nCloseBtnID, bEnable) : FALSE; } void UpdateLayout() { - RECT rcClient = { 0 }; - GetClientRect(&rcClient); + RECT rcClient = {}; + this->GetClientRect(&rcClient); T* pT = static_cast(this); pT->UpdateLayout(rcClient.right, rcClient.bottom); } @@ -2518,9 +2405,7 @@ public: MESSAGE_HANDLER(WM_SETFONT, OnSetFont) MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackground) MESSAGE_HANDLER(WM_PAINT, OnPaint) -#ifndef _WIN32_WCE MESSAGE_HANDLER(WM_PRINTCLIENT, OnPaint) -#endif // !_WIN32_WCE MESSAGE_HANDLER(WM_NOTIFY, OnNotify) MESSAGE_HANDLER(WM_COMMAND, OnCommand) FORWARD_NOTIFICATIONS() @@ -2604,7 +2489,7 @@ public: } else { - CPaintDC dc(m_hWnd); + CPaintDC dc(this->m_hWnd); pT->DrawPaneTitle(dc.m_hDC); if(m_wndClient.m_hWnd == NULL) // no client window @@ -2623,21 +2508,19 @@ public: } T* pT = static_cast(this); - pT; + (void)pT; // avoid level 4 warning LPNMHDR lpnmh = (LPNMHDR)lParam; LRESULT lRet = 0; // pass toolbar custom draw notifications to the base class - if(lpnmh->code == NM_CUSTOMDRAW && lpnmh->hwndFrom == m_tb.m_hWnd) + if((lpnmh->code == NM_CUSTOMDRAW) && (lpnmh->hwndFrom == m_tb.m_hWnd)) lRet = CCustomDraw< T >::OnCustomDraw(0, lpnmh, bHandled); -#ifndef _WIN32_WCE // tooltip notifications come with the tooltip window handle and button ID, // pass them to the parent if we don't handle them - else if(lpnmh->code == TTN_GETDISPINFO && lpnmh->idFrom == pT->m_nCloseBtnID) + else if((lpnmh->code == TTN_GETDISPINFO) && (lpnmh->idFrom == pT->m_nCloseBtnID)) bHandled = pT->GetToolTipText(lpnmh); -#endif // !_WIN32_WCE // only let notifications not from the toolbar go to the parent - else if(lpnmh->hwndFrom != m_tb.m_hWnd && lpnmh->idFrom != pT->m_nCloseBtnID) + else if((lpnmh->hwndFrom != m_tb.m_hWnd) && (lpnmh->idFrom != pT->m_nCloseBtnID)) bHandled = FALSE; return lRet; @@ -2646,8 +2529,8 @@ public: LRESULT OnCommand(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { // if command comes from the close button, substitute HWND of the pane container instead - if(m_tb.m_hWnd != NULL && (HWND)lParam == m_tb.m_hWnd) - return ::SendMessage(GetParent(), WM_COMMAND, wParam, (LPARAM)m_hWnd); + if((m_tb.m_hWnd != NULL) && ((HWND)lParam == m_tb.m_hWnd)) + return this->GetParent().SendMessage(WM_COMMAND, wParam, (LPARAM)this->m_hWnd); bHandled = FALSE; return 1; @@ -2667,12 +2550,7 @@ public: DWORD OnItemPostPaint(int /*idCtrl*/, LPNMCUSTOMDRAW lpNMCustomDraw) { CDCHandle dc = lpNMCustomDraw->hdc; -#if (_WIN32_IE >= 0x0400) RECT& rc = lpNMCustomDraw->rc; -#else // !(_WIN32_IE >= 0x0400) - RECT rc = { 0 }; - m_tb.GetItemRect(0, &rc); -#endif // !(_WIN32_IE >= 0x0400) RECT rcImage = { m_xBtnImageLeft, m_yBtnImageTop, m_xBtnImageRight + 1, m_yBtnImageBottom + 1 }; ::OffsetRect(&rcImage, rc.left, rc.top); @@ -2707,21 +2585,11 @@ public: if(m_hFont == NULL) { // The same as AtlCreateControlFont() for horizontal pane -#ifndef _WIN32_WCE - LOGFONT lf = { 0 }; + LOGFONT lf = {}; ATLVERIFY(::SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(LOGFONT), &lf, 0) != FALSE); if(IsVertical()) lf.lfEscapement = 900; // 90 degrees m_hFont = ::CreateFontIndirect(&lf); -#else // CE specific - m_hFont = (HFONT)::GetStockObject(SYSTEM_FONT); - if(IsVertical()) - { - CLogFont lf(m_hFont); - lf.lfEscapement = 900; // 90 degrees - m_hFont = ::CreateFontIndirect(&lf); - } -#endif // _WIN32_WCE m_bInternalFont = true; } @@ -2734,8 +2602,8 @@ public: void UpdateLayout(int cxWidth, int cyHeight) { - ATLASSERT(::IsWindow(m_hWnd)); - RECT rect = { 0 }; + ATLASSERT(::IsWindow(this->m_hWnd)); + RECT rect = {}; if(IsVertical()) { @@ -2760,24 +2628,24 @@ public: rect.bottom = cyHeight; } - InvalidateRect(&rect); + this->InvalidateRect(&rect); } void CreateCloseButton() { ATLASSERT(m_tb.m_hWnd == NULL); // create toolbar for the "x" button - m_tb.Create(m_hWnd, rcDefault, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | CCS_NODIVIDER | CCS_NORESIZE | CCS_NOPARENTALIGN | CCS_NOMOVEY | TBSTYLE_TOOLTIPS | TBSTYLE_FLAT, 0); + m_tb.Create(this->m_hWnd, this->rcDefault, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | CCS_NODIVIDER | CCS_NORESIZE | CCS_NOPARENTALIGN | CCS_NOMOVEY | TBSTYLE_TOOLTIPS | TBSTYLE_FLAT, 0); ATLASSERT(m_tb.IsWindow()); if(m_tb.m_hWnd != NULL) { T* pT = static_cast(this); - pT; // avoid level 4 warning + (void)pT; // avoid level 4 warning m_tb.SetButtonStructSize(); - TBBUTTON tbbtn = { 0 }; + TBBUTTON tbbtn = {}; tbbtn.idCommand = pT->m_nCloseBtnID; tbbtn.fsState = TBSTATE_ENABLED; tbbtn.fsStyle = BTNS_BUTTON; @@ -2805,7 +2673,7 @@ public: CFontHandle font = pT->GetTitleFont(); if(font.IsNull()) font = (HFONT)::GetStockObject(SYSTEM_FONT); - LOGFONT lf = { 0 }; + LOGFONT lf = {}; font.GetLogFont(lf); if(IsVertical()) { @@ -2824,17 +2692,15 @@ public: return m_hFont; } -#ifndef _WIN32_WCE BOOL GetToolTipText(LPNMHDR /*lpnmh*/) { return FALSE; } -#endif // !_WIN32_WCE void DrawPaneTitle(CDCHandle dc) { - RECT rect = { 0 }; - GetClientRect(&rect); + RECT rect = {}; + this->GetClientRect(&rect); UINT uBorder = BF_LEFT | BF_TOP | BF_ADJUST; if(IsVertical()) @@ -2866,9 +2732,6 @@ public: dc.SetBkMode(TRANSPARENT); T* pT = static_cast(this); HFONT hFontOld = dc.SelectFont(pT->GetTitleFont()); -#if defined(_WIN32_WCE) && !defined(DT_END_ELLIPSIS) - const UINT DT_END_ELLIPSIS = 0; -#endif // defined(_WIN32_WCE) && !defined(DT_END_ELLIPSIS) if(IsVertical()) { @@ -2879,7 +2742,7 @@ public: RECT rcCalc = { rect.left, rect.bottom, rect.right, rect.top }; int cxFont = dc.DrawText(m_szTitle, -1, &rcCalc, DT_TOP | DT_SINGLELINE | DT_END_ELLIPSIS | DT_CALCRECT); - RECT rcText = { 0 }; + RECT rcText = {}; rcText.left = (rect.right - rect.left - cxFont) / 2; rcText.right = rcText.left + (rect.bottom - rect.top); rcText.top = rect.bottom; @@ -2901,31 +2764,29 @@ public: void DrawPaneTitleBackground(CDCHandle dc) { - RECT rect = { 0 }; - GetClientRect(&rect); + RECT rect = {}; + this->GetClientRect(&rect); if(IsVertical()) rect.right = m_cxyHeader; else rect.bottom = m_cxyHeader; -#if (!defined(_WIN32_WCE) && !defined(_ATL_NO_MSIMG)) || (_WIN32_WCE >= 420) if((m_dwExtendedStyle & PANECNT_GRADIENT) != 0) dc.GradientFillRect(rect, ::GetSysColor(COLOR_WINDOW), ::GetSysColor(COLOR_3DFACE), IsVertical()); else -#endif // (!defined(_WIN32_WCE) && !defined(_ATL_NO_MSIMG)) || (_WIN32_WCE >= 420) dc.FillRect(&rect, COLOR_3DFACE); } // called only if pane is empty void DrawPane(CDCHandle dc) { - RECT rect = { 0 }; - GetClientRect(&rect); + RECT rect = {}; + this->GetClientRect(&rect); if(IsVertical()) rect.left += m_cxyHeader; else rect.top += m_cxyHeader; - if((GetExStyle() & WS_EX_CLIENTEDGE) == 0) + if((this->GetExStyle() & WS_EX_CLIENTEDGE) == 0) dc.DrawEdge(&rect, EDGE_SUNKEN, BF_RECT | BF_ADJUST); dc.FillRect(&rect, COLOR_APPWORKSPACE); } @@ -2933,7 +2794,6 @@ public: // drawing helper - draws "x" button image void DrawButtonImage(CDCHandle dc, RECT& rcImage, HPEN hPen) { -#if !defined(_WIN32_WCE) || (_WIN32_WCE >= 400) HPEN hPenOld = dc.SelectPen(hPen); dc.MoveTo(rcImage.left, rcImage.top); @@ -2947,11 +2807,6 @@ public: dc.LineTo(rcImage.right + 1, rcImage.top - 1); dc.SelectPen(hPenOld); -#else // (_WIN32_WCE < 400) - rcImage; - hPen; - // no support for the "x" button image -#endif // (_WIN32_WCE < 400) } bool IsVertical() const @@ -3058,12 +2913,10 @@ public: m_dwSortLVExtendedStyle(SORTLV_USESHELLBITMAPS), m_bUseWaitCursor(true) { -#ifndef _WIN32_WCE DWORD dwMajor = 0; DWORD dwMinor = 0; HRESULT hRet = ATL::AtlGetCommCtrlVersion(&dwMajor, &dwMinor); - m_bCommCtrl6 = SUCCEEDED(hRet) && dwMajor >= 6; -#endif // !_WIN32_WCE + m_bCommCtrl6 = SUCCEEDED(hRet) && (dwMajor >= 6); } // Attributes @@ -3073,26 +2926,20 @@ public: ATLASSERT(::IsWindow(pT->m_hWnd)); CHeaderCtrl header = pT->GetHeader(); ATLASSERT(header.m_hWnd != NULL); - ATLASSERT(iCol >= -1 && iCol < m_arrColSortType.GetSize()); + ATLASSERT((iCol >= -1) && (iCol < m_arrColSortType.GetSize())); int iOldSortCol = m_iSortColumn; m_iSortColumn = iCol; if(m_bCommCtrl6) { -#ifndef HDF_SORTUP - const int HDF_SORTUP = 0x0400; -#endif // HDF_SORTUP -#ifndef HDF_SORTDOWN - const int HDF_SORTDOWN = 0x0200; -#endif // HDF_SORTDOWN const int nMask = HDF_SORTUP | HDF_SORTDOWN; HDITEM hditem = { HDI_FORMAT }; - if(iOldSortCol != iCol && iOldSortCol >= 0 && header.GetItem(iOldSortCol, &hditem)) + if((iOldSortCol != iCol) && (iOldSortCol >= 0) && header.GetItem(iOldSortCol, &hditem)) { hditem.fmt &= ~nMask; header.SetItem(iOldSortCol, &hditem); } - if(iCol >= 0 && header.GetItem(iCol, &hditem)) + if((iCol >= 0) && header.GetItem(iCol, &hditem)) { hditem.fmt &= ~nMask; hditem.fmt |= m_bSortDescending ? HDF_SORTDOWN : HDF_SORTUP; @@ -3106,7 +2953,7 @@ public: // restore previous sort column's bitmap, if any, and format HDITEM hditem = { HDI_BITMAP | HDI_FORMAT }; - if(iOldSortCol != iCol && iOldSortCol >= 0) + if((iOldSortCol != iCol) && (iOldSortCol >= 0)) { hditem.hbm = m_hbmOldSortCol; hditem.fmt = m_fmtOldSortCol; @@ -3114,7 +2961,7 @@ public: } // save new sort column's bitmap and format, and add our sort bitmap - if(iCol >= 0 && header.GetItem(iCol, &hditem)) + if((iCol >= 0) && header.GetItem(iCol, &hditem)) { if(iOldSortCol != iCol) { @@ -3136,14 +2983,14 @@ public: void SetColumnSortType(int iCol, WORD wType) { - ATLASSERT(iCol >= 0 && iCol < m_arrColSortType.GetSize()); - ATLASSERT(wType >= LVCOLSORT_NONE && wType <= LVCOLSORT_LAST); + ATLASSERT((iCol >= 0) && (iCol < m_arrColSortType.GetSize())); + ATLASSERT((wType >= LVCOLSORT_NONE) && (wType <= LVCOLSORT_LAST)); m_arrColSortType[iCol] = wType; } WORD GetColumnSortType(int iCol) const { - ATLASSERT((iCol >= 0) && iCol < m_arrColSortType.GetSize()); + ATLASSERT((iCol >= 0) && (iCol < m_arrColSortType.GetSize())); return m_arrColSortType[iCol]; } @@ -3180,7 +3027,7 @@ public: { T* pT = static_cast(this); ATLASSERT(::IsWindow(pT->m_hWnd)); - ATLASSERT(iCol >= 0 && iCol < m_arrColSortType.GetSize()); + ATLASSERT((iCol >= 0) && (iCol < m_arrColSortType.GetSize())); WORD wType = m_arrColSortType[iCol]; if(wType == LVCOLSORT_NONE) @@ -3201,7 +3048,7 @@ public: LVCompareParam* pParam = NULL; ATLTRY(pParam = new LVCompareParam[nCount]); PFNLVCOMPARE pFunc = NULL; - TCHAR pszTemp[pT->m_cchCmpTextMax] = { 0 }; + TCHAR pszTemp[pT->m_cchCmpTextMax] = {}; bool bStrValue = false; switch(wType) @@ -3339,11 +3186,7 @@ public: if(!m_bmSort[i].IsNull()) m_bmSort[i].DeleteObject(); m_bmSort[i] = (HBITMAP)::LoadImage(hShell, MAKEINTRESOURCE(m_nShellSortUpID + i), -#ifndef _WIN32_WCE IMAGE_BITMAP, 0, 0, LR_LOADMAP3DCOLORS); -#else // CE specific - IMAGE_BITMAP, 0, 0, 0); -#endif // _WIN32_WCE if(m_bmSort[i].IsNull()) { bSuccess = false; @@ -3426,7 +3269,7 @@ public: double DateStrToDouble(LPCTSTR lpstr, DWORD dwFlags) { ATLASSERT(lpstr != NULL); - if(lpstr == NULL || lpstr[0] == _T('\0')) + if((lpstr == NULL) || (lpstr[0] == _T('\0'))) return 0; USES_CONVERSION; @@ -3443,7 +3286,7 @@ public: long StrToLong(LPCTSTR lpstr) { ATLASSERT(lpstr != NULL); - if(lpstr == NULL || lpstr[0] == _T('\0')) + if((lpstr == NULL) || (lpstr[0] == _T('\0'))) return 0; USES_CONVERSION; @@ -3460,7 +3303,7 @@ public: double StrToDouble(LPCTSTR lpstr) { ATLASSERT(lpstr != NULL); - if(lpstr == NULL || lpstr[0] == _T('\0')) + if((lpstr == NULL) || (lpstr[0] == _T('\0'))) return 0; USES_CONVERSION; @@ -3478,7 +3321,7 @@ public: { ATLASSERT(lpstr != NULL); ATLASSERT(pDecimal != NULL); - if(lpstr == NULL || pDecimal == NULL) + if((lpstr == NULL) || (pDecimal == NULL)) return false; USES_CONVERSION; @@ -3497,7 +3340,7 @@ public: // Overrideable PFNLVCOMPARE functions static int CALLBACK LVCompareText(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) { - ATLASSERT(lParam1 != NULL && lParam2 != NULL && lParamSort != NULL); + ATLASSERT((lParam1 != NULL) && (lParam2 != NULL) && (lParamSort != NULL)); LVCompareParam* pParam1 = (LVCompareParam*)lParam1; LVCompareParam* pParam2 = (LVCompareParam*)lParam2; @@ -3509,7 +3352,7 @@ public: static int CALLBACK LVCompareTextNoCase(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) { - ATLASSERT(lParam1 != NULL && lParam2 != NULL && lParamSort != NULL); + ATLASSERT((lParam1 != NULL) && (lParam2 != NULL) && (lParamSort != NULL)); LVCompareParam* pParam1 = (LVCompareParam*)lParam1; LVCompareParam* pParam2 = (LVCompareParam*)lParam2; @@ -3521,7 +3364,7 @@ public: static int CALLBACK LVCompareLong(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) { - ATLASSERT(lParam1 != NULL && lParam2 != NULL && lParamSort != NULL); + ATLASSERT((lParam1 != NULL) && (lParam2 != NULL) && (lParamSort != NULL)); LVCompareParam* pParam1 = (LVCompareParam*)lParam1; LVCompareParam* pParam2 = (LVCompareParam*)lParam2; @@ -3537,7 +3380,7 @@ public: static int CALLBACK LVCompareDouble(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) { - ATLASSERT(lParam1 != NULL && lParam2 != NULL && lParamSort != NULL); + ATLASSERT((lParam1 != NULL) && (lParam2 != NULL) && (lParamSort != NULL)); LVCompareParam* pParam1 = (LVCompareParam*)lParam1; LVCompareParam* pParam2 = (LVCompareParam*)lParam2; @@ -3553,7 +3396,7 @@ public: static int CALLBACK LVCompareCustom(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) { - ATLASSERT(lParam1 != NULL && lParam2 != NULL && lParamSort != NULL); + ATLASSERT((lParam1 != NULL) && (lParam2 != NULL) && (lParamSort != NULL)); LVCompareParam* pParam1 = (LVCompareParam*)lParam1; LVCompareParam* pParam2 = (LVCompareParam*)lParam2; @@ -3563,10 +3406,9 @@ public: return pInfo->bDescending ? -nRet : nRet; } -#ifndef _WIN32_WCE static int CALLBACK LVCompareDecimal(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) { - ATLASSERT(lParam1 != NULL && lParam2 != NULL && lParamSort != NULL); + ATLASSERT((lParam1 != NULL) && (lParam2 != NULL) && (lParamSort != NULL)); LVCompareParam* pParam1 = (LVCompareParam*)lParam1; LVCompareParam* pParam2 = (LVCompareParam*)lParam2; @@ -3576,147 +3418,6 @@ public: nRet--; return pInfo->bDescending ? -nRet : nRet; } -#else - // Compare mantissas, ignore sign and scale - static int CompareMantissas(const DECIMAL& decLeft, const DECIMAL& decRight) - { - if (decLeft.Hi32 < decRight.Hi32) - { - return -1; - } - if (decLeft.Hi32 > decRight.Hi32) - { - return 1; - } - // Here, decLeft.Hi32 == decRight.Hi32 - if (decLeft.Lo64 < decRight.Lo64) - { - return -1; - } - if (decLeft.Lo64 > decRight.Lo64) - { - return 1; - } - return 0; - } - - // return values: VARCMP_LT, VARCMP_EQ, VARCMP_GT, VARCMP_NULL - static HRESULT VarDecCmp(const DECIMAL* pdecLeft, const DECIMAL* pdecRight) - { - static const ULONG powersOfTen[] = - { - 10ul, - 100ul, - 1000ul, - 10000ul, - 100000ul, - 1000000ul, - 10000000ul, - 100000000ul, - 1000000000ul - }; - static const int largestPower = sizeof(powersOfTen) / sizeof(powersOfTen[0]); - if (!pdecLeft || !pdecRight) - { - return VARCMP_NULL; - } - - // Degenerate case - at least one comparand is of the form - // [+-]0*10^N (denormalized zero) - bool bLeftZero = (!pdecLeft->Lo64 && !pdecLeft->Hi32); - bool bRightZero = (!pdecRight->Lo64 && !pdecRight->Hi32); - if (bLeftZero && bRightZero) - { - return VARCMP_EQ; - } - bool bLeftNeg = ((pdecLeft->sign & DECIMAL_NEG) != 0); - bool bRightNeg = ((pdecRight->sign & DECIMAL_NEG) != 0); - if (bLeftZero) - { - return (bRightNeg ? VARCMP_GT : VARCMP_LT); - } - // This also covers the case where the comparands have different signs - if (bRightZero || bLeftNeg != bRightNeg) - { - return (bLeftNeg ? VARCMP_LT : VARCMP_GT); - } - - // Here both comparands have the same sign and need to be compared - // on mantissa and scale. The result is obvious when - // 1. Scales are equal (then compare mantissas) - // 2. A number with smaller scale is also the one with larger mantissa - // (then this number is obviously larger) - // In the remaining case, we would multiply the number with smaller - // scale by 10 and simultaneously increment its scale (which amounts to - // adding trailing zeros after decimal point), until the numbers fall under - // one of the two cases above - DECIMAL temp; - bool bInvert = bLeftNeg; // the final result needs to be inverted - if (pdecLeft->scale < pdecRight->scale) - { - temp = *pdecLeft; - } - else - { - temp = *pdecRight; - pdecRight = pdecLeft; - bInvert = !bInvert; - } - - // Now temp is the number with smaller (or equal) scale, and - // we can modify it freely without touching original parameters - int comp; - while ((comp = CompareMantissas(temp, *pdecRight)) < 0 && - temp.scale < pdecRight->scale) - { - // Multiply by an appropriate power of 10 - int scaleDiff = pdecRight->scale - temp.scale; - if (scaleDiff > largestPower) - { - // Keep the multiplier representable in 32bit - scaleDiff = largestPower; - } - DWORDLONG power = powersOfTen[scaleDiff - 1]; - // Multiply temp's mantissa by power - DWORDLONG product = temp.Lo32 * power; - ULONG carry = static_cast(product >> 32); - temp.Lo32 = static_cast(product); - product = temp.Mid32 * power + carry; - carry = static_cast(product >> 32); - temp.Mid32 = static_cast(product); - product = temp.Hi32 * power + carry; - if (static_cast(product >> 32)) - { - // Multiplication overflowed - pdecLeft is clearly larger - break; - } - temp.Hi32 = static_cast(product); - temp.scale = (BYTE)(temp.scale + scaleDiff); - } - if (temp.scale < pdecRight->scale) - { - comp = 1; - } - if (bInvert) - { - comp = -comp; - } - return (comp > 0 ? VARCMP_GT : comp < 0 ? VARCMP_LT : VARCMP_EQ); - } - - static int CALLBACK LVCompareDecimal(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) - { - ATLASSERT(lParam1 != NULL && lParam2 != NULL && lParamSort != NULL); - - LVCompareParam* pParam1 = (LVCompareParam*)lParam1; - LVCompareParam* pParam2 = (LVCompareParam*)lParam2; - LVSortInfo* pInfo = (LVSortInfo*)lParamSort; - - int nRet = (int)VarDecCmp(&pParam1->decValue, &pParam2->decValue); - nRet--; - return pInfo->bDescending ? -nRet : nRet; - } -#endif // !_WIN32_WCE BEGIN_MSG_MAP(CSortListViewImpl) MESSAGE_HANDLER(LVM_INSERTCOLUMN, OnInsertColumn) @@ -3781,13 +3482,8 @@ public: LRESULT OnSettingChange(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) { -#ifndef _WIN32_WCE if(wParam == SPI_SETNONCLIENTMETRICS) GetSystemSettings(); -#else // CE specific - wParam; // avoid level 4 warning - GetSystemSettings(); -#endif // _WIN32_WCE bHandled = FALSE; return 0; } @@ -3812,11 +3508,11 @@ template , public CSortListViewImpl { public: - DECLARE_WND_SUPERCLASS(NULL, TBase::GetWndClassName()) + DECLARE_WND_SUPERCLASS2(NULL, T, TBase::GetWndClassName()) bool SortItems(int iCol, bool bDescending = false) { - return DoSortItems(iCol, bDescending); + return this->DoSortItems(iCol, bDescending); } BEGIN_MSG_MAP(CSortListViewCtrlImpl) @@ -3839,8 +3535,11 @@ public: // CTabView - implements tab view window // TabView Notifications -#define TBVN_PAGEACTIVATED (0U-741) -#define TBVN_CONTEXTMENU (0U-742) +#define TBVN_PAGEACTIVATED (0U-741) +#define TBVN_CONTEXTMENU (0U-742) +#define TBVN_TABCLOSEBTN (0U-743) // return 0 to close page, 1 to keep open +// internal +#define TBVN_CLOSEBTNMOUSELEAVE (0U-744) // Notification data for TBVN_CONTEXTMENU struct TBVCONTEXTMENUINFO @@ -3852,11 +3551,191 @@ struct TBVCONTEXTMENUINFO typedef TBVCONTEXTMENUINFO* LPTBVCONTEXTMENUINFO; +// Helper class for tab item hover close button +class CTabViewCloseBtn : public ATL::CWindowImpl +{ +public: + DECLARE_WND_CLASS_EX(_T("WTL_TabView_CloseBtn"), 0, -1) + + enum { _xyBtnImageLeftTop = 3, _xyBtnImageRightBottom = 9 }; + + bool m_bHover; + bool m_bPressed; + CToolTipCtrl m_tip; + + CTabViewCloseBtn() : m_bHover(false), m_bPressed(false) + { } + +// Message map and handlers + BEGIN_MSG_MAP(CTabViewCloseBtn) + MESSAGE_RANGE_HANDLER(WM_MOUSEFIRST, WM_MOUSELAST, OnMouseMessage) + MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown) + MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove) + MESSAGE_HANDLER(WM_MOUSELEAVE, OnMouseLeave) + MESSAGE_HANDLER(WM_LBUTTONUP, OnLButtonUp) + MESSAGE_HANDLER(WM_CAPTURECHANGED, OnCaptureChanged) + MESSAGE_HANDLER(WM_PAINT, OnPaint) + MESSAGE_HANDLER(WM_PRINTCLIENT, OnPaint) + FORWARD_NOTIFICATIONS() + END_MSG_MAP() + + LRESULT OnMouseMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) + { + MSG msg = { m_hWnd, uMsg, wParam, lParam }; + if(m_tip.IsWindow() != FALSE) + m_tip.RelayEvent(&msg); + + bHandled = FALSE; + return 1; + } + + LRESULT OnLButtonDown(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + SetCapture(); + m_bHover = false; + m_bPressed = true; + Invalidate(FALSE); + UpdateWindow(); + + return 0; + } + + LRESULT OnMouseMove(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/) + { + if(::GetCapture() == m_hWnd) + { + POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; + ClientToScreen(&pt); + RECT rect = {}; + GetWindowRect(&rect); + bool bPressed = (::PtInRect(&rect, pt) != FALSE); + if(m_bPressed != bPressed) + { + m_bPressed = bPressed; + Invalidate(FALSE); + UpdateWindow(); + } + } + else + { + if(!m_bHover) + { + m_bHover = true; + Invalidate(FALSE); + UpdateWindow(); + } + + TRACKMOUSEEVENT tme = { sizeof(TRACKMOUSEEVENT), TME_LEAVE, m_hWnd }; + ::TrackMouseEvent(&tme); + } + + return 0; + } + + LRESULT OnMouseLeave(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + if(m_bHover) + { + m_bHover = false; + Invalidate(FALSE); + UpdateWindow(); + } + + NMHDR nmhdr = { m_hWnd, (UINT_PTR)GetDlgCtrlID(), TBVN_CLOSEBTNMOUSELEAVE }; + GetParent().SendMessage(WM_NOTIFY, GetDlgCtrlID(), (LPARAM)&nmhdr); + + return 0; + } + + LRESULT OnLButtonUp(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + if(::GetCapture() == m_hWnd) + { + bool bAction = m_bPressed; + ReleaseCapture(); + + if(bAction) + GetParent().SendMessage(WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(), BN_CLICKED), (LPARAM)m_hWnd); + } + + return 0; + } + + LRESULT OnCaptureChanged(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + if(m_bPressed) + { + m_bPressed = false; + Invalidate(FALSE); + UpdateWindow(); + } + + return 0; + } + + LRESULT OnPaint(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + if(wParam != NULL) + { + DoPaint((HDC)wParam); + } + else + { + CPaintDC dc(this->m_hWnd); + DoPaint(dc.m_hDC); + } + + return 0; + } + + // painting helper + void DoPaint(CDCHandle dc) + { + RECT rect = {}; + GetClientRect(&rect); + + RECT rcImage = { _xyBtnImageLeftTop, _xyBtnImageLeftTop, _xyBtnImageRightBottom + 1, _xyBtnImageRightBottom + 1 }; + ::OffsetRect(&rcImage, rect.left, rect.top); + if(m_bPressed) + ::OffsetRect(&rcImage, 1, 0); + + // draw button frame and background + CPen penFrame; + penFrame.CreatePen(PS_SOLID, 0, ::GetSysColor((m_bHover || m_bPressed) ? COLOR_BTNTEXT : COLOR_BTNSHADOW)); + HPEN hPenOld = dc.SelectPen(penFrame); + + CBrush brush; + brush.CreateSysColorBrush(m_bPressed ? COLOR_BTNSHADOW : COLOR_WINDOW); + HBRUSH hBrushOld = dc.SelectBrush(brush); + + dc.Rectangle(&rect); + + // draw button "X" + CPen penX; + penX.CreatePen(PS_SOLID, 0, ::GetSysColor(COLOR_BTNTEXT)); + dc.SelectPen(penX); + + dc.MoveTo(rcImage.left, rcImage.top); + dc.LineTo(rcImage.right, rcImage.bottom); + dc.MoveTo(rcImage.left + 1, rcImage.top); + dc.LineTo(rcImage.right + 1, rcImage.bottom); + + dc.MoveTo(rcImage.left, rcImage.bottom - 1); + dc.LineTo(rcImage.right, rcImage.top - 1); + dc.MoveTo(rcImage.left + 1, rcImage.bottom - 1); + dc.LineTo(rcImage.right + 1, rcImage.top - 1); + + dc.SelectPen(hPenOld); + dc.SelectBrush(hBrushOld); + } +}; + + template class ATL_NO_VTABLE CTabViewImpl : public ATL::CWindowImpl< T, TBase, TWinTraits > { public: - DECLARE_WND_CLASS_EX(NULL, 0, COLOR_APPWORKSPACE) + DECLARE_WND_CLASS_EX2(NULL, T, 0, COLOR_APPWORKSPACE) // Declarations and enums struct TABVIEWPAGE @@ -3882,6 +3761,25 @@ public: m_nMenuItemsMax = (ID_WINDOW_TABLAST - ID_WINDOW_TABFIRST + 1) }; + enum { _nAutoScrollTimerID = 4321 }; + + enum AutoScroll + { + _AUTOSCROLL_NONE = 0, + _AUTOSCROLL_LEFT = -1, + _AUTOSCROLL_RIGHT = 1 + }; + + enum CloseBtn + { + _cxCloseBtn = 14, + _cyCloseBtn = 13, + _cxCloseBtnMargin = 4, + _cxCloseBtnMarginSel = 1, + + _nCloseBtnID = ID_PANE_CLOSE + }; + // Data members ATL::CContainedWindowT m_tab; int m_cyTabHeight; @@ -3903,6 +3801,12 @@ public: CImageList m_ilDrag; + AutoScroll m_AutoScroll; + CUpDownCtrl m_ud; + + CTabViewCloseBtn m_btnClose; + int m_nCloseItem; + bool m_bDestroyPageOnRemove:1; bool m_bDestroyImageList:1; bool m_bActivePageMenuItem:1; @@ -3910,6 +3814,8 @@ public: bool m_bEmptyMenuItem:1; bool m_bWindowsMenuItem:1; bool m_bNoTabDrag:1; + bool m_bNoTabDragAutoScroll:1; + bool m_bTabCloseButton:1; // internal bool m_bTabCapture:1; bool m_bTabDrag:1; @@ -3917,14 +3823,16 @@ public: // Constructor/destructor CTabViewImpl() : - m_nActivePage(-1), - m_cyTabHeight(0), - m_tab(this, 1), + m_tab(this, 1), + m_cyTabHeight(0), + m_nActivePage(-1), m_nInsertItem(-1), m_cchTabTextLength(30), m_nMenuItemsCount(10), m_lpstrTitleBarBase(NULL), m_cchTitleBarLength(100), + m_AutoScroll(_AUTOSCROLL_NONE), + m_nCloseItem(-1), m_bDestroyPageOnRemove(true), m_bDestroyImageList(true), m_bActivePageMenuItem(true), @@ -3932,6 +3840,8 @@ public: m_bEmptyMenuItem(false), m_bWindowsMenuItem(false), m_bNoTabDrag(false), + m_bNoTabDragAutoScroll(false), + m_bTabCloseButton(true), m_bTabCapture(false), m_bTabDrag(false), m_bInternalFont(false) @@ -3948,7 +3858,7 @@ public: // Message filter function - to be called from PreTranslateMessage of the main window BOOL PreTranslateMessage(MSG* pMsg) { - if(IsWindow() == FALSE) + if(this->IsWindow() == FALSE) return FALSE; BOOL bRet = FALSE; @@ -3981,7 +3891,7 @@ public: // If we are doing drag-drop, check for Escape key that cancels it if(bRet == FALSE) { - if(m_bTabCapture && pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_ESCAPE) + if(m_bTabCapture && (pMsg->message == WM_KEYDOWN) && (pMsg->wParam == VK_ESCAPE)) { ::ReleaseCapture(); bRet = TRUE; @@ -4001,7 +3911,7 @@ public: // Attributes int GetPageCount() const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); return m_tab.GetItemCount(); } @@ -4012,25 +3922,27 @@ public: void SetActivePage(int nPage) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(IsValidPageIndex(nPage)); T* pT = static_cast(this); - SetRedraw(FALSE); + this->SetRedraw(FALSE); if(m_nActivePage != -1) - ::ShowWindow(GetPageHWND(m_nActivePage), FALSE); + ::ShowWindow(GetPageHWND(m_nActivePage), SW_HIDE); m_nActivePage = nPage; m_tab.SetCurSel(m_nActivePage); - ::ShowWindow(GetPageHWND(m_nActivePage), TRUE); + ::ShowWindow(GetPageHWND(m_nActivePage), SW_SHOW); pT->UpdateLayout(); - SetRedraw(TRUE); - RedrawWindow(NULL, NULL, RDW_FRAME | RDW_INVALIDATE | RDW_UPDATENOW | RDW_ALLCHILDREN); + this->SetRedraw(TRUE); + this->RedrawWindow(NULL, NULL, RDW_FRAME | RDW_INVALIDATE | RDW_UPDATENOW | RDW_ALLCHILDREN); - if(::GetFocus() != m_tab.m_hWnd) + HWND hWndFocus = ::GetFocus(); + ATL::CWindow wndTop = this->GetTopLevelWindow(); + if((hWndFocus == wndTop.m_hWnd) || ((wndTop.IsChild(hWndFocus) != FALSE) && (hWndFocus != m_tab.m_hWnd))) ::SetFocus(GetPageHWND(m_nActivePage)); pT->UpdateTitleBar(); @@ -4039,19 +3951,19 @@ public: HIMAGELIST GetImageList() const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); return m_tab.GetImageList(); } HIMAGELIST SetImageList(HIMAGELIST hImageList) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); return m_tab.SetImageList(hImageList); } void SetWindowMenu(HMENU hMenu) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); m_menu = hMenu; @@ -4061,7 +3973,7 @@ public: void SetTitleBarWindow(HWND hWnd) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); delete [] m_lpstrTitleBarBase; m_lpstrTitleBarBase = NULL; @@ -4083,10 +3995,10 @@ public: // Page attributes HWND GetPageHWND(int nPage) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(IsValidPageIndex(nPage)); - TCITEMEXTRA tcix = { 0 }; + TCITEMEXTRA tcix = {}; tcix.tciheader.mask = TCIF_PARAM; m_tab.GetItem(nPage, tcix); @@ -4095,10 +4007,10 @@ public: LPCTSTR GetPageTitle(int nPage) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(IsValidPageIndex(nPage)); - TCITEMEXTRA tcix = { 0 }; + TCITEMEXTRA tcix = {}; tcix.tciheader.mask = TCIF_PARAM; if(m_tab.GetItem(nPage, tcix) == FALSE) return NULL; @@ -4108,7 +4020,7 @@ public: bool SetPageTitle(int nPage, LPCTSTR lpstrTitle) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(IsValidPageIndex(nPage)); T* pT = static_cast(this); @@ -4119,13 +4031,13 @@ public: if(lpstrBuff == NULL) return false; - SecureHelper::strcpy_x(lpstrBuff, cchBuff, lpstrTitle); - TCITEMEXTRA tcix = { 0 }; + ATL::Checked::tcscpy_s(lpstrBuff, cchBuff, lpstrTitle); + TCITEMEXTRA tcix = {}; tcix.tciheader.mask = TCIF_PARAM; if(m_tab.GetItem(nPage, tcix) == FALSE) return false; - CTempBuffer buff; + ATL::CTempBuffer buff; LPTSTR lpstrTabText = buff.Allocate(m_cchTabTextLength + 1); if(lpstrTabText == NULL) return false; @@ -4148,10 +4060,10 @@ public: LPVOID GetPageData(int nPage) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(IsValidPageIndex(nPage)); - TCITEMEXTRA tcix = { 0 }; + TCITEMEXTRA tcix = {}; tcix.tciheader.mask = TCIF_PARAM; m_tab.GetItem(nPage, tcix); @@ -4160,10 +4072,10 @@ public: LPVOID SetPageData(int nPage, LPVOID pData) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(IsValidPageIndex(nPage)); - TCITEMEXTRA tcix = { 0 }; + TCITEMEXTRA tcix = {}; tcix.tciheader.mask = TCIF_PARAM; m_tab.GetItem(nPage, tcix); LPVOID pDataOld = tcix.tvpage.pData; @@ -4176,10 +4088,10 @@ public: int GetPageImage(int nPage) const { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(IsValidPageIndex(nPage)); - TCITEMEXTRA tcix = { 0 }; + TCITEMEXTRA tcix = {}; tcix.tciheader.mask = TCIF_IMAGE; m_tab.GetItem(nPage, tcix); @@ -4188,10 +4100,10 @@ public: int SetPageImage(int nPage, int nImage) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(IsValidPageIndex(nPage)); - TCITEMEXTRA tcix = { 0 }; + TCITEMEXTRA tcix = {}; tcix.tciheader.mask = TCIF_IMAGE; m_tab.GetItem(nPage, tcix); int nImageOld = tcix.tciheader.iImage; @@ -4210,8 +4122,8 @@ public: bool InsertPage(int nPage, HWND hWndView, LPCTSTR lpstrTitle, int nImage = -1, LPVOID pData = NULL) { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT(nPage == GetPageCount() || IsValidPageIndex(nPage)); + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((nPage == GetPageCount()) || IsValidPageIndex(nPage)); T* pT = static_cast(this); @@ -4221,18 +4133,18 @@ public: if(lpstrBuff == NULL) return false; - SecureHelper::strcpy_x(lpstrBuff, cchBuff, lpstrTitle); + ATL::Checked::tcscpy_s(lpstrBuff, cchBuff, lpstrTitle); - CTempBuffer buff; + ATL::CTempBuffer buff; LPTSTR lpstrTabText = buff.Allocate(m_cchTabTextLength + 1); if(lpstrTabText == NULL) return false; pT->ShortenTitle(lpstrTitle, lpstrTabText, m_cchTabTextLength + 1); - SetRedraw(FALSE); + this->SetRedraw(FALSE); - TCITEMEXTRA tcix = { 0 }; + TCITEMEXTRA tcix = {}; tcix.tciheader.mask = TCIF_TEXT | TCIF_IMAGE | TCIF_PARAM; tcix.tciheader.pszText = lpstrTabText; tcix.tciheader.iImage = nImage; @@ -4243,7 +4155,7 @@ public: if(nItem == -1) { delete [] lpstrBuff; - SetRedraw(TRUE); + this->SetRedraw(TRUE); return false; } @@ -4259,20 +4171,20 @@ public: pT->UpdateLayout(); - SetRedraw(TRUE); - RedrawWindow(NULL, NULL, RDW_FRAME | RDW_INVALIDATE | RDW_UPDATENOW | RDW_ALLCHILDREN); + this->SetRedraw(TRUE); + this->RedrawWindow(NULL, NULL, RDW_FRAME | RDW_INVALIDATE | RDW_UPDATENOW | RDW_ALLCHILDREN); return true; } void RemovePage(int nPage) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); ATLASSERT(IsValidPageIndex(nPage)); T* pT = static_cast(this); - SetRedraw(FALSE); + this->SetRedraw(FALSE); if(GetPageCount() == 1) pT->ShowTabControl(false); @@ -4280,7 +4192,7 @@ public: if(m_bDestroyPageOnRemove) ::DestroyWindow(GetPageHWND(nPage)); else - ::ShowWindow(GetPageHWND(nPage), FALSE); + ::ShowWindow(GetPageHWND(nPage), SW_HIDE); LPTSTR lpstrTitle = (LPTSTR)GetPageTitle(nPage); delete [] lpstrTitle; @@ -4300,9 +4212,9 @@ public: } else { - SetRedraw(TRUE); - Invalidate(); - UpdateWindow(); + this->SetRedraw(TRUE); + this->Invalidate(); + this->UpdateWindow(); pT->UpdateTitleBar(); pT->UpdateMenu(); } @@ -4319,14 +4231,14 @@ public: void RemoveAllPages() { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); if(GetPageCount() == 0) return; T* pT = static_cast(this); - SetRedraw(FALSE); + this->SetRedraw(FALSE); pT->ShowTabControl(false); @@ -4335,7 +4247,7 @@ public: if(m_bDestroyPageOnRemove) ::DestroyWindow(GetPageHWND(i)); else - ::ShowWindow(GetPageHWND(i), FALSE); + ::ShowWindow(GetPageHWND(i), SW_HIDE); LPTSTR lpstrTitle = (LPTSTR)GetPageTitle(i); delete [] lpstrTitle; } @@ -4344,9 +4256,9 @@ public: m_nActivePage = -1; pT->OnPageActivated(m_nActivePage); - SetRedraw(TRUE); - Invalidate(); - UpdateWindow(); + this->SetRedraw(TRUE); + this->Invalidate(); + this->UpdateWindow(); pT->UpdateTitleBar(); pT->UpdateMenu(); @@ -4370,33 +4282,20 @@ public: void BuildWindowMenu(HMENU hMenu, int nMenuItemsCount = 10, bool bEmptyMenuItem = true, bool bWindowsMenuItem = true, bool bActivePageMenuItem = true, bool bActiveAsDefaultMenuItem = false) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); CMenuHandle menu = hMenu; T* pT = static_cast(this); - pT; // avoid level 4 warning + (void)pT; // avoid level 4 warning int nFirstPos = 0; // Find first menu item in our range -#ifndef _WIN32_WCE for(nFirstPos = 0; nFirstPos < menu.GetMenuItemCount(); nFirstPos++) { UINT nID = menu.GetMenuItemID(nFirstPos); - if((nID >= ID_WINDOW_TABFIRST && nID <= ID_WINDOW_TABLAST) || nID == ID_WINDOW_SHOWTABLIST) - break; - } -#else // CE specific - for(nFirstPos = 0; ; nFirstPos++) - { - CMenuItemInfo mii; - mii.fMask = MIIM_ID; - BOOL bRet = menu.GetMenuItemInfo(nFirstPos, TRUE, &mii); - if(bRet == FALSE) - break; - if((mii.wID >= ID_WINDOW_TABFIRST && mii.wID <= ID_WINDOW_TABLAST) || mii.wID == ID_WINDOW_SHOWTABLIST) + if(((nID >= ID_WINDOW_TABFIRST) && (nID <= ID_WINDOW_TABLAST)) || (nID == ID_WINDOW_SHOWTABLIST)) break; } -#endif // _WIN32_WCE // Remove all menu items for tab pages BOOL bRet = TRUE; @@ -4410,7 +4309,7 @@ public: CMenuItemInfo mii; mii.fMask = MIIM_TYPE; menu.GetMenuItemInfo(nFirstPos - 1, TRUE, &mii); - if((nFirstPos <= 0) || ((mii.fType & MFT_SEPARATOR) == 0)) + if((mii.fType & MFT_SEPARATOR) == 0) { menu.AppendMenu(MF_SEPARATOR); nFirstPos++; @@ -4431,13 +4330,13 @@ public: { LPCTSTR lpstrTitle = GetPageTitle(i); int nLen = lstrlen(lpstrTitle); - CTempBuffer buff; + ATL::CTempBuffer buff; LPTSTR lpstrText = buff.Allocate(cchPrefix + nLen + 1); ATLASSERT(lpstrText != NULL); if(lpstrText != NULL) { LPCTSTR lpstrFormat = (i < 9) ? _T("&%i %s") : _T("%i %s"); - SecureHelper::wsprintf_x(lpstrText, cchPrefix + nLen + 1, lpstrFormat, i + 1, lpstrTitle); + _stprintf_s(lpstrText, cchPrefix + nLen + 1, lpstrFormat, i + 1, lpstrTitle); menu.AppendMenu(MF_STRING, ID_WINDOW_TABFIRST + i, lpstrText); } } @@ -4445,16 +4344,12 @@ public: // Mark active page if(bActivePageMenuItem && (m_nActivePage != -1)) { -#ifndef _WIN32_WCE if(bActiveAsDefaultMenuItem) { menu.SetMenuDefaultItem((UINT)-1, TRUE); menu.SetMenuDefaultItem(nFirstPos + m_nActivePage, TRUE); } else -#else // CE specific - bActiveAsDefaultMenuItem; // avoid level 4 warning -#endif // _WIN32_WCE { menu.CheckMenuRadioItem(nFirstPos, nFirstPos + nMenuItemsCount, nFirstPos + m_nActivePage, MF_BYPOSITION); } @@ -4486,12 +4381,7 @@ public: BOOL SubclassWindow(HWND hWnd) { -#if (_MSC_VER >= 1300) BOOL bRet = ATL::CWindowImpl< T, TBase, TWinTraits >::SubclassWindow(hWnd); -#else // !(_MSC_VER >= 1300) - typedef ATL::CWindowImpl< T, TBase, TWinTraits > _baseClass; - BOOL bRet = _baseClass::SubclassWindow(hWnd); -#endif // !(_MSC_VER >= 1300) if(bRet != FALSE) { T* pT = static_cast(this); @@ -4510,19 +4400,20 @@ public: MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus) MESSAGE_HANDLER(WM_GETFONT, OnGetFont) MESSAGE_HANDLER(WM_SETFONT, OnSetFont) + MESSAGE_HANDLER(WM_TIMER, OnTimer) + MESSAGE_HANDLER(WM_CONTEXTMENU, OnTabContextMenu) NOTIFY_HANDLER(m_nTabID, TCN_SELCHANGE, OnTabChanged) NOTIFY_ID_HANDLER(m_nTabID, OnTabNotification) -#ifndef _WIN32_WCE NOTIFY_CODE_HANDLER(TTN_GETDISPINFO, OnTabGetDispInfo) -#endif // !_WIN32_WCE FORWARD_NOTIFICATIONS() ALT_MSG_MAP(1) // tab control MESSAGE_HANDLER(WM_LBUTTONDOWN, OnTabLButtonDown) MESSAGE_HANDLER(WM_LBUTTONUP, OnTabLButtonUp) MESSAGE_HANDLER(WM_CAPTURECHANGED, OnTabCaptureChanged) MESSAGE_HANDLER(WM_MOUSEMOVE, OnTabMouseMove) - MESSAGE_HANDLER(WM_RBUTTONUP, OnTabRButtonUp) - MESSAGE_HANDLER(WM_SYSKEYDOWN, OnTabSysKeyDown) + MESSAGE_HANDLER(WM_MOUSELEAVE, OnTabMouseLeave) + NOTIFY_HANDLER(T::_nCloseBtnID, TBVN_CLOSEBTNMOUSELEAVE, OnTabCloseBtnMouseLeave) + COMMAND_HANDLER(T::_nCloseBtnID, BN_CLICKED, OnTabCloseBtnClicked) END_MSG_MAP() LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) @@ -4552,6 +4443,8 @@ public: m_bInternalFont = false; } + m_ud.m_hWnd = NULL; + return 0; } @@ -4595,8 +4488,71 @@ public: return 0; } + LRESULT OnTimer(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) + { + if(wParam == _nAutoScrollTimerID) + { + T* pT = static_cast(this); + pT->DoAutoScroll(); + } + else + { + bHandled = FALSE; + } + + return 0; + } + + LRESULT OnTabContextMenu(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled) + { + POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; + int nPage = m_nActivePage; + bool bAction = false; + if((HWND)wParam == m_tab.m_hWnd) + { + if((pt.x == -1) && (pt.y == -1)) // keyboard + { + RECT rect = {}; + m_tab.GetItemRect(m_nActivePage, &rect); + pt.x = rect.left; + pt.y = rect.bottom; + m_tab.ClientToScreen(&pt); + bAction = true; + } + else if(::WindowFromPoint(pt) == m_tab.m_hWnd) + { + TCHITTESTINFO hti = {}; + hti.pt = pt; + this->ScreenToClient(&hti.pt); + nPage = m_tab.HitTest(&hti); + + bAction = true; + } + } + + if(bAction) + { + T* pT = static_cast(this); + pT->OnContextMenu(nPage, pt); + } + else + { + bHandled = FALSE; + } + + return 0; + } + LRESULT OnTabChanged(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/) { + if(m_bTabCloseButton && (m_btnClose.m_hWnd != NULL)) + { + T* pT = static_cast(this); + RECT rcClose = {}; + pT->CalcCloseButtonRect(m_nCloseItem, rcClose); + m_btnClose.SetWindowPos(NULL, &rcClose, SWP_NOZORDER | SWP_NOACTIVATE); + } + SetActivePage(m_tab.GetCurSel()); T* pT = static_cast(this); pT->OnPageActivated(m_nActivePage); @@ -4611,7 +4567,6 @@ public: return 0; } -#ifndef _WIN32_WCE LRESULT OnTabGetDispInfo(int /*idCtrl*/, LPNMHDR pnmh, BOOL& bHandled) { LPNMTTDISPINFO pTTDI = (LPNMTTDISPINFO)pnmh; @@ -4627,7 +4582,6 @@ public: return 0; } -#endif // !_WIN32_WCE // Tab control message handlers LRESULT OnTabLButtonDown(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled) @@ -4651,10 +4605,9 @@ public: { if(m_bTabDrag) { - TCHITTESTINFO hti = { 0 }; - hti.pt.x = GET_X_LPARAM(lParam); - hti.pt.y = GET_Y_LPARAM(lParam); - int nItem = m_tab.HitTest(&hti); + T* pT = static_cast(this); + POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; + int nItem = pT->DragHitTest(pt); if(nItem != -1) MovePage(m_nActivePage, nItem); } @@ -4675,12 +4628,14 @@ public: if(m_bTabDrag) { m_bTabDrag = false; + T* pT = static_cast(this); + if(!m_bNoTabDragAutoScroll) + pT->StartStopAutoScroll(-1); + pT->DrawMoveMark(-1); -#ifndef _WIN32_WCE m_ilDrag.DragLeave(GetDesktopWindow()); -#endif // !_WIN32_WCE m_ilDrag.EndDrag(); m_ilDrag.Destroy(); @@ -4702,13 +4657,8 @@ public: if(!m_bTabDrag) { -#ifndef _WIN32_WCE - if(abs(m_ptStartDrag.x - GET_X_LPARAM(lParam)) >= ::GetSystemMetrics(SM_CXDRAG) || - abs(m_ptStartDrag.y - GET_Y_LPARAM(lParam)) >= ::GetSystemMetrics(SM_CYDRAG)) -#else // CE specific - if(abs(m_ptStartDrag.x - GET_X_LPARAM(lParam)) >= 4 || - abs(m_ptStartDrag.y - GET_Y_LPARAM(lParam)) >= 4) -#endif // _WIN32_WCE + if((abs(m_ptStartDrag.x - GET_X_LPARAM(lParam)) >= ::GetSystemMetrics(SM_CXDRAG)) || + (abs(m_ptStartDrag.y - GET_Y_LPARAM(lParam)) >= ::GetSystemMetrics(SM_CYDRAG))) { T* pT = static_cast(this); pT->GenerateDragImage(m_nActivePage); @@ -4716,11 +4666,9 @@ public: int cxCursor = ::GetSystemMetrics(SM_CXCURSOR); int cyCursor = ::GetSystemMetrics(SM_CYCURSOR); m_ilDrag.BeginDrag(0, -(cxCursor / 2), -(cyCursor / 2)); -#ifndef _WIN32_WCE POINT ptEnter = m_ptStartDrag; m_tab.ClientToScreen(&ptEnter); m_ilDrag.DragEnter(GetDesktopWindow(), ptEnter); -#endif // !_WIN32_WCE m_bTabDrag = true; } @@ -4728,16 +4676,17 @@ public: if(m_bTabDrag) { - TCHITTESTINFO hti = { 0 }; - hti.pt = pt; - int nItem = m_tab.HitTest(&hti); - T* pT = static_cast(this); + int nItem = pT->DragHitTest(pt); + pT->SetMoveCursor(nItem != -1); if(m_nInsertItem != nItem) pT->DrawMoveMark(nItem); + if(!m_bNoTabDragAutoScroll) + pT->StartStopAutoScroll(pt.x); + m_ilDrag.DragShowNolock((nItem != -1) ? TRUE : FALSE); m_tab.ClientToScreen(&pt); m_ilDrag.DragMove(pt); @@ -4745,43 +4694,80 @@ public: bHandled = TRUE; } } + else if(m_bTabCloseButton) + { + TCHITTESTINFO thti = {}; + thti.pt.x = GET_X_LPARAM(lParam); + thti.pt.y = GET_Y_LPARAM(lParam); - return 0; - } + int nItem = m_tab.HitTest(&thti); + if(nItem >= 0) + { + ATLTRACE(_T("+++++ item = %i\n"), nItem); - LRESULT OnTabRButtonUp(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/) - { - TCHITTESTINFO hti = { 0 }; - hti.pt.x = GET_X_LPARAM(lParam); - hti.pt.y = GET_Y_LPARAM(lParam); - int nItem = m_tab.HitTest(&hti); - if(nItem != -1) - { - T* pT = static_cast(this); - pT->OnContextMenu(nItem, hti.pt); + T* pT = static_cast(this); + if(m_btnClose.m_hWnd == NULL) + { + pT->CreateCloseButton(nItem); + m_nCloseItem = nItem; + } + else if(m_nCloseItem != nItem) + { + RECT rcClose = {}; + pT->CalcCloseButtonRect(nItem, rcClose); + m_btnClose.SetWindowPos(NULL, &rcClose, SWP_NOZORDER | SWP_NOACTIVATE); + m_nCloseItem = nItem; + } + + TRACKMOUSEEVENT tme = { sizeof(TRACKMOUSEEVENT), TME_LEAVE, m_tab.m_hWnd }; + ::TrackMouseEvent(&tme); + } } return 0; } - LRESULT OnTabSysKeyDown(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) + LRESULT OnTabMouseLeave(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) { - bool bShift = (::GetKeyState(VK_SHIFT) < 0); - if(wParam == VK_F10 && bShift) + bHandled = FALSE; + + if(m_btnClose.m_hWnd != NULL) { - if(m_nActivePage != -1) + POINT pt = {}; + ::GetCursorPos(&pt); + RECT rect = {}; + m_btnClose.GetWindowRect(&rect); + if(::PtInRect(&rect, pt) == FALSE) { - RECT rect = { 0 }; - m_tab.GetItemRect(m_nActivePage, &rect); - POINT pt = { rect.left, rect.bottom }; + m_nCloseItem = -1; T* pT = static_cast(this); - pT->OnContextMenu(m_nActivePage, pt); + pT->DestroyCloseButton(); + } + else + { + bHandled = TRUE; } } - else - { - bHandled = FALSE; - } + + return 0; + } + + LRESULT OnTabCloseBtnMouseLeave(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/) + { + TCHITTESTINFO thti = {}; + ::GetCursorPos(&thti.pt); + m_tab.ScreenToClient(&thti.pt); + int nItem = m_tab.HitTest(&thti); + if(nItem == -1) + m_tab.SendMessage(WM_MOUSELEAVE); + + return 0; + } + + LRESULT OnTabCloseBtnClicked(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) + { + T* pT = static_cast(this); + pT->OnTabCloseBtn(m_nCloseItem); return 0; } @@ -4789,7 +4775,7 @@ public: // Implementation helpers bool IsValidPageIndex(int nPage) const { - return (nPage >= 0 && nPage < GetPageCount()); + return ((nPage >= 0) && (nPage < GetPageCount())); } bool MovePage(int nMovePage, int nInsertBeforePage) @@ -4803,11 +4789,11 @@ public: if(nMovePage == nInsertBeforePage) return true; // nothing to do - CTempBuffer buff; + ATL::CTempBuffer buff; LPTSTR lpstrTabText = buff.Allocate(m_cchTabTextLength + 1); if(lpstrTabText == NULL) return false; - TCITEMEXTRA tcix = { 0 }; + TCITEMEXTRA tcix = {}; tcix.tciheader.mask = TCIF_TEXT | TCIF_IMAGE | TCIF_PARAM; tcix.tciheader.pszText = lpstrTabText; tcix.tciheader.cchTextMax = m_cchTabTextLength + 1; @@ -4840,11 +4826,7 @@ public: // Implementation overrideables bool CreateTabControl() { -#ifndef _WIN32_WCE - m_tab.Create(m_hWnd, rcDefault, NULL, WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | TCS_TOOLTIPS, 0, m_nTabID); -#else // CE specific - m_tab.Create(m_hWnd, rcDefault, NULL, WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, 0, m_nTabID); -#endif // _WIN32_WCE + m_tab.Create(this->m_hWnd, this->rcDefault, NULL, WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | TCS_TOOLTIPS, 0, m_nTabID); ATLASSERT(m_tab.m_hWnd != NULL); if(m_tab.m_hWnd == NULL) return false; @@ -4864,7 +4846,7 @@ public: { int nCount = m_tab.GetItemCount(); TCHAR szText[] = _T("NS"); - TCITEMEXTRA tcix = { 0 }; + TCITEMEXTRA tcix = {}; tcix.tciheader.mask = TCIF_TEXT; tcix.tciheader.pszText = szText; int nIndex = m_tab.InsertItem(nCount, tcix); @@ -4891,8 +4873,8 @@ public: void UpdateLayout() { - RECT rect = { 0 }; - GetClientRect(&rect); + RECT rect = {}; + this->GetClientRect(&rect); int cyOffset = 0; if(m_tab.IsWindow() && ((m_tab.GetStyle() & WS_VISIBLE) != 0)) @@ -4913,7 +4895,7 @@ public: void UpdateTitleBar() { - if(!m_wndTitleBar.IsWindow() || m_lpstrTitleBarBase == NULL) + if(!m_wndTitleBar.IsWindow() || (m_lpstrTitleBarBase == NULL)) return; // nothing to do if(m_nActivePage != -1) @@ -4922,14 +4904,14 @@ public: LPCTSTR lpstrTitle = pT->GetPageTitle(m_nActivePage); LPCTSTR lpstrDivider = pT->GetTitleDividerText(); int cchBuffer = m_cchTitleBarLength + lstrlen(lpstrDivider) + lstrlen(m_lpstrTitleBarBase) + 1; - CTempBuffer buff; + ATL::CTempBuffer buff; LPTSTR lpstrPageTitle = buff.Allocate(cchBuffer); ATLASSERT(lpstrPageTitle != NULL); if(lpstrPageTitle != NULL) { pT->ShortenTitle(lpstrTitle, lpstrPageTitle, m_cchTitleBarLength + 1); - SecureHelper::strcat_x(lpstrPageTitle, cchBuffer, lpstrDivider); - SecureHelper::strcat_x(lpstrPageTitle, cchBuffer, m_lpstrTitleBarBase); + ATL::Checked::tcscat_s(lpstrPageTitle, cchBuffer, lpstrDivider); + ATL::Checked::tcscat_s(lpstrPageTitle, cchBuffer, m_lpstrTitleBarBase); } else { @@ -4950,7 +4932,7 @@ public: if(m_nInsertItem != -1) { - RECT rect = { 0 }; + RECT rect = {}; pT->GetMoveMarkRect(rect); m_tab.InvalidateRect(&rect); } @@ -4961,7 +4943,7 @@ public: { CClientDC dc(m_tab.m_hWnd); - RECT rect = { 0 }; + RECT rect = {}; pT->GetMoveMarkRect(rect); CPen pen; @@ -4990,7 +4972,7 @@ public: { m_tab.GetClientRect(&rect); - RECT rcItem = { 0 }; + RECT rcItem = {}; m_tab.GetItemRect(m_nInsertItem, &rcItem); if(m_nInsertItem <= m_nActivePage) @@ -5014,19 +4996,14 @@ public: { ATLASSERT(IsValidPageIndex(nItem)); -#ifndef _WIN32_WCE - RECT rcItem = { 0 }; + RECT rcItem = {}; m_tab.GetItemRect(nItem, &rcItem); ::InflateRect(&rcItem, 2, 2); // make bigger to cover selected item -#else // CE specific - nItem; // avoid level 4 warning - RECT rcItem = { 0, 0, 40, 20 }; -#endif // _WIN32_WCE ATLASSERT(m_ilDrag.m_hImageList == NULL); m_ilDrag.Create(rcItem.right - rcItem.left, rcItem.bottom - rcItem.top, ILC_COLORDDB | ILC_MASK, 1, 1); - CClientDC dc(m_hWnd); + CClientDC dc(this->m_hWnd); CDC dcMem; dcMem.CreateCompatibleDC(dc); ATLASSERT(dcMem.m_hDC != NULL); @@ -5037,11 +5014,7 @@ public: ATLASSERT(bmp.m_hBitmap != NULL); HBITMAP hBmpOld = dcMem.SelectBitmap(bmp); -#ifndef _WIN32_WCE m_tab.SendMessage(WM_PRINTCLIENT, (WPARAM)dcMem.m_hDC); -#else // CE specific - dcMem.Rectangle(&rcItem); -#endif // _WIN32_WCE dcMem.SelectBitmap(hBmpOld); ATLVERIFY(m_ilDrag.Add(bmp.m_hBitmap, RGB(255, 0, 255)) != -1); @@ -5053,22 +5026,111 @@ public: { LPCTSTR lpstrEllipsis = _T("..."); int cchEllipsis = lstrlen(lpstrEllipsis); - SecureHelper::strncpy_x(lpstrShortTitle, cchShortTitle, lpstrTitle, cchShortTitle - cchEllipsis - 1); - SecureHelper::strcat_x(lpstrShortTitle, cchShortTitle, lpstrEllipsis); + ATL::Checked::tcsncpy_s(lpstrShortTitle, cchShortTitle, lpstrTitle, cchShortTitle - cchEllipsis - 1); + ATL::Checked::tcscat_s(lpstrShortTitle, cchShortTitle, lpstrEllipsis); } else { - SecureHelper::strcpy_x(lpstrShortTitle, cchShortTitle, lpstrTitle); + ATL::Checked::tcscpy_s(lpstrShortTitle, cchShortTitle, lpstrTitle); } } -#ifndef _WIN32_WCE void UpdateTooltipText(LPNMTTDISPINFO pTTDI) { ATLASSERT(pTTDI != NULL); pTTDI->lpszText = (LPTSTR)GetPageTitle((int)pTTDI->hdr.idFrom); } -#endif // !_WIN32_WCE + + int DragHitTest(POINT pt) const + { + RECT rect = {}; + this->GetClientRect(&rect); + if(::PtInRect(&rect, pt) == FALSE) + return -1; + + m_tab.GetClientRect(&rect); + TCHITTESTINFO hti = {}; + hti.pt.x = pt.x; + hti.pt.y = rect.bottom / 2; // use middle to ignore + int nItem = m_tab.HitTest(&hti); + if(nItem == -1) + { + int nLast = m_tab.GetItemCount() - 1; + RECT rcItem = {}; + m_tab.GetItemRect(nLast, &rcItem); + if(pt.x >= rcItem.right) + nItem = nLast; + } + + return nItem; + } + + void StartStopAutoScroll(int x) + { + AutoScroll scroll = _AUTOSCROLL_NONE; + if(x != -1) + { + RECT rect = {}; + m_tab.GetClientRect(&rect); + int dx = ::GetSystemMetrics(SM_CXVSCROLL); + if((x >= 0) && (x < dx)) + { + RECT rcItem = {}; + m_tab.GetItemRect(0, &rcItem); + if(rcItem.left < rect.left) + scroll = _AUTOSCROLL_LEFT; + } + else if((x >= (rect.right - dx)) && (x < rect.right)) + { + RECT rcItem = {}; + m_tab.GetItemRect(m_tab.GetItemCount() - 1, &rcItem); + if(rcItem.right > rect.right) + scroll = _AUTOSCROLL_RIGHT; + } + } + + if(scroll != _AUTOSCROLL_NONE) + { + if(m_ud.m_hWnd == NULL) + m_ud = m_tab.GetWindow(GW_CHILD); + + if(m_AutoScroll != scroll) + { + m_AutoScroll = scroll; + this->SetTimer(_nAutoScrollTimerID, 300); + } + } + else + { + this->KillTimer(_nAutoScrollTimerID); + m_AutoScroll = _AUTOSCROLL_NONE; + } + } + + void DoAutoScroll() + { + ATLASSERT(m_AutoScroll != _AUTOSCROLL_NONE); + + int nMin = -1, nMax = -1; + m_ud.GetRange(nMin, nMax); + int nPos = m_ud.GetPos(); + + int nNewPos = -1; + if((m_AutoScroll == _AUTOSCROLL_LEFT) && (nPos > nMin)) + nNewPos = nPos - 1; + else if((m_AutoScroll == _AUTOSCROLL_RIGHT) && (nPos < nMax)) + nNewPos = nPos + 1; + if(nNewPos != -1) + { + m_tab.SendMessage(WM_HSCROLL, MAKEWPARAM(SB_THUMBPOSITION, nNewPos)); + m_tab.SendMessage(WM_HSCROLL, MAKEWPARAM(SB_ENDSCROLL, 0)); + + POINT pt = {}; + ::GetCursorPos(&pt); + m_tab.ScreenToClient(&pt); + m_tab.SendMessage(WM_MOUSEMOVE, NULL, MAKELPARAM(pt.x, pt.y)); + } + } // Text for menu items and title bar - override to provide different strings static LPCTSTR GetEmptyListText() @@ -5089,23 +5151,99 @@ public: // Notifications - override to provide different behavior void OnPageActivated(int nPage) { - NMHDR nmhdr = { 0 }; - nmhdr.hwndFrom = m_hWnd; + NMHDR nmhdr = {}; + nmhdr.hwndFrom = this->m_hWnd; nmhdr.idFrom = nPage; nmhdr.code = TBVN_PAGEACTIVATED; - ::SendMessage(GetParent(), WM_NOTIFY, GetDlgCtrlID(), (LPARAM)&nmhdr); + this->GetParent().SendMessage(WM_NOTIFY, this->GetDlgCtrlID(), (LPARAM)&nmhdr); } void OnContextMenu(int nPage, POINT pt) { - m_tab.ClientToScreen(&pt); - - TBVCONTEXTMENUINFO cmi = { 0 }; - cmi.hdr.hwndFrom = m_hWnd; + TBVCONTEXTMENUINFO cmi = {}; + cmi.hdr.hwndFrom = this->m_hWnd; cmi.hdr.idFrom = nPage; cmi.hdr.code = TBVN_CONTEXTMENU; cmi.pt = pt; - ::SendMessage(GetParent(), WM_NOTIFY, GetDlgCtrlID(), (LPARAM)&cmi); + this->GetParent().SendMessage(WM_NOTIFY, this->GetDlgCtrlID(), (LPARAM)&cmi); + } + + void OnTabCloseBtn(int nPage) + { + NMHDR nmhdr = {}; + nmhdr.hwndFrom = this->m_hWnd; + nmhdr.idFrom = nPage; + nmhdr.code = TBVN_TABCLOSEBTN; + LRESULT lRet = this->GetParent().SendMessage(WM_NOTIFY, this->GetDlgCtrlID(), (LPARAM)&nmhdr); + if(lRet == 0) // default - close page + { + T* pT = static_cast(this); + pT->RemovePage(m_nCloseItem); + m_nCloseItem = -1; + pT->DestroyCloseButton(); + } + else + { + m_tab.SendMessage(WM_MOUSELEAVE); + } + } + +// Close button overrideables + void CreateCloseButton(int nItem) + { + ATLASSERT(m_btnClose.m_hWnd == NULL); + + m_btnClose.m_bPressed = false; + + T* pT = static_cast(this); + RECT rcClose = {}; + pT->CalcCloseButtonRect(nItem, rcClose); + m_btnClose.Create(m_tab.m_hWnd, rcClose, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 0, T::_nCloseBtnID); + ATLASSERT(m_btnClose.IsWindow()); + + if(m_btnClose.m_hWnd != NULL) + { + // create a tool tip + ATLASSERT(m_btnClose.m_tip.m_hWnd == NULL); + m_btnClose.m_tip.Create(m_btnClose.m_hWnd); + ATLASSERT(m_btnClose.m_tip.IsWindow()); + + if(m_btnClose.m_tip.IsWindow()) + { + m_btnClose.m_tip.Activate(TRUE); + + RECT rect = {}; + m_btnClose.GetClientRect(&rect); + m_btnClose.m_tip.AddTool(m_btnClose.m_hWnd, LPSTR_TEXTCALLBACK, &rect, T::_nCloseBtnID); + } + } + } + + void DestroyCloseButton() + { + ATLASSERT(m_btnClose.m_hWnd != NULL); + + if(m_btnClose.m_hWnd != NULL) + { + if(m_btnClose.m_tip.IsWindow()) + { + m_btnClose.m_tip.DestroyWindow(); + m_btnClose.m_tip.m_hWnd = NULL; + } + + m_btnClose.DestroyWindow(); + } + } + + void CalcCloseButtonRect(int nItem, RECT& rcClose) + { + RECT rcItem = {}; + m_tab.GetItemRect(nItem, &rcItem); + + int cy = (rcItem.bottom - rcItem.top - _cyCloseBtn) / 2; + int cx = (nItem == m_tab.GetCurSel()) ? _cxCloseBtnMarginSel : _cxCloseBtnMargin; + ::SetRect(&rcClose, rcItem.right - cx - _cxCloseBtn, rcItem.top + cy, + rcItem.right - cx, rcItem.top + cy + _cyCloseBtn); } }; @@ -5115,6 +5253,6 @@ public: DECLARE_WND_CLASS_EX(_T("WTL_TabView"), 0, COLOR_APPWORKSPACE) }; -}; // namespace WTL +} // namespace WTL #endif // __ATLCTRLX_H__ diff --git a/ZbaSDK/SampleCode/PluginWinExe/WTL/atlddx.h b/ZbaSDK/SampleCode/PluginWinExe/WTL/atlddx.h index aa12bbb0cc7557bd229d91f79c80ca3b195763c2..7723b99a825fc65fff4a61d158e188d927b3c33c 100644 --- a/ZbaSDK/SampleCode/PluginWinExe/WTL/atlddx.h +++ b/ZbaSDK/SampleCode/PluginWinExe/WTL/atlddx.h @@ -1,4 +1,4 @@ -// Windows Template Library - WTL version 9.10 +// Windows Template Library - WTL version 10.0 // Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. // // This file is a part of the Windows Template Library. @@ -15,13 +15,7 @@ #error atlddx.h requires atlapp.h to be included first #endif -#if defined(_ATL_USE_DDX_FLOAT) && defined(_ATL_MIN_CRT) - #error Cannot use floating point DDX with _ATL_MIN_CRT defined -#endif // defined(_ATL_USE_DDX_FLOAT) && defined(_ATL_MIN_CRT) - -#ifdef _ATL_USE_DDX_FLOAT - #include -#endif // _ATL_USE_DDX_FLOAT +#include /////////////////////////////////////////////////////////////////////////////// @@ -45,90 +39,88 @@ namespace WTL (nCtlID); #define DDX_TEXT(nID, var) \ - if(nCtlID == (UINT)-1 || nCtlID == nID) \ + if((nCtlID == (UINT)-1) || (nCtlID == nID)) \ { \ if(!DDX_Text(nID, var, sizeof(var), bSaveAndValidate)) \ return FALSE; \ } #define DDX_TEXT_LEN(nID, var, len) \ - if(nCtlID == (UINT)-1 || nCtlID == nID) \ + if((nCtlID == (UINT)-1) || (nCtlID == nID)) \ { \ if(!DDX_Text(nID, var, sizeof(var), bSaveAndValidate, TRUE, len)) \ return FALSE; \ } #define DDX_INT(nID, var) \ - if(nCtlID == (UINT)-1 || nCtlID == nID) \ + if((nCtlID == (UINT)-1) || (nCtlID == nID)) \ { \ if(!DDX_Int(nID, var, TRUE, bSaveAndValidate)) \ return FALSE; \ } #define DDX_INT_RANGE(nID, var, min, max) \ - if(nCtlID == (UINT)-1 || nCtlID == nID) \ + if((nCtlID == (UINT)-1) || (nCtlID == nID)) \ { \ if(!DDX_Int(nID, var, TRUE, bSaveAndValidate, TRUE, min, max)) \ return FALSE; \ } #define DDX_UINT(nID, var) \ - if(nCtlID == (UINT)-1 || nCtlID == nID) \ + if((nCtlID == (UINT)-1) || (nCtlID == nID)) \ { \ if(!DDX_Int(nID, var, FALSE, bSaveAndValidate)) \ return FALSE; \ } #define DDX_UINT_RANGE(nID, var, min, max) \ - if(nCtlID == (UINT)-1 || nCtlID == nID) \ + if((nCtlID == (UINT)-1) || (nCtlID == nID)) \ { \ if(!DDX_Int(nID, var, FALSE, bSaveAndValidate, TRUE, min, max)) \ return FALSE; \ } -#ifdef _ATL_USE_DDX_FLOAT #define DDX_FLOAT(nID, var) \ - if(nCtlID == (UINT)-1 || nCtlID == nID) \ + if((nCtlID == (UINT)-1) || (nCtlID == nID)) \ { \ if(!DDX_Float(nID, var, bSaveAndValidate)) \ return FALSE; \ } #define DDX_FLOAT_RANGE(nID, var, min, max) \ - if(nCtlID == (UINT)-1 || nCtlID == nID) \ + if((nCtlID == (UINT)-1) || (nCtlID == nID)) \ { \ if(!DDX_Float(nID, var, bSaveAndValidate, TRUE, min, max)) \ return FALSE; \ } #define DDX_FLOAT_P(nID, var, precision) \ - if(nCtlID == (UINT)-1 || nCtlID == nID) \ + if((nCtlID == (UINT)-1) || (nCtlID == nID)) \ { \ if(!DDX_Float(nID, var, bSaveAndValidate, FALSE, 0, 0, precision)) \ return FALSE; \ } #define DDX_FLOAT_P_RANGE(nID, var, min, max, precision) \ - if(nCtlID == (UINT)-1 || nCtlID == nID) \ + if((nCtlID == (UINT)-1) || (nCtlID == nID)) \ { \ if(!DDX_Float(nID, var, bSaveAndValidate, TRUE, min, max, precision)) \ return FALSE; \ } -#endif // _ATL_USE_DDX_FLOAT #define DDX_CONTROL(nID, obj) \ - if(nCtlID == (UINT)-1 || nCtlID == nID) \ + if((nCtlID == (UINT)-1) || (nCtlID == nID)) \ DDX_Control(nID, obj, bSaveAndValidate); #define DDX_CONTROL_HANDLE(nID, obj) \ - if(nCtlID == (UINT)-1 || nCtlID == nID) \ + if((nCtlID == (UINT)-1) || (nCtlID == nID)) \ DDX_Control_Handle(nID, obj, bSaveAndValidate); #define DDX_CHECK(nID, var) \ - if(nCtlID == (UINT)-1 || nCtlID == nID) \ + if((nCtlID == (UINT)-1) || (nCtlID == nID)) \ DDX_Check(nID, var, bSaveAndValidate); #define DDX_RADIO(nID, var) \ - if(nCtlID == (UINT)-1 || nCtlID == nID) \ + if((nCtlID == (UINT)-1) || (nCtlID == nID)) \ DDX_Radio(nID, var, bSaveAndValidate); #define END_DDX_MAP() \ @@ -137,23 +129,18 @@ namespace WTL // DDX support for Tab, Combo, ListBox and ListView selection index // Note: Specialized versions require atlctrls.h to be included first -#if (_MSC_VER >= 1300) #define DDX_INDEX(CtrlClass, nID, var) \ - if(nCtlID == (UINT)-1 || nCtlID == nID) \ + if((nCtlID == (UINT)-1) || (nCtlID == nID)) \ DDX_Index(nID, var, bSaveAndValidate); #ifdef __ATLCTRLS_H__ #define DDX_TAB_INDEX(nID, var) DDX_INDEX(WTL::CTabCtrl, nID, var) - #ifndef WIN32_PLATFORM_WFSP // No COMBOBOX on SmartPhones - #define DDX_COMBO_INDEX(nID, var) DDX_INDEX(WTL::CComboBox, nID, var) - #endif + #define DDX_COMBO_INDEX(nID, var) DDX_INDEX(WTL::CComboBox, nID, var) #define DDX_LISTBOX_INDEX(nID, var) DDX_INDEX(WTL::CListBox, nID, var) #define DDX_LISTVIEW_INDEX(nID, var) DDX_INDEX(WTL::CListViewCtrl, nID, var) #endif // __ATLCTRLS_H__ -#endif // (_MSC_VER >= 1300) - /////////////////////////////////////////////////////////////////////////////// // CWinDataExchange - provides support for DDX @@ -322,8 +309,8 @@ public: return bSuccess; } -#if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) - BOOL DDX_Text(UINT nID, _CSTRING_NS::CString& strText, int /*cbSize*/, BOOL bSave, BOOL bValidate = FALSE, int nLength = 0) +#ifdef __ATLSTR_H__ + BOOL DDX_Text(UINT nID, ATL::CString& strText, int /*cbSize*/, BOOL bSave, BOOL bValidate = FALSE, int nLength = 0) { T* pT = static_cast(this); BOOL bSuccess = TRUE; @@ -365,7 +352,7 @@ public: } return bSuccess; } -#endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) +#endif // __ATLSTR_H__ // Numeric exchange template @@ -380,7 +367,7 @@ public: } else { - ATLASSERT(!bValidate || (nVal >= nMin && nVal <= nMax)); + ATLASSERT(!bValidate || ((nVal >= nMin) && (nVal <= nMax))); bSuccess = pT->SetDlgItemInt(nID, nVal, bSigned); } @@ -391,7 +378,7 @@ public: else if(bSave && bValidate) // validation { ATLASSERT(nMin != nMax); - if(nVal < nMin || nVal > nMax) + if((nVal < nMin) || (nVal > nMax)) { _XData data = { ddxDataInt }; data.intData.nVal = (long)nVal; @@ -405,18 +392,17 @@ public: } // Float exchange -#ifdef _ATL_USE_DDX_FLOAT static BOOL _AtlSimpleFloatParse(LPCTSTR lpszText, double& d) { ATLASSERT(lpszText != NULL); - while (*lpszText == _T(' ') || *lpszText == _T('\t')) + while ((*lpszText == _T(' ')) || (*lpszText == _T('\t'))) lpszText++; TCHAR chFirst = lpszText[0]; d = _tcstod(lpszText, (LPTSTR*)&lpszText); - if (d == 0.0 && chFirst != _T('0')) + if ((d == 0.0) && (chFirst != _T('0'))) return FALSE; // could not convert - while (*lpszText == _T(' ') || *lpszText == _T('\t')) + while ((*lpszText == _T(' ')) || (*lpszText == _T('\t'))) lpszText++; if (*lpszText != _T('\0')) @@ -430,7 +416,7 @@ public: T* pT = static_cast(this); BOOL bSuccess = TRUE; const int cchBuff = 32; - TCHAR szBuff[cchBuff] = { 0 }; + TCHAR szBuff[cchBuff] = {}; if(bSave) { @@ -443,8 +429,8 @@ public: } else { - ATLASSERT(!bValidate || (nVal >= nMin && nVal <= nMax)); - SecureHelper::sprintf_x(szBuff, cchBuff, _T("%.*g"), nPrecision, nVal); + ATLASSERT(!bValidate || ((nVal >= nMin) && (nVal <= nMax))); + _stprintf_s(szBuff, cchBuff, _T("%.*g"), nPrecision, nVal); bSuccess = pT->SetDlgItemText(nID, szBuff); } @@ -455,7 +441,7 @@ public: else if(bSave && bValidate) // validation { ATLASSERT(nMin != nMax); - if(nVal < nMin || nVal > nMax) + if((nVal < nMin) || (nVal > nMax)) { _XData data = { ddxDataFloat }; data.floatData.nVal = (double)nVal; @@ -473,7 +459,7 @@ public: T* pT = static_cast(this); BOOL bSuccess = TRUE; const int cchBuff = 32; - TCHAR szBuff[cchBuff] = { 0 }; + TCHAR szBuff[cchBuff] = {}; if(bSave) { @@ -486,8 +472,8 @@ public: } else { - ATLASSERT(!bValidate || (nVal >= nMin && nVal <= nMax)); - SecureHelper::sprintf_x(szBuff, cchBuff, _T("%.*g"), nPrecision, nVal); + ATLASSERT(!bValidate || ((nVal >= nMin) && (nVal <= nMax))); + _stprintf_s(szBuff, cchBuff, _T("%.*g"), nPrecision, nVal); bSuccess = pT->SetDlgItemText(nID, szBuff); } @@ -498,7 +484,7 @@ public: else if(bSave && bValidate) // validation { ATLASSERT(nMin != nMax); - if(nVal < nMin || nVal > nMax) + if((nVal < nMin) || (nVal > nMax)) { _XData data = { ddxDataFloat }; data.floatData.nVal = nVal; @@ -510,13 +496,12 @@ public: } return bSuccess; } -#endif // _ATL_USE_DDX_FLOAT // Full control subclassing (for CWindowImpl derived controls) template void DDX_Control(UINT nID, TControl& ctrl, BOOL bSave) { - if(!bSave && ctrl.m_hWnd == NULL) + if(!bSave && (ctrl.m_hWnd == NULL)) { T* pT = static_cast(this); ctrl.SubclassWindow(pT->GetDlgItem(nID)); @@ -527,7 +512,7 @@ public: template void DDX_Control_Handle(UINT nID, TControl& ctrl, BOOL bSave) { - if(!bSave && ctrl.m_hWnd == NULL) + if(!bSave && (ctrl.m_hWnd == NULL)) { T* pT = static_cast(this); ctrl = pT->GetDlgItem(nID); @@ -542,11 +527,11 @@ public: if(bSave) { nValue = (int)::SendMessage(hWndCtrl, BM_GETCHECK, 0, 0L); - ATLASSERT(nValue >= 0 && nValue <= 2); + ATLASSERT((nValue >= 0) && (nValue <= 2)); } else { - if(nValue < 0 || nValue > 2) + if((nValue < 0) || (nValue > 2)) { ATLTRACE2(atlTraceUI, 0, _T("ATL: Warning - dialog data checkbox value (%d) out of range.\n"), nValue); nValue = 0; // default to off @@ -610,11 +595,10 @@ public: } hWndCtrl = ::GetWindow(hWndCtrl, GW_HWNDNEXT); } - while (hWndCtrl != NULL && !(GetWindowLong(hWndCtrl, GWL_STYLE) & WS_GROUP)); + while ((hWndCtrl != NULL) && !(GetWindowLong(hWndCtrl, GWL_STYLE) & WS_GROUP)); } // DDX support for Tab, Combo, ListBox and ListView selection index -#if (_MSC_VER >= 1300) template INT _getSel(TCtrl& tCtrl) { @@ -659,7 +643,6 @@ public: else _setSel(ctrl, nVal); } -#endif // (_MSC_VER >= 1300) // Overrideables void OnDataExchangeError(UINT nCtrlID, BOOL /*bSave*/) @@ -679,6 +662,6 @@ public: } }; -}; // namespace WTL +} // namespace WTL #endif // __ATLDDX_H__ diff --git a/ZbaSDK/SampleCode/PluginWinExe/WTL/atldlgs.h b/ZbaSDK/SampleCode/PluginWinExe/WTL/atldlgs.h index 3ff14944252f9635b79d41cc824945595b8d7ced..3622945c6ff7f3e8f7f9e6468f33b40242c3dff4 100644 --- a/ZbaSDK/SampleCode/PluginWinExe/WTL/atldlgs.h +++ b/ZbaSDK/SampleCode/PluginWinExe/WTL/atldlgs.h @@ -1,4 +1,4 @@ -// Windows Template Library - WTL version 9.10 +// Windows Template Library - WTL version 10.0 // Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. // // This file is a part of the Windows Template Library. @@ -19,12 +19,11 @@ #error atldlgs.h requires atlwin.h to be included first #endif -#include #include -#if (_WIN32_WINNT >= 0x0600) && !defined(_WIN32_WCE) +#if (_WIN32_WINNT >= 0x0600) #include -#endif // (_WIN32_WINNT >= 0x0600) && !defined(_WIN32_WCE) +#endif // (_WIN32_WINNT >= 0x0600) /////////////////////////////////////////////////////////////////////////////// @@ -32,7 +31,7 @@ // // CFileDialogImpl // CFileDialog -// CFileDialogEx +// CSimpleFileDialog // CMultiFileDialogImpl // CMultiFileDialog // CShellFileDialogImpl @@ -101,33 +100,11 @@ namespace WTL /////////////////////////////////////////////////////////////////////////////// // CFileDialogImpl - used for File Open or File Save As -// compatibility with the old (vc6.0) headers -#if (_WIN32_WINNT >= 0x0500) && !defined(OPENFILENAME_SIZE_VERSION_400) - #ifndef CDSIZEOF_STRUCT - #define CDSIZEOF_STRUCT(structname, member) (((int)((LPBYTE)(&((structname*)0)->member) - ((LPBYTE)((structname*)0)))) + sizeof(((structname*)0)->member)) - #endif - #define OPENFILENAME_SIZE_VERSION_400A CDSIZEOF_STRUCT(OPENFILENAMEA,lpTemplateName) - #define OPENFILENAME_SIZE_VERSION_400W CDSIZEOF_STRUCT(OPENFILENAMEW,lpTemplateName) - #ifdef UNICODE - #define OPENFILENAME_SIZE_VERSION_400 OPENFILENAME_SIZE_VERSION_400W - #else - #define OPENFILENAME_SIZE_VERSION_400 OPENFILENAME_SIZE_VERSION_400A - #endif // !UNICODE -#endif // (_WIN32_WINNT >= 0x0500) && !defined(OPENFILENAME_SIZE_VERSION_400) - -#if !defined(_WIN32_WCE) && !defined(CDN_INCLUDEITEM) - #define CDN_INCLUDEITEM (CDN_FIRST - 0x0007) -#endif - template class ATL_NO_VTABLE CFileDialogImpl : public ATL::CDialogImplBase { public: -#if defined(__AYGSHELL_H__) && (_WIN32_WCE >= 0x0501) - OPENFILENAMEEX m_ofn; -#else OPENFILENAME m_ofn; -#endif BOOL m_bOpenFileDialog; // TRUE for file open, FALSE for file save TCHAR m_szFileTitle[_MAX_FNAME]; // contains file title after return TCHAR m_szFileName[_MAX_PATH]; // contains full path name after return @@ -137,46 +114,27 @@ public: LPCTSTR lpszFileName = NULL, DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, LPCTSTR lpszFilter = NULL, - HWND hWndParent = NULL) + HWND hWndParent = NULL) : m_bOpenFileDialog(bOpenFileDialog) { memset(&m_ofn, 0, sizeof(m_ofn)); // initialize structure to 0/NULL - m_szFileName[0] = _T('\0'); - m_szFileTitle[0] = _T('\0'); - - m_bOpenFileDialog = bOpenFileDialog; - -#if defined(__AYGSHELL_H__) && (_WIN32_WCE >= 0x0501) - m_ofn.lStructSize = bOpenFileDialog ? sizeof(m_ofn) : sizeof(OPENFILENAME); -#else m_ofn.lStructSize = sizeof(m_ofn); -#endif - -#if (_WIN32_WINNT >= 0x0500) - // adjust struct size if running on older version of Windows - if(AtlIsOldWindows()) - { - ATLASSERT(sizeof(m_ofn) > OPENFILENAME_SIZE_VERSION_400); // must be - m_ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; - } -#endif // (_WIN32_WINNT >= 0x0500) m_ofn.lpstrFile = m_szFileName; m_ofn.nMaxFile = _MAX_PATH; m_ofn.lpstrDefExt = lpszDefExt; m_ofn.lpstrFileTitle = (LPTSTR)m_szFileTitle; m_ofn.nMaxFileTitle = _MAX_FNAME; -#ifndef _WIN32_WCE m_ofn.Flags = dwFlags | OFN_EXPLORER | OFN_ENABLEHOOK | OFN_ENABLESIZING; -#else // CE specific - m_ofn.Flags = dwFlags | OFN_EXPLORER | OFN_ENABLEHOOK; -#endif // !_WIN32_WCE m_ofn.lpstrFilter = lpszFilter; m_ofn.hInstance = ModuleHelper::GetResourceInstance(); m_ofn.lpfnHook = (LPOFNHOOKPROC)T::StartDialogProc; m_ofn.hwndOwner = hWndParent; + m_szFileName[0] = _T('\0'); + m_szFileTitle[0] = _T('\0'); + // setup initial file name if(lpszFileName != NULL) - SecureHelper::strncpy_x(m_szFileName, _countof(m_szFileName), lpszFileName, _TRUNCATE); + ATL::Checked::tcsncpy_s(m_szFileName, _countof(m_szFileName), lpszFileName, _TRUNCATE); } INT_PTR DoModal(HWND hWndParent = ::GetActiveWindow()) @@ -191,7 +149,6 @@ public: ATLASSERT(m_hWnd == NULL); -#if (_ATL_VER >= 0x0800) // Allocate the thunk structure here, where we can fail gracefully. BOOL bRetTh = m_thunk.Init(NULL, NULL); if(bRetTh == FALSE) @@ -199,25 +156,14 @@ public: ::SetLastError(ERROR_OUTOFMEMORY); return -1; } -#endif // (_ATL_VER >= 0x0800) ModuleHelper::AddCreateWndData(&m_thunk.cd, (ATL::CDialogImplBase*)this); - BOOL bRet; - if(m_bOpenFileDialog) -#if defined(__AYGSHELL_H__) && (_WIN32_WCE >= 0x0501) - bRet = ::GetOpenFileNameEx(&m_ofn); - else - bRet = ::GetSaveFileName((LPOPENFILENAME)&m_ofn); -#else - bRet = ::GetOpenFileName(&m_ofn); - else - bRet = ::GetSaveFileName(&m_ofn); -#endif + BOOL bRet = (m_bOpenFileDialog != FALSE) ? ::GetOpenFileName(&m_ofn) : ::GetSaveFileName(&m_ofn); m_hWnd = NULL; - return bRet ? IDOK : IDCANCEL; + return (bRet != FALSE) ? IDOK : IDCANCEL; } // Attributes @@ -306,9 +252,7 @@ public: NOTIFY_CODE_HANDLER(CDN_SELCHANGE, _OnSelChange) NOTIFY_CODE_HANDLER(CDN_SHAREVIOLATION, _OnShareViolation) NOTIFY_CODE_HANDLER(CDN_TYPECHANGE, _OnTypeChange) -#ifndef _WIN32_WCE NOTIFY_CODE_HANDLER(CDN_INCLUDEITEM, _OnIncludeItem) -#endif // !_WIN32_WCE END_MSG_MAP() LRESULT _OnFileOK(int /*idCtrl*/, LPNMHDR pnmh, BOOL& /*bHandled*/) @@ -365,14 +309,12 @@ public: return 0; } -#ifndef _WIN32_WCE LRESULT _OnIncludeItem(int /*idCtrl*/, LPNMHDR pnmh, BOOL& /*bHandled*/) { ATLASSERT(::IsWindow(m_hWnd)); T* pT = static_cast(this); return pT->OnIncludeItem((LPOFNOTIFYEX)pnmh); } -#endif // !_WIN32_WCE // Overrideables BOOL OnFileOK(LPOFNOTIFY /*lpon*/) @@ -405,12 +347,10 @@ public: { } -#ifndef _WIN32_WCE BOOL OnIncludeItem(LPOFNOTIFYEX /*lponex*/) { return TRUE; // include item } -#endif // !_WIN32_WCE }; class CFileDialog : public CFileDialogImpl @@ -429,35 +369,62 @@ public: DECLARE_EMPTY_MSG_MAP() }; -#if defined(__AYGSHELL_H__) && (_WIN32_WCE >= 0x0501) -class CFileDialogEx : public CFileDialogImpl + +/////////////////////////////////////////////////////////////////////////////// +// CSimpleFileDialog - simple class for non-customized Open/SaveAs dialogs + +class CSimpleFileDialog { public: - CFileDialogEx( // Supports only FileOpen - LPCTSTR lpszDefExt = NULL, - LPCTSTR lpszFileName = NULL, - DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, - OFN_EXFLAG ExFlags = OFN_EXFLAG_THUMBNAILVIEW, - OFN_SORTORDER dwSortOrder = OFN_SORTORDER_AUTO, - LPCTSTR lpszFilter = NULL, - HWND hWndParent = NULL) - : CFileDialogImpl(TRUE, lpszDefExt, lpszFileName, dwFlags, lpszFilter, hWndParent) + OPENFILENAME m_ofn; + BOOL m_bOpenFileDialog; // TRUE for file open, FALSE for file save + TCHAR m_szFileTitle[_MAX_FNAME]; // contains file title after return + TCHAR m_szFileName[_MAX_PATH]; // contains full path name after return + + CSimpleFileDialog(BOOL bOpenFileDialog, // TRUE for FileOpen, FALSE for FileSaveAs + LPCTSTR lpszDefExt = NULL, + LPCTSTR lpszFileName = NULL, + DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, + LPCTSTR lpszFilter = NULL, + HWND hWndParent = NULL) : m_bOpenFileDialog(bOpenFileDialog) { - m_ofn.ExFlags = ExFlags; - m_ofn.dwSortOrder = dwSortOrder; + memset(&m_ofn, 0, sizeof(m_ofn)); // initialize structure to 0/NULL + m_ofn.lStructSize = sizeof(m_ofn); + m_ofn.lpstrFile = m_szFileName; + m_ofn.nMaxFile = _MAX_PATH; + m_ofn.lpstrDefExt = lpszDefExt; + m_ofn.lpstrFileTitle = (LPTSTR)m_szFileTitle; + m_ofn.nMaxFileTitle = _MAX_FNAME; + m_ofn.Flags = dwFlags | OFN_EXPLORER | OFN_ENABLESIZING; + m_ofn.lpstrFilter = lpszFilter; + m_ofn.hInstance = ModuleHelper::GetResourceInstance(); + m_ofn.hwndOwner = hWndParent; + + m_szFileName[0] = _T('\0'); + m_szFileTitle[0] = _T('\0'); + + // setup initial file name + if(lpszFileName != NULL) + ATL::Checked::tcsncpy_s(m_szFileName, _countof(m_szFileName), lpszFileName, _TRUNCATE); } - // override base class map and references to handlers - DECLARE_EMPTY_MSG_MAP() + INT_PTR DoModal(HWND hWndParent = ::GetActiveWindow()) + { + ATLASSERT((m_ofn.Flags & OFN_EXPLORER) != 0); + + if(m_ofn.hwndOwner == NULL) // set only if not specified before + m_ofn.hwndOwner = hWndParent; + + BOOL bRet = (m_bOpenFileDialog != FALSE) ? ::GetOpenFileName(&m_ofn) : ::GetSaveFileName(&m_ofn); + + return (bRet != FALSE) ? IDOK : IDCANCEL; + } }; -#endif // defined(__AYGSHELL_H__) && (_WIN32_WCE >= 0x0501) /////////////////////////////////////////////////////////////////////////////// // Multi File Dialog - Multi-select File Open dialog -#ifndef _WIN32_WCE - // The class dynamically resizes the buffer as the file selection changes // (as described in Knowledge Base article 131462). It also expands selected // shortcut files to take into account the full path of the target file. @@ -486,7 +453,7 @@ public: : CFileDialogImpl(TRUE, lpszDefExt, lpszFileName, dwFlags, lpszFilter, hWndParent), m_pNextFile(NULL) { - m_ofn.Flags |= OFN_ALLOWMULTISELECT; // Force multiple selection mode + this->m_ofn.Flags |= OFN_ALLOWMULTISELECT; // Force multiple selection mode #ifndef _UNICODE #ifdef _versionhelpers_H_INCLUDED_ @@ -510,8 +477,8 @@ public: ~CMultiFileDialogImpl() { - if (m_ofn.lpstrFile != m_szFileName) // Free the buffer if we allocated it - delete[] m_ofn.lpstrFile; + if (this->m_ofn.lpstrFile != this->m_szFileName) // Free the buffer if we allocated it + delete[] this->m_ofn.lpstrFile; } // Operations @@ -521,15 +488,15 @@ public: // If the function fails, the return value is zero. int GetDirectory(LPTSTR pBuffer, int nBufLen) const { - if (m_ofn.lpstrFile == NULL) + if (this->m_ofn.lpstrFile == NULL) return 0; - LPCTSTR pStr = m_ofn.lpstrFile; + LPCTSTR pStr = this->m_ofn.lpstrFile; int nLength = lstrlen(pStr); if (pStr[nLength + 1] == 0) { // The OFN buffer contains a single item so extract its path. - LPCTSTR pSep = MinCrtHelper::_strrchr(pStr, _T('\\')); + LPCTSTR pSep = _tcsrchr(pStr, _T('\\')); if (pSep != NULL) nLength = (int)(DWORD_PTR)(pSep - pStr); } @@ -541,15 +508,15 @@ public: } else if (nBufLen > nLength) { - SecureHelper::strncpy_x(pBuffer, nBufLen, pStr, nLength); + ATL::Checked::tcsncpy_s(pBuffer, nBufLen, pStr, nLength); nRet = nLength; } return nRet; } -#if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) - bool GetDirectory(_CSTRING_NS::CString& strDir) const +#ifdef __ATLSTR_H__ + bool GetDirectory(ATL::CString& strDir) const { bool bRet = false; @@ -562,17 +529,17 @@ public: return bRet; } -#endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) +#endif // __ATLSTR_H__ // Get the first filename as a pointer into the buffer. LPCTSTR GetFirstFileName() const { - if (m_ofn.lpstrFile == NULL) + if (this->m_ofn.lpstrFile == NULL) return NULL; m_pNextFile = NULL; // Reset internal buffer pointer - LPCTSTR pStr = m_ofn.lpstrFile; + LPCTSTR pStr = this->m_ofn.lpstrFile; int nLength = lstrlen(pStr); if (pStr[nLength + 1] != 0) { @@ -587,7 +554,7 @@ public: else { // A single item was selected. Skip forward past the path. - LPCTSTR pSep = MinCrtHelper::_strrchr(pStr, _T('\\')); + LPCTSTR pSep = _tcsrchr(pStr, _T('\\')); if (pSep != NULL) pStr = pSep + 1; } @@ -632,16 +599,16 @@ public: else if (nBufLen > nLengthTotal) // If the buffer is big enough, go ahead and construct the path { GetDirectory(pBuffer, nBufLen); - SecureHelper::strcat_x(pBuffer, nBufLen, _T("\\")); - SecureHelper::strcat_x(pBuffer, nBufLen, pStr); + ATL::Checked::tcscat_s(pBuffer, nBufLen, _T("\\")); + ATL::Checked::tcscat_s(pBuffer, nBufLen, pStr); nRet = nLengthTotal; } return nRet; } -#if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) - bool GetFirstPathName(_CSTRING_NS::CString& strPath) const +#ifdef __ATLSTR_H__ + bool GetFirstPathName(ATL::CString& strPath) const { bool bRet = false; @@ -654,7 +621,7 @@ public: return bRet; } -#endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) +#endif // __ATLSTR_H__ // Get the next filename as a full path. // The function returns the number of characters copied, not including the terminating zero. @@ -669,7 +636,7 @@ public: int nRet = 0; LPCTSTR pStr = m_pNextFile; // Does the filename contain a backslash? - if (MinCrtHelper::_strrchr(pStr, _T('\\')) != NULL) + if (_tcsrchr(pStr, _T('\\')) != NULL) { // Yes, so we'll assume it's a full path. int nLength = lstrlen(pStr); @@ -680,7 +647,7 @@ public: } else if (nBufLen > nLength) // The buffer is big enough, so go ahead and copy the filename { - SecureHelper::strcpy_x(pBuffer, nBufLen, GetNextFileName()); + ATL::Checked::tcscpy_s(pBuffer, nBufLen, GetNextFileName()); nRet = nBufLen; } } @@ -700,8 +667,8 @@ public: else if (nBufLen > nLengthTotal) // If the buffer is big enough, go ahead and construct the path { GetDirectory(pBuffer, nBufLen); - SecureHelper::strcat_x(pBuffer, nBufLen, _T("\\")); - SecureHelper::strcat_x(pBuffer, nBufLen, GetNextFileName()); + ATL::Checked::tcscat_s(pBuffer, nBufLen, _T("\\")); + ATL::Checked::tcscat_s(pBuffer, nBufLen, GetNextFileName()); nRet = nLengthTotal; } } @@ -710,8 +677,8 @@ public: return nRet; } -#if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) - bool GetNextPathName(_CSTRING_NS::CString& strPath) const +#ifdef __ATLSTR_H__ + bool GetNextPathName(ATL::CString& strPath) const { bool bRet = false; @@ -724,19 +691,19 @@ public: return bRet; } -#endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) +#endif // __ATLSTR_H__ // Implementation bool ResizeFilenameBuffer(DWORD dwLength) { - if (dwLength > m_ofn.nMaxFile) + if (dwLength > this->m_ofn.nMaxFile) { // Free the old buffer. - if (m_ofn.lpstrFile != m_szFileName) + if (this->m_ofn.lpstrFile != this->m_szFileName) { - delete[] m_ofn.lpstrFile; - m_ofn.lpstrFile = NULL; - m_ofn.nMaxFile = 0; + delete[] this->m_ofn.lpstrFile; + this->m_ofn.lpstrFile = NULL; + this->m_ofn.nMaxFile = 0; } // Allocate the new buffer. @@ -744,13 +711,13 @@ public: ATLTRY(lpstrBuff = new TCHAR[dwLength]); if (lpstrBuff != NULL) { - m_ofn.lpstrFile = lpstrBuff; - m_ofn.lpstrFile[0] = 0; - m_ofn.nMaxFile = dwLength; + this->m_ofn.lpstrFile = lpstrBuff; + this->m_ofn.lpstrFile[0] = 0; + this->m_ofn.nMaxFile = dwLength; } } - return (m_ofn.lpstrFile != NULL); + return (this->m_ofn.lpstrFile != NULL); } void OnSelChange(LPOFNOTIFY /*lpon*/) @@ -762,12 +729,12 @@ public: #endif // Get the buffer length required to hold the spec. - int nLength = GetSpec(NULL, 0); + int nLength = this->GetSpec(NULL, 0); if (nLength <= 1) return; // no files are selected, presumably // Add room for the directory, and an extra terminating zero. - nLength += GetFolderPath(NULL, 0) + 1; + nLength += this->GetFolderPath(NULL, 0) + 1; if (!ResizeFilenameBuffer(nLength)) { @@ -776,22 +743,22 @@ public: } // If we are not following links then our work is done. - if ((m_ofn.Flags & OFN_NODEREFERENCELINKS) != 0) + if ((this->m_ofn.Flags & OFN_NODEREFERENCELINKS) != 0) return; // Get the file spec, which is the text in the edit control. - if (GetSpec(m_ofn.lpstrFile, m_ofn.nMaxFile) <= 0) + if (this->GetSpec(this->m_ofn.lpstrFile, this->m_ofn.nMaxFile) <= 0) return; // Get the ID-list of the current folder. - int nBytes = GetFolderIDList(NULL, 0); + int nBytes = this->GetFolderIDList(NULL, 0); #ifdef STRICT_TYPED_ITEMIDS - CTempBuffer idlist; + ATL::CTempBuffer idlist; #else - CTempBuffer idlist; + ATL::CTempBuffer idlist; #endif idlist.AllocateBytes(nBytes); - if ((nBytes <= 0) || (GetFolderIDList(idlist, nBytes) <= 0)) + if ((nBytes <= 0) || (this->GetFolderIDList(idlist, nBytes) <= 0)) return; // First bind to the desktop folder, then to the current folder. @@ -805,8 +772,8 @@ public: // we need to add enough extra buffer space to hold its target path. DWORD nExtraChars = 0; bool bInsideQuotes = false; - LPCTSTR pAnchor = m_ofn.lpstrFile; - LPCTSTR pChar = m_ofn.lpstrFile; + LPCTSTR pAnchor = this->m_ofn.lpstrFile; + LPCTSTR pChar = this->m_ofn.lpstrFile; for ( ; *pChar; ++pChar) { // Look for quotation marks. @@ -830,8 +797,8 @@ public: // Get the ID-list and attributes of the file. USES_CONVERSION; int nFileNameLength = (int)(DWORD_PTR)(pChar - pAnchor); - TCHAR szFileName[MAX_PATH] = { 0 }; - SecureHelper::strncpy_x(szFileName, MAX_PATH, pAnchor, nFileNameLength); + TCHAR szFileName[MAX_PATH] = {}; + ATL::Checked::tcsncpy_s(szFileName, MAX_PATH, pAnchor, nFileNameLength); #ifdef STRICT_TYPED_ITEMIDS PIDLIST_RELATIVE pidl = NULL; #else @@ -848,7 +815,7 @@ public: if (SUCCEEDED(pFolder->BindToObject(pidl, NULL, IID_IShellLink, (void**)&pLink))) { // Get the shortcut's target path. - TCHAR szPath[MAX_PATH] = { 0 }; + TCHAR szPath[MAX_PATH] = {}; if (SUCCEEDED(pLink->GetPath(szPath, MAX_PATH, NULL, 0))) { // If the target path is longer than the shortcut name, then add on the number @@ -869,7 +836,7 @@ public: // If we need more space for shortcut targets, then reallocate. if (nExtraChars > 0) - ATLVERIFY(ResizeFilenameBuffer(m_ofn.nMaxFile + nExtraChars)); + ATLVERIFY(ResizeFilenameBuffer(this->m_ofn.nMaxFile + nExtraChars)); } }; @@ -890,8 +857,6 @@ public: END_MSG_MAP() }; -#endif // !_WIN32_WCE - /////////////////////////////////////////////////////////////////////////////// // Shell File Dialog - new Shell File Open and Save dialogs in Vista @@ -901,7 +866,7 @@ public: // CShellFileOpenDialog dlg; // dlg.GetPtr()->SetTitle(L"MyFileOpenDialog"); -#if (_WIN32_WINNT >= 0x0600) && !defined(_WIN32_WCE) +#if (_WIN32_WINNT >= 0x0600) /////////////////////////////////////////////////////////////////////////////// // CShellFileDialogImpl - base class for CShellFileOpenDialogImpl and CShellFileSaveDialogImpl @@ -973,8 +938,8 @@ public: return hRet; } -#if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) - HRESULT GetFilePath(_CSTRING_NS::CString& strFilePath) +#ifdef __ATLSTR_H__ + HRESULT GetFilePath(ATL::CString& strFilePath) { T* pT = static_cast(this); ATLASSERT(pT->m_spFileDlg != NULL); @@ -988,7 +953,7 @@ public: return hRet; } - HRESULT GetFileTitle(_CSTRING_NS::CString& strFileTitle) + HRESULT GetFileTitle(ATL::CString& strFileTitle) { T* pT = static_cast(this); ATLASSERT(pT->m_spFileDlg != NULL); @@ -1001,7 +966,7 @@ public: return hRet; } -#endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) +#endif // __ATLSTR_H__ // Helpers for IShellItem static HRESULT GetFileNameFromShellItem(IShellItem* pShellItem, SIGDN type, LPWSTR lpstr, int cchLength) @@ -1015,7 +980,7 @@ public: { if(lstrlenW(lpstrName) < cchLength) { - SecureHelper::strcpyW_x(lpstr, cchLength, lpstrName); + ATL::Checked::wcscpy_s(lpstr, cchLength, lpstrName); } else { @@ -1029,8 +994,8 @@ public: return hRet; } -#if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) - static HRESULT GetFileNameFromShellItem(IShellItem* pShellItem, SIGDN type, _CSTRING_NS::CString& str) +#ifdef __ATLSTR_H__ + static HRESULT GetFileNameFromShellItem(IShellItem* pShellItem, SIGDN type, ATL::CString& str) { ATLASSERT(pShellItem != NULL); @@ -1045,7 +1010,7 @@ public: return hRet; } -#endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) +#endif // __ATLSTR_H__ // Implementation void _Advise(DWORD& dwCookie) @@ -1086,7 +1051,7 @@ public: ATLASSERT(SUCCEEDED(hRet)); } - if(arrFilterSpec != NULL && uFilterSpecCount != 0U) + if((arrFilterSpec != NULL) && (uFilterSpecCount != 0U)) { hRet = pT->m_spFileDlg->SetFileTypes(uFilterSpecCount, arrFilterSpec); ATLASSERT(SUCCEEDED(hRet)); @@ -1121,59 +1086,59 @@ public: } // Implementation - IFileDialogEvents interface - virtual HRESULT STDMETHODCALLTYPE IFileDialogEvents::OnFileOk(IFileDialog* pfd) + virtual HRESULT STDMETHODCALLTYPE OnFileOk(IFileDialog* pfd) { T* pT = static_cast(this); ATLASSERT(pT->m_spFileDlg.IsEqualObject(pfd)); - pfd; // avoid level 4 warning + (void)pfd; // avoid level 4 warning return pT->OnFileOk(); } - virtual HRESULT STDMETHODCALLTYPE IFileDialogEvents::OnFolderChanging(IFileDialog* pfd, IShellItem* psiFolder) + virtual HRESULT STDMETHODCALLTYPE OnFolderChanging(IFileDialog* pfd, IShellItem* psiFolder) { T* pT = static_cast(this); ATLASSERT(pT->m_spFileDlg.IsEqualObject(pfd)); - pfd; // avoid level 4 warning + (void)pfd; // avoid level 4 warning return pT->OnFolderChanging(psiFolder); } - virtual HRESULT STDMETHODCALLTYPE IFileDialogEvents::OnFolderChange(IFileDialog* pfd) + virtual HRESULT STDMETHODCALLTYPE OnFolderChange(IFileDialog* pfd) { T* pT = static_cast(this); ATLASSERT(pT->m_spFileDlg.IsEqualObject(pfd)); - pfd; // avoid level 4 warning + (void)pfd; // avoid level 4 warning return pT->OnFolderChange(); } - virtual HRESULT STDMETHODCALLTYPE IFileDialogEvents::OnSelectionChange(IFileDialog* pfd) + virtual HRESULT STDMETHODCALLTYPE OnSelectionChange(IFileDialog* pfd) { T* pT = static_cast(this); ATLASSERT(pT->m_spFileDlg.IsEqualObject(pfd)); - pfd; // avoid level 4 warning + (void)pfd; // avoid level 4 warning return pT->OnSelectionChange(); } - virtual HRESULT STDMETHODCALLTYPE IFileDialogEvents::OnShareViolation(IFileDialog* pfd, IShellItem* psi, FDE_SHAREVIOLATION_RESPONSE* pResponse) + virtual HRESULT STDMETHODCALLTYPE OnShareViolation(IFileDialog* pfd, IShellItem* psi, FDE_SHAREVIOLATION_RESPONSE* pResponse) { T* pT = static_cast(this); ATLASSERT(pT->m_spFileDlg.IsEqualObject(pfd)); - pfd; // avoid level 4 warning + (void)pfd; // avoid level 4 warning return pT->OnShareViolation(psi, pResponse); } - virtual HRESULT STDMETHODCALLTYPE IFileDialogEvents::OnTypeChange(IFileDialog* pfd) + virtual HRESULT STDMETHODCALLTYPE OnTypeChange(IFileDialog* pfd) { T* pT = static_cast(this); ATLASSERT(pT->m_spFileDlg.IsEqualObject(pfd)); - pfd; // avoid level 4 warning + (void)pfd; // avoid level 4 warning return pT->OnTypeChange(); } - virtual HRESULT STDMETHODCALLTYPE IFileDialogEvents::OnOverwrite(IFileDialog* pfd, IShellItem* psi, FDE_OVERWRITE_RESPONSE* pResponse) + virtual HRESULT STDMETHODCALLTYPE OnOverwrite(IFileDialog* pfd, IShellItem* psi, FDE_OVERWRITE_RESPONSE* pResponse) { T* pT = static_cast(this); ATLASSERT(pT->m_spFileDlg.IsEqualObject(pfd)); - pfd; // avoid level 4 warning + (void)pfd; // avoid level 4 warning return pT->OnOverwrite(psi, pResponse); } @@ -1233,9 +1198,12 @@ public: HRESULT hRet = m_spFileDlg.CoCreateInstance(CLSID_FileOpenDialog); if(SUCCEEDED(hRet)) - _Init(lpszFileName, dwOptions, lpszDefExt, arrFilterSpec, uFilterSpecCount); + this->_Init(lpszFileName, dwOptions, lpszDefExt, arrFilterSpec, uFilterSpecCount); } + virtual ~CShellFileOpenDialogImpl() + { } + IFileOpenDialog* GetPtr() { return m_spFileDlg; @@ -1256,6 +1224,9 @@ public: UINT uFilterSpecCount = 0U) : CShellFileOpenDialogImpl(lpszFileName, dwOptions, lpszDefExt, arrFilterSpec, uFilterSpecCount) { } + virtual ~CShellFileOpenDialog() + { } + // Implementation (remove _Advise/_Unadvise code using template magic) void _Advise(DWORD& /*dwCookie*/) { } @@ -1283,9 +1254,12 @@ public: HRESULT hRet = m_spFileDlg.CoCreateInstance(CLSID_FileSaveDialog); if(SUCCEEDED(hRet)) - _Init(lpszFileName, dwOptions, lpszDefExt, arrFilterSpec, uFilterSpecCount); + this->_Init(lpszFileName, dwOptions, lpszDefExt, arrFilterSpec, uFilterSpecCount); } + virtual ~CShellFileSaveDialogImpl() + { } + IFileSaveDialog* GetPtr() { return m_spFileDlg; @@ -1306,6 +1280,9 @@ public: UINT uFilterSpecCount = 0U) : CShellFileSaveDialogImpl(lpszFileName, dwOptions, lpszDefExt, arrFilterSpec, uFilterSpecCount) { } + virtual ~CShellFileSaveDialog() + { } + // Implementation (remove _Advise/_Unadvise code using template magic) void _Advise(DWORD& /*dwCookie*/) { } @@ -1314,14 +1291,12 @@ public: { } }; -#endif // (_WIN32_WINNT >= 0x0600) && !defined(_WIN32_WCE) +#endif // (_WIN32_WINNT >= 0x0600) /////////////////////////////////////////////////////////////////////////////// // CFolderDialogImpl - used for browsing for a folder -#ifndef _WIN32_WCE - template class ATL_NO_VTABLE CFolderDialogImpl { @@ -1443,20 +1418,6 @@ public: // Callback function and overrideables static int CALLBACK BrowseCallbackProc(HWND hWnd, UINT uMsg, LPARAM lParam, LPARAM lpData) { -#ifndef BFFM_VALIDATEFAILED - #ifdef UNICODE - const int BFFM_VALIDATEFAILED = 4; - #else - const int BFFM_VALIDATEFAILED = 3; - #endif -#endif // !BFFM_VALIDATEFAILED -#ifndef BFFM_IUNKNOWN - const int BFFM_IUNKNOWN = 5; -#endif // !BFFM_IUNKNOWN -#ifndef BIF_NEWDIALOGSTYLE - const UINT BIF_NEWDIALOGSTYLE = 0x0040; -#endif // !BIF_NEWDIALOGSTYLE - int nRet = 0; T* pT = (T*)lpData; bool bClear = false; @@ -1553,9 +1514,6 @@ public: void SetOKText(LPCTSTR lpstrOKText) { -#ifndef BFFM_SETOKTEXT - const UINT BFFM_SETOKTEXT = WM_USER + 105; -#endif ATLASSERT(m_hWnd != NULL); USES_CONVERSION; LPCWSTR lpstr = T2CW(lpstrOKText); @@ -1564,18 +1522,12 @@ public: void SetExpanded(LPCITEMIDLIST pItemIDList) { -#ifndef BFFM_SETEXPANDED - const UINT BFFM_SETEXPANDED = WM_USER + 106; -#endif ATLASSERT(m_hWnd != NULL); ::SendMessage(m_hWnd, BFFM_SETEXPANDED, FALSE, (LPARAM)pItemIDList); } void SetExpanded(LPCTSTR lpstrFolderPath) { -#ifndef BFFM_SETEXPANDED - const UINT BFFM_SETEXPANDED = WM_USER + 106; -#endif ATLASSERT(m_hWnd != NULL); USES_CONVERSION; LPCWSTR lpstr = T2CW(lpstrFolderPath); @@ -1591,8 +1543,6 @@ public: { } }; -#endif // !_WIN32_WCE - /////////////////////////////////////////////////////////////////////////////// // CCommonDialogImplBase - base class for common dialog classes @@ -1647,8 +1597,6 @@ public: /////////////////////////////////////////////////////////////////////////////// // CFontDialogImpl - font selection dialog -#ifndef _WIN32_WCE - template class ATL_NO_VTABLE CFontDialogImpl : public CCommonDialogImplBase { @@ -1705,7 +1653,6 @@ public: ATLASSERT(m_hWnd == NULL); -#if (_ATL_VER >= 0x0800) // Allocate the thunk structure here, where we can fail gracefully. BOOL bRetTh = m_thunk.Init(NULL, NULL); if(bRetTh == FALSE) @@ -1713,7 +1660,6 @@ public: ::SetLastError(ERROR_OUTOFMEMORY); return -1; } -#endif // (_ATL_VER >= 0x0800) ModuleHelper::AddCreateWndData(&m_thunk.cd, (CCommonDialogImplBase*)this); @@ -1722,7 +1668,7 @@ public: m_hWnd = NULL; if(bRet) // copy logical font from user's initialization buffer (if needed) - SecureHelper::memcpy_x(&m_lf, sizeof(m_lf), m_cf.lpLogFont, sizeof(m_lf)); + ATL::Checked::memcpy_s(&m_lf, sizeof(m_lf), m_cf.lpLogFont, sizeof(m_lf)); return bRet ? IDOK : IDCANCEL; } @@ -1739,13 +1685,10 @@ public: } // works only when the dialog is dislayed or before -#ifndef _WIN32_WCE void SetLogFont(LPLOGFONT lplf) { ATLASSERT(lplf != NULL); -#ifndef WM_CHOOSEFONT_SETLOGFONT - const UINT WM_CHOOSEFONT_SETLOGFONT = (WM_USER + 101); -#endif + if(m_hWnd != NULL) { ::SendMessage(m_hWnd, WM_CHOOSEFONT_SETLOGFONT, 0, (LPARAM)lplf); @@ -1759,9 +1702,6 @@ public: void SetFlags(DWORD dwFlags) { -#ifndef WM_CHOOSEFONT_SETFLAGS - const UINT WM_CHOOSEFONT_SETFLAGS = (WM_USER + 102); -#endif if(m_hWnd != NULL) { CHOOSEFONT cf = { sizeof(CHOOSEFONT) }; @@ -1773,7 +1713,6 @@ public: m_cf.Flags = dwFlags; } } -#endif // !_WIN32_WCE // Helpers for parsing information after successful return LPCTSTR GetFaceName() const // return the face name of the font @@ -1835,13 +1774,11 @@ public: DECLARE_EMPTY_MSG_MAP() }; -#endif // _WIN32_WCE - /////////////////////////////////////////////////////////////////////////////// // CRichEditFontDialogImpl - font selection for the Rich Edit ctrl -#if defined(_RICHEDIT_) && !defined(_WIN32_WCE) +#ifdef _RICHEDIT_ template class ATL_NO_VTABLE CRichEditFontDialogImpl : public CFontDialogImpl< T > @@ -1853,12 +1790,12 @@ public: HWND hWndParent = NULL) : CFontDialogImpl< T >(NULL, dwFlags, hDCPrinter, hWndParent) { - m_cf.Flags |= CF_INITTOLOGFONTSTRUCT; - m_cf.Flags |= FillInLogFont(charformat); - m_cf.lpLogFont = &m_lf; + this->m_cf.Flags |= CF_INITTOLOGFONTSTRUCT; + this->m_cf.Flags |= FillInLogFont(charformat); + this->m_cf.lpLogFont = &this->m_lf; if((charformat.dwMask & CFM_COLOR) != 0) - m_cf.rgbColors = charformat.crTextColor; + this->m_cf.rgbColors = charformat.crTextColor; } void GetCharFormat(CHARFORMAT& cf) const @@ -1866,40 +1803,36 @@ public: USES_CONVERSION; cf.dwEffects = 0; cf.dwMask = 0; - if((m_cf.Flags & CF_NOSTYLESEL) == 0) + if((this->m_cf.Flags & CF_NOSTYLESEL) == 0) { cf.dwMask |= CFM_BOLD | CFM_ITALIC; - cf.dwEffects |= IsBold() ? CFE_BOLD : 0; - cf.dwEffects |= IsItalic() ? CFE_ITALIC : 0; + cf.dwEffects |= this->IsBold() ? CFE_BOLD : 0; + cf.dwEffects |= this->IsItalic() ? CFE_ITALIC : 0; } - if((m_cf.Flags & CF_NOSIZESEL) == 0) + if((this->m_cf.Flags & CF_NOSIZESEL) == 0) { cf.dwMask |= CFM_SIZE; // GetSize() returns in tenths of points so mulitply by 2 to get twips - cf.yHeight = GetSize() * 2; + cf.yHeight = this->GetSize() * 2; } - if((m_cf.Flags & CF_NOFACESEL) == 0) + if((this->m_cf.Flags & CF_NOFACESEL) == 0) { cf.dwMask |= CFM_FACE; - cf.bPitchAndFamily = m_cf.lpLogFont->lfPitchAndFamily; -#if (_RICHEDIT_VER >= 0x0200) - SecureHelper::strcpy_x(cf.szFaceName, _countof(cf.szFaceName), GetFaceName()); -#else // !(_RICHEDIT_VER >= 0x0200) - SecureHelper::strcpyA_x(cf.szFaceName, _countof(cf.szFaceName), T2A((LPTSTR)(LPCTSTR)GetFaceName())); -#endif // !(_RICHEDIT_VER >= 0x0200) + cf.bPitchAndFamily = this->m_cf.lpLogFont->lfPitchAndFamily; + ATL::Checked::tcscpy_s(cf.szFaceName, _countof(cf.szFaceName), this->GetFaceName()); } - if((m_cf.Flags & CF_EFFECTS) != 0) + if((this->m_cf.Flags & CF_EFFECTS) != 0) { cf.dwMask |= CFM_UNDERLINE | CFM_STRIKEOUT | CFM_COLOR; - cf.dwEffects |= IsUnderline() ? CFE_UNDERLINE : 0; - cf.dwEffects |= IsStrikeOut() ? CFE_STRIKEOUT : 0; - cf.crTextColor = GetColor(); + cf.dwEffects |= this->IsUnderline() ? CFE_UNDERLINE : 0; + cf.dwEffects |= this->IsStrikeOut() ? CFE_STRIKEOUT : 0; + cf.crTextColor = this->GetColor(); } - if((m_cf.Flags & CF_NOSCRIPTSEL) == 0) + if((this->m_cf.Flags & CF_NOSCRIPTSEL) == 0) { - cf.bCharSet = m_cf.lpLogFont->lfCharSet; + cf.bCharSet = this->m_cf.lpLogFont->lfCharSet; cf.dwMask |= CFM_CHARSET; } cf.yOffset = 0; @@ -1913,59 +1846,55 @@ public: { HDC hDC = ::CreateDC(_T("DISPLAY"), NULL, NULL, NULL); LONG yPerInch = ::GetDeviceCaps(hDC, LOGPIXELSY); - m_lf.lfHeight = -(int)((cf.yHeight * yPerInch) / 1440); + this->m_lf.lfHeight = -(int)((cf.yHeight * yPerInch) / 1440); } else - m_lf.lfHeight = 0; + this->m_lf.lfHeight = 0; - m_lf.lfWidth = 0; - m_lf.lfEscapement = 0; - m_lf.lfOrientation = 0; + this->m_lf.lfWidth = 0; + this->m_lf.lfEscapement = 0; + this->m_lf.lfOrientation = 0; if((cf.dwMask & (CFM_ITALIC | CFM_BOLD)) == (CFM_ITALIC | CFM_BOLD)) { - m_lf.lfWeight = ((cf.dwEffects & CFE_BOLD) != 0) ? FW_BOLD : FW_NORMAL; - m_lf.lfItalic = (BYTE)(((cf.dwEffects & CFE_ITALIC) != 0) ? TRUE : FALSE); + this->m_lf.lfWeight = ((cf.dwEffects & CFE_BOLD) != 0) ? FW_BOLD : FW_NORMAL; + this->m_lf.lfItalic = (BYTE)(((cf.dwEffects & CFE_ITALIC) != 0) ? TRUE : FALSE); } else { dwFlags |= CF_NOSTYLESEL; - m_lf.lfWeight = FW_DONTCARE; - m_lf.lfItalic = FALSE; + this->m_lf.lfWeight = FW_DONTCARE; + this->m_lf.lfItalic = FALSE; } if((cf.dwMask & (CFM_UNDERLINE | CFM_STRIKEOUT | CFM_COLOR)) == (CFM_UNDERLINE|CFM_STRIKEOUT|CFM_COLOR)) { dwFlags |= CF_EFFECTS; - m_lf.lfUnderline = (BYTE)(((cf.dwEffects & CFE_UNDERLINE) != 0) ? TRUE : FALSE); - m_lf.lfStrikeOut = (BYTE)(((cf.dwEffects & CFE_STRIKEOUT) != 0) ? TRUE : FALSE); + this->m_lf.lfUnderline = (BYTE)(((cf.dwEffects & CFE_UNDERLINE) != 0) ? TRUE : FALSE); + this->m_lf.lfStrikeOut = (BYTE)(((cf.dwEffects & CFE_STRIKEOUT) != 0) ? TRUE : FALSE); } else { - m_lf.lfUnderline = (BYTE)FALSE; - m_lf.lfStrikeOut = (BYTE)FALSE; + this->m_lf.lfUnderline = (BYTE)FALSE; + this->m_lf.lfStrikeOut = (BYTE)FALSE; } if((cf.dwMask & CFM_CHARSET) != 0) - m_lf.lfCharSet = cf.bCharSet; + this->m_lf.lfCharSet = cf.bCharSet; else dwFlags |= CF_NOSCRIPTSEL; - m_lf.lfOutPrecision = OUT_DEFAULT_PRECIS; - m_lf.lfClipPrecision = CLIP_DEFAULT_PRECIS; - m_lf.lfQuality = DEFAULT_QUALITY; + this->m_lf.lfOutPrecision = OUT_DEFAULT_PRECIS; + this->m_lf.lfClipPrecision = CLIP_DEFAULT_PRECIS; + this->m_lf.lfQuality = DEFAULT_QUALITY; if((cf.dwMask & CFM_FACE) != 0) { - m_lf.lfPitchAndFamily = cf.bPitchAndFamily; -#if (_RICHEDIT_VER >= 0x0200) - SecureHelper::strcpy_x(m_lf.lfFaceName, _countof(m_lf.lfFaceName), cf.szFaceName); -#else // !(_RICHEDIT_VER >= 0x0200) - SecureHelper::strcpy_x(m_lf.lfFaceName, _countof(m_lf.lfFaceName), A2T((LPSTR)cf.szFaceName)); -#endif // !(_RICHEDIT_VER >= 0x0200) + this->m_lf.lfPitchAndFamily = cf.bPitchAndFamily; + ATL::Checked::tcscpy_s(this->m_lf.lfFaceName, _countof(this->m_lf.lfFaceName), cf.szFaceName); } else { - m_lf.lfPitchAndFamily = DEFAULT_PITCH|FF_DONTCARE; - m_lf.lfFaceName[0] = (TCHAR)0; + this->m_lf.lfPitchAndFamily = DEFAULT_PITCH|FF_DONTCARE; + this->m_lf.lfFaceName[0] = (TCHAR)0; } return dwFlags; } @@ -1984,26 +1913,12 @@ public: DECLARE_EMPTY_MSG_MAP() }; -#endif // defined(_RICHEDIT_) && !defined(_WIN32_WCE) +#endif // _RICHEDIT_ /////////////////////////////////////////////////////////////////////////////// // CColorDialogImpl - color selection -#if !defined(_WIN32_WCE) || ((_WIN32_WCE > 420) && !(defined(WIN32_PLATFORM_WFSP) && (_WIN32_WCE > 0x0500))) - -#ifdef _WIN32_WCE - #pragma comment(lib, "commdlg.lib") - - #ifndef SETRGBSTRING - #define SETRGBSTRING _T("commdlg_SetRGBColor") - #endif - - #ifndef COLOROKSTRING - #define COLOROKSTRING _T("commdlg_ColorOK") - #endif -#endif - template class ATL_NO_VTABLE CColorDialogImpl : public CCommonDialogImplBase { @@ -2039,7 +1954,6 @@ public: ATLASSERT(m_hWnd == NULL); -#if (_ATL_VER >= 0x0800) // Allocate the thunk structure here, where we can fail gracefully. BOOL bRetTh = m_thunk.Init(NULL, NULL); if(bRetTh == FALSE) @@ -2047,7 +1961,6 @@ public: ::SetLastError(ERROR_OUTOFMEMORY); return -1; } -#endif // (_ATL_VER >= 0x0800) ModuleHelper::AddCreateWndData(&m_thunk.cd, (CCommonDialogImplBase*)this); @@ -2074,7 +1987,7 @@ public: // Special override for the color dialog static UINT_PTR APIENTRY HookProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - if(uMsg != WM_INITDIALOG && uMsg != _GetColorOKMessage()) + if((uMsg != WM_INITDIALOG) && (uMsg != _GetColorOKMessage())) return 0; LPCHOOSECOLOR lpCC = (LPCHOOSECOLOR)lParam; @@ -2205,14 +2118,10 @@ public: DECLARE_EMPTY_MSG_MAP() }; -#endif // !defined(_WIN32_WCE) || ((_WIN32_WCE > 420) && !(defined(WIN32_PLATFORM_WFSP) && (_WIN32_WCE > 0x0500))) - /////////////////////////////////////////////////////////////////////////////// // CPrintDialogImpl - used for Print... and PrintSetup... -#ifndef _WIN32_WCE - // global helper static inline HDC _AtlCreateDC(HGLOBAL hDevNames, HGLOBAL hDevMode) { @@ -2282,7 +2191,6 @@ public: ATLASSERT(m_hWnd == NULL); -#if (_ATL_VER >= 0x0800) // Allocate the thunk structure here, where we can fail gracefully. BOOL bRetTh = m_thunk.Init(NULL, NULL); if(bRetTh == FALSE) @@ -2290,7 +2198,6 @@ public: ::SetLastError(ERROR_OUTOFMEMORY); return -1; } -#endif // (_ATL_VER >= 0x0800) ModuleHelper::AddCreateWndData(&m_thunk.cd, (CCommonDialogImplBase*)this); @@ -2424,7 +2331,9 @@ public: // The following handle the case of print setup... from the print dialog CPrintDialogImpl(PRINTDLG& pdInit) : m_pd(pdInit) - { } + { + memset(&m_pdActual, 0, sizeof(m_pdActual)); + } BEGIN_MSG_MAP(CPrintDialogImpl) #ifdef psh1 @@ -2457,15 +2366,11 @@ public: #pragma warning(pop) -#endif // _WIN32_WCE - /////////////////////////////////////////////////////////////////////////////// // CPrintDialogExImpl - new print dialog for Windows 2000 -#if (WINVER >= 0x0500) && !defined(_WIN32_WCE) - -}; // namespace WTL +} // namespace WTL #include @@ -2694,10 +2599,10 @@ public: // call message map HRESULT hRet = ProcessWindowMessage(hWnd, uMsg, wParam, lParam, *plResult, 0) ? S_OK : S_FALSE; - if(hRet == S_OK && uMsg == WM_NOTIFY) // return in DWLP_MSGRESULT + if((hRet == S_OK) && (uMsg == WM_NOTIFY)) // return in DWLP_MSGRESULT ::SetWindowLongPtr(GetParent(), DWLP_MSGRESULT, (LONG_PTR)*plResult); - if(uMsg == WM_INITDIALOG && hRet == S_OK && (BOOL)*plResult != FALSE) + if((uMsg == WM_INITDIALOG) && (hRet == S_OK) && ((BOOL)*plResult != FALSE)) hRet = S_FALSE; return hRet; @@ -2716,14 +2621,10 @@ public: DECLARE_EMPTY_MSG_MAP() }; -#endif // (WINVER >= 0x0500) && !defined(_WIN32_WCE) - /////////////////////////////////////////////////////////////////////////////// // CPageSetupDialogImpl - Page Setup dialog -#ifndef _WIN32_WCE - template class ATL_NO_VTABLE CPageSetupDialogImpl : public CCommonDialogImplBase { @@ -2741,11 +2642,7 @@ public: m_psd.Flags = (dwFlags | PSD_ENABLEPAGESETUPHOOK | PSD_ENABLEPAGEPAINTHOOK); m_psd.lpfnPageSetupHook = (LPPAGESETUPHOOK)T::HookProc; m_thunkPaint.Init((WNDPROC)T::PaintHookProc, this); -#if (_ATL_VER >= 0x0700) m_psd.lpfnPagePaintHook = (LPPAGEPAINTHOOK)m_thunkPaint.GetWNDPROC(); -#else - m_psd.lpfnPagePaintHook = (LPPAGEPAINTHOOK)&(m_thunkPaint.thunk); -#endif } DECLARE_EMPTY_MSG_MAP() @@ -2818,7 +2715,6 @@ public: ATLASSERT(m_hWnd == NULL); -#if (_ATL_VER >= 0x0800) // Allocate the thunk structure here, where we can fail gracefully. BOOL bRetTh = m_thunk.Init(NULL, NULL); if(bRetTh == FALSE) @@ -2826,7 +2722,6 @@ public: ::SetLastError(ERROR_OUTOFMEMORY); return -1; } -#endif // (_ATL_VER >= 0x0800) ModuleHelper::AddCreateWndData(&m_thunk.cd, (CCommonDialogImplBase*)this); @@ -2889,14 +2784,10 @@ public: } }; -#endif // _WIN32_WCE - /////////////////////////////////////////////////////////////////////////////// // CFindReplaceDialogImpl - Find/FindReplace modeless dialogs -#ifndef _WIN32_WCE - template class ATL_NO_VTABLE CFindReplaceDialogImpl : public CCommonDialogImplBase { @@ -2948,14 +2839,13 @@ public: ATLASSERT(m_fr.hwndOwner != NULL); // must have an owner for modeless dialog if(lpszFindWhat != NULL) - SecureHelper::strncpy_x(m_szFindWhat, _countof(m_szFindWhat), lpszFindWhat, _TRUNCATE); + ATL::Checked::tcsncpy_s(m_szFindWhat, _countof(m_szFindWhat), lpszFindWhat, _TRUNCATE); if(lpszReplaceWith != NULL) - SecureHelper::strncpy_x(m_szReplaceWith, _countof(m_szReplaceWith), lpszReplaceWith, _TRUNCATE); + ATL::Checked::tcsncpy_s(m_szReplaceWith, _countof(m_szReplaceWith), lpszReplaceWith, _TRUNCATE); ATLASSERT(m_hWnd == NULL); -#if (_ATL_VER >= 0x0800) // Allocate the thunk structure here, where we can fail gracefully. BOOL bRet = m_thunk.Init(NULL, NULL); if(bRet == FALSE) @@ -2963,7 +2853,6 @@ public: ::SetLastError(ERROR_OUTOFMEMORY); return NULL; } -#endif // (_ATL_VER >= 0x0800) ModuleHelper::AddCreateWndData(&m_thunk.cd, (CCommonDialogImplBase*)this); @@ -2977,7 +2866,7 @@ public: return hWnd; } - static const UINT GetFindReplaceMsg() + static UINT GetFindReplaceMsg() { static const UINT nMsgFindReplace = ::RegisterWindowMessage(FINDMSGSTRING); return nMsgFindReplace; @@ -3045,8 +2934,6 @@ public: DECLARE_EMPTY_MSG_MAP() }; -#endif // !_WIN32_WCE - ///////////////////////////////////////////////////////////////////////// // CDialogBaseUnits - Dialog Units helper @@ -3084,7 +2971,7 @@ public: } } - CDialogBaseUnits(LOGFONT lf, HWND hWnd = NULL) + CDialogBaseUnits(const LOGFONT& lf, HWND hWnd = NULL) { if(!InitDialogBaseUnits(lf, hWnd)) { LONG nDlgBaseUnits = ::GetDialogBaseUnits(); @@ -3104,7 +2991,7 @@ public: return TRUE; } - BOOL InitDialogBaseUnits(LOGFONT lf, HWND hWnd = NULL) + BOOL InitDialogBaseUnits(const LOGFONT& lf, HWND hWnd = NULL) { CFont font; font.CreateFontIndirect(&lf); @@ -3116,8 +3003,8 @@ public: { ATLASSERT(hFont != NULL); CWindowDC dc = hWnd; - TEXTMETRIC tmText = { 0 }; - SIZE sizeText = { 0 }; + TEXTMETRIC tmText = {}; + SIZE sizeText = {}; HFONT hFontOld = dc.SelectFont(hFont); dc.GetTextMetrics(&tmText); m_sizeUnits.cy = tmText.tmHeight + tmText.tmExternalLeading; @@ -3193,31 +3080,16 @@ public: /////////////////////////////////////////////////////////////////////////////// // CMemDlgTemplate - in-memory dialog template - DLGTEMPLATE or DLGTEMPLATEEX -#if (_ATL_VER >= 0x800) - typedef ATL::_DialogSplitHelper::DLGTEMPLATEEX DLGTEMPLATEEX; - typedef ATL::_DialogSplitHelper::DLGITEMTEMPLATEEX DLGITEMTEMPLATEEX; -#else // (_ATL_VER >= 0x800) - typedef ATL::_DialogSizeHelper::_ATL_DLGTEMPLATEEX DLGTEMPLATEEX; - #pragma pack(push, 4) - struct DLGITEMTEMPLATEEX - { - DWORD helpID; - DWORD exStyle; - DWORD style; - short x; - short y; - short cx; - short cy; - DWORD id; - }; - #pragma pack(pop) -#endif // (_ATL_VER >= 0x800) - +// traits suitable for dialog controls +typedef ATL::CWinTraits CDlgControlWinTraits; template class CMemDlgTemplateT { public: + typedef ATL::_DialogSplitHelper::DLGTEMPLATEEX DLGTEMPLATEEX; + typedef ATL::_DialogSplitHelper::DLGITEMTEMPLATEEX DLGITEMTEMPLATEEX; + enum StdCtrlType { CTRL_BUTTON = 0x0080, @@ -3263,10 +3135,9 @@ public: void Reset() { - if (IsValid()) { -#ifndef UNDER_CE + if (IsValid()) + { ::GlobalUnlock(m_pData); -#endif ATLVERIFY(::GlobalFree(m_hData) == NULL); } @@ -3309,7 +3180,6 @@ public: AddData(&dlg, sizeof(dlg)); } -#ifndef _WIN32_WCE if (Menu.m_lpstr == NULL) { WORD menuData = 0; @@ -3324,13 +3194,6 @@ public: { AddString(Menu.m_lpstr); } -#else // _WIN32_WCE - // Windows CE doesn't support the addition of menus to a dialog box - ATLASSERT(Menu.m_lpstr == NULL); - Menu.m_lpstr; // avoid level 4 warning - WORD menuData = 0; - AddData(&menuData, sizeof(WORD)); -#endif // _WIN32_WCE if (ClassName.m_lpstr == NULL) { @@ -3450,32 +3313,22 @@ public: m_cAllocated = ((nData / ALLOCATION_INCREMENT) + 1) * ALLOCATION_INCREMENT; m_hData = ::GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, m_cAllocated); ATLASSERT(m_hData != NULL); -#ifndef UNDER_CE m_pPtr = m_pData = static_cast(::GlobalLock(m_hData)); -#else - m_pPtr = m_pData = static_cast(m_hData); -#endif ATLASSERT(m_pData != NULL); } else if (((m_pPtr - m_pData) + nData) > m_cAllocated) { SIZE_T ptrPos = (m_pPtr - m_pData); m_cAllocated += ((nData / ALLOCATION_INCREMENT) + 1) * ALLOCATION_INCREMENT; -#ifndef UNDER_CE ::GlobalUnlock(m_pData); -#endif m_hData = ::GlobalReAlloc(m_hData, m_cAllocated, GMEM_MOVEABLE | GMEM_ZEROINIT); ATLASSERT(m_hData != NULL); -#ifndef UNDER_CE m_pData = static_cast(::GlobalLock(m_hData)); -#else - m_pData = static_cast(m_hData); -#endif ATLASSERT(m_pData != NULL); m_pPtr = m_pData + ptrPos; } - SecureHelper::memcpy_x(m_pPtr, m_cAllocated - (m_pPtr - m_pData), pData, nData); + ATL::Checked::memcpy_s(m_pPtr, m_cAllocated - (m_pPtr - m_pData), pData, nData); m_pPtr += nData; } @@ -3497,7 +3350,7 @@ public: } }; -typedef CMemDlgTemplateT CMemDlgTemplate; +typedef CMemDlgTemplateT CMemDlgTemplate; /////////////////////////////////////////////////////////////////////////////// @@ -3541,7 +3394,7 @@ typedef CMemDlgTemplateT CMemDlgTemplate; #define END_DIALOG() \ m_Template.Create(bExTemplate, szCaption, nX, nY, nWidth, nHeight, dwStyle, dwExStyle, szFontName, wFontSize, wWeight, bItalic, bCharset, dwHelpID, ClassName, Menu); \ - }; + } #define DIALOG_CAPTION(caption) \ szCaption = caption; @@ -3569,7 +3422,7 @@ typedef CMemDlgTemplateT CMemDlgTemplate; { #define END_CONTROLS_MAP() \ - }; + } #define CONTROL_LTEXT(text, id, x, y, width, height, style, exStyle) \ @@ -3582,10 +3435,8 @@ typedef CMemDlgTemplateT CMemDlgTemplate; m_Template.AddStdControl(m_Template.CTRL_BUTTON, (WORD)id, x, y, width, height, style | BS_PUSHBUTTON | WS_TABSTOP, exStyle, text, NULL, 0); #define CONTROL_DEFPUSHBUTTON(text, id, x, y, width, height, style, exStyle) \ m_Template.AddStdControl(m_Template.CTRL_BUTTON, (WORD)id, x, y, width, height, style | BS_DEFPUSHBUTTON | WS_TABSTOP, exStyle, text, NULL, 0); -#ifndef _WIN32_WCE #define CONTROL_PUSHBOX(text, id, x, y, width, height, style, exStyle) \ m_Template.AddStdControl(m_Template.CTRL_BUTTON, (WORD)id, x, y, width, height, style | BS_PUSHBOX | WS_TABSTOP, exStyle, text, NULL, 0); -#endif // !_WIN32_WCE #define CONTROL_STATE3(text, id, x, y, width, height, style, exStyle) \ m_Template.AddStdControl(m_Template.CTRL_BUTTON, (WORD)id, x, y, width, height, style | BS_3STATE | WS_TABSTOP, exStyle, text, NULL, 0); #define CONTROL_AUTO3STATE(text, id, x, y, width, height, style, exStyle) \ @@ -3640,20 +3491,18 @@ public: if(!m_Template.IsValid()) CreateTemplate(); -#if (_ATL_VER >= 0x0800) // Allocate the thunk structure here, where we can fail gracefully. - BOOL bRet = m_thunk.Init(NULL, NULL); + BOOL bRet = this->m_thunk.Init(NULL, NULL); if(bRet == FALSE) { ::SetLastError(ERROR_OUTOFMEMORY); return -1; } -#endif // (_ATL_VER >= 0x0800) - ModuleHelper::AddCreateWndData(&m_thunk.cd, (ATL::CDialogImplBaseT< TBase >*)pT); + ModuleHelper::AddCreateWndData(&this->m_thunk.cd, (ATL::CDialogImplBaseT< TBase >*)pT); #ifdef _DEBUG - m_bModal = true; + this->m_bModal = true; #endif // _DEBUG return ::DialogBoxIndirectParam(ModuleHelper::GetResourceInstance(), m_Template.GetTemplatePtr(), hWndParent, (DLGPROC)T::StartDialogProc, dwInitParam); @@ -3667,24 +3516,22 @@ public: if(!m_Template.IsValid()) CreateTemplate(); -#if (_ATL_VER >= 0x0800) // Allocate the thunk structure here, where we can fail gracefully. - BOOL bRet = m_thunk.Init(NULL, NULL); + BOOL bRet = this->m_thunk.Init(NULL, NULL); if(bRet == FALSE) { ::SetLastError(ERROR_OUTOFMEMORY); return NULL; } -#endif // (_ATL_VER >= 0x0800) - ModuleHelper::AddCreateWndData(&m_thunk.cd, (ATL::CDialogImplBaseT< TBase >*)pT); + ModuleHelper::AddCreateWndData(&this->m_thunk.cd, (ATL::CDialogImplBaseT< TBase >*)pT); #ifdef _DEBUG - m_bModal = false; + this->m_bModal = false; #endif // _DEBUG HWND hWnd = ::CreateDialogIndirectParam(ModuleHelper::GetResourceInstance(), (LPCDLGTEMPLATE)m_Template.GetTemplatePtr(), hWndParent, (DLGPROC)T::StartDialogProc, dwInitParam); - ATLASSERT(m_hWnd == hWnd); + ATLASSERT(this->m_hWnd == hWnd); return hWnd; } @@ -3809,7 +3656,6 @@ public: return (BOOL)::SendMessage(m_hWnd, PSM_ADDPAGE, 0, (LPARAM)hPage); } -#ifndef _WIN32_WCE BOOL InsertPage(int nNewPageIndex, HPROPSHEETPAGE hPage) { ATLASSERT(::IsWindow(m_hWnd)); @@ -3843,7 +3689,6 @@ public: return FALSE; return (BOOL)::SendMessage(m_hWnd, PSM_INSERTPAGE, (WPARAM)hPageInsertAfter, (LPARAM)hPage); } -#endif // !_WIN32_WCE void RemovePage(int nPageIndex) { @@ -3908,7 +3753,6 @@ public: return (BOOL)::SendMessage(m_hWnd, PSM_ISDIALOGMESSAGE, 0, (LPARAM)lpMsg); } -#if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) int HwndToIndex(HWND hWnd) const { ATLASSERT(::IsWindow(m_hWnd)); @@ -3968,7 +3812,6 @@ public: ATLASSERT(::IsWindow(m_hWnd)); ::SendMessage(m_hWnd, PSM_SETHEADERSUBTITLE, nIndex, (LPARAM)lpstrHeaderSubTitle); } -#endif // (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) // Implementation - override to prevent usage HWND Create(LPCTSTR, HWND, ATL::_U_RECT = NULL, LPCTSTR = NULL, DWORD = 0, DWORD = 0, ATL::_U_MENUorID = 0U, LPVOID = NULL) @@ -3988,15 +3831,6 @@ public: PROPSHEETHEADER m_psh; ATL::CSimpleArray m_arrPages; -#if defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) // PPC specific - #ifndef PROPSHEET_LINK_SIZE - #define PROPSHEET_LINK_SIZE 128 - #endif // PROPSHEET_LINK_SIZE - TCHAR m_szLink[PROPSHEET_LINK_SIZE]; - static LPCTSTR m_pszTitle; - static LPCTSTR m_pszLink; -#endif // defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) - // Construction/Destruction CPropertySheetImpl(ATL::_U_STRINGorID title = (LPCTSTR)NULL, UINT uStartPage = 0, HWND hWndParent = NULL) { @@ -4010,11 +3844,6 @@ public: m_psh.nStartPage = uStartPage; m_psh.hwndParent = hWndParent; // if NULL, will be set in DoModal/Create m_psh.pfnCallback = T::PropSheetCallback; - -#if defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) // PPC specific - m_psh.dwFlags |= PSH_MAXIMIZE; - m_szLink[0] = 0; -#endif // defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) } ~CPropertySheetImpl() @@ -4029,7 +3858,7 @@ public: // Callback function and overrideables static int CALLBACK PropSheetCallback(HWND hWnd, UINT uMsg, LPARAM lParam) { - lParam; // avoid level 4 warning + (void)lParam; // avoid level 4 warning int nRet = 0; if(uMsg == PSCB_INITIALIZED) @@ -4041,41 +3870,8 @@ public: // remove page handles array pT->_CleanUpPages(); -#if defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) // PPC specific - m_pszTitle = pT->m_psh.pszCaption; - if(*pT->m_szLink != 0) - m_pszLink = pT->m_szLink; -#endif // defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) // PPC specific - pT->OnSheetInitialized(); } -#if defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) // PPC specific uMsg - else - { - switch(uMsg) - { - case PSCB_GETVERSION : - nRet = COMCTL32_VERSION; - break; - case PSCB_GETTITLE : - if(m_pszTitle != NULL) - { - lstrcpy((LPTSTR)lParam, m_pszTitle); - m_pszTitle = NULL; - } - break; - case PSCB_GETLINKTEXT: - if(m_pszLink != NULL) - { - lstrcpy((LPTSTR)lParam, m_pszLink); - m_pszLink = NULL; - } - break; - default: - break; - } - } -#endif // defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) return nRet; } @@ -4087,7 +3883,7 @@ public: // Create method HWND Create(HWND hWndParent = NULL) { - ATLASSERT(m_hWnd == NULL); + ATLASSERT(this->m_hWnd == NULL); m_psh.dwFlags |= PSH_MODELESS; if(m_psh.hwndParent == NULL) @@ -4097,7 +3893,6 @@ public: T* pT = static_cast(this); -#if (_ATL_VER >= 0x0800) // Allocate the thunk structure here, where we can fail gracefully. BOOL bRet = pT->m_thunk.Init(NULL, NULL); if(bRet == FALSE) @@ -4105,21 +3900,20 @@ public: ::SetLastError(ERROR_OUTOFMEMORY); return NULL; } -#endif // (_ATL_VER >= 0x0800) ModuleHelper::AddCreateWndData(&pT->m_thunk.cd, pT); HWND hWnd = (HWND)::PropertySheet(&m_psh); _CleanUpPages(); // ensure clean-up, required if call failed - ATLASSERT(m_hWnd == hWnd); + ATLASSERT(this->m_hWnd == hWnd); return hWnd; } INT_PTR DoModal(HWND hWndParent = ::GetActiveWindow()) { - ATLASSERT(m_hWnd == NULL); + ATLASSERT(this->m_hWnd == NULL); m_psh.dwFlags &= ~PSH_MODELESS; if(m_psh.hwndParent == NULL) @@ -4129,7 +3923,6 @@ public: T* pT = static_cast(this); -#if (_ATL_VER >= 0x0800) // Allocate the thunk structure here, where we can fail gracefully. BOOL bRet = pT->m_thunk.Init(NULL, NULL); if(bRet == FALSE) @@ -4137,7 +3930,6 @@ public: ::SetLastError(ERROR_OUTOFMEMORY); return -1; } -#endif // (_ATL_VER >= 0x0800) ModuleHelper::AddCreateWndData(&pT->m_thunk.cd, pT); @@ -4160,35 +3952,35 @@ public: // Note: Calling these after the sheet is created gives unpredictable results int GetPageCount() const { - if(m_hWnd == NULL) // not created yet + if(this->m_hWnd == NULL) // not created yet return m_arrPages.GetSize(); return TBase::GetPageCount(); } int GetActiveIndex() const { - if(m_hWnd == NULL) // not created yet + if(this->m_hWnd == NULL) // not created yet return m_psh.nStartPage; return TBase::GetActiveIndex(); } HPROPSHEETPAGE GetPage(int nPageIndex) const { - ATLASSERT(m_hWnd == NULL); // can't do this after it's created + ATLASSERT(this->m_hWnd == NULL); // can't do this after it's created return (HPROPSHEETPAGE)m_arrPages[nPageIndex]; } int GetPageIndex(HPROPSHEETPAGE hPage) const { - ATLASSERT(m_hWnd == NULL); // can't do this after it's created + ATLASSERT(this->m_hWnd == NULL); // can't do this after it's created return m_arrPages.Find((HPROPSHEETPAGE&)hPage); } BOOL SetActivePage(int nPageIndex) { - if(m_hWnd == NULL) // not created yet + if(this->m_hWnd == NULL) // not created yet { - ATLASSERT(nPageIndex >= 0 && nPageIndex < m_arrPages.GetSize()); + ATLASSERT((nPageIndex >= 0) && (nPageIndex < m_arrPages.GetSize())); m_psh.nStartPage = nPageIndex; return TRUE; } @@ -4198,7 +3990,7 @@ public: BOOL SetActivePage(HPROPSHEETPAGE hPage) { ATLASSERT(hPage != NULL); - if (m_hWnd == NULL) // not created yet + if(this->m_hWnd == NULL) // not created yet { int nPageIndex = GetPageIndex(hPage); if(nPageIndex == -1) @@ -4215,7 +4007,7 @@ public: ATLASSERT((nStyle & ~PSH_PROPTITLE) == 0); // only PSH_PROPTITLE is valid ATLASSERT(lpszText != NULL); - if(m_hWnd == NULL) + if(this->m_hWnd == NULL) { // set internal state m_psh.pszCaption = lpszText; // must exist until sheet is created @@ -4229,15 +4021,6 @@ public: } } -#if defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) // PPC specific Link field - void SetLinkText(LPCTSTR lpszText) - { - ATLASSERT(lpszText != NULL); - ATLASSERT(lstrlen(lpszText) < PROPSHEET_LINK_SIZE); - lstrcpy(m_szLink, lpszText); - } -#endif // defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) - void SetWizardMode() { m_psh.dwFlags |= PSH_WIZARD; @@ -4253,7 +4036,7 @@ public: { ATLASSERT(hPage != NULL); BOOL bRet = FALSE; - if(m_hWnd != NULL) + if(this->m_hWnd != NULL) bRet = TBase::AddPage(hPage); else // sheet not created yet, use internal data bRet = m_arrPages.Add((HPROPSHEETPAGE&)hPage); @@ -4275,7 +4058,7 @@ public: BOOL RemovePage(HPROPSHEETPAGE hPage) { ATLASSERT(hPage != NULL); - if (m_hWnd == NULL) // not created yet + if(this->m_hWnd == NULL) // not created yet { int nPage = GetPageIndex(hPage); if(nPage == -1) @@ -4290,17 +4073,16 @@ public: BOOL RemovePage(int nPageIndex) { BOOL bRet = TRUE; - if(m_hWnd != NULL) + if(this->m_hWnd != NULL) TBase::RemovePage(nPageIndex); else // sheet not created yet, use internal data bRet = m_arrPages.RemoveAt(nPageIndex); return bRet; } -#if (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) void SetHeader(LPCTSTR szbmHeader) { - ATLASSERT(m_hWnd == NULL); // can't do this after it's created + ATLASSERT(this->m_hWnd == NULL); // can't do this after it's created m_psh.dwFlags &= ~PSH_WIZARD; m_psh.dwFlags |= (PSH_HEADER | PSH_WIZARD97); @@ -4309,7 +4091,7 @@ public: void SetHeader(HBITMAP hbmHeader) { - ATLASSERT(m_hWnd == NULL); // can't do this after it's created + ATLASSERT(this->m_hWnd == NULL); // can't do this after it's created m_psh.dwFlags &= ~PSH_WIZARD; m_psh.dwFlags |= (PSH_HEADER | PSH_USEHBMHEADER | PSH_WIZARD97); @@ -4318,13 +4100,13 @@ public: void SetWatermark(LPCTSTR szbmWatermark, HPALETTE hplWatermark = NULL) { - ATLASSERT(m_hWnd == NULL); // can't do this after it's created + ATLASSERT(this->m_hWnd == NULL); // can't do this after it's created m_psh.dwFlags &= ~PSH_WIZARD; m_psh.dwFlags |= PSH_WATERMARK | PSH_WIZARD97; m_psh.pszbmWatermark = szbmWatermark; - if (hplWatermark != NULL) + if(hplWatermark != NULL) { m_psh.dwFlags |= PSH_USEHPLWATERMARK; m_psh.hplWatermark = hplWatermark; @@ -4333,13 +4115,13 @@ public: void SetWatermark(HBITMAP hbmWatermark, HPALETTE hplWatermark = NULL) { - ATLASSERT(m_hWnd == NULL); // can't do this after it's created + ATLASSERT(this->m_hWnd == NULL); // can't do this after it's created m_psh.dwFlags &= ~PSH_WIZARD; m_psh.dwFlags |= (PSH_WATERMARK | PSH_USEHBMWATERMARK | PSH_WIZARD97); m_psh.hbmWatermark = hbmWatermark; - if (hplWatermark != NULL) + if(hplWatermark != NULL) { m_psh.dwFlags |= PSH_USEHPLWATERMARK; m_psh.hplWatermark = hplWatermark; @@ -4348,13 +4130,12 @@ public: void StretchWatermark(bool bStretchWatermark) { - ATLASSERT(m_hWnd == NULL); // can't do this after it's created - if (bStretchWatermark) + ATLASSERT(this->m_hWnd == NULL); // can't do this after it's created + if(bStretchWatermark) m_psh.dwFlags |= PSH_STRETCHWATERMARK; else m_psh.dwFlags &= ~PSH_STRETCHWATERMARK; } -#endif // (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) // Message map and handlers BEGIN_MSG_MAP(CPropertySheetImpl) @@ -4364,30 +4145,23 @@ public: LRESULT OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) { - LRESULT lRet = DefWindowProc(uMsg, wParam, lParam); - if(HIWORD(wParam) == BN_CLICKED && (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) && - ((m_psh.dwFlags & PSH_MODELESS) != 0) && (GetActivePage() == NULL)) - DestroyWindow(); + LRESULT lRet = this->DefWindowProc(uMsg, wParam, lParam); + if((HIWORD(wParam) == BN_CLICKED) && ((LOWORD(wParam) == IDOK) || (LOWORD(wParam) == IDCANCEL)) && + ((m_psh.dwFlags & PSH_MODELESS) != 0) && (this->GetActivePage() == NULL)) + this->DestroyWindow(); return lRet; } LRESULT OnSysCommand(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) { if(((m_psh.dwFlags & PSH_MODELESS) == PSH_MODELESS) && ((wParam & 0xFFF0) == SC_CLOSE)) - SendMessage(WM_CLOSE); + this->SendMessage(WM_CLOSE); else bHandled = FALSE; return 0; } }; -#if defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) // PPC static pointers -template < class T, class TBase > -LPCWSTR CPropertySheetImpl::m_pszTitle = NULL; -template < class T, class TBase> -LPCWSTR CPropertySheetImpl::m_pszLink = NULL; -#endif // defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) - // for non-customized sheets class CPropertySheet : public CPropertySheetImpl { @@ -4482,6 +4256,19 @@ public: /////////////////////////////////////////////////////////////////////////////// // CPropertyPageImpl - implements a property page +#if defined(_WTL_FORCE_OLD_PAGE_NOTIFY_HANDLERS) && defined(_WTL_NEW_PAGE_NOTIFY_HANDLERS) + #error _WTL_FORCE_OLD_PAGE_NOTIFY_HANDLERS and _WTL_NEW_PAGE_NOTIFY_HANDLERS cannot be both defined +#endif + +#if !defined(_WTL_FORCE_OLD_PAGE_NOTIFY_HANDLERS) && !defined(_WTL_NEW_PAGE_NOTIFY_HANDLERS) + #define _WTL_NEW_PAGE_NOTIFY_HANDLERS +#endif + +// NOTE: _WTL_NEW_PAGE_NOTIFY_HANDLERS is now defined by default. +// It enables use of new notification handlers that +// return direct values without any restrictions. +// Define _WTL_FORCE_OLD_PAGE_NOTIFY_HANDLERS to use old handlers. + template class ATL_NO_VTABLE CPropertyPageImpl : public ATL::CDialogImplBaseT< TBase > { @@ -4511,7 +4298,7 @@ public: // Callback function and overrideables static UINT CALLBACK PropPageCallback(HWND hWnd, UINT uMsg, LPPROPSHEETPAGE ppsp) { - hWnd; // avoid level 4 warning + (void)hWnd; // avoid level 4 warning ATLASSERT(hWnd == NULL); T* pT = (T*)ppsp->lParam; UINT uRet = 0; @@ -4525,11 +4312,9 @@ public: uRet = pT->OnPageCreate() ? 1 : 0; } break; -#if (_WIN32_IE >= 0x0500) case PSPCB_ADDREF: pT->OnPageAddRef(); break; -#endif // (_WIN32_IE >= 0x0500) case PSPCB_RELEASE: pT->OnPageRelease(); break; @@ -4545,11 +4330,9 @@ public: return true; // true - allow page to be created, false - prevent creation } -#if (_WIN32_IE >= 0x0500) void OnPageAddRef() { } -#endif // (_WIN32_IE >= 0x0500) void OnPageRelease() { @@ -4568,21 +4351,19 @@ public: m_psp.dwFlags |= PSP_USETITLE; } -#if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) void SetHeaderTitle(LPCTSTR lpstrHeaderTitle) { - ATLASSERT(m_hWnd == NULL); // can't do this after it's created + ATLASSERT(this->m_hWnd == NULL); // can't do this after it's created m_psp.dwFlags |= PSP_USEHEADERTITLE; m_psp.pszHeaderTitle = lpstrHeaderTitle; } void SetHeaderSubTitle(LPCTSTR lpstrHeaderSubTitle) { - ATLASSERT(m_hWnd == NULL); // can't do this after it's created + ATLASSERT(this->m_hWnd == NULL); // can't do this after it's created m_psp.dwFlags |= PSP_USEHEADERSUBTITLE; m_psp.pszHeaderSubTitle = lpstrHeaderSubTitle; } -#endif // (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) // Operations void EnableHelp() @@ -4595,25 +4376,17 @@ public: MESSAGE_HANDLER(WM_NOTIFY, OnNotify) END_MSG_MAP() - // NOTE: Define _WTL_NEW_PAGE_NOTIFY_HANDLERS to use new notification - // handlers that return direct values without any restrictions LRESULT OnNotify(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled) { -#ifndef _WIN32_WCE - // This notification is sometimes received on Windows CE after the window is already destroyed - ATLASSERT(::IsWindow(m_hWnd)); -#endif + ATLASSERT(::IsWindow(this->m_hWnd)); NMHDR* pNMHDR = (NMHDR*)lParam; // don't handle messages not from the page/sheet itself - if(pNMHDR->hwndFrom != m_hWnd && pNMHDR->hwndFrom != ::GetParent(m_hWnd)) + if((pNMHDR->hwndFrom != this->m_hWnd) && (pNMHDR->hwndFrom != ::GetParent(this->m_hWnd))) { bHandled = FALSE; return 1; } -#ifdef _WIN32_WCE - ATLASSERT(::IsWindow(m_hWnd)); -#endif T* pT = static_cast(this); LRESULT lResult = 0; @@ -4647,14 +4420,10 @@ public: case PSN_HELP: pT->OnHelp(); break; -#ifndef _WIN32_WCE -#if (_WIN32_IE >= 0x0400) case PSN_GETOBJECT: if(!pT->OnGetObject((LPNMOBJECTNOTIFY)lParam)) bHandled = FALSE; break; -#endif // (_WIN32_IE >= 0x0400) -#if (_WIN32_IE >= 0x0500) case PSN_TRANSLATEACCELERATOR: { LPPSHNOTIFY lpPSHNotify = (LPPSHNOTIFY)lParam; @@ -4667,8 +4436,6 @@ public: lResult = (LRESULT)pT->OnQueryInitialFocus((HWND)lpPSHNotify->lParam); } break; -#endif // (_WIN32_IE >= 0x0500) -#endif // !_WIN32_WCE #else // !_WTL_NEW_PAGE_NOTIFY_HANDLERS case PSN_SETACTIVE: @@ -4698,14 +4465,10 @@ public: case PSN_HELP: pT->OnHelp(); break; -#ifndef _WIN32_WCE -#if (_WIN32_IE >= 0x0400) case PSN_GETOBJECT: if(!pT->OnGetObject((LPNMOBJECTNOTIFY)lParam)) bHandled = FALSE; break; -#endif // (_WIN32_IE >= 0x0400) -#if (_WIN32_IE >= 0x0500) case PSN_TRANSLATEACCELERATOR: { LPPSHNOTIFY lpPSHNotify = (LPPSHNOTIFY)lParam; @@ -4718,8 +4481,6 @@ public: lResult = (LRESULT)pT->OnQueryInitialFocus((HWND)lpPSHNotify->lParam); } break; -#endif // (_WIN32_IE >= 0x0500) -#endif // !_WIN32_WCE #endif // !_WTL_NEW_PAGE_NOTIFY_HANDLERS default: @@ -4730,8 +4491,6 @@ public: } // Overridables - // NOTE: Define _WTL_NEW_PAGE_NOTIFY_HANDLERS to use new notification - // handlers that return direct values without any restrictions #ifdef _WTL_NEW_PAGE_NOTIFY_HANDLERS int OnSetActive() { @@ -4795,15 +4554,11 @@ public: { } -#ifndef _WIN32_WCE -#if (_WIN32_IE >= 0x0400) BOOL OnGetObject(LPNMOBJECTNOTIFY /*lpObjectNotify*/) { return FALSE; // not processed } -#endif // (_WIN32_IE >= 0x0400) -#if (_WIN32_IE >= 0x0500) int OnTranslateAccelerator(LPMSG /*lpMsg*/) { // PSNRET_NOERROR - message not handled @@ -4817,8 +4572,6 @@ public: // HWND = set focus to HWND return NULL; } -#endif // (_WIN32_IE >= 0x0500) -#endif // !_WIN32_WCE #else // !_WTL_NEW_PAGE_NOTIFY_HANDLERS BOOL OnSetActive() @@ -4870,15 +4623,11 @@ public: { } -#ifndef _WIN32_WCE -#if (_WIN32_IE >= 0x0400) BOOL OnGetObject(LPNMOBJECTNOTIFY /*lpObjectNotify*/) { return FALSE; // not processed } -#endif // (_WIN32_IE >= 0x0400) -#if (_WIN32_IE >= 0x0500) BOOL OnTranslateAccelerator(LPMSG /*lpMsg*/) { return FALSE; // not translated @@ -4888,8 +4637,6 @@ public: { return NULL; // default } -#endif // (_WIN32_IE >= 0x0500) -#endif // !_WIN32_WCE #endif // !_WTL_NEW_PAGE_NOTIFY_HANDLERS }; @@ -4929,7 +4676,7 @@ public: m_hInitData(NULL), m_hDlgRes(NULL), m_hDlgResSplit(NULL) { T* pT = static_cast(this); - pT; // avoid level 4 warning + (void)pT; // avoid level 4 warning // initialize ActiveX hosting and modify dialog template ATL::AtlAxWinInit(); @@ -4957,8 +4704,8 @@ public: // set up property page to use in-memory dialog template if(lpDialogTemplate != NULL) { - m_psp.dwFlags |= PSP_DLGINDIRECT; - m_psp.pResource = lpDialogTemplate; + this->m_psp.dwFlags |= PSP_DLGINDIRECT; + this->m_psp.pResource = lpDialogTemplate; } else { @@ -4993,25 +4740,24 @@ public: // call this one to handle keyboard message for ActiveX controls BOOL PreTranslateMessage(LPMSG pMsg) { - if ((pMsg->message < WM_KEYFIRST || pMsg->message > WM_KEYLAST) && - (pMsg->message < WM_MOUSEFIRST || pMsg->message > WM_MOUSELAST)) + if (((pMsg->message < WM_KEYFIRST) || (pMsg->message > WM_KEYLAST)) && + ((pMsg->message < WM_MOUSEFIRST) || (pMsg->message > WM_MOUSELAST))) return FALSE; // find a direct child of the dialog from the window that has focus HWND hWndCtl = ::GetFocus(); - if (IsChild(hWndCtl) && ::GetParent(hWndCtl) != m_hWnd) + if (this->IsChild(hWndCtl) && (::GetParent(hWndCtl) != this->m_hWnd)) { do { hWndCtl = ::GetParent(hWndCtl); } - while (::GetParent(hWndCtl) != m_hWnd); + while (::GetParent(hWndCtl) != this->m_hWnd); } // give controls a chance to translate this message return (BOOL)::SendMessage(hWndCtl, WM_FORWARDMSG, 0, (LPARAM)pMsg); } // Overridables -#if (_WIN32_IE >= 0x0500) // new default implementation for ActiveX hosting pages #ifdef _WTL_NEW_PAGE_NOTIFY_HANDLERS int OnTranslateAccelerator(LPMSG lpMsg) @@ -5026,10 +4772,7 @@ public: return pT->PreTranslateMessage(lpMsg); } #endif // !_WTL_NEW_PAGE_NOTIFY_HANDLERS -#endif // (_WIN32_IE >= 0x0500) -// Support for new stuff in ATL7 -#if (_ATL_VER >= 0x0700) int GetIDD() { return( static_cast(this)->IDD ); @@ -5086,7 +4829,7 @@ public: // Get first control on the dialog DLGITEMTEMPLATE* pItem = ATL::_DialogSplitHelper::FindFirstDlgItem(pDlg); - HWND hWndPrev = GetWindow(GW_CHILD); + HWND hWndPrev = this->GetWindow(GW_CHILD); // Create all ActiveX cotnrols in the dialog template and place them in the correct tab order (z-order) for (WORD nItem = 0; nItem < nItems; nItem++) @@ -5104,7 +4847,7 @@ public: { BYTE* pBytes = (BYTE*) GlobalLock(h); BYTE* pSource = pData; - SecureHelper::memcpy_x(pBytes, dwLen, pSource, dwLen); + ATL::Checked::memcpy_s(pBytes, dwLen, pSource, dwLen); GlobalUnlock(h); CreateStreamOnHGlobal(h, TRUE, &spStream); } @@ -5126,17 +4869,17 @@ public: (LPWSTR)(((ATL::_DialogSplitHelper::DLGITEMTEMPLATEEX*)pItem) + 1) : (LPWSTR)(pItem + 1); // Get control rect. - RECT rect = { 0 }; + RECT rect = {}; rect.left = bDialogEx ? ((ATL::_DialogSplitHelper::DLGITEMTEMPLATEEX*)pItem)->x : pItem->x; rect.top = bDialogEx ? ((ATL::_DialogSplitHelper::DLGITEMTEMPLATEEX*)pItem)->y : pItem->y; rect.right = rect.left + (bDialogEx ? ((ATL::_DialogSplitHelper::DLGITEMTEMPLATEEX*)pItem)->cx : pItem->cx); rect.bottom = rect.top + (bDialogEx ? ((ATL::_DialogSplitHelper::DLGITEMTEMPLATEEX*)pItem)->cy : pItem->cy); // Convert from dialog units to screen units - MapDialogRect(&rect); + this->MapDialogRect(&rect); // Create AxWindow with a NULL caption. - wnd.Create(m_hWnd, + wnd.Create(this->m_hWnd, &rect, NULL, (bDialogEx ? @@ -5152,11 +4895,9 @@ public: if (wnd != NULL) { -#ifndef _WIN32_WCE // Set the Help ID if (bDialogEx && ((ATL::_DialogSplitHelper::DLGITEMTEMPLATEEX*)pItem)->helpID != 0) wnd.SetWindowContextHelpId(((ATL::_DialogSplitHelper::DLGITEMTEMPLATEEX*)pItem)->helpID); -#endif // !_WIN32_WCE // Try to create the ActiveX control. hr = wnd.CreateControlLic(pszClassName, spStream, NULL, bstrLicKey); if (FAILED(hr)) @@ -5193,7 +4934,7 @@ public: // Event handling support HRESULT AdviseSinkMap(bool bAdvise) { - if(!bAdvise && m_hWnd == NULL) + if(!bAdvise && (this->m_hWnd == NULL)) { // window is gone, controls are already unadvised ATLTRACE2(atlTraceUI, 0, _T("CAxPropertyPageImpl::AdviseSinkMap called after the window was destroyed\n")); @@ -5219,7 +4960,7 @@ public: LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) { // initialize controls in dialog with DLGINIT resource section - ExecuteDlgInit(static_cast(this)->IDD); + this->ExecuteDlgInit(static_cast(this)->IDD); AdviseSinkMap(true); bHandled = FALSE; return 1; @@ -5231,7 +4972,6 @@ public: bHandled = FALSE; return 1; } -#endif // (_ATL_VER >= 0x0700) }; // for non-customized pages @@ -5244,14 +4984,9 @@ public: CAxPropertyPage(ATL::_U_STRINGorID title = (LPCTSTR)NULL) : CAxPropertyPageImpl(title) { } -#if (_WIN32_IE >= 0x0500) || (_ATL_VER >= 0x0700) - // not empty so we handle accelerators/create controls BEGIN_MSG_MAP(CAxPropertyPage) CHAIN_MSG_MAP(CAxPropertyPageImpl >) END_MSG_MAP() -#else // !((_WIN32_IE >= 0x0500) || (_ATL_VER >= 0x0700)) - DECLARE_EMPTY_MSG_MAP() -#endif // !((_WIN32_IE >= 0x0500) || (_ATL_VER >= 0x0700)) }; #endif // _ATL_NO_HOSTING @@ -5260,8 +4995,6 @@ public: /////////////////////////////////////////////////////////////////////////////// // Wizard97 Support -#if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) - // Sample wizard dialog resources: // // IDD_WIZ97_INTERIOR_BLANK DIALOG 0, 0, 317, 143 @@ -5425,11 +5158,11 @@ public: baseClass(title, uStartPage, hWndParent), m_bReceivedFirstSizeMessage(false) { - m_psh.dwFlags &= ~(PSH_NOCONTEXTHELP); - m_psh.dwFlags &= ~(PSH_WIZARD | PSH_WIZARD_LITE); + this->m_psh.dwFlags &= ~(PSH_NOCONTEXTHELP); + this->m_psh.dwFlags &= ~(PSH_WIZARD | PSH_WIZARD_LITE); - m_psh.dwFlags |= (PSH_HASHELP | PSH_WIZARDCONTEXTHELP); - m_psh.dwFlags |= PSH_WIZARD97; + this->m_psh.dwFlags |= (PSH_HASHELP | PSH_WIZARDCONTEXTHELP); + this->m_psh.dwFlags |= PSH_WIZARD97; baseClass::SetHeader(headerBitmap.m_lpstr); baseClass::SetWatermark(watermarkBitmap.m_lpstr); @@ -5455,8 +5188,8 @@ public: CFontHandle fontThisDialog = this->GetFont(); CClientDC dcScreen(NULL); - LOGFONT titleLogFont = {0}; - LOGFONT bulletLogFont = {0}; + LOGFONT titleLogFont = {}; + LOGFONT bulletLogFont = {}; fontThisDialog.GetLogFont(&titleLogFont); fontThisDialog.GetLogFont(&bulletLogFont); @@ -5464,7 +5197,7 @@ public: // as Verdana Bold, 12pt. titleLogFont.lfCharSet = DEFAULT_CHARSET; titleLogFont.lfWeight = FW_BOLD; - SecureHelper::strcpy_x(titleLogFont.lfFaceName, _countof(titleLogFont.lfFaceName), _T("Verdana Bold")); + ATL::Checked::tcscpy_s(titleLogFont.lfFaceName, _countof(titleLogFont.lfFaceName), _T("Verdana Bold")); INT titleFontPointSize = 12; titleLogFont.lfHeight = -::MulDiv(titleFontPointSize, dcScreen.GetDeviceCaps(LOGPIXELSY), 72); m_fontExteriorPageTitle.CreateFontIndirect(&titleLogFont); @@ -5473,7 +5206,7 @@ public: // static text of "h" in the Marlett font. bulletLogFont.lfCharSet = DEFAULT_CHARSET; bulletLogFont.lfWeight = FW_NORMAL; - SecureHelper::strcpy_x(bulletLogFont.lfFaceName, _countof(bulletLogFont.lfFaceName), _T("Marlett")); + ATL::Checked::tcscpy_s(bulletLogFont.lfFaceName, _countof(bulletLogFont.lfFaceName), _T("Marlett")); INT bulletFontSize = 8; bulletLogFont.lfHeight = -::MulDiv(bulletFontSize, dcScreen.GetDeviceCaps(LOGPIXELSY), 72); m_fontBullet.CreateFontIndirect(&bulletLogFont); @@ -5618,8 +5351,8 @@ public: // Constructors CWizard97ExteriorPageImpl(ATL::_U_STRINGorID title = (LPCTSTR)NULL) : baseClass(title) { - m_psp.dwFlags |= PSP_HASHELP; - m_psp.dwFlags |= PSP_HIDEHEADER; + this->m_psp.dwFlags |= PSP_HASHELP; + this->m_psp.dwFlags |= PSP_HIDEHEADER; } // Message Handling @@ -5644,9 +5377,9 @@ public: // Constructors CWizard97InteriorPageImpl(ATL::_U_STRINGorID title = (LPCTSTR)NULL) : baseClass(title) { - m_psp.dwFlags |= PSP_HASHELP; - m_psp.dwFlags &= ~PSP_HIDEHEADER; - m_psp.dwFlags |= PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE; + this->m_psp.dwFlags |= PSP_HASHELP; + this->m_psp.dwFlags &= ~PSP_HIDEHEADER; + this->m_psp.dwFlags |= PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE; // Be sure to have the derived class define this in the constructor. // We'll default it to something obvious in case its forgotten. @@ -5660,13 +5393,11 @@ public: END_MSG_MAP() }; -#endif // (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) - /////////////////////////////////////////////////////////////////////////////// // Aero Wizard support -#if (_WIN32_WINNT >= 0x0600) && !defined(_WIN32_WCE) +#if (_WIN32_WINNT >= 0x0600) /////////////////////////////////////////////////////////////////////////////// // CAeroWizardFrameWindow - client side for an Aero Wizard frame window @@ -5722,26 +5453,26 @@ public: CAeroWizardFrameImpl(ATL::_U_STRINGorID title = (LPCTSTR)NULL, UINT uStartPage = 0, HWND hWndParent = NULL) : CPropertySheetImpl(title, uStartPage, hWndParent) { - m_psh.dwFlags |= PSH_WIZARD | PSH_AEROWIZARD; + this->m_psh.dwFlags |= PSH_WIZARD | PSH_AEROWIZARD; } // Operations void EnableResizing() { - ATLASSERT(m_hWnd == NULL); // can't do this after it's created - m_psh.dwFlags |= PSH_RESIZABLE; + ATLASSERT(this->m_hWnd == NULL); // can't do this after it's created + this->m_psh.dwFlags |= PSH_RESIZABLE; } void UseHeaderBitmap() { - ATLASSERT(m_hWnd == NULL); // can't do this after it's created - m_psh.dwFlags |= PSH_HEADERBITMAP; + ATLASSERT(this->m_hWnd == NULL); // can't do this after it's created + this->m_psh.dwFlags |= PSH_HEADERBITMAP; } void SetNoMargin() { - ATLASSERT(m_hWnd == NULL); // can't do this after it's created - m_psh.dwFlags |= PSH_NOMARGIN; + ATLASSERT(this->m_hWnd == NULL); // can't do this after it's created + this->m_psh.dwFlags |= PSH_NOMARGIN; } // Override to prevent use @@ -5880,25 +5611,20 @@ public: CAeroWizardAxPage(ATL::_U_STRINGorID title = (LPCTSTR)NULL) : CAeroWizardAxPageImpl(title) { } -#if (_WIN32_IE >= 0x0500) || (_ATL_VER >= 0x0700) - // not empty so we handle accelerators/create controls BEGIN_MSG_MAP(CAeroWizardAxPage) CHAIN_MSG_MAP(CAeroWizardAxPageImpl >) END_MSG_MAP() -#else // !((_WIN32_IE >= 0x0500) || (_ATL_VER >= 0x0700)) - DECLARE_EMPTY_MSG_MAP() -#endif // !((_WIN32_IE >= 0x0500) || (_ATL_VER >= 0x0700)) }; #endif // _ATL_NO_HOSTING -#endif // (_WIN32_WINNT >= 0x0600) && !defined(_WIN32_WCE) +#endif // (_WIN32_WINNT >= 0x0600) /////////////////////////////////////////////////////////////////////////////// // TaskDialog support -#if ((_WIN32_WINNT >= 0x0600) || defined(_WTL_TASKDIALOG)) && !defined(_WIN32_WCE) +#if (_WIN32_WINNT >= 0x0600) || defined(_WTL_TASKDIALOG) /////////////////////////////////////////////////////////////////////////////// // AtlTaskDialog - support for TaskDialog() function @@ -6267,7 +5993,7 @@ public: static HRESULT CALLBACK TaskDialogCallback(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LONG_PTR lpRefData) { T* pT = (T*)lpRefData; - ATLASSERT(pT->m_hWnd == NULL || pT->m_hWnd == hWnd); + ATLASSERT((pT->m_hWnd == NULL) || (pT->m_hWnd == hWnd)); BOOL bRet = FALSE; switch(uMsg) @@ -6500,8 +6226,8 @@ public: } }; -#endif // ((_WIN32_WINNT >= 0x0600) || defined(_WTL_TASKDIALOG)) && !defined(_WIN32_WCE) +#endif // (_WIN32_WINNT >= 0x0600) || defined(_WTL_TASKDIALOG) -}; // namespace WTL +} // namespace WTL #endif // __ATLDLGS_H__ diff --git a/ZbaSDK/SampleCode/PluginWinExe/WTL/atldwm.h b/ZbaSDK/SampleCode/PluginWinExe/WTL/atldwm.h index 52b67c658f33a0e2d35a1d30e861f3a0d556f22c..f78d30fc87ecacbd1037ddbe54a8188258b678ff 100644 --- a/ZbaSDK/SampleCode/PluginWinExe/WTL/atldwm.h +++ b/ZbaSDK/SampleCode/PluginWinExe/WTL/atldwm.h @@ -1,4 +1,4 @@ -// Windows Template Library - WTL version 9.10 +// Windows Template Library - WTL version 10.0 // Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. // // This file is a part of the Windows Template Library. @@ -11,10 +11,6 @@ #pragma once -#ifdef _WIN32_WCE - #error atldwm.h is not supported on Windows CE -#endif - #ifndef __ATLAPP_H__ #error atldwm.h requires atlapp.h to be included first #endif @@ -37,10 +33,7 @@ // Delay load is NOT AUTOMATIC for VC++ 7, you have to link to delayimp.lib, // and add dwmapi.dll in the Linker.Input.Delay Loaded DLLs section of the // project properties. -#if (_MSC_VER < 1300) && !defined(_WTL_NO_DWMAPI_DELAYLOAD) - #pragma comment(lib, "delayimp.lib") - #pragma comment(linker, "/delayload:dwmapi.dll") -#endif // (_MSC_VER < 1300) && !defined(_WTL_NO_DWMAPI_DELAYLOAD) + /////////////////////////////////////////////////////////////////////////////// // Classes in this file: @@ -155,7 +148,7 @@ class CDwmImpl : public TBase public: HRESULT DwmEnableBlurBehindWindow(const DWM_BLURBEHIND* pBB) { - if(!IsDwmSupported()) + if(!this->IsDwmSupported()) return E_NOTIMPL; T* pT = static_cast(this); @@ -165,7 +158,7 @@ public: HRESULT DwmExtendFrameIntoClientArea(const MARGINS* pMargins) { - if(!IsDwmSupported()) + if(!this->IsDwmSupported()) return E_NOTIMPL; T* pT = static_cast(this); @@ -181,7 +174,7 @@ public: HRESULT DwmGetCompositionTimingInfo(DWM_TIMING_INFO* pTimingInfo) { - if(!IsDwmSupported()) + if(!this->IsDwmSupported()) return E_NOTIMPL; T* pT = static_cast(this); @@ -191,7 +184,7 @@ public: HRESULT DwmGetWindowAttribute(DWORD dwAttribute, PVOID pvAttribute, DWORD cbAttribute) { - if(!IsDwmSupported()) + if(!this->IsDwmSupported()) return E_NOTIMPL; T* pT = static_cast(this); @@ -201,7 +194,7 @@ public: HRESULT DwmModifyPreviousDxFrameDuration(INT cRefreshes, BOOL fRelative) { - if(!IsDwmSupported()) + if(!this->IsDwmSupported()) return E_NOTIMPL; T* pT = static_cast(this); @@ -211,7 +204,7 @@ public: HRESULT DwmSetDxFrameDuration(INT cRefreshes) { - if(!IsDwmSupported()) + if(!this->IsDwmSupported()) return E_NOTIMPL; T* pT = static_cast(this); @@ -221,7 +214,7 @@ public: HRESULT DwmSetPresentParameters(DWM_PRESENT_PARAMETERS* pPresentParams) { - if(!IsDwmSupported()) + if(!this->IsDwmSupported()) return E_NOTIMPL; T* pT = static_cast(this); @@ -231,7 +224,7 @@ public: HRESULT DwmSetWindowAttribute(DWORD dwAttribute, LPCVOID pvAttribute, DWORD cbAttribute) { - if(!IsDwmSupported()) + if(!this->IsDwmSupported()) return E_NOTIMPL; T* pT = static_cast(this); @@ -241,7 +234,7 @@ public: HRESULT DwmAttachMilContent() { - if(!IsDwmSupported()) + if(!this->IsDwmSupported()) return E_NOTIMPL; T* pT = static_cast(this); @@ -251,7 +244,7 @@ public: HRESULT DwmDetachMilContent() { - if(!IsDwmSupported()) + if(!this->IsDwmSupported()) return E_NOTIMPL; T* pT = static_cast(this); @@ -269,7 +262,7 @@ public: CDwmWindowT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } }; @@ -306,7 +299,7 @@ public: void Attach(HTHUMBNAIL hThumbnailNew) { - if(t_bManaged && m_hThumbnail != NULL && m_hThumbnail != hThumbnailNew) + if(t_bManaged && (m_hThumbnail != NULL) && (m_hThumbnail != hThumbnailNew)) Unregister(); m_hThumbnail = hThumbnailNew; } @@ -324,7 +317,7 @@ public: ATLASSERT(::IsWindow(hwndSource)); ATLASSERT(m_hThumbnail==NULL); - if(!IsDwmSupported()) + if(!this->IsDwmSupported()) return E_NOTIMPL; return ::DwmRegisterThumbnail(hwndDestination, hwndSource, &m_hThumbnail); @@ -332,7 +325,7 @@ public: HRESULT Unregister() { - if(!IsDwmSupported()) + if(!this->IsDwmSupported()) return E_NOTIMPL; if(m_hThumbnail == NULL) return S_FALSE; @@ -350,7 +343,7 @@ public: HRESULT UpdateProperties(const DWM_THUMBNAIL_PROPERTIES* ptnProperties) { - if(!IsDwmSupported()) + if(!this->IsDwmSupported()) return E_NOTIMPL; ATLASSERT(m_hThumbnail != NULL); @@ -360,7 +353,7 @@ public: // Attributes HRESULT QuerySourceSize(PSIZE pSize) { - if(!IsDwmSupported()) + if(!this->IsDwmSupported()) return E_NOTIMPL; ATLASSERT(m_hThumbnail != NULL); @@ -389,7 +382,7 @@ public: CAeroControlImpl() { - m_PaintParams.dwFlags = BPPF_ERASE; + this->m_PaintParams.dwFlags = BPPF_ERASE; } static LPCWSTR GetThemeName() @@ -421,8 +414,8 @@ public: LRESULT OnActivate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) { - if(IsThemingSupported()) - Invalidate(FALSE); + if(this->IsThemingSupported()) + this->Invalidate(FALSE); bHandled = FALSE; return 0; @@ -431,7 +424,7 @@ public: // Operations BOOL SubclassWindow(HWND hWnd) { - ATLASSERT(m_hWnd == NULL); + ATLASSERT(this->m_hWnd == NULL); ATLASSERT(::IsWindow(hWnd)); BOOL bRet = _windowClass::SubclassWindow(hWnd); if(bRet) @@ -446,7 +439,7 @@ public: // Implementation LRESULT DefWindowProc() { - const ATL::_ATL_MSG* pMsg = m_pCurrentMsg; + const ATL::_ATL_MSG* pMsg = this->m_pCurrentMsg; LRESULT lRes = 0; if(pMsg != NULL) lRes = DefWindowProc(pMsg->message, pMsg->wParam, pMsg->lParam); @@ -468,12 +461,12 @@ public: { T* pT = static_cast(this); HDC hDCPaint = NULL; - RECT rcClient = { 0 }; - GetClientRect(&rcClient); - m_BufferedPaint.Begin(hDC, &rcClient, m_dwFormat, &m_PaintParams, &hDCPaint); + RECT rcClient = {}; + this->GetClientRect(&rcClient); + this->m_BufferedPaint.Begin(hDC, &rcClient, this->m_dwFormat, &this->m_PaintParams, &hDCPaint); ATLASSERT(hDCPaint != NULL); pT->DoAeroPaint(hDCPaint, rcClient, rcPaint); - m_BufferedPaint.End(); + this->m_BufferedPaint.End(); } void DoPaint(HDC /*hdc*/, RECT& /*rcClient*/) @@ -485,21 +478,21 @@ public: void Init() { T* pT = static_cast(this); - pT; // avoid level 4 warning - SetThemeClassList(pT->GetThemeName()); - if(m_lpstrThemeClassList != NULL) - OpenThemeData(); + (void)pT; // avoid level 4 warning + this->SetThemeClassList(pT->GetThemeName()); + if(this->m_lpstrThemeClassList != NULL) + this->OpenThemeData(); } void DoAeroPaint(HDC hDC, RECT& /*rcClient*/, RECT& rcPaint) { DefWindowProc(WM_PAINT, (WPARAM) hDC, 0L); - m_BufferedPaint.MakeOpaque(&rcPaint); + this->m_BufferedPaint.MakeOpaque(&rcPaint); } }; #endif // __ATLTHEME_H__ -}; // namespace WTL +} // namespace WTL #endif // __ATLDWM_H__ diff --git a/ZbaSDK/SampleCode/PluginWinExe/WTL/atlfind.h b/ZbaSDK/SampleCode/PluginWinExe/WTL/atlfind.h index 25bd3e412edbbee88aea926b8eda865ca869947c..9b8c3291d0a37bf05cee8f2755c5e3039f152527 100644 --- a/ZbaSDK/SampleCode/PluginWinExe/WTL/atlfind.h +++ b/ZbaSDK/SampleCode/PluginWinExe/WTL/atlfind.h @@ -1,4 +1,4 @@ -// Windows Template Library - WTL version 9.10 +// Windows Template Library - WTL version 10.0 // Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. // // This file is a part of the Windows Template Library. @@ -11,10 +11,6 @@ #pragma once -#ifdef _WIN32_WCE - #error atlfind.h is not supported on Windows CE -#endif - #ifndef __ATLCTRLS_H__ #error atlfind.h requires atlctrls.h to be included first #endif @@ -23,8 +19,8 @@ #error atlfind.h requires atldlgs.h to be included first #endif -#if !((defined(__ATLMISC_H__) && defined(_WTL_USE_CSTRING)) || defined(__ATLSTR_H__)) - #error atlfind.h requires CString (either from ATL's atlstr.h or WTL's atlmisc.h with _WTL_USE_CSTRING) +#ifndef __ATLSTR_H__ + #error atlfind.h requires CString #endif @@ -50,13 +46,6 @@ protected: // Typedefs typedef CEditFindReplaceImplBase thisClass; -// Data members - TFindReplaceDialog* m_pFindReplaceDialog; - _CSTRING_NS::CString m_sFindNext, m_sReplaceWith; - BOOL m_bFindOnly, m_bFirstSearch, m_bMatchCase, m_bWholeWord, m_bFindDown; - LONG m_nInitialSearchPos; - HCURSOR m_hOldCursor; - // Enumerations enum TranslationTextItem { @@ -67,6 +56,13 @@ protected: }; public: +// Data members + TFindReplaceDialog* m_pFindReplaceDialog; + ATL::CString m_sFindNext, m_sReplaceWith; + BOOL m_bFindOnly, m_bFirstSearch, m_bMatchCase, m_bWholeWord, m_bFindDown; + LONG m_nInitialSearchPos; + HCURSOR m_hOldCursor; + // Constructors CEditFindReplaceImplBase() : m_pFindReplaceDialog(NULL), @@ -83,25 +79,12 @@ public: // Message Handlers BEGIN_MSG_MAP(thisClass) ALT_MSG_MAP(1) - MESSAGE_HANDLER(WM_DESTROY, OnDestroy) MESSAGE_HANDLER(TFindReplaceDialog::GetFindReplaceMsg(), OnFindReplaceCmd) COMMAND_ID_HANDLER(ID_EDIT_FIND, OnEditFind) COMMAND_ID_HANDLER(ID_EDIT_REPEAT, OnEditRepeat) COMMAND_ID_HANDLER(ID_EDIT_REPLACE, OnEditReplace) END_MSG_MAP() - LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) - { - if(m_pFindReplaceDialog != NULL) - { - m_pFindReplaceDialog->SendMessage(WM_CLOSE); - ATLASSERT(m_pFindReplaceDialog == NULL); - } - - bHandled = FALSE; - return 0; - } - LRESULT OnFindReplaceCmd(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/) { T* pT = static_cast(this); @@ -204,7 +187,8 @@ public: { // You can override all of this in a derived class - TFindReplaceDialog* findReplaceDialog = new TFindReplaceDialog(); + TFindReplaceDialog* findReplaceDialog = NULL; + ATLTRY(findReplaceDialog = new TFindReplaceDialog()); if(findReplaceDialog == NULL) { ::MessageBeep(MB_ICONHAND); @@ -238,27 +222,27 @@ public: // (CEdit::GetSel uses int&, and CRichEditCtrlT::GetSel uses LONG&) ::SendMessage(pT->m_hWnd, EM_GETSEL, (WPARAM)&nStartChar, (LPARAM)&nEndChar); POINT point = pT->PosFromChar(nStartChar); - ::ClientToScreen(pT->GetParent(), &point); - CRect rect; + pT->ClientToScreen(&point); + RECT rect = {}; ::GetWindowRect(hWndDialog, &rect); - if(rect.PtInRect(point)) + if(::PtInRect(&rect, point) != FALSE) { - if(point.y > rect.Height()) + if(point.y > (rect.bottom - rect.top)) { - rect.OffsetRect(0, point.y - rect.bottom - 20); + ::OffsetRect(&rect, 0, point.y - rect.bottom - 20); } else { int nVertExt = GetSystemMetrics(SM_CYSCREEN); - if(point.y + rect.Height() < nVertExt) - rect.OffsetRect(0, 40 + point.y - rect.top); + if((point.y + (rect.bottom - rect.top)) < nVertExt) + ::OffsetRect(&rect, 0, 40 + point.y - rect.top); } - ::MoveWindow(hWndDialog, rect.left, rect.top, rect.Width(), rect.Height(), TRUE); + ::MoveWindow(hWndDialog, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, TRUE); } } - DWORD GetFindReplaceDialogFlags(void) const + DWORD GetFindReplaceDialogFlags() const { DWORD dwFlags = 0; if(m_bFindDown) @@ -292,12 +276,12 @@ public: ATLASSERT(m_pFindReplaceDialog == NULL); - _CSTRING_NS::CString findNext; + ATL::CString findNext; pT->GetSelText(findNext); // if selection is empty or spans multiple lines use old find text if(findNext.IsEmpty() || (findNext.FindOneOf(_T("\n\r")) != -1)) findNext = m_sFindNext; - _CSTRING_NS::CString replaceWith = m_sReplaceWith; + ATL::CString replaceWith = m_sReplaceWith; DWORD dwFlags = pT->GetFindReplaceDialogFlags(); m_pFindReplaceDialog = pT->CreateFindReplaceDialog(bFindOnly, @@ -321,11 +305,11 @@ public: return FALSE; // length is the same, check contents - _CSTRING_NS::CString selectedText; + ATL::CString selectedText; pT->GetSelText(selectedText); - return (bMatchCase && selectedText.Compare(lpszCompare) == 0) || - (!bMatchCase && selectedText.CompareNoCase(lpszCompare) == 0); + return (bMatchCase && (selectedText.Compare(lpszCompare) == 0)) || + (!bMatchCase && (selectedText.CompareNoCase(lpszCompare) == 0)); } void TextNotFound(LPCTSTR lpszFind) @@ -335,9 +319,9 @@ public: pT->OnTextNotFound(lpszFind); } - _CSTRING_NS::CString GetTranslationText(enum TranslationTextItem eItem) const + ATL::CString GetTranslationText(enum TranslationTextItem eItem) const { - _CSTRING_NS::CString text; + ATL::CString text; switch(eItem) { case eText_OnReplaceAllMessage: @@ -441,11 +425,11 @@ public: ::SetCursor(m_hOldCursor); - _CSTRING_NS::CString message = pT->GetTranslationText(eText_OnReplaceAllMessage); + ATL::CString message = pT->GetTranslationText(eText_OnReplaceAllMessage); if(message.GetLength() > 0) { - _CSTRING_NS::CString formattedMessage; - formattedMessage.Format(message, replaceCount, m_sFindNext, m_sReplaceWith); + ATL::CString formattedMessage; + formattedMessage.Format(message, replaceCount, (LPCTSTR)m_sFindNext, (LPCTSTR)m_sReplaceWith); if(m_pFindReplaceDialog != NULL) { m_pFindReplaceDialog->MessageBox(formattedMessage, @@ -464,10 +448,10 @@ public: void OnTextNotFound(LPCTSTR lpszFind) { T* pT = static_cast(this); - _CSTRING_NS::CString message = pT->GetTranslationText(eText_OnTextNotFoundMessage); + ATL::CString message = pT->GetTranslationText(eText_OnTextNotFoundMessage); if(message.GetLength() > 0) { - _CSTRING_NS::CString formattedMessage; + ATL::CString formattedMessage; formattedMessage.Format(message, lpszFind); if(m_pFindReplaceDialog != NULL) { @@ -518,29 +502,7 @@ protected: typedef CEditFindReplaceImpl thisClass; typedef CEditFindReplaceImplBase baseClass; -// Data members - LPTSTR m_pShadowBuffer; // Special shadow buffer only used in some cases. - UINT m_nShadowSize; - int m_bShadowBufferNeeded; // TRUE, FALSE, < 0 => Need to check - public: -// Constructors - CEditFindReplaceImpl() : - m_pShadowBuffer(NULL), - m_nShadowSize(0), - m_bShadowBufferNeeded(-1) - { - } - - virtual ~CEditFindReplaceImpl() - { - if(m_pShadowBuffer != NULL) - { - delete [] m_pShadowBuffer; - m_pShadowBuffer = NULL; - } - } - // Message Handlers BEGIN_MSG_MAP(thisClass) ALT_MSG_MAP(1) @@ -575,7 +537,7 @@ public: bool isDBCS = false; #ifdef _MBCS - CPINFO info = { 0 }; + CPINFO info = {}; ::GetCPInfo(::GetOEMCP(), &info); isDBCS = (info.MaxCharSize > 1); #endif @@ -650,9 +612,9 @@ public: while(lpsz <= lpszStop) { #ifndef _UNICODE - if(!bMatchCase || (*lpsz == *lpszFind && (!::IsDBCSLeadByte(*lpsz) || lpsz[1] == lpszFind[1]))) + if(!bMatchCase || ((*lpsz == *lpszFind) && (!::IsDBCSLeadByte(*lpsz) || (lpsz[1] == lpszFind[1])))) #else - if(!bMatchCase || (*lpsz == *lpszFind && lpsz[1] == lpszFind[1])) + if(!bMatchCase || ((*lpsz == *lpszFind) && (lpsz[1] == lpszFind[1]))) #endif { LPTSTR lpch = (LPTSTR)(lpsz + nLenFind); @@ -723,32 +685,18 @@ public: const T* pT = static_cast(this); ATLASSERT(pT->m_hWnd != NULL); - BOOL useShadowBuffer = pT->UseShadowBuffer(); - if(useShadowBuffer) - { - if((m_pShadowBuffer == NULL) || pT->GetModify()) - { - ATLASSERT((m_pShadowBuffer != NULL) || (m_nShadowSize == 0)); - UINT nSize = pT->GetWindowTextLength() + 1; - if(nSize > m_nShadowSize) - { - // need more room for shadow buffer - T* pThisNoConst = const_cast(pT); - delete[] m_pShadowBuffer; - pThisNoConst->m_pShadowBuffer = NULL; - pThisNoConst->m_nShadowSize = 0; - pThisNoConst->m_pShadowBuffer = new TCHAR[nSize]; - pThisNoConst->m_nShadowSize = nSize; - } - - // update the shadow buffer with GetWindowText - ATLASSERT(m_nShadowSize >= nSize); - ATLASSERT(m_pShadowBuffer != NULL); - pT->GetWindowText(m_pShadowBuffer, nSize); - } - - return m_pShadowBuffer; +#ifndef _UNICODE + // If common controls version 6 is in use (such as via theming), then EM_GETHANDLE + // will always return a UNICODE string. You're really not supposed to superclass + // or subclass common controls with an ANSI windows procedure. + DWORD dwMajor = 0, dwMinor = 0; + HRESULT hRet = ATL::AtlGetCommCtrlVersion(&dwMajor, &dwMinor); + if(SUCCEEDED(hRet) && (dwMajor >= 6)) + { + ATLTRACE2(atlTraceUI, 0, _T("AtlFind Warning: You have compiled for MBCS/ANSI but are using common controls version 6 or later which are always Unicode.\r\n")); + ATLASSERT(FALSE); } +#endif // !_UNICODE HLOCAL hLocal = pT->GetHandle(); ATLASSERT(hLocal != NULL); @@ -763,13 +711,9 @@ public: const T* pT = static_cast(this); ATLASSERT(pT->m_hWnd != NULL); - BOOL useShadowBuffer = pT->UseShadowBuffer(); - if(!useShadowBuffer) - { - HLOCAL hLocal = pT->GetHandle(); - ATLASSERT(hLocal != NULL); - ::LocalUnlock(hLocal); - } + HLOCAL hLocal = pT->GetHandle(); + ATLASSERT(hLocal != NULL); + ::LocalUnlock(hLocal); } UINT GetBufferLength() const @@ -790,12 +734,12 @@ public: { LPCTSTR lpsz = lpszText + nIndex; LPCTSTR lpszStop = lpszText + nLen; - while(lpsz < lpszStop && *lpsz != _T('\r')) + while((lpsz < lpszStop) && (*lpsz != _T('\r'))) ++lpsz; return LONG(lpsz - lpszText); } - LONG GetSelText(_CSTRING_NS::CString& strText) const + LONG GetSelText(ATL::CString& strText) const { const T* pT = static_cast(this); @@ -804,78 +748,12 @@ public: ATLASSERT((UINT)nEndChar <= pT->GetBufferLength()); LPCTSTR lpszText = pT->LockBuffer(); LONG nLen = pT->EndOfLine(lpszText, nEndChar, nStartChar) - nStartChar; - SecureHelper::memcpy_x(strText.GetBuffer(nLen), nLen * sizeof(TCHAR), lpszText + nStartChar, nLen * sizeof(TCHAR)); + ATL::Checked::memcpy_s(strText.GetBuffer(nLen), nLen * sizeof(TCHAR), lpszText + nStartChar, nLen * sizeof(TCHAR)); strText.ReleaseBuffer(nLen); pT->UnlockBuffer(); return nLen; } - - BOOL UseShadowBuffer(void) const - { - const T* pT = static_cast(this); - - if(pT->m_bShadowBufferNeeded < 0) - { - T* pThisNoConst = const_cast(pT); - -#ifdef _versionhelpers_H_INCLUDED_ - OSVERSIONINFOEX ovi = { sizeof(OSVERSIONINFOEX) }; - ovi.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS; - DWORDLONG const dwlConditionMask = ::VerSetConditionMask(0, VER_PLATFORMID, VER_EQUAL); - bool bWin9x = (::VerifyVersionInfo(&ovi, VER_PLATFORMID, dwlConditionMask) != FALSE); -#else // !_versionhelpers_H_INCLUDED_ - OSVERSIONINFO ovi = { sizeof(OSVERSIONINFO) }; - ::GetVersionEx(&ovi); - - bool bWin9x = (ovi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS); -#endif // _versionhelpers_H_INCLUDED_ - if(bWin9x) - { - // Windows 95, 98, ME - // Under Win9x, it is necessary to maintain a shadow buffer. - // It is only updated when the control contents have been changed. - pThisNoConst->m_bShadowBufferNeeded = TRUE; - } - else - { - // Windows NT, 2000, XP, etc. - pThisNoConst->m_bShadowBufferNeeded = FALSE; - -#ifndef _UNICODE - // On Windows XP (or later), if common controls version 6 is in use - // (such as via theming), then EM_GETHANDLE will always return a UNICODE string. - // If theming is enabled and Common Controls version 6 is in use, - // you're really not suppose to superclass or subclass common controls - // with an ANSI windows procedure (so its best to only theme if you use UNICODE). - // Using a shadow buffer uses GetWindowText instead, so it solves - // this problem for us (although it makes it a little less efficient). - -#ifdef _versionhelpers_H_INCLUDED_ - if(::IsWindowsXPOrGreater()) -#else // !_versionhelpers_H_INCLUDED_ - if ((ovi.dwMajorVersion == 5 && ovi.dwMinorVersion >= 1) || (ovi.dwMajorVersion > 5)) -#endif // _versionhelpers_H_INCLUDED_ - { - DWORD dwMajor = 0, dwMinor = 0; - HRESULT hRet = ATL::AtlGetCommCtrlVersion(&dwMajor, &dwMinor); - if(SUCCEEDED(hRet)) - { - if(dwMajor >= 6) - { - pThisNoConst->m_bShadowBufferNeeded = TRUE; - - ATLTRACE2(atlTraceUI, 0, _T("Warning: You have compiled for MBCS/ANSI but are using common controls version 6 or later (likely through a manifest file).\r\n")); - ATLTRACE2(atlTraceUI, 0, _T("If you use common controls version 6 or later, you should only do so for UNICODE builds.\r\n")); - } - } - } -#endif // !_UNICODE - } - } - - return (pT->m_bShadowBufferNeeded != FALSE); - } }; @@ -915,24 +793,19 @@ public: T* pT = static_cast(this); ATLASSERT(lpszFind != NULL); - FINDTEXTEX ft = { 0 }; + FINDTEXTEX ft = {}; pT->GetSel(ft.chrg); - if(m_bFirstSearch) + if(this->m_bFirstSearch) { if(bFindDown) - m_nInitialSearchPos = ft.chrg.cpMin; + this->m_nInitialSearchPos = ft.chrg.cpMin; else - m_nInitialSearchPos = ft.chrg.cpMax; - m_bFirstSearch = FALSE; + this->m_nInitialSearchPos = ft.chrg.cpMax; + this->m_bFirstSearch = FALSE; } -#if (_RICHEDIT_VER >= 0x0200) ft.lpstrText = (LPTSTR)lpszFind; -#else // !(_RICHEDIT_VER >= 0x0200) - USES_CONVERSION; - ft.lpstrText = T2A((LPTSTR)lpszFind); -#endif // !(_RICHEDIT_VER >= 0x0200) if(ft.chrg.cpMin != ft.chrg.cpMax) // i.e. there is a selection { @@ -950,11 +823,11 @@ public: DWORD dwFlags = bMatchCase ? FR_MATCHCASE : 0; dwFlags |= bWholeWord ? FR_WHOLEWORD : 0; - ft.chrg.cpMax = pT->GetTextLength() + m_nInitialSearchPos; + ft.chrg.cpMax = pT->GetTextLength() + this->m_nInitialSearchPos; if(bFindDown) { - if(m_nInitialSearchPos >= 0) + if(this->m_nInitialSearchPos >= 0) ft.chrg.cpMax = pT->GetTextLength(); dwFlags |= FR_DOWN; @@ -962,7 +835,7 @@ public: } else { - if(m_nInitialSearchPos >= 0) + if(this->m_nInitialSearchPos >= 0) ft.chrg.cpMax = 0; dwFlags &= ~FR_DOWN; @@ -974,21 +847,21 @@ public: { bRet = TRUE; // we found the text } - else if(m_nInitialSearchPos > 0) + else if(this->m_nInitialSearchPos > 0) { // if the original starting point was not the beginning // of the buffer and we haven't already been here if(bFindDown) { ft.chrg.cpMin = 0; - ft.chrg.cpMax = m_nInitialSearchPos; + ft.chrg.cpMax = this->m_nInitialSearchPos; } else { ft.chrg.cpMin = pT->GetTextLength(); - ft.chrg.cpMax = m_nInitialSearchPos; + ft.chrg.cpMax = this->m_nInitialSearchPos; } - m_nInitialSearchPos = m_nInitialSearchPos - pT->GetTextLength(); + this->m_nInitialSearchPos = this->m_nInitialSearchPos - pT->GetTextLength(); bRet = (pT->FindAndSelect(dwFlags, ft) != -1) ? TRUE : FALSE; } @@ -1007,6 +880,6 @@ public: } }; -}; // namespace WTL +} // namespace WTL #endif // __ATLFIND_H__ diff --git a/ZbaSDK/SampleCode/PluginWinExe/WTL/atlframe.h b/ZbaSDK/SampleCode/PluginWinExe/WTL/atlframe.h index e8dc66b7db9d3ce7cf0a84e316ab176aa1d501a6..604c1ab6b111dd6240b79c1bdb320299d941146c 100644 --- a/ZbaSDK/SampleCode/PluginWinExe/WTL/atlframe.h +++ b/ZbaSDK/SampleCode/PluginWinExe/WTL/atlframe.h @@ -1,4 +1,4 @@ -// Windows Template Library - WTL version 9.10 +// Windows Template Library - WTL version 10.0 // Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. // // This file is a part of the Windows Template Library. @@ -33,6 +33,7 @@ // CDynamicUpdateUI // CAutoUpdateUI // CDialogResize +// CDynamicDialogLayout // CDoubleBufferImpl // CDoubleBufferWindowImpl // @@ -49,13 +50,8 @@ namespace WTL class CFrameWndClassInfo { public: -#ifndef _WIN32_WCE enum { cchAutoName = 5 + sizeof(void*) * 2 }; // sizeof(void*) * 2 is the number of digits %p outputs WNDCLASSEX m_wc; -#else // CE specific - enum { cchAutoName = MAX_PATH }; // MAX_PATH because this can be set in the wizard generated CMainFrame::ActivatePreviousInstance to a user defined string. - WNDCLASS m_wc; -#endif // !_WIN32_WCE LPCTSTR m_lpszOrigName; WNDPROC pWndProc; LPCTSTR m_lpszCursorID; @@ -64,7 +60,6 @@ public: TCHAR m_szAutoName[cchAutoName]; UINT m_uCommonResourceID; -#ifndef _WIN32_WCE ATOM Register(WNDPROC* pProc) { if (m_atom == 0) @@ -112,11 +107,7 @@ public: m_wc.style &= ~CS_GLOBALCLASS; // we don't register global classes if (m_wc.lpszClassName == NULL) { -#if (_WIN32_WINNT >= 0x0500) || defined(_WIN64) - SecureHelper::wsprintf_x(m_szAutoName, cchAutoName, _T("ATL:%p"), &m_wc); -#else // !((_WIN32_WINNT >= 0x0500) || defined(_WIN64)) - SecureHelper::wsprintf_x(m_szAutoName, cchAutoName, _T("ATL:%8.8X"), (DWORD_PTR)&m_wc); -#endif // !((_WIN32_WINNT >= 0x0500) || defined(_WIN64)) + _stprintf_s(m_szAutoName, cchAutoName, _T("ATL:%p"), &m_wc); m_wc.lpszClassName = m_szAutoName; } @@ -149,95 +140,12 @@ public: return m_atom; } -#else // CE specific - ATOM Register(WNDPROC* pProc) - { - if (m_atom == 0) - { - CWindowCreateCriticalSectionLock lock; - if(FAILED(lock.Lock())) - { - ATLTRACE2(atlTraceUI, 0, _T("ERROR : Unable to lock critical section in CFrameWndClassInfo::Register.\n")); - ATLASSERT(FALSE); - return 0; - } - - if(m_atom == 0) - { - HINSTANCE hInst = ModuleHelper::GetModuleInstance(); - - if (m_lpszOrigName != NULL) - { - ATLASSERT(pProc != NULL); - LPCTSTR lpsz = m_wc.lpszClassName; - WNDPROC proc = m_wc.lpfnWndProc; - - WNDCLASS wc = { 0 }; - // try process local class first - if(!::GetClassInfo(ModuleHelper::GetModuleInstance(), m_lpszOrigName, &wc)) - { - // try global class - if(!::GetClassInfo(NULL, m_lpszOrigName, &wc)) - { - lock.Unlock(); - return 0; - } - } - m_wc = wc; - pWndProc = m_wc.lpfnWndProc; - m_wc.lpszClassName = lpsz; - m_wc.lpfnWndProc = proc; - } - else - { -#if defined(GWES_CURSOR) || defined(GWES_MCURSOR) - m_wc.hCursor = ::LoadCursor(m_bSystemCursor ? NULL : hInst, m_lpszCursorID); -#else // !(defined(GWES_CURSOR) || defined(GWES_MCURSOR)) - m_wc.hCursor = NULL; -#endif // !(defined(GWES_CURSOR) || defined(GWES_MCURSOR)) - } - - m_wc.hInstance = hInst; - m_wc.style &= ~CS_GLOBALCLASS; // we don't register global classes - if (m_wc.lpszClassName == NULL) - { - wsprintf(m_szAutoName, _T("ATL:%8.8X"), (DWORD_PTR)&m_wc); - m_wc.lpszClassName = m_szAutoName; - } - - WNDCLASS wcTemp = m_wc; - m_atom = (ATOM)::GetClassInfo(m_wc.hInstance, m_wc.lpszClassName, &wcTemp); - if (m_atom == 0) - { - if(m_uCommonResourceID != 0) // use it if not zero - m_wc.hIcon = (HICON)::LoadImage(ModuleHelper::GetResourceInstance(), - MAKEINTRESOURCE(m_uCommonResourceID), IMAGE_ICON, - ::GetSystemMetrics(SM_CXICON), ::GetSystemMetrics(SM_CYICON), LR_DEFAULTCOLOR); - m_atom = ::RegisterClass(&m_wc); - } - } - - lock.Unlock(); - } - - if (m_lpszOrigName != NULL) - { - ATLASSERT(pProc != NULL); - ATLASSERT(pWndProc != NULL); - *pProc = pWndProc; - } - - return m_atom; - } -#endif // _WIN32_WCE }; /////////////////////////////////////////////////////////////////////////////// // Macros for declaring frame window WNDCLASS -#ifndef _WIN32_WCE - #define DECLARE_FRAME_WND_CLASS(WndClassName, uCommonResourceID) \ static WTL::CFrameWndClassInfo& GetWndClassInfo() \ { \ @@ -274,54 +182,51 @@ static WTL::CFrameWndClassInfo& GetWndClassInfo() \ return wc; \ } -#else // CE specific - -#define DECLARE_FRAME_WND_CLASS(WndClassName, uCommonResourceID) \ +// These are for templated classes +#define DECLARE_FRAME_WND_CLASS2(WndClassName, EnclosingClass, uCommonResourceID) \ static WTL::CFrameWndClassInfo& GetWndClassInfo() \ { \ static WTL::CFrameWndClassInfo wc = \ { \ - { 0, StartWindowProc, \ - 0, 0, NULL, NULL, NULL, (HBRUSH)(COLOR_WINDOW + 1), NULL, WndClassName }, \ + { sizeof(WNDCLASSEX), 0, EnclosingClass::StartWindowProc, \ + 0, 0, NULL, NULL, NULL, (HBRUSH)(COLOR_WINDOW + 1), NULL, WndClassName, NULL }, \ NULL, NULL, IDC_ARROW, TRUE, 0, _T(""), uCommonResourceID \ }; \ return wc; \ } -#define DECLARE_FRAME_WND_CLASS_EX(WndClassName, uCommonResourceID, style, bkgnd) \ +#define DECLARE_FRAME_WND_CLASS_EX2(WndClassName, EnclosingClass, uCommonResourceID, style, bkgnd) \ static WTL::CFrameWndClassInfo& GetWndClassInfo() \ { \ static WTL::CFrameWndClassInfo wc = \ { \ - { style, StartWindowProc, \ - 0, 0, NULL, NULL, NULL, (HBRUSH)(bkgnd + 1), NULL, WndClassName }, \ + { sizeof(WNDCLASSEX), style, EnclosingClass::StartWindowProc, \ + 0, 0, NULL, NULL, NULL, (HBRUSH)(bkgnd + 1), NULL, WndClassName, NULL }, \ NULL, NULL, IDC_ARROW, TRUE, 0, _T(""), uCommonResourceID \ }; \ return wc; \ } -#define DECLARE_FRAME_WND_SUPERCLASS(WndClassName, OrigWndClassName, uCommonResourceID) \ +#define DECLARE_FRAME_WND_SUPERCLASS2(WndClassName, EnclosingClass, OrigWndClassName, uCommonResourceID) \ static WTL::CFrameWndClassInfo& GetWndClassInfo() \ { \ static WTL::CFrameWndClassInfo wc = \ { \ - { NULL, StartWindowProc, \ - 0, 0, NULL, NULL, NULL, NULL, NULL, WndClassName }, \ - OrigWndClassName, NULL, IDC_ARROW, TRUE, 0, _T(""), uCommonResourceID \ + { sizeof(WNDCLASSEX), 0, EnclosingClass::StartWindowProc, \ + 0, 0, NULL, NULL, NULL, NULL, NULL, WndClassName, NULL }, \ + OrigWndClassName, NULL, NULL, TRUE, 0, _T(""), uCommonResourceID \ }; \ return wc; \ } -#endif // !_WIN32_WCE - /////////////////////////////////////////////////////////////////////////////// // CFrameWindowImpl // Client window command chaining macro (only for frame windows) #define CHAIN_CLIENT_COMMANDS() \ - if(uMsg == WM_COMMAND && m_hWndClient != NULL) \ - ::SendMessage(m_hWndClient, uMsg, wParam, lParam); + if((uMsg == WM_COMMAND) && (this->m_hWndClient != NULL)) \ + ::SendMessage(this->m_hWndClient, uMsg, wParam, lParam); // standard toolbar styles #define ATL_SIMPLE_TOOLBAR_STYLE \ @@ -330,24 +235,14 @@ static WTL::CFrameWndClassInfo& GetWndClassInfo() \ #define ATL_SIMPLE_TOOLBAR_PANE_STYLE \ (WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | CCS_NODIVIDER | CCS_NORESIZE | CCS_NOPARENTALIGN | TBSTYLE_TOOLTIPS | TBSTYLE_FLAT) // standard rebar styles -#if (_WIN32_IE >= 0x0400) #define ATL_SIMPLE_REBAR_STYLE \ (WS_CHILD | WS_VISIBLE | WS_BORDER | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | RBS_VARHEIGHT | RBS_BANDBORDERS | RBS_AUTOSIZE) -#else - #define ATL_SIMPLE_REBAR_STYLE \ - (WS_CHILD | WS_VISIBLE | WS_BORDER | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | RBS_VARHEIGHT | RBS_BANDBORDERS) -#endif // !(_WIN32_IE >= 0x0400) // rebar without borders -#if (_WIN32_IE >= 0x0400) #define ATL_SIMPLE_REBAR_NOBORDER_STYLE \ (WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | RBS_VARHEIGHT | RBS_BANDBORDERS | RBS_AUTOSIZE | CCS_NODIVIDER) -#else - #define ATL_SIMPLE_REBAR_NOBORDER_STYLE \ - (WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | RBS_VARHEIGHT | RBS_BANDBORDERS | CCS_NODIVIDER) -#endif // !(_WIN32_IE >= 0x0400) // command bar support -#if !defined(__ATLCTRLW_H__) && !defined(_WIN32_WCE) +#if !defined(__ATLCTRLW_H__) #define CBRM_GETCMDBAR (WM_USER + 301) // returns command bar HWND #define CBRM_GETMENU (WM_USER + 302) // returns loaded or attached menu @@ -365,33 +260,28 @@ struct _AtlFrameWnd_CmdBarPopupMenu #define CBRPOPUPMENU _AtlFrameWnd_CmdBarPopupMenu -#endif // !defined(__ATLCTRLW_H__) && !defined(_WIN32_WCE) +#endif // !defined(__ATLCTRLW_H__) template class ATL_NO_VTABLE CFrameWindowImplBase : public ATL::CWindowImplBaseT< TBase, TWinTraits > { public: - DECLARE_FRAME_WND_CLASS(NULL, 0) + typedef CFrameWindowImplBase _thisClass; + DECLARE_FRAME_WND_CLASS2(NULL, _thisClass, 0) -#if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) struct _ChevronMenuInfo { HMENU hMenu; LPNMREBARCHEVRON lpnm; bool bCmdBar; }; -#endif // (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) // Data members HWND m_hWndToolBar; HWND m_hWndStatusBar; HWND m_hWndClient; -#ifdef _WIN32_WCE - HWND m_hWndCECommandBar; -#endif // _WIN32_WCE - HACCEL m_hAccel; // Constructor @@ -399,33 +289,28 @@ public: m_hWndToolBar(NULL), m_hWndStatusBar(NULL), m_hWndClient(NULL), -#ifdef _WIN32_WCE - m_hWndCECommandBar(NULL), -#endif // _WIN32_WCE m_hAccel(NULL) { } // Methods HWND Create(HWND hWndParent, ATL::_U_RECT rect, LPCTSTR szWindowName, DWORD dwStyle, DWORD dwExStyle, ATL::_U_MENUorID MenuOrID, ATOM atom, LPVOID lpCreateParam) { - ATLASSERT(m_hWnd == NULL); + ATLASSERT(this->m_hWnd == NULL); -#if (_ATL_VER >= 0x0800) // Allocate the thunk structure here, where we can fail gracefully. - BOOL bRet = m_thunk.Init(NULL, NULL); + BOOL bRet = this->m_thunk.Init(NULL, NULL); if(bRet == FALSE) { ::SetLastError(ERROR_OUTOFMEMORY); return NULL; } -#endif // (_ATL_VER >= 0x0800) if(atom == 0) return NULL; - ModuleHelper::AddCreateWndData(&m_thunk.cd, this); + ModuleHelper::AddCreateWndData(&this->m_thunk.cd, this); - if(MenuOrID.m_hMenu == NULL && (dwStyle & WS_CHILD)) + if((MenuOrID.m_hMenu == NULL) && (dwStyle & WS_CHILD)) MenuOrID.m_hMenu = (HMENU)(UINT_PTR)this; if(rect.m_lpRect == NULL) rect.m_lpRect = &TBase::rcDefault; @@ -435,7 +320,7 @@ public: rect.m_lpRect->bottom - rect.m_lpRect->top, hWndParent, MenuOrID.m_hMenu, ModuleHelper::GetModuleInstance(), lpCreateParam); - ATLASSERT(hWnd == NULL || m_hWnd == hWnd); + ATLASSERT((hWnd == NULL) || (this->m_hWnd == hWnd)); return hWnd; } @@ -459,7 +344,7 @@ public: WORD* pItems = pData->items(); int nItems = pData->wItemCount + (bInitialSeparator ? 1 : 0); - CTempBuffer buff; + ATL::CTempBuffer buff; TBBUTTON* pTBBtn = buff.Allocate(nItems); ATLASSERT(pTBBtn != NULL); if(pTBBtn == NULL) @@ -501,19 +386,12 @@ public: } } -#ifndef _WIN32_WCE HWND hWnd = ::CreateWindowEx(0, TOOLBARCLASSNAME, NULL, dwStyle, 0, 0, 100, 100, hWndParent, (HMENU)LongToHandle(nID), ModuleHelper::GetModuleInstance(), NULL); if(hWnd == NULL) { ATLASSERT(FALSE); return NULL; } -#else // CE specific - dwStyle; - nID; - // The toolbar must go onto the existing CommandBar or MenuBar - HWND hWnd = hWndParent; -#endif // _WIN32_WCE ::SendMessage(hWnd, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0L); @@ -521,11 +399,10 @@ public: CFontHandle font = (HFONT)::SendMessage(hWnd, WM_GETFONT, 0, 0L); if(font.IsNull()) font = (HFONT)::GetStockObject(SYSTEM_FONT); - LOGFONT lf = { 0 }; + LOGFONT lf = {}; font.GetLogFont(lf); WORD cyFontHeight = (WORD)abs(lf.lfHeight); -#ifndef _WIN32_WCE WORD bitsPerPixel = AtlGetBitmapResourceBitsPerPixel(nResourceID); if(bitsPerPixel > 4) { @@ -540,9 +417,8 @@ public: ::SendMessage(hWnd, TB_SETIMAGELIST, 0, (LPARAM)hImageList); } else -#endif // !_WIN32_WCE { - TBADDBITMAP tbab = { 0 }; + TBADDBITMAP tbab = {}; tbab.hInst = hInst; tbab.nID = nResourceID; ::SendMessage(hWnd, TB_ADDBITMAP, nBmp, (LPARAM)&tbab); @@ -556,11 +432,10 @@ public: return hWnd; } -#ifndef _WIN32_WCE static HWND CreateSimpleReBarCtrl(HWND hWndParent, DWORD dwStyle = ATL_SIMPLE_REBAR_STYLE, UINT nID = ATL_IDW_TOOLBAR) { // Ensure style combinations for proper rebar painting - if(dwStyle & CCS_NODIVIDER && dwStyle & WS_BORDER) + if(dwStyle & CCS_NODIVIDER && (dwStyle & WS_BORDER)) dwStyle &= ~WS_BORDER; else if(!(dwStyle & WS_BORDER) && !(dwStyle & CCS_NODIVIDER)) dwStyle |= CCS_NODIVIDER; @@ -588,7 +463,7 @@ public: BOOL CreateSimpleReBar(DWORD dwStyle = ATL_SIMPLE_REBAR_STYLE, UINT nID = ATL_IDW_TOOLBAR) { ATLASSERT(!::IsWindow(m_hWndToolBar)); - m_hWndToolBar = CreateSimpleReBarCtrl(m_hWnd, dwStyle, nID); + m_hWndToolBar = CreateSimpleReBarCtrl(this->m_hWnd, dwStyle, nID); return (m_hWndToolBar != NULL); } @@ -598,7 +473,7 @@ public: #ifdef _DEBUG // block - check if this is really a rebar { - TCHAR lpszClassName[sizeof(REBARCLASSNAME)] = { 0 }; + TCHAR lpszClassName[sizeof(REBARCLASSNAME)] = {}; ::GetClassName(hWndReBar, lpszClassName, sizeof(REBARCLASSNAME)); ATLASSERT(lstrcmp(lpszClassName, REBARCLASSNAME) == 0); } @@ -610,18 +485,12 @@ public: // Set band info structure REBARBANDINFO rbBand = { RunTimeHelper::SizeOf_REBARBANDINFO() }; -#if (_WIN32_IE >= 0x0400) rbBand.fMask = RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_STYLE | RBBIM_ID | RBBIM_SIZE | RBBIM_IDEALSIZE; -#else - rbBand.fMask = RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_STYLE | RBBIM_ID | RBBIM_SIZE; -#endif // !(_WIN32_IE >= 0x0400) if(lpstrTitle != NULL) rbBand.fMask |= RBBIM_TEXT; rbBand.fStyle = RBBS_CHILDEDGE; -#if (_WIN32_IE >= 0x0500) if(nBtnCount > 0) // add chevron style for toolbar with buttons rbBand.fStyle |= RBBS_USECHEVRON; -#endif // (_WIN32_IE >= 0x0500) if(bNewRow) rbBand.fStyle |= RBBS_BREAK; @@ -633,7 +502,7 @@ public: // Calculate the size of the band BOOL bRet = FALSE; - RECT rcTmp = { 0 }; + RECT rcTmp = {}; if(nBtnCount > 0) { bRet = (BOOL)::SendMessage(hWndBand, TB_GETITEMRECT, nBtnCount - 1, (LPARAM)&rcTmp); @@ -664,9 +533,7 @@ public: rbBand.cyMinChild = rcTmp.bottom - rcTmp.top; } -#if (_WIN32_IE >= 0x0400) rbBand.cxIdeal = rbBand.cx; -#endif // (_WIN32_IE >= 0x0400) // Add the band LRESULT lRes = ::SendMessage(hWndReBar, RB_INSERTBAND, (WPARAM)-1, (LPARAM)&rbBand); @@ -676,10 +543,8 @@ public: return FALSE; } -#if (_WIN32_IE >= 0x0501) DWORD dwExStyle = (DWORD)::SendMessage(hWndBand, TB_GETEXTENDEDSTYLE, 0, 0L); ::SendMessage(hWndBand, TB_SETEXTENDEDSTYLE, 0, dwExStyle | TBSTYLE_EX_HIDECLIPPEDBUTTONS); -#endif // (_WIN32_IE >= 0x0501) return TRUE; } @@ -691,7 +556,6 @@ public: return AddSimpleReBarBandCtrl(m_hWndToolBar, hWndBand, 0, lpstrTitle, bNewRow, cxWidth, bFullWidthAlways); } -#if (_WIN32_IE >= 0x0400) void SizeSimpleReBarBands() { ATLASSERT(::IsWindow(m_hWndToolBar)); // must be an existing rebar @@ -704,105 +568,33 @@ public: rbBand.fMask = RBBIM_SIZE; BOOL bRet = (BOOL)::SendMessage(m_hWndToolBar, RB_GETBANDINFO, i, (LPARAM)&rbBand); ATLASSERT(bRet); - RECT rect = { 0 }; + RECT rect = {}; ::SendMessage(m_hWndToolBar, RB_GETBANDBORDERS, i, (LPARAM)&rect); rbBand.cx += rect.left + rect.right; bRet = (BOOL)::SendMessage(m_hWndToolBar, RB_SETBANDINFO, i, (LPARAM)&rbBand); ATLASSERT(bRet); } } -#endif // (_WIN32_IE >= 0x0400) -#endif // _WIN32_WCE -#ifndef _WIN32_WCE BOOL CreateSimpleStatusBar(LPCTSTR lpstrText, DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | SBARS_SIZEGRIP, UINT nID = ATL_IDW_STATUS_BAR) -#else // CE specific - BOOL CreateSimpleStatusBar(LPCTSTR lpstrText, DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, UINT nID = ATL_IDW_STATUS_BAR) -#endif // _WIN32_WCE { ATLASSERT(!::IsWindow(m_hWndStatusBar)); - m_hWndStatusBar = ::CreateStatusWindow(dwStyle, lpstrText, m_hWnd, nID); + m_hWndStatusBar = ::CreateStatusWindow(dwStyle, lpstrText, this->m_hWnd, nID); return (m_hWndStatusBar != NULL); } -#ifndef _WIN32_WCE BOOL CreateSimpleStatusBar(UINT nTextID = ATL_IDS_IDLEMESSAGE, DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | SBARS_SIZEGRIP, UINT nID = ATL_IDW_STATUS_BAR) -#else // CE specific - BOOL CreateSimpleStatusBar(UINT nTextID = ATL_IDS_IDLEMESSAGE, DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, UINT nID = ATL_IDW_STATUS_BAR) -#endif // _WIN32_WCE { const int cchMax = 128; // max text length is 127 for status bars (+1 for null) - TCHAR szText[cchMax] = { 0 }; + TCHAR szText[cchMax] = {}; ::LoadString(ModuleHelper::GetResourceInstance(), nTextID, szText, cchMax); return CreateSimpleStatusBar(szText, dwStyle, nID); } -#ifdef _WIN32_WCE - BOOL CreateSimpleCECommandBar(LPTSTR pszMenu = NULL, WORD iButton = 0, DWORD dwFlags = 0, int nCmdBarID = 1) - { - ATLASSERT(m_hWndCECommandBar == NULL); - ATLASSERT(m_hWndToolBar == NULL); - - m_hWndCECommandBar = ::CommandBar_Create(ModuleHelper::GetModuleInstance(), m_hWnd, nCmdBarID); - if(m_hWndCECommandBar == NULL) - return FALSE; - - m_hWndToolBar = m_hWndCECommandBar; - - BOOL bRet = TRUE; - - if(pszMenu != NULL) - bRet &= ::CommandBar_InsertMenubarEx(m_hWndCECommandBar, IS_INTRESOURCE(pszMenu) ? ModuleHelper::GetResourceInstance() : NULL, pszMenu, iButton); - - bRet &= ::CommandBar_AddAdornments(m_hWndCECommandBar, dwFlags, 0); - - return bRet; - } - -#if defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) - BOOL CreateSimpleCEMenuBar(UINT nToolBarId = ATL_IDW_MENU_BAR, DWORD dwFlags = 0, int nBmpId = 0, int cBmpImages = 0) - { - ATLASSERT(m_hWndCECommandBar == NULL); - - SHMENUBARINFO mbi = { 0 }; - mbi.cbSize = sizeof(mbi); - mbi.hwndParent = m_hWnd; - mbi.dwFlags = dwFlags; - mbi.nToolBarId = nToolBarId; - mbi.hInstRes = ModuleHelper::GetResourceInstance(); - mbi.nBmpId = nBmpId; - mbi.cBmpImages = cBmpImages; - mbi.hwndMB = NULL; // This gets set by SHCreateMenuBar - - BOOL bRet = ::SHCreateMenuBar(&mbi); - if(bRet != FALSE) - { - m_hWndCECommandBar = mbi.hwndMB; - SizeToMenuBar(); - } - - return bRet; - } - - void SizeToMenuBar() // for menu bar only - { - ATLASSERT(::IsWindow(m_hWnd)); - ATLASSERT(::IsWindow(m_hWndCECommandBar)); - - RECT rect = { 0 }; - GetWindowRect(&rect); - RECT rectMB = { 0 }; - ::GetWindowRect(m_hWndCECommandBar, &rectMB); - int cy = ::IsWindowVisible(m_hWndCECommandBar) ? rectMB.top - rect.top : rectMB.bottom - rect.top; - SetWindowPos(NULL, 0, 0, rect.right - rect.left, cy, SWP_NOZORDER | SWP_NOMOVE); - } -#endif // defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) -#endif // _WIN32_WCE - void UpdateLayout(BOOL bResizeBars = TRUE) { - RECT rect = { 0 }; - GetClientRect(&rect); + RECT rect = {}; + this->GetClientRect(&rect); // position bars and offset their dimensions UpdateBarsPosition(rect, bResizeBars); @@ -817,24 +609,24 @@ public: void UpdateBarsPosition(RECT& rect, BOOL bResizeBars = TRUE) { // resize toolbar - if(m_hWndToolBar != NULL && ((DWORD)::GetWindowLong(m_hWndToolBar, GWL_STYLE) & WS_VISIBLE)) + if((m_hWndToolBar != NULL) && ((DWORD)::GetWindowLong(m_hWndToolBar, GWL_STYLE) & WS_VISIBLE)) { if(bResizeBars != FALSE) { ::SendMessage(m_hWndToolBar, WM_SIZE, 0, 0); ::InvalidateRect(m_hWndToolBar, NULL, TRUE); } - RECT rectTB = { 0 }; + RECT rectTB = {}; ::GetWindowRect(m_hWndToolBar, &rectTB); rect.top += rectTB.bottom - rectTB.top; } // resize status bar - if(m_hWndStatusBar != NULL && ((DWORD)::GetWindowLong(m_hWndStatusBar, GWL_STYLE) & WS_VISIBLE)) + if((m_hWndStatusBar != NULL) && ((DWORD)::GetWindowLong(m_hWndStatusBar, GWL_STYLE) & WS_VISIBLE)) { if(bResizeBars != FALSE) ::SendMessage(m_hWndStatusBar, WM_SIZE, 0, 0); - RECT rectSB = { 0 }; + RECT rectSB = {}; ::GetWindowRect(m_hWndStatusBar, &rectSB); rect.bottom -= rectSB.bottom - rectSB.top; } @@ -842,22 +634,18 @@ public: BOOL PreTranslateMessage(MSG* pMsg) { - if(m_hAccel != NULL && ::TranslateAccelerator(m_hWnd, m_hAccel, pMsg)) + if((m_hAccel != NULL) && ::TranslateAccelerator(this->m_hWnd, m_hAccel, pMsg)) return TRUE; return FALSE; } BEGIN_MSG_MAP(CFrameWindowImplBase) MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackground) -#ifndef _WIN32_WCE MESSAGE_HANDLER(WM_MENUSELECT, OnMenuSelect) -#endif // !_WIN32_WCE MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus) MESSAGE_HANDLER(WM_DESTROY, OnDestroy) -#ifndef _WIN32_WCE NOTIFY_CODE_HANDLER(TTN_GETDISPINFOA, OnToolTipTextA) NOTIFY_CODE_HANDLER(TTN_GETDISPINFOW, OnToolTipTextW) -#endif // !_WIN32_WCE END_MSG_MAP() LRESULT OnEraseBackground(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) @@ -869,7 +657,6 @@ public: return 0; } -#ifndef _WIN32_WCE LRESULT OnMenuSelect(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { bHandled = FALSE; @@ -878,23 +665,23 @@ public: return 1; WORD wFlags = HIWORD(wParam); - if(wFlags == 0xFFFF && lParam == NULL) // menu closing + if((wFlags == 0xFFFF) && (lParam == NULL)) // menu closing { ::SendMessage(m_hWndStatusBar, SB_SIMPLE, FALSE, 0L); } else { const int cchBuff = 256; - TCHAR szBuff[cchBuff] = { 0 }; + TCHAR szBuff[cchBuff] = {}; if(!(wFlags & MF_POPUP)) { WORD wID = LOWORD(wParam); // check for special cases - if(wID >= 0xF000 && wID < 0xF1F0) // system menu IDs + if((wID >= 0xF000) && (wID < 0xF1F0)) // system menu IDs wID = (WORD)(((wID - 0xF000) >> 4) + ATL_IDS_SCFIRST); - else if(wID >= ID_FILE_MRU_FIRST && wID <= ID_FILE_MRU_LAST) // MRU items + else if((wID >= ID_FILE_MRU_FIRST) && (wID <= ID_FILE_MRU_LAST)) // MRU items wID = ATL_IDS_MRU_FILE; - else if(wID >= ATL_IDM_FIRST_MDICHILD && wID <= ATL_IDM_LAST_MDICHILD) // MDI child windows + else if((wID >= ATL_IDM_FIRST_MDICHILD) && (wID <= ATL_IDM_LAST_MDICHILD)) // MDI child windows wID = ATL_IDS_MDICHILD; int nRet = ::LoadString(ModuleHelper::GetResourceInstance(), wID, szBuff, cchBuff); @@ -913,7 +700,6 @@ public: return 1; } -#endif // !_WIN32_WCE LRESULT OnSetFocus(UINT, WPARAM, LPARAM, BOOL& bHandled) { @@ -926,34 +712,31 @@ public: LRESULT OnDestroy(UINT, WPARAM, LPARAM, BOOL& bHandled) { - if((GetStyle() & (WS_CHILD | WS_POPUP)) == 0) + if((this->GetStyle() & (WS_CHILD | WS_POPUP)) == 0) ::PostQuitMessage(1); bHandled = FALSE; return 1; } -#ifndef _WIN32_WCE LRESULT OnToolTipTextA(int idCtrl, LPNMHDR pnmh, BOOL& /*bHandled*/) { LPNMTTDISPINFOA pDispInfo = (LPNMTTDISPINFOA)pnmh; if((idCtrl != 0) && !(pDispInfo->uFlags & TTF_IDISHWND)) { const int cchBuff = 256; - char szBuff[cchBuff] = { 0 }; + char szBuff[cchBuff] = {}; int nRet = ::LoadStringA(ModuleHelper::GetResourceInstance(), idCtrl, szBuff, cchBuff); for(int i = 0; i < nRet; i++) { if(szBuff[i] == '\n') { - SecureHelper::strncpyA_x(pDispInfo->szText, _countof(pDispInfo->szText), &szBuff[i + 1], _TRUNCATE); + ATL::Checked::strncpy_s(pDispInfo->szText, _countof(pDispInfo->szText), &szBuff[i + 1], _TRUNCATE); break; } } -#if (_WIN32_IE >= 0x0300) if(nRet > 0) // string was loaded, save it pDispInfo->uFlags |= TTF_DI_SETITEM; -#endif // (_WIN32_IE >= 0x0300) } return 0; @@ -965,28 +748,24 @@ public: if((idCtrl != 0) && !(pDispInfo->uFlags & TTF_IDISHWND)) { const int cchBuff = 256; - wchar_t szBuff[cchBuff] = { 0 }; + wchar_t szBuff[cchBuff] = {}; int nRet = ::LoadStringW(ModuleHelper::GetResourceInstance(), idCtrl, szBuff, cchBuff); for(int i = 0; i < nRet; i++) { if(szBuff[i] == L'\n') { - SecureHelper::strncpyW_x(pDispInfo->szText, _countof(pDispInfo->szText), &szBuff[i + 1], _TRUNCATE); + ATL::Checked::wcsncpy_s(pDispInfo->szText, _countof(pDispInfo->szText), &szBuff[i + 1], _TRUNCATE); break; } } -#if (_WIN32_IE >= 0x0300) if(nRet > 0) // string was loaded, save it pDispInfo->uFlags |= TTF_DI_SETITEM; -#endif // (_WIN32_IE >= 0x0300) } return 0; } -#endif // !_WIN32_WCE // Implementation - chevron menu support -#if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) bool PrepareChevronMenu(_ChevronMenuInfo& cmi) { // get rebar and toolbar @@ -1009,18 +788,18 @@ public: CMenuHandle menu; bRet = menu.CreatePopupMenu(); ATLASSERT(bRet); - RECT rcClient = { 0 }; + RECT rcClient = {}; bRet = wnd.GetClientRect(&rcClient); ATLASSERT(bRet); for(int i = 0; i < nCount; i++) { - TBBUTTON tbb = { 0 }; + TBBUTTON tbb = {}; bRet = (BOOL)wnd.SendMessage(TB_GETBUTTON, i, (LPARAM)&tbb); ATLASSERT(bRet); // skip hidden buttons if((tbb.fsState & TBSTATE_HIDDEN) != 0) continue; - RECT rcButton = { 0 }; + RECT rcButton = {}; bRet = (BOOL)wnd.SendMessage(TB_GETITEMRECT, i, (LPARAM)&rcButton); ATLASSERT(bRet); bool bEnabled = ((tbb.fsState & TBSTATE_ENABLED) != 0); @@ -1034,7 +813,7 @@ public: else if(cmi.bCmdBar) { const int cchBuff = 200; - TCHAR szBuff[cchBuff] = { 0 }; + TCHAR szBuff[cchBuff] = {}; CMenuItemInfo mii; mii.fMask = MIIM_TYPE | MIIM_SUBMENU; mii.dwTypeData = szBuff; @@ -1050,9 +829,9 @@ public: { // get button's text const int cchBuff = 200; - TCHAR szBuff[cchBuff] = { 0 }; + TCHAR szBuff[cchBuff] = {}; LPCTSTR lpstrText = szBuff; - TBBUTTONINFO tbbi = { 0 }; + TBBUTTONINFO tbbi = {}; tbbi.cbSize = sizeof(TBBUTTONINFO); tbbi.dwMask = TBIF_TEXT; tbbi.pszText = szBuff; @@ -1090,9 +869,6 @@ public: void DisplayChevronMenu(_ChevronMenuInfo& cmi) { -#ifndef TPM_VERPOSANIMATION - const UINT TPM_VERPOSANIMATION = 0x1000L; // Menu animation flag -#endif // convert chevron rect to screen coordinates ATL::CWindow wndFrom = cmi.lpnm->hdr.hwndFrom; POINT pt = { cmi.lpnm->rc.left, cmi.lpnm->rc.bottom }; @@ -1100,12 +876,12 @@ public: RECT rc = cmi.lpnm->rc; wndFrom.MapWindowPoints(NULL, &rc); // set up flags and rect - UINT uMenuFlags = TPM_LEFTBUTTON | TPM_VERTICAL | TPM_LEFTALIGN | TPM_TOPALIGN | (!AtlIsOldWindows() ? TPM_VERPOSANIMATION : 0); - TPMPARAMS TPMParams = { 0 }; + UINT uMenuFlags = TPM_LEFTBUTTON | TPM_VERTICAL | TPM_LEFTALIGN | TPM_TOPALIGN | TPM_VERPOSANIMATION; + TPMPARAMS TPMParams = {}; TPMParams.cbSize = sizeof(TPMPARAMS); TPMParams.rcExclude = rc; // check if this window has a command bar - HWND hWndCmdBar = (HWND)::SendMessage(m_hWnd, CBRM_GETCMDBAR, 0, 0L); + HWND hWndCmdBar = (HWND)::SendMessage(this->m_hWnd, CBRM_GETCMDBAR, 0, 0L); if(::IsWindow(hWndCmdBar)) { CBRPOPUPMENU CBRPopupMenu = { sizeof(CBRPOPUPMENU), cmi.hMenu, uMenuFlags, pt.x, pt.y, &TPMParams }; @@ -1114,7 +890,7 @@ public: else { CMenuHandle menu = cmi.hMenu; - menu.TrackPopupMenuEx(uMenuFlags, pt.x, pt.y, m_hWnd, &TPMParams); + menu.TrackPopupMenuEx(uMenuFlags, pt.x, pt.y, this->m_hWnd, &TPMParams); } } @@ -1134,11 +910,10 @@ public: RECT rc = cmi.lpnm->rc; wndFrom.MapWindowPoints(NULL, &rc); // eat next message if click is on the same button - MSG msg = { 0 }; - if(::PeekMessage(&msg, m_hWnd, WM_LBUTTONDOWN, WM_LBUTTONDOWN, PM_NOREMOVE) && ::PtInRect(&rc, msg.pt)) - ::PeekMessage(&msg, m_hWnd, WM_LBUTTONDOWN, WM_LBUTTONDOWN, PM_REMOVE); + MSG msg = {}; + if(::PeekMessage(&msg, this->m_hWnd, WM_LBUTTONDOWN, WM_LBUTTONDOWN, PM_NOREMOVE) && ::PtInRect(&rc, msg.pt)) + ::PeekMessage(&msg, this->m_hWnd, WM_LBUTTONDOWN, WM_LBUTTONDOWN, PM_REMOVE); } -#endif // (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) }; @@ -1150,7 +925,7 @@ public: DWORD dwStyle = 0, DWORD dwExStyle = 0, HMENU hMenu = NULL, LPVOID lpCreateParam = NULL) { - ATOM atom = T::GetWndClassInfo().Register(&m_pfnSuperWindowProc); + ATOM atom = T::GetWndClassInfo().Register(&this->m_pfnSuperWindowProc); dwStyle = T::GetWndStyle(dwStyle); dwExStyle = T::GetWndExStyle(dwExStyle); @@ -1164,24 +939,15 @@ public: HWND CreateEx(HWND hWndParent = NULL, ATL::_U_RECT rect = NULL, DWORD dwStyle = 0, DWORD dwExStyle = 0, LPVOID lpCreateParam = NULL) { const int cchName = 256; - TCHAR szWindowName[cchName] = { 0 }; -#ifndef _WIN32_WCE + TCHAR szWindowName[cchName] = {}; ::LoadString(ModuleHelper::GetResourceInstance(), T::GetWndClassInfo().m_uCommonResourceID, szWindowName, cchName); HMENU hMenu = ::LoadMenu(ModuleHelper::GetResourceInstance(), MAKEINTRESOURCE(T::GetWndClassInfo().m_uCommonResourceID)); -#else // CE specific - ::LoadString(ModuleHelper::GetResourceInstance(), T::GetWndClassInfo().m_uCommonResourceID, szWindowName, cchName); - - // This always needs to be NULL for Windows CE. - // Frame Window menus have to go onto the CommandBar. - // Use CreateSimpleCECommandBar - HMENU hMenu = NULL; -#endif // _WIN32_WCE T* pT = static_cast(this); HWND hWnd = pT->Create(hWndParent, rect, szWindowName, dwStyle, dwExStyle, hMenu, lpCreateParam); if(hWnd != NULL) - m_hAccel = ::LoadAccelerators(ModuleHelper::GetResourceInstance(), MAKEINTRESOURCE(T::GetWndClassInfo().m_uCommonResourceID)); + this->m_hAccel = ::LoadAccelerators(ModuleHelper::GetResourceInstance(), MAKEINTRESOURCE(T::GetWndClassInfo().m_uCommonResourceID)); return hWnd; } @@ -1190,26 +956,10 @@ public: { if(nResourceID == 0) nResourceID = T::GetWndClassInfo().m_uCommonResourceID; -#ifndef _WIN32_WCE - ATLASSERT(!::IsWindow(m_hWndToolBar)); - m_hWndToolBar = T::CreateSimpleToolBarCtrl(m_hWnd, nResourceID, TRUE, dwStyle, nID); - return (m_hWndToolBar != NULL); -#else // CE specific - HWND hWnd= T::CreateSimpleToolBarCtrl(m_hWndCECommandBar, nResourceID, TRUE, dwStyle, nID); - return (hWnd != NULL); -#endif // _WIN32_WCE - } - -#ifdef _WIN32_WCE - // CE specific variant that returns the handle of the toolbar - HWND CreateSimpleCEToolBar(UINT nResourceID = 0, DWORD dwStyle = ATL_SIMPLE_TOOLBAR_STYLE, UINT nID = ATL_IDW_TOOLBAR) - { - if(nResourceID == 0) - nResourceID = T::GetWndClassInfo().m_uCommonResourceID; - - return T::CreateSimpleToolBarCtrl(m_hWndCECommandBar, nResourceID, TRUE, dwStyle, nID); + ATLASSERT(!::IsWindow(this->m_hWndToolBar)); + this->m_hWndToolBar = T::CreateSimpleToolBarCtrl(this->m_hWnd, nResourceID, TRUE, dwStyle, nID); + return (this->m_hWndToolBar != NULL); } -#endif // _WIN32_WCE // message map and handlers typedef CFrameWindowImplBase< TBase, TWinTraits > _baseClass; @@ -1217,12 +967,8 @@ public: BEGIN_MSG_MAP(CFrameWindowImpl) MESSAGE_HANDLER(WM_SIZE, OnSize) #ifndef _ATL_NO_REBAR_SUPPORT -#if (_WIN32_IE >= 0x0400) NOTIFY_CODE_HANDLER(RBN_AUTOSIZE, OnReBarAutoSize) -#endif // (_WIN32_IE >= 0x0400) -#if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) NOTIFY_CODE_HANDLER(RBN_CHEVRONPUSHED, OnChevronPushed) -#endif // (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) #endif // !_ATL_NO_REBAR_SUPPORT CHAIN_MSG_MAP(_baseClass) END_MSG_MAP() @@ -1239,20 +985,17 @@ public: } #ifndef _ATL_NO_REBAR_SUPPORT -#if (_WIN32_IE >= 0x0400) LRESULT OnReBarAutoSize(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/) { T* pT = static_cast(this); pT->UpdateLayout(FALSE); return 0; } -#endif // (_WIN32_IE >= 0x0400) -#if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) LRESULT OnChevronPushed(int /*idCtrl*/, LPNMHDR pnmh, BOOL& bHandled) { T* pT = static_cast(this); - _ChevronMenuInfo cmi = { NULL, (LPNMREBARCHEVRON)pnmh, false }; + typename CFrameWindowImplBase< TBase, TWinTraits >::_ChevronMenuInfo cmi = { NULL, (LPNMREBARCHEVRON)pnmh, false }; if(!pT->PrepareChevronMenu(cmi)) { bHandled = FALSE; @@ -1264,7 +1007,6 @@ public: pT->CleanupChevronMenu(cmi); return 0; } -#endif // (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) #endif // !_ATL_NO_REBAR_SUPPORT }; @@ -1272,24 +1014,18 @@ public: /////////////////////////////////////////////////////////////////////////////// // AtlCreateSimpleToolBar - helper for creating simple toolbars -#ifndef _WIN32_WCE - inline HWND AtlCreateSimpleToolBar(HWND hWndParent, UINT nResourceID, BOOL bInitialSeparator = FALSE, DWORD dwStyle = ATL_SIMPLE_TOOLBAR_STYLE, UINT nID = ATL_IDW_TOOLBAR) { return CFrameWindowImplBase<>::CreateSimpleToolBarCtrl(hWndParent, nResourceID, bInitialSeparator, dwStyle, nID); } -#endif // !_WIN32_WCE - /////////////////////////////////////////////////////////////////////////////// // CMDIWindow -#ifndef _WIN32_WCE - #ifndef _WTL_MDIWINDOWMENU_TEXT -#define _WTL_MDIWINDOWMENU_TEXT _T("&Window") + #define _WTL_MDIWINDOWMENU_TEXT _T("&Window") #endif class CMDIWindow : public ATL::CWindow @@ -1326,7 +1062,7 @@ public: void MDINext(HWND hWndChild, BOOL bPrevious = FALSE) { ATLASSERT(::IsWindow(m_hWndMDIClient)); - ATLASSERT(hWndChild == NULL || ::IsWindow(hWndChild)); + ATLASSERT((hWndChild == NULL) || ::IsWindow(hWndChild)); ::SendMessage(m_hWndMDIClient, WM_MDINEXT, (WPARAM)hWndChild, (LPARAM)bPrevious); } @@ -1390,7 +1126,7 @@ public: int nLen = ::GetMenuString(hMenu, nCount - 2, NULL, 0, MF_BYPOSITION); if(nLen == 0) return NULL; - CTempBuffer buff; + ATL::CTempBuffer buff; LPTSTR lpszText = buff.Allocate(nLen + 1); if(lpszText == NULL) return NULL; @@ -1415,19 +1151,15 @@ public: } }; -#endif // !_WIN32_WCE - /////////////////////////////////////////////////////////////////////////////// // CMDIFrameWindowImpl -#ifndef _WIN32_WCE - // MDI child command chaining macro (only for MDI frame windows) #define CHAIN_MDI_CHILD_COMMANDS() \ if(uMsg == WM_COMMAND) \ { \ - HWND hWndChild = MDIGetActive(); \ + HWND hWndChild = this->MDIGetActive(); \ if(hWndChild != NULL) \ ::SendMessage(hWndChild, uMsg, wParam, lParam); \ } @@ -1440,8 +1172,8 @@ public: DWORD dwStyle = 0, DWORD dwExStyle = 0, HMENU hMenu = NULL, LPVOID lpCreateParam = NULL) { - m_hMenu = hMenu; - ATOM atom = T::GetWndClassInfo().Register(&m_pfnSuperWindowProc); + this->m_hMenu = hMenu; + ATOM atom = T::GetWndClassInfo().Register(&this->m_pfnSuperWindowProc); dwStyle = T::GetWndStyle(dwStyle); dwExStyle = T::GetWndExStyle(dwExStyle); @@ -1455,7 +1187,7 @@ public: HWND CreateEx(HWND hWndParent = NULL, ATL::_U_RECT rect = NULL, DWORD dwStyle = 0, DWORD dwExStyle = 0, LPVOID lpCreateParam = NULL) { const int cchName = 256; - TCHAR szWindowName[cchName] = { 0 }; + TCHAR szWindowName[cchName] = {}; ::LoadString(ModuleHelper::GetResourceInstance(), T::GetWndClassInfo().m_uCommonResourceID, szWindowName, cchName); HMENU hMenu = ::LoadMenu(ModuleHelper::GetResourceInstance(), MAKEINTRESOURCE(T::GetWndClassInfo().m_uCommonResourceID)); @@ -1463,18 +1195,18 @@ public: HWND hWnd = pT->Create(hWndParent, rect, szWindowName, dwStyle, dwExStyle, hMenu, lpCreateParam); if(hWnd != NULL) - m_hAccel = ::LoadAccelerators(ModuleHelper::GetResourceInstance(), MAKEINTRESOURCE(T::GetWndClassInfo().m_uCommonResourceID)); + this->m_hAccel = ::LoadAccelerators(ModuleHelper::GetResourceInstance(), MAKEINTRESOURCE(T::GetWndClassInfo().m_uCommonResourceID)); return hWnd; } BOOL CreateSimpleToolBar(UINT nResourceID = 0, DWORD dwStyle = ATL_SIMPLE_TOOLBAR_STYLE, UINT nID = ATL_IDW_TOOLBAR) { - ATLASSERT(!::IsWindow(m_hWndToolBar)); + ATLASSERT(!::IsWindow(this->m_hWndToolBar)); if(nResourceID == 0) nResourceID = T::GetWndClassInfo().m_uCommonResourceID; - m_hWndToolBar = T::CreateSimpleToolBarCtrl(m_hWnd, nResourceID, TRUE, dwStyle, nID); - return (m_hWndToolBar != NULL); + this->m_hWndToolBar = T::CreateSimpleToolBarCtrl(this->m_hWnd, nResourceID, TRUE, dwStyle, nID); + return (this->m_hWndToolBar != NULL); } virtual WNDPROC GetWindowProc() @@ -1486,13 +1218,8 @@ public: { CMDIFrameWindowImpl< T, TBase, TWinTraits >* pThis = (CMDIFrameWindowImpl< T, TBase, TWinTraits >*)hWnd; // set a ptr to this message and save the old value -#if (_ATL_VER >= 0x0700) ATL::_ATL_MSG msg(pThis->m_hWnd, uMsg, wParam, lParam); const ATL::_ATL_MSG* pOldMsg = pThis->m_pCurrentMsg; -#else // !(_ATL_VER >= 0x0700) - MSG msg = { pThis->m_hWnd, uMsg, wParam, lParam, 0, { 0, 0 } }; - const MSG* pOldMsg = pThis->m_pCurrentMsg; -#endif // !(_ATL_VER >= 0x0700) pThis->m_pCurrentMsg = &msg; // pass to the message map to process LRESULT lRes = 0; @@ -1512,38 +1239,28 @@ public: // unsubclass, if needed LONG_PTR pfnWndProc = ::GetWindowLongPtr(pThis->m_hWnd, GWLP_WNDPROC); lRes = pThis->DefWindowProc(uMsg, wParam, lParam); - if(pThis->m_pfnSuperWindowProc != ::DefWindowProc && ::GetWindowLongPtr(pThis->m_hWnd, GWLP_WNDPROC) == pfnWndProc) + if((pThis->m_pfnSuperWindowProc != ::DefWindowProc) && (::GetWindowLongPtr(pThis->m_hWnd, GWLP_WNDPROC) == pfnWndProc)) ::SetWindowLongPtr(pThis->m_hWnd, GWLP_WNDPROC, (LONG_PTR)pThis->m_pfnSuperWindowProc); -#if (_ATL_VER >= 0x0700) // mark window as destryed - pThis->m_dwState |= WINSTATE_DESTROYED; -#else // !(_ATL_VER >= 0x0700) - // clear out window handle - HWND hWnd = pThis->m_hWnd; - pThis->m_hWnd = NULL; - // clean up after window is destroyed - pThis->OnFinalMessage(hWnd); -#endif // !(_ATL_VER >= 0x0700) + pThis->m_dwState |= ATL::CWindowImplRoot< TBase >::WINSTATE_DESTROYED; } } -#if (_ATL_VER >= 0x0700) - if(pThis->m_dwState & WINSTATE_DESTROYED && pThis->m_pCurrentMsg == NULL) + if((pThis->m_dwState & ATL::CWindowImplRoot< TBase >::WINSTATE_DESTROYED) && (pThis->m_pCurrentMsg == NULL)) { // clear out window handle HWND hWndThis = pThis->m_hWnd; pThis->m_hWnd = NULL; - pThis->m_dwState &= ~WINSTATE_DESTROYED; + pThis->m_dwState &= ~ATL::CWindowImplRoot< TBase >::WINSTATE_DESTROYED; // clean up after window is destroyed pThis->OnFinalMessage(hWndThis); } -#endif // (_ATL_VER >= 0x0700) return lRes; } // Overriden to call DefWindowProc which uses DefFrameProc LRESULT DefWindowProc() { - const MSG* pMsg = m_pCurrentMsg; + const ATL::_ATL_MSG* pMsg = this->m_pCurrentMsg; LRESULT lRes = 0; if (pMsg != NULL) lRes = DefWindowProc(pMsg->message, pMsg->wParam, pMsg->lParam); @@ -1552,14 +1269,14 @@ public: LRESULT DefWindowProc(UINT uMsg, WPARAM wParam, LPARAM lParam) { - return ::DefFrameProc(m_hWnd, m_hWndMDIClient, uMsg, wParam, lParam); + return ::DefFrameProc(this->m_hWnd, this->m_hWndMDIClient, uMsg, wParam, lParam); } BOOL PreTranslateMessage(MSG* pMsg) { if(CFrameWindowImplBase::PreTranslateMessage(pMsg)) return TRUE; - return ::TranslateMDISysAccel(m_hWndMDIClient, pMsg); + return ::TranslateMDISysAccel(this->m_hWndMDIClient, pMsg); } HWND CreateMDIClient(HMENU hWindowMenu = NULL, UINT nID = ATL_IDW_CLIENT, UINT nFirstChildID = ATL_IDM_FIRST_MDICHILD) @@ -1567,40 +1284,40 @@ public: DWORD dwStyle = WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | MDIS_ALLCHILDSTYLES; DWORD dwExStyle = WS_EX_CLIENTEDGE; - CLIENTCREATESTRUCT ccs = { 0 }; + CLIENTCREATESTRUCT ccs = {}; ccs.hWindowMenu = hWindowMenu; ccs.idFirstChild = nFirstChildID; - if((GetStyle() & (WS_HSCROLL | WS_VSCROLL)) != 0) + if((this->GetStyle() & (WS_HSCROLL | WS_VSCROLL)) != 0) { // parent MDI frame's scroll styles move to the MDICLIENT - dwStyle |= (GetStyle() & (WS_HSCROLL | WS_VSCROLL)); + dwStyle |= (this->GetStyle() & (WS_HSCROLL | WS_VSCROLL)); // fast way to turn off the scrollbar bits (without a resize) - ModifyStyle(WS_HSCROLL | WS_VSCROLL, 0, SWP_NOREDRAW | SWP_FRAMECHANGED); + this->ModifyStyle(WS_HSCROLL | WS_VSCROLL, 0, SWP_NOREDRAW | SWP_FRAMECHANGED); } // Create MDICLIENT window - m_hWndClient = ::CreateWindowEx(dwExStyle, _T("MDIClient"), NULL, - dwStyle, 0, 0, 1, 1, m_hWnd, (HMENU)LongToHandle(nID), + this->m_hWndClient = ::CreateWindowEx(dwExStyle, _T("MDIClient"), NULL, + dwStyle, 0, 0, 1, 1, this->m_hWnd, (HMENU)LongToHandle(nID), ModuleHelper::GetModuleInstance(), (LPVOID)&ccs); - if (m_hWndClient == NULL) + if (this->m_hWndClient == NULL) { ATLTRACE2(atlTraceUI, 0, _T("MDI Frame failed to create MDICLIENT.\n")); return NULL; } // Move it to the top of z-order - ::BringWindowToTop(m_hWndClient); + ::BringWindowToTop(this->m_hWndClient); // set as MDI client window - m_hWndMDIClient = m_hWndClient; + this->m_hWndMDIClient = this->m_hWndClient; // update to proper size T* pT = static_cast(this); pT->UpdateLayout(); - return m_hWndClient; + return this->m_hWndClient; } typedef CFrameWindowImplBase _baseClass; @@ -1610,12 +1327,8 @@ public: MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus) MESSAGE_HANDLER(WM_MDISETMENU, OnMDISetMenu) #ifndef _ATL_NO_REBAR_SUPPORT -#if (_WIN32_IE >= 0x0400) NOTIFY_CODE_HANDLER(RBN_AUTOSIZE, OnReBarAutoSize) -#endif // (_WIN32_IE >= 0x0400) -#if (_WIN32_IE >= 0x0500) NOTIFY_CODE_HANDLER(RBN_CHEVRONPUSHED, OnChevronPushed) -#endif // (_WIN32_IE >= 0x0500) #endif // !_ATL_NO_REBAR_SUPPORT CHAIN_MSG_MAP(_baseClass) END_MSG_MAP() @@ -1639,25 +1352,22 @@ public: LRESULT OnMDISetMenu(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { - SetMDIFrameMenu(); + this->SetMDIFrameMenu(); return 0; } #ifndef _ATL_NO_REBAR_SUPPORT -#if (_WIN32_IE >= 0x0400) LRESULT OnReBarAutoSize(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/) { T* pT = static_cast(this); pT->UpdateLayout(FALSE); return 0; } -#endif // (_WIN32_IE >= 0x0400) -#if (_WIN32_IE >= 0x0500) LRESULT OnChevronPushed(int /*idCtrl*/, LPNMHDR pnmh, BOOL& bHandled) { T* pT = static_cast(this); - _ChevronMenuInfo cmi = { NULL, (LPNMREBARCHEVRON)pnmh, false }; + typename CFrameWindowImplBase::_ChevronMenuInfo cmi = { NULL, (LPNMREBARCHEVRON)pnmh, false }; if(!pT->PrepareChevronMenu(cmi)) { bHandled = FALSE; @@ -1669,18 +1379,13 @@ public: pT->CleanupChevronMenu(cmi); return 0; } -#endif // (_WIN32_IE >= 0x0500) #endif // !_ATL_NO_REBAR_SUPPORT }; -#endif // !_WIN32_WCE - /////////////////////////////////////////////////////////////////////////////// // CMDIChildWindowImpl -#ifndef _WIN32_WCE - template class ATL_NO_VTABLE CMDIChildWindowImpl : public CFrameWindowImplBase { @@ -1689,18 +1394,18 @@ public: DWORD dwStyle = 0, DWORD dwExStyle = 0, UINT nMenuID = 0, LPVOID lpCreateParam = NULL) { - ATOM atom = T::GetWndClassInfo().Register(&m_pfnSuperWindowProc); + ATOM atom = T::GetWndClassInfo().Register(&this->m_pfnSuperWindowProc); if(nMenuID != 0) - m_hMenu = ::LoadMenu(ModuleHelper::GetResourceInstance(), MAKEINTRESOURCE(nMenuID)); + this->m_hMenu = ::LoadMenu(ModuleHelper::GetResourceInstance(), MAKEINTRESOURCE(nMenuID)); dwStyle = T::GetWndStyle(dwStyle); dwExStyle = T::GetWndExStyle(dwExStyle); dwExStyle |= WS_EX_MDICHILD; // force this one - m_pfnSuperWindowProc = ::DefMDIChildProc; - m_hWndMDIClient = hWndParent; - ATLASSERT(::IsWindow(m_hWndMDIClient)); + this->m_pfnSuperWindowProc = ::DefMDIChildProc; + this->m_hWndMDIClient = hWndParent; + ATLASSERT(::IsWindow(this->m_hWndMDIClient)); if(rect.m_lpRect == NULL) rect.m_lpRect = &TBase::rcDefault; @@ -1718,12 +1423,12 @@ public: { // Maximize and redraw everything if(hWnd != NULL) - MDIMaximize(hWnd); + this->MDIMaximize(hWnd); wndParent.SetRedraw(TRUE); wndParent.RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_ALLCHILDREN); - ::SetFocus(GetMDIFrame()); // focus will be set back to this window + ::SetFocus(this->GetMDIFrame()); // focus will be set back to this window } - else if(hWnd != NULL && ::IsWindowVisible(m_hWnd) && !::IsChild(hWnd, ::GetFocus())) + else if((hWnd != NULL) && ::IsWindowVisible(this->m_hWnd) && !::IsChild(hWnd, ::GetFocus())) { ::SetFocus(hWnd); } @@ -1734,7 +1439,7 @@ public: HWND CreateEx(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR lpcstrWindowName = NULL, DWORD dwStyle = 0, DWORD dwExStyle = 0, LPVOID lpCreateParam = NULL) { const int cchName = 256; - TCHAR szWindowName[cchName] = { 0 }; + TCHAR szWindowName[cchName] = {}; if(lpcstrWindowName == NULL) { ::LoadString(ModuleHelper::GetResourceInstance(), T::GetWndClassInfo().m_uCommonResourceID, szWindowName, cchName); @@ -1745,31 +1450,31 @@ public: HWND hWnd = pT->Create(hWndParent, rect, lpcstrWindowName, dwStyle, dwExStyle, T::GetWndClassInfo().m_uCommonResourceID, lpCreateParam); if(hWnd != NULL) - m_hAccel = ::LoadAccelerators(ModuleHelper::GetResourceInstance(), MAKEINTRESOURCE(T::GetWndClassInfo().m_uCommonResourceID)); + this->m_hAccel = ::LoadAccelerators(ModuleHelper::GetResourceInstance(), MAKEINTRESOURCE(T::GetWndClassInfo().m_uCommonResourceID)); return hWnd; } BOOL CreateSimpleToolBar(UINT nResourceID = 0, DWORD dwStyle = ATL_SIMPLE_TOOLBAR_STYLE, UINT nID = ATL_IDW_TOOLBAR) { - ATLASSERT(!::IsWindow(m_hWndToolBar)); + ATLASSERT(!::IsWindow(this->m_hWndToolBar)); if(nResourceID == 0) nResourceID = T::GetWndClassInfo().m_uCommonResourceID; - m_hWndToolBar = T::CreateSimpleToolBarCtrl(m_hWnd, nResourceID, TRUE, dwStyle, nID); - return (m_hWndToolBar != NULL); + this->m_hWndToolBar = T::CreateSimpleToolBarCtrl(this->m_hWnd, nResourceID, TRUE, dwStyle, nID); + return (this->m_hWndToolBar != NULL); } BOOL UpdateClientEdge(LPRECT lpRect = NULL) { // only adjust for active MDI child window - HWND hWndChild = MDIGetActive(); - if(hWndChild != NULL && hWndChild != m_hWnd) + HWND hWndChild = this->MDIGetActive(); + if((hWndChild != NULL) && (hWndChild != this->m_hWnd)) return FALSE; // need to adjust the client edge style as max/restore happens - DWORD dwStyle = ::GetWindowLong(m_hWndMDIClient, GWL_EXSTYLE); + DWORD dwStyle = ::GetWindowLong(this->m_hWndMDIClient, GWL_EXSTYLE); DWORD dwNewStyle = dwStyle; - if(hWndChild != NULL && ((GetExStyle() & WS_EX_CLIENTEDGE) == 0) && ((GetStyle() & WS_MAXIMIZE) != 0)) + if((hWndChild != NULL) && ((this->GetExStyle() & WS_EX_CLIENTEDGE) == 0) && ((this->GetStyle() & WS_MAXIMIZE) != 0)) dwNewStyle &= ~(WS_EX_CLIENTEDGE); else dwNewStyle |= WS_EX_CLIENTEDGE; @@ -1777,17 +1482,17 @@ public: if(dwStyle != dwNewStyle) { // SetWindowPos will not move invalid bits - ::RedrawWindow(m_hWndMDIClient, NULL, NULL, + ::RedrawWindow(this->m_hWndMDIClient, NULL, NULL, RDW_INVALIDATE | RDW_ALLCHILDREN); // remove/add WS_EX_CLIENTEDGE to MDI client area - ::SetWindowLong(m_hWndMDIClient, GWL_EXSTYLE, dwNewStyle); - ::SetWindowPos(m_hWndMDIClient, NULL, 0, 0, 0, 0, + ::SetWindowLong(this->m_hWndMDIClient, GWL_EXSTYLE, dwNewStyle); + ::SetWindowPos(this->m_hWndMDIClient, NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOCOPYBITS); // return new client area if (lpRect != NULL) - ::GetClientRect(m_hWndMDIClient, lpRect); + ::GetClientRect(this->m_hWndMDIClient, lpRect); return TRUE; } @@ -1804,19 +1509,15 @@ public: MESSAGE_HANDLER(WM_MDIACTIVATE, OnMDIActivate) MESSAGE_HANDLER(WM_DESTROY, OnDestroy) #ifndef _ATL_NO_REBAR_SUPPORT -#if (_WIN32_IE >= 0x0400) NOTIFY_CODE_HANDLER(RBN_AUTOSIZE, OnReBarAutoSize) -#endif // (_WIN32_IE >= 0x0400) -#if (_WIN32_IE >= 0x0500) NOTIFY_CODE_HANDLER(RBN_CHEVRONPUSHED, OnChevronPushed) -#endif // (_WIN32_IE >= 0x0500) #endif // !_ATL_NO_REBAR_SUPPORT CHAIN_MSG_MAP(_baseClass) END_MSG_MAP() LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) { - DefWindowProc(uMsg, wParam, lParam); // needed for MDI children + this->DefWindowProc(uMsg, wParam, lParam); // needed for MDI children if(wParam != SIZE_MINIMIZED) { T* pT = static_cast(this); @@ -1832,10 +1533,10 @@ public: if(!(lpWndPos->flags & SWP_NOSIZE)) { - RECT rectClient = { 0 }; - if(UpdateClientEdge(&rectClient) && ((GetStyle() & WS_MAXIMIZE) != 0)) + RECT rectClient = {}; + if(UpdateClientEdge(&rectClient) && ((this->GetStyle() & WS_MAXIMIZE) != 0)) { - ::AdjustWindowRectEx(&rectClient, GetStyle(), FALSE, GetExStyle()); + ::AdjustWindowRectEx(&rectClient, this->GetStyle(), FALSE, this->GetExStyle()); lpWndPos->x = rectClient.left; lpWndPos->y = rectClient.top; lpWndPos->cx = rectClient.right - rectClient.left; @@ -1849,13 +1550,13 @@ public: LRESULT OnMouseActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) { - LRESULT lRes = DefWindowProc(uMsg, wParam, lParam); + LRESULT lRes = this->DefWindowProc(uMsg, wParam, lParam); // Activate this MDI window if needed - if(lRes == MA_ACTIVATE || lRes == MA_ACTIVATEANDEAT) + if((lRes == MA_ACTIVATE) || (lRes == MA_ACTIVATEANDEAT)) { - if(MDIGetActive() != m_hWnd) - MDIActivate(m_hWnd); + if(this->MDIGetActive() != this->m_hWnd) + this->MDIActivate(this->m_hWnd); } return lRes; @@ -1863,15 +1564,15 @@ public: LRESULT OnMenuSelect(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) { - return ::SendMessage(GetMDIFrame(), uMsg, wParam, lParam); + return ::SendMessage(this->GetMDIFrame(), uMsg, wParam, lParam); } LRESULT OnMDIActivate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled) { - if((HWND)lParam == m_hWnd && m_hMenu != NULL) - SetMDIFrameMenu(); + if(((HWND)lParam == this->m_hWnd) && (this->m_hMenu != NULL)) + this->SetMDIFrameMenu(); else if((HWND)lParam == NULL) - ::SendMessage(GetMDIFrame(), WM_MDISETMENU, 0, 0); + ::SendMessage(this->GetMDIFrame(), WM_MDISETMENU, 0, 0); bHandled = FALSE; return 1; @@ -1879,10 +1580,10 @@ public: LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) { - if(m_hMenu != NULL) + if(this->m_hMenu != NULL) { - ::DestroyMenu(m_hMenu); - m_hMenu = NULL; + ::DestroyMenu(this->m_hMenu); + this->m_hMenu = NULL; } UpdateClientEdge(); bHandled = FALSE; @@ -1890,20 +1591,17 @@ public: } #ifndef _ATL_NO_REBAR_SUPPORT -#if (_WIN32_IE >= 0x0400) LRESULT OnReBarAutoSize(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/) { T* pT = static_cast(this); pT->UpdateLayout(FALSE); return 0; } -#endif // (_WIN32_IE >= 0x0400) -#if (_WIN32_IE >= 0x0500) LRESULT OnChevronPushed(int /*idCtrl*/, LPNMHDR pnmh, BOOL& bHandled) { T* pT = static_cast(this); - _ChevronMenuInfo cmi = { NULL, (LPNMREBARCHEVRON)pnmh, false }; + typename CFrameWindowImplBase::_ChevronMenuInfo cmi = { NULL, (LPNMREBARCHEVRON)pnmh, false }; if(!pT->PrepareChevronMenu(cmi)) { bHandled = FALSE; @@ -1915,12 +1613,9 @@ public: pT->CleanupChevronMenu(cmi); return 0; } -#endif // (_WIN32_IE >= 0x0500) #endif // !_ATL_NO_REBAR_SUPPORT }; -#endif // !_WIN32_WCE - /////////////////////////////////////////////////////////////////////////////// // COwnerDraw - MI class for owner-draw support @@ -1929,19 +1624,6 @@ template class COwnerDraw { public: -#if (_ATL_VER < 0x0700) - BOOL m_bHandledOD; - - BOOL IsMsgHandled() const - { - return m_bHandledOD; - } - void SetMsgHandled(BOOL bHandled) - { - m_bHandledOD = bHandled; - } -#endif // (_ATL_VER < 0x0700) - // Message map and handlers BEGIN_MSG_MAP(COwnerDraw< T >) MESSAGE_HANDLER(WM_DRAWITEM, OnDrawItem) @@ -2005,7 +1687,7 @@ public: T* pT = static_cast(this); HWND hWnd = pT->GetDlgItem(lpMeasureItemStruct->CtlID); CClientDC dc(hWnd); - TEXTMETRIC tm = { 0 }; + TEXTMETRIC tm = {}; dc.GetTextMetrics(&tm); lpMeasureItemStruct->itemHeight = tm.tmHeight; @@ -2034,7 +1716,7 @@ public: #define BEGIN_UPDATE_UI_MAP(thisClass) \ static const CUpdateUIBase::_AtlUpdateUIMap* GetUpdateUIMap() \ { \ - static const _AtlUpdateUIMap theMap[] = \ + static const CUpdateUIBase::_AtlUpdateUIMap theMap[] = \ { #define UPDATE_ELEMENT(nID, wType) \ @@ -2080,7 +1762,7 @@ public: WORD m_wType; bool operator ==(const _AtlUpdateUIElement& e) const - { return (m_hWnd == e.m_hWnd && m_wType == e.m_wType); } + { return ((m_hWnd == e.m_hWnd) && (m_wType == e.m_wType)); } }; // map data @@ -2090,7 +1772,7 @@ public: WORD m_wType; bool operator ==(const _AtlUpdateUIMap& e) const - { return (m_nID == e.m_nID && m_wType == e.m_wType); } + { return ((m_nID == e.m_nID) && (m_wType == e.m_wType)); } }; // instance data @@ -2112,7 +1794,7 @@ public: }; bool operator ==(const _AtlUpdateUIData& e) const - { return (m_wState == e.m_wState && m_lpData == e.m_lpData); } + { return ((m_wState == e.m_wState) && (m_lpData == e.m_lpData)); } }; #pragma warning(pop) @@ -2131,7 +1813,7 @@ public: ~CUpdateUIBase() { - if(m_pUIMap != NULL && m_pUIData != NULL) + if((m_pUIMap != NULL) && (m_pUIData != NULL)) { const _AtlUpdateUIMap* pUIMap = m_pUIMap; _AtlUpdateUIData* pUIData = m_pUIData; @@ -2234,7 +1916,7 @@ public: LRESULT OnCommand(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) { bHandled = FALSE; - if(m_bBlockAccelerators && HIWORD(wParam) == 1) // accelerators only + if(m_bBlockAccelerators && (HIWORD(wParam) == 1)) // accelerators only { int nID = LOWORD(wParam); if((UIGetState(nID) & UPDUI_DISABLED) == UPDUI_DISABLED) @@ -2405,7 +2087,7 @@ public: if(pUIData->m_wState & pMap->m_wType) m_wDirtyType |= pMap->m_wType; } - else if(pMap->m_nID >= nIDFirst && pMap->m_nID <= nIDLast) + else if((pMap->m_nID >= nIDFirst) && (pMap->m_nID <= nIDLast)) { if(pUIData->m_wState & UPDUI_RADIO) { @@ -2436,7 +2118,7 @@ public: { if(nID == (int)pMap->m_nID) { - if(pUIData->m_lpstrText == NULL || lstrcmp(pUIData->m_lpstrText, lpstrText)) + if((pUIData->m_lpstrText == NULL) || (lstrcmp(pUIData->m_lpstrText, lpstrText) != 0)) { delete [] pUIData->m_lpstrText; pUIData->m_lpstrText = NULL; @@ -2447,7 +2129,7 @@ public: ATLTRACE2(atlTraceUI, 0, _T("UISetText - memory allocation failed\n")); break; } - SecureHelper::strcpy_x(pUIData->m_lpstrText, nStrLen + 1, lpstrText); + ATL::Checked::tcscpy_s(pUIData->m_lpstrText, nStrLen + 1, lpstrText); pUIData->m_wState |= (UPDUI_TEXT | pMap->m_wType); } @@ -2538,7 +2220,6 @@ public: } // methods for updating UI -#ifndef _WIN32_WCE BOOL UIUpdateMenuBar(BOOL bForceUpdate = FALSE, BOOL bMainMenu = FALSE) { if(!(m_wDirtyType & UPDUI_MENUBAR) && !bForceUpdate) @@ -2556,7 +2237,7 @@ public: if(m_UIElements[i].m_wType == UPDUI_MENUBAR) { HMENU hMenu = ::GetMenu(m_UIElements[i].m_hWnd); - if(hMenu != NULL && (pUIData->m_wState & UPDUI_MENUBAR) && (pMap->m_wType & UPDUI_MENUBAR)) + if((hMenu != NULL) && (pUIData->m_wState & UPDUI_MENUBAR) && (pMap->m_wType & UPDUI_MENUBAR)) UIUpdateMenuBarElement(pMap->m_nID, pUIData, hMenu); } if(bMainMenu) @@ -2576,7 +2257,6 @@ public: m_wDirtyType &= ~UPDUI_MENUBAR; return TRUE; } -#endif // !_WIN32_WCE BOOL UIUpdateToolBar(BOOL bForceUpdate = FALSE) { @@ -2680,19 +2360,16 @@ public: // internal element specific methods static void UIUpdateMenuBarElement(int nID, _AtlUpdateUIData* pUIData, HMENU hMenu) { -#ifndef _WIN32_WCE if((pUIData->m_wState & UPDUI_CLEARDEFAULT) != 0) { ::SetMenuDefaultItem(hMenu, (UINT)-1, 0); pUIData->m_wState &= ~UPDUI_CLEARDEFAULT; } -#endif // !_WIN32_WCE CMenuItemInfo mii; mii.fMask = MIIM_STATE; mii.wID = nID; -#ifndef _WIN32_WCE if((pUIData->m_wState & UPDUI_DISABLED) != 0) mii.fState |= MFS_DISABLED | MFS_GRAYED; else @@ -2705,23 +2382,6 @@ public: if((pUIData->m_wState & UPDUI_DEFAULT) != 0) mii.fState |= MFS_DEFAULT; -#else // CE specific - // ::SetMenuItemInfo() can't disable or check menu items - // on Windows CE, so we have to do that directly - UINT uEnable = MF_BYCOMMAND; - if((pUIData->m_wState & UPDUI_DISABLED) != 0) - uEnable |= MF_GRAYED; - else - uEnable |= MF_ENABLED; - ::EnableMenuItem(hMenu, nID, uEnable); - - UINT uCheck = MF_BYCOMMAND; - if((pUIData->m_wState & UPDUI_CHECKED) != 0) - uCheck |= MF_CHECKED; - else - uCheck |= MF_UNCHECKED; - ::CheckMenuItem(hMenu, nID, uCheck); -#endif // _WIN32_WCE if((pUIData->m_wState & UPDUI_TEXT) != 0) { @@ -2732,11 +2392,7 @@ public: { mii.fMask |= MIIM_TYPE; // MFT_BITMAP and MFT_SEPARATOR don't go together with MFT_STRING -#ifndef _WIN32_WCE mii.fType |= (miiNow.fType & ~(MFT_BITMAP | MFT_SEPARATOR)) | MFT_STRING; -#else // CE specific - mii.fType |= (miiNow.fType & ~(MFT_SEPARATOR)) | MFT_STRING; -#endif // _WIN32_WCE mii.dwTypeData = pUIData->m_lpstrText; } } @@ -2767,7 +2423,7 @@ public: ::EnableWindow(hChild, (pUIData->m_wState & UPDUI_DISABLED) ? FALSE : TRUE); // for check and radio, assume that window is a button int nCheck = BST_UNCHECKED; - if(pUIData->m_wState & UPDUI_CHECKED || pUIData->m_wState & UPDUI_RADIO) + if((pUIData->m_wState & UPDUI_CHECKED) || (pUIData->m_wState & UPDUI_RADIO)) nCheck = BST_CHECKED; else if(pUIData->m_wState & UPDUI_CHECKED2) nCheck = BST_INDETERMINATE; @@ -2795,7 +2451,7 @@ public: CUpdateUI() { T* pT = static_cast(this); - pT; + (void)pT; // avoid level 4 warning const _AtlUpdateUIMap* pMap = pT->GetUpdateUIMap(); m_pUIMap = pMap; ATLASSERT(m_pUIMap != NULL); @@ -2841,7 +2497,7 @@ public: CDynamicUpdateUI() { T* pT = static_cast(this); - pT; + (void)pT; // avoid level 4 warning const _AtlUpdateUIMap* pMap = pT->GetUpdateUIMap(); ATLASSERT(pMap != NULL); @@ -2975,10 +2631,10 @@ class CAutoUpdateUI : public CDynamicUpdateUI public: LPCTSTR UIGetText(int nID) { - for(int i = 0; i < m_arrUIMap.GetSize(); i++) + for(int i = 0; i < this->m_arrUIMap.GetSize(); i++) { - if(m_arrUIMap[i].m_nID == nID) - return m_arrUIData[i].m_lpstrText; + if(this->m_arrUIMap[i].m_nID == nID) + return this->m_arrUIData[i].m_lpstrText; } return NULL; @@ -2989,36 +2645,36 @@ public: bool UIAddElement(UINT nID) { // check for existing UI map element - for(int i = 0; i < m_arrUIMap.GetSize(); i++) + for(int i = 0; i < this->m_arrUIMap.GetSize(); i++) { - if(m_arrUIMap[i].m_nID == nID) + if(this->m_arrUIMap[i].m_nID == nID) { // set requested type - m_arrUIMap[i].m_wType |= t_wType; + this->m_arrUIMap[i].m_wType |= t_wType; return true; } } // Add element to UI map with requested type - return UIAddUpdateElement((WORD)nID, t_wType); + return this->UIAddUpdateElement((WORD)nID, t_wType); } template bool UIRemoveElement(UINT nID) { - for(int i = 0; i < m_arrUIMap.GetSize(); i++) + for(int i = 0; i < this->m_arrUIMap.GetSize(); i++) { - if(m_arrUIMap[i].m_nID == nID) // matching UI map element + if(this->m_arrUIMap[i].m_nID == nID) // matching UI map element { - WORD wType = m_arrUIMap[i].m_wType & ~t_wType; + WORD wType = this->m_arrUIMap[i].m_wType & ~t_wType; if (wType != 0) // has other types { - m_arrUIMap[i].m_wType = wType; // keep other types + this->m_arrUIMap[i].m_wType = wType; // keep other types return true; } else { - return UIRemoveUpdateElement((WORD)nID); + return this->UIRemoveUpdateElement((WORD)nID); } } } @@ -3029,9 +2685,6 @@ public: // Menu bool UIAddMenu(HMENU hMenu, bool bSetText = false) { -#if defined(_WIN32_WCE) && (_ATL_VER >= 0x0800) - using ATL::GetMenuString; -#endif ATLASSERT(::IsMenu(hMenu)); MENUITEMINFO mii = {sizeof(MENUITEMINFO), MIIM_TYPE | MIIM_ID | MIIM_SUBMENU}; @@ -3046,17 +2699,13 @@ public: else if (mii.wID != 0) { // Add element to UI map - UIAddElement(mii.wID); -#if !defined(_WIN32_WCE) || (_ATL_VER >= 0x0800) + UIAddElement::UPDUI_MENUPOPUP>(mii.wID); if (bSetText) { - TCHAR sText[64] = { 0 }; + TCHAR sText[64] = {}; if (GetMenuString(hMenu, uItem, sText, 64, MF_BYPOSITION)) - UISetText(mii.wID, sText); + this->UISetText(mii.wID, sText); } -#else - bSetText; -#endif // !defined(_WIN32_WCE) || (_ATL_VER >= 0x0800) } } @@ -3071,7 +2720,6 @@ public: } // ToolBar -#if !defined(_WIN32_WCE) || (defined(_AUTOUI_CE_TOOLBAR) && defined(TBIF_BYINDEX)) bool UIAddToolBar(HWND hWndToolBar) { ATLASSERT(::IsWindow(hWndToolBar)); @@ -3081,7 +2729,7 @@ public: for (int uItem = 0; ::SendMessage(hWndToolBar, TB_GETBUTTONINFO, uItem, (LPARAM)&tbbi) != -1; uItem++) { if (tbbi.fsStyle ^ BTNS_SEP) - UIAddElement(tbbi.idCommand); + UIAddElement::UPDUI_TOOLBAR>(tbbi.idCommand); } // Add embedded controls if any @@ -3090,7 +2738,6 @@ public: return (CUpdateUIBase::UIAddToolBar(hWndToolBar) != FALSE); } -#endif // !defined(_WIN32_WCE) || (defined(_AUTOUI_CE_TOOLBAR) && defined(TBIF_BYINDEX)) // Container bool UIAddChildWindowContainer(HWND hWnd) @@ -3102,7 +2749,7 @@ public: { int id = wCtl.GetDlgCtrlID(); if(id != 0) - UIAddElement(id); + UIAddElement::UPDUI_CHILDWINDOW>(id); } return (CUpdateUIBase::UIAddChildWindowContainer(hWnd) != FALSE); @@ -3111,26 +2758,26 @@ public: // StatusBar BOOL UIUpdateStatusBar(BOOL bForceUpdate = FALSE) { - if(!(m_wDirtyType & UPDUI_STATUSBAR) && !bForceUpdate) + if(!(this->m_wDirtyType & CDynamicUpdateUI::UPDUI_STATUSBAR) && !bForceUpdate) return TRUE; - for(int i = 0; i < m_arrUIMap.GetSize(); i++) + for(int i = 0; i < this->m_arrUIMap.GetSize(); i++) { - for(int e = 0; e < m_UIElements.GetSize(); e++) + for(int e = 0; e < this->m_UIElements.GetSize(); e++) { - if((m_UIElements[e].m_wType == UPDUI_STATUSBAR) && - (m_arrUIMap[i].m_wType & UPDUI_STATUSBAR) && - (m_arrUIData[i].m_wState & UPDUI_STATUSBAR)) + if((this->m_UIElements[e].m_wType == CDynamicUpdateUI::UPDUI_STATUSBAR) && + (this->m_arrUIMap[i].m_wType & CDynamicUpdateUI::UPDUI_STATUSBAR) && + (this->m_arrUIData[i].m_wState & CDynamicUpdateUI::UPDUI_STATUSBAR)) { - UIUpdateStatusBarElement(m_arrUIMap[i].m_nID, &m_arrUIData[i], m_UIElements[e].m_hWnd); - m_arrUIData[i].m_wState &= ~UPDUI_STATUSBAR; - if(m_arrUIData[i].m_wState & UPDUI_TEXT) - m_arrUIData[i].m_wState &= ~UPDUI_TEXT; + this->UIUpdateStatusBarElement(this->m_arrUIMap[i].m_nID, &this->m_arrUIData[i], this->m_UIElements[e].m_hWnd); + this->m_arrUIData[i].m_wState &= ~CDynamicUpdateUI::UPDUI_STATUSBAR; + if(this->m_arrUIData[i].m_wState & CDynamicUpdateUI::UPDUI_TEXT) + this->m_arrUIData[i].m_wState &= ~CDynamicUpdateUI::UPDUI_TEXT; } } } - m_wDirtyType &= ~UPDUI_STATUSBAR; + this->m_wDirtyType &= ~CDynamicUpdateUI::UPDUI_STATUSBAR; return TRUE; } @@ -3140,7 +2787,7 @@ public: // Add StatusBar panes for (int iPane = 0; iPane < nPanes; iPane++) - UIAddElement(ID_DEFAULT_PANE + iPane); + UIAddElement::UPDUI_STATUSBAR>(ID_DEFAULT_PANE + iPane); return (CUpdateUIBase::UIAddStatusBar(hWndStatusBar) != FALSE); } @@ -3168,10 +2815,16 @@ public: // on the position of the previous control in a group. // dialog resize map macros +struct _AtlDlgResizeMap +{ + int m_nCtlID; + DWORD m_dwResizeFlags; +}; + #define BEGIN_DLGRESIZE_MAP(thisClass) \ - static const _AtlDlgResizeMap* GetDlgResizeMap() \ + static const WTL::_AtlDlgResizeMap* GetDlgResizeMap() \ { \ - static const _AtlDlgResizeMap theMap[] = \ + static const WTL::_AtlDlgResizeMap theMap[] = \ { #define END_DLGRESIZE_MAP() \ @@ -3211,12 +2864,6 @@ public: _DLSZ_GRIPPER = 0x00004000 }; - struct _AtlDlgResizeMap - { - int m_nCtlID; - DWORD m_dwResizeFlags; - }; - struct _AtlDlgResizeData { int m_nCtlID; @@ -3230,14 +2877,14 @@ public: void SetGroupCount(int nCount) { - ATLASSERT(nCount > 0 && nCount < 256); + ATLASSERT((nCount > 0) && (nCount < 256)); DWORD dwCount = (DWORD)MAKELONG(0, MAKEWORD(nCount, 0)); m_dwResizeFlags &= 0xFF00FFFF; m_dwResizeFlags |= dwCount; } bool operator ==(const _AtlDlgResizeData& r) const - { return (m_nCtlID == r.m_nCtlID && m_dwResizeFlags == r.m_dwResizeFlags); } + { return ((m_nCtlID == r.m_nCtlID) && (m_dwResizeFlags == r.m_dwResizeFlags)); } }; ATL::CSimpleArray<_AtlDlgResizeData> m_arrData; @@ -3273,7 +2920,6 @@ public: if((dwStyle & dwForceStyle) != dwForceStyle) pT->ModifyStyle(0, dwForceStyle); -#ifndef _WIN32_WCE // Adding this style removes an empty icon that dialogs with WS_THICKFRAME have. // Setting icon to NULL is required when XP themes are active. // Note: This will not prevent adding an icon for the dialog using SetIcon() @@ -3283,13 +2929,12 @@ public: if(pT->GetIcon(FALSE) == NULL) pT->SetIcon(NULL, FALSE); } -#endif // Cleanup in case of multiple initialization // block: first check for the gripper control, destroy it if needed { ATL::CWindow wndGripper = pT->GetDlgItem(ATL_IDW_STATUS_BAR); - if(wndGripper.IsWindow() && m_arrData.GetSize() > 0 && (m_arrData[0].m_dwResizeFlags & _DLSZ_GRIPPER) != 0) + if(wndGripper.IsWindow() && (m_arrData.GetSize() > 0) && (m_arrData[0].m_dwResizeFlags & _DLSZ_GRIPPER) != 0) wndGripper.DestroyWindow(); } // clear out everything else @@ -3300,27 +2945,26 @@ public: m_ptMinTrackSize.y = -1; // Get initial dialog client size - RECT rectDlg = { 0 }; + RECT rectDlg = {}; pT->GetClientRect(&rectDlg); m_sizeDialog.cx = rectDlg.right; m_sizeDialog.cy = rectDlg.bottom; -#ifndef _WIN32_WCE // Create gripper if requested m_bGripper = false; if(bAddGripper) { // shouldn't exist already - ATLASSERT(!::IsWindow(pT->GetDlgItem(ATL_IDW_STATUS_BAR))); - if(!::IsWindow(pT->GetDlgItem(ATL_IDW_STATUS_BAR))) + ATLASSERT(!pT->GetDlgItem(ATL_IDW_STATUS_BAR).IsWindow()); + if(!pT->GetDlgItem(ATL_IDW_STATUS_BAR).IsWindow()) { ATL::CWindow wndGripper; - wndGripper.Create(_T("SCROLLBAR"), pT->m_hWnd, rectDlg, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | SBS_SIZEBOX | SBS_SIZEGRIP | SBS_SIZEBOXBOTTOMRIGHTALIGN, 0, ATL_IDW_STATUS_BAR); + wndGripper.Create(_T("SCROLLBAR"), pT->m_hWnd, rectDlg, NULL, WS_CHILD | WS_VISIBLE | WS_GROUP | WS_CLIPSIBLINGS | SBS_SIZEBOX | SBS_SIZEGRIP | SBS_SIZEBOXBOTTOMRIGHTALIGN, 0, ATL_IDW_STATUS_BAR); ATLASSERT(wndGripper.IsWindow()); if(wndGripper.IsWindow()) { m_bGripper = true; - RECT rectCtl = { 0 }; + RECT rectCtl = {}; wndGripper.GetWindowRect(&rectCtl); ::MapWindowPoints(NULL, pT->m_hWnd, (LPPOINT)&rectCtl, 2); _AtlDlgResizeData data = { ATL_IDW_STATUS_BAR, DLSZ_MOVE_X | DLSZ_MOVE_Y | DLSZ_REPAINT | _DLSZ_GRIPPER, { rectCtl.left, rectCtl.top, rectCtl.right, rectCtl.bottom } }; @@ -3328,23 +2972,20 @@ public: } } } -#else // CE specific - bAddGripper; // avoid level 4 warning -#endif // _WIN32_WCE // Get min track position if requested if(bUseMinTrackSize) { if((dwStyle & WS_CHILD) != 0) { - RECT rect = { 0 }; + RECT rect = {}; pT->GetClientRect(&rect); m_ptMinTrackSize.x = rect.right - rect.left; m_ptMinTrackSize.y = rect.bottom - rect.top; } else { - RECT rect = { 0 }; + RECT rect = {}; pT->GetWindowRect(&rect); m_ptMinTrackSize.x = rect.right - rect.left; m_ptMinTrackSize.y = rect.bottom - rect.top; @@ -3355,7 +2996,7 @@ public: const _AtlDlgResizeMap* pMap = pT->GetDlgResizeMap(); ATLASSERT(pMap != NULL); int nGroupStart = -1; - for(int nCount = 1; !(pMap->m_nCtlID == -1 && pMap->m_dwResizeFlags == 0); nCount++, pMap++) + for(int nCount = 1; !((pMap->m_nCtlID == -1) && (pMap->m_dwResizeFlags == 0)); nCount++, pMap++) { if(pMap->m_nCtlID == -1) { @@ -3385,11 +3026,11 @@ public: ATL::CWindow ctl = pT->GetDlgItem(pMap->m_nCtlID); ATLASSERT(ctl.IsWindow()); - RECT rectCtl = { 0 }; + RECT rectCtl = {}; ctl.GetWindowRect(&rectCtl); ::MapWindowPoints(NULL, pT->m_hWnd, (LPPOINT)&rectCtl, 2); - DWORD dwGroupFlag = (nGroupStart != -1 && m_arrData.GetSize() == nGroupStart) ? _DLSZ_BEGIN_GROUP : 0; + DWORD dwGroupFlag = ((nGroupStart != -1) && (m_arrData.GetSize() == nGroupStart)) ? _DLSZ_BEGIN_GROUP : 0; _AtlDlgResizeData data = { pMap->m_nCtlID, pMap->m_dwResizeFlags | dwGroupFlag, { rectCtl.left, rectCtl.top, rectCtl.right, rectCtl.bottom } }; m_arrData.Add(data); } @@ -3403,7 +3044,7 @@ public: ATLASSERT(::IsWindow(pT->m_hWnd)); // Restrict minimum size if requested - if(((pT->GetStyle() & WS_CHILD) != 0) && m_ptMinTrackSize.x != -1 && m_ptMinTrackSize.y != -1) + if(((pT->GetStyle() & WS_CHILD) != 0) && (m_ptMinTrackSize.x != -1) && (m_ptMinTrackSize.y != -1)) { if(cxWidth < m_ptMinTrackSize.x) cxWidth = m_ptMinTrackSize.x; @@ -3420,7 +3061,7 @@ public: if((m_arrData[i].m_dwResizeFlags & _DLSZ_BEGIN_GROUP) != 0) // start of a group { int nGroupCount = m_arrData[i].GetGroupCount(); - ATLASSERT(nGroupCount > 0 && i + nGroupCount - 1 < m_arrData.GetSize()); + ATLASSERT((nGroupCount > 0) && ((i + nGroupCount - 1) < m_arrData.GetSize())); RECT rectGroup = m_arrData[i].m_rect; int j = 1; @@ -3444,7 +3085,7 @@ public: } else // one control entry { - RECT rectGroup = { 0 }; + RECT rectGroup = {}; pT->DlgResize_PositionControl(cxWidth, cyHeight, rectGroup, m_arrData[i], false); } } @@ -3458,15 +3099,12 @@ public: // Message map and handlers BEGIN_MSG_MAP(CDialogResize) MESSAGE_HANDLER(WM_SIZE, OnSize) -#ifndef _WIN32_WCE MESSAGE_HANDLER(WM_GETMINMAXINFO, OnGetMinMaxInfo) -#endif // _WIN32_WCE END_MSG_MAP() LRESULT OnSize(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) { T* pT = static_cast(this); -#ifndef _WIN32_WCE if(m_bGripper) { ATL::CWindow wndGripper = pT->GetDlgItem(ATL_IDW_STATUS_BAR); @@ -3475,7 +3113,6 @@ public: else if(wParam == SIZE_RESTORED) wndGripper.ShowWindow(SW_SHOW); } -#endif // _WIN32_WCE if(wParam != SIZE_MINIMIZED) { ATLASSERT(::IsWindow(pT->m_hWnd)); @@ -3484,17 +3121,15 @@ public: return 0; } -#ifndef _WIN32_WCE LRESULT OnGetMinMaxInfo(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/) { - if(m_ptMinTrackSize.x != -1 && m_ptMinTrackSize.y != -1) + if((m_ptMinTrackSize.x != -1) && (m_ptMinTrackSize.y != -1)) { LPMINMAXINFO lpMMI = (LPMINMAXINFO)lParam; lpMMI->ptMinTrackSize = m_ptMinTrackSize; } return 0; } -#endif // _WIN32_WCE // Implementation bool DlgResize_PositionControl(int cxWidth, int cyHeight, RECT& rectGroup, _AtlDlgResizeData& data, bool bGroup, @@ -3503,7 +3138,7 @@ public: T* pT = static_cast(this); ATLASSERT(::IsWindow(pT->m_hWnd)); ATL::CWindow ctl; - RECT rectCtl = { 0 }; + RECT rectCtl = {}; ctl = pT->GetDlgItem(data.m_nCtlID); if(!ctl.GetWindowRect(&rectCtl)) @@ -3530,7 +3165,7 @@ public: if(pDataPrev != NULL) { ATL::CWindow ctlPrev = pT->GetDlgItem(pDataPrev->m_nCtlID); - RECT rcPrev = { 0 }; + RECT rcPrev = {}; ctlPrev.GetWindowRect(&rcPrev); ::MapWindowPoints(NULL, pT->m_hWnd, (LPPOINT)&rcPrev, 2); int dxAdjust = (rectCtl.left - rcPrev.right) - (data.m_rect.left - pDataPrev->m_rect.right); @@ -3562,7 +3197,7 @@ public: if(pDataPrev != NULL) { ATL::CWindow ctlPrev = pT->GetDlgItem(pDataPrev->m_nCtlID); - RECT rcPrev = { 0 }; + RECT rcPrev = {}; ctlPrev.GetWindowRect(&rcPrev); ::MapWindowPoints(NULL, pT->m_hWnd, (LPPOINT)&rcPrev, 2); int dxAdjust = (rectCtl.top - rcPrev.bottom) - (data.m_rect.top - pDataPrev->m_rect.bottom); @@ -3618,6 +3253,254 @@ public: }; +/////////////////////////////////////////////////////////////////////////////// +// CDynamicDialogLayout - support for dialog dynamic layout resource info +// (AFX_DIALOG_LAYOUT) in VS2015 and higher + +#if (_MSC_VER >= 1900) + +template +class CDynamicDialogLayout +{ +public: +// Data declarations + struct _AtlDynamicLayoutData + { + HWND m_hWnd; + char m_nMoveRatioX; + char m_nMoveRatioY; + char m_nSizeRatioX; + char m_nSizeRatioY; + RECT m_rcInit; + }; + +// Data members + ATL::CSimpleArray<_AtlDynamicLayoutData> m_arrLayoutData; + SIZE m_szParentInit; + POINT m_ptMinTrackSize; + bool m_bGripper; + +// Constructor + CDynamicDialogLayout() : m_bGripper(false) + { + m_szParentInit.cx = 0; + m_szParentInit.cy = 0; + m_ptMinTrackSize.x = -1; + m_ptMinTrackSize.y = -1; + } + +// Methods + void InitDynamicLayout(bool bAddGripper = true, bool bMinTrackSize = true) + { + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + + // Cleanup in case of multiple initialization + // block: first check for the gripper control, destroy it if needed + { + ATL::CWindow wndGripper = pT->GetDlgItem(ATL_IDW_STATUS_BAR); + if(wndGripper.IsWindow() != FALSE) + wndGripper.DestroyWindow(); + } + // clear out everything else + m_arrLayoutData.RemoveAll(); + m_ptMinTrackSize.x = -1; + m_ptMinTrackSize.y = -1; + m_szParentInit.cx = 0; + m_szParentInit.cy = 0; + m_bGripper = false; + + CResource rcLayout; + if(rcLayout.Load(_T("AFX_DIALOG_LAYOUT"), pT->IDD)) + { + int nCount = rcLayout.GetSize() / sizeof(WORD); + if(nCount > 1) + { + RECT rcParent = {}; + pT->GetWindowRect(&rcParent); + m_szParentInit.cx = rcParent.right - rcParent.left; + m_szParentInit.cy = rcParent.bottom - rcParent.top; + + WORD* pnData = (WORD*)rcLayout.Lock(); + WORD wVersion = *pnData; // AFX_DIALOG_LAYOUT version + ATLASSERT(wVersion == 0); + if(wVersion == 0) + { + pnData++; // skip version + ATL::CWindow wndChild = pT->GetWindow(GW_CHILD); + for(int i = 0; (i < nCount) && (wndChild.m_hWnd != NULL); i += 4) + { + char nMoveRatioX = _GetDataPct(pnData[i]); + char nMoveRatioY = _GetDataPct(pnData[i + 1]); + char nSizeRatioX = _GetDataPct(pnData[i + 2]); + char nSizeRatioY = _GetDataPct(pnData[i + 3]); + + bool bValid = ((nMoveRatioX != -1) && (nMoveRatioY != -1) && (nSizeRatioX != -1) && (nSizeRatioY != -1)); + bool bAction = ((nMoveRatioX != 0) || (nMoveRatioY != 0) || (nSizeRatioX != 0) || (nSizeRatioY != 0)); + if(bValid && bAction) + { + _AtlDynamicLayoutData LayoutData = { wndChild.m_hWnd, nMoveRatioX, nMoveRatioY, nSizeRatioX, nSizeRatioY }; + wndChild.GetWindowRect(&LayoutData.m_rcInit); + pT->ScreenToClient(&LayoutData.m_rcInit); + m_arrLayoutData.Add(LayoutData); + } + + wndChild = wndChild.GetWindow(GW_HWNDNEXT); + } + } + + rcLayout.Release(); + } + } + + if(bAddGripper) + { + RECT rcDialog = {}; + pT->GetClientRect(&rcDialog); + + ATL::CWindow wndGripper = pT->GetDlgItem(ATL_IDW_STATUS_BAR); + if(wndGripper.m_hWnd != NULL) + wndGripper.DestroyWindow(); + + wndGripper.Create(_T("SCROLLBAR"), pT->m_hWnd, rcDialog, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | SBS_SIZEBOX | SBS_SIZEGRIP | SBS_SIZEBOXBOTTOMRIGHTALIGN, 0, ATL_IDW_STATUS_BAR); + ATLASSERT(wndGripper.m_hWnd != NULL); + if(wndGripper.m_hWnd != NULL) + { + m_bGripper = true; + _AtlDynamicLayoutData LayoutData = { wndGripper.m_hWnd, 100, 100, 0, 0 }; + wndGripper.GetWindowRect(&LayoutData.m_rcInit); + pT->ScreenToClient(&LayoutData.m_rcInit); + m_arrLayoutData.Add(LayoutData); + } + } + + if(bMinTrackSize) + { + RECT rcMinTrack = {}; + if((pT->GetStyle() & WS_CHILD) != 0) + pT->GetClientRect(&rcMinTrack); + else + pT->GetWindowRect(&rcMinTrack); + + m_ptMinTrackSize.x = rcMinTrack.right - rcMinTrack.left; + m_ptMinTrackSize.y = rcMinTrack.bottom - rcMinTrack.top; + } + } + + void UpdateDynamicLayout() + { + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + + int nCount = m_arrLayoutData.GetSize(); + if(nCount == 0) + return; + + RECT rcParent = {}; + pT->GetWindowRect(&rcParent); + + int nDeltaWidth = rcParent.right - rcParent.left - m_szParentInit.cx; + int nDeltaHeight = rcParent.bottom - rcParent.top - m_szParentInit.cy; + + HDWP hDwp = ::BeginDeferWindowPos(nCount); + + for(int i = 0; i < nCount; i++) + { + _AtlDynamicLayoutData& LayoutData = m_arrLayoutData[i]; + + ATLASSERT(::IsWindow(LayoutData.m_hWnd) != FALSE); + + int nID = ::GetDlgCtrlID(LayoutData.m_hWnd); + UINT nFlags = (SWP_NOMOVE | SWP_NOSIZE); + RECT rcItem = LayoutData.m_rcInit; + + if(((nID == ATL_IDW_STATUS_BAR) || (nDeltaWidth >= 0)) && (LayoutData.m_nMoveRatioX != 0)) + { + rcItem.left += ::MulDiv(nDeltaWidth, LayoutData.m_nMoveRatioX, 100); + rcItem.right += ::MulDiv(nDeltaWidth, LayoutData.m_nMoveRatioX, 100); + nFlags &= ~SWP_NOMOVE; + } + + if(((nID == ATL_IDW_STATUS_BAR) || (nDeltaHeight >= 0)) && (LayoutData.m_nMoveRatioY != 0)) + { + rcItem.top += ::MulDiv(nDeltaHeight, LayoutData.m_nMoveRatioY, 100); + rcItem.bottom += ::MulDiv(nDeltaHeight, LayoutData.m_nMoveRatioY, 100); + nFlags &= ~SWP_NOMOVE; + } + + if((nDeltaWidth >= 0) && (LayoutData.m_nSizeRatioX != 0)) + { + rcItem.right += ::MulDiv(nDeltaWidth, LayoutData.m_nSizeRatioX, 100); + nFlags &= ~SWP_NOSIZE; + } + + if((nDeltaHeight >= 0) && (LayoutData.m_nSizeRatioY != 0)) + { + rcItem.bottom += ::MulDiv(nDeltaHeight, LayoutData.m_nSizeRatioY, 100); + nFlags &= ~SWP_NOSIZE; + } + + if(nFlags != (SWP_NOMOVE | SWP_NOSIZE)) + ::DeferWindowPos(hDwp, LayoutData.m_hWnd, NULL, rcItem.left, rcItem.top, rcItem.right - rcItem.left, rcItem.bottom - rcItem.top, nFlags | SWP_NOZORDER | SWP_NOREPOSITION | SWP_NOACTIVATE | SWP_NOCOPYBITS); + } + + ::EndDeferWindowPos(hDwp); + } + +// Message map and handlers + BEGIN_MSG_MAP(CDynamicDialogLayout) + MESSAGE_HANDLER(WM_SIZE, OnSize) + MESSAGE_HANDLER(WM_GETMINMAXINFO, OnGetMinMaxInfo) + END_MSG_MAP() + + LRESULT OnSize(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + T* pT = static_cast(this); + + if(m_bGripper) + { + ATL::CWindow wndGripper = pT->GetDlgItem(ATL_IDW_STATUS_BAR); + if(wndGripper.m_hWnd != NULL) + { + if(wParam == SIZE_MAXIMIZED) + wndGripper.ShowWindow(SW_HIDE); + else if(wParam == SIZE_RESTORED) + wndGripper.ShowWindow(SW_SHOW); + } + } + + if(wParam != SIZE_MINIMIZED) + pT->UpdateDynamicLayout(); + + return 0; + } + + LRESULT OnGetMinMaxInfo(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/) + { + if((m_ptMinTrackSize.x != -1) && (m_ptMinTrackSize.y != -1)) + { + LPMINMAXINFO lpMMI = (LPMINMAXINFO)lParam; + lpMMI->ptMinTrackSize = m_ptMinTrackSize; + } + + return 0; + } + +// Implementation + char _GetDataPct(WORD wResData) + { + ATLASSERT((wResData >= 0) && (wResData <= 100)); + char nPct = (char)LOBYTE(wResData); + if((nPct < 0) || (nPct > 100)) + nPct = -1; + + return nPct; + } +}; + +#endif // (_MSC_VER >= 1900) + + /////////////////////////////////////////////////////////////////////////////// // CDoubleBufferImpl - Provides double-buffer painting support to any window @@ -3636,9 +3519,7 @@ public: BEGIN_MSG_MAP(CDoubleBufferImpl) MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackground) MESSAGE_HANDLER(WM_PAINT, OnPaint) -#ifndef _WIN32_WCE MESSAGE_HANDLER(WM_PRINTCLIENT, OnPaint) -#endif // !_WIN32_WCE END_MSG_MAP() LRESULT OnEraseBackground(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) @@ -3653,7 +3534,7 @@ public: if(wParam != NULL) { - RECT rect = { 0 }; + RECT rect = {}; pT->GetClientRect(&rect); CMemoryDC dcMem((HDC)wParam, rect); pT->DoPaint(dcMem.m_hDC); @@ -3684,13 +3565,13 @@ public: // command bar support -#if !defined(__ATLCTRLW_H__) && !defined(_WIN32_WCE) +#if !defined(__ATLCTRLW_H__) #undef CBRM_GETMENU #undef CBRM_TRACKPOPUPMENU #undef CBRM_GETCMDBAR #undef CBRPOPUPMENU -#endif // !defined(__ATLCTRLW_H__) && !defined(_WIN32_WCE) +#endif // !defined(__ATLCTRLW_H__) -}; // namespace WTL +} // namespace WTL #endif // __ATLFRAME_H__ diff --git a/ZbaSDK/SampleCode/PluginWinExe/WTL/atlgdi.h b/ZbaSDK/SampleCode/PluginWinExe/WTL/atlgdi.h index 946e8de6530df0eb9355f3de2a13c691e412f34a..14e151899b3dd3354bd1a7ffe919b576dfea7ca5 100644 --- a/ZbaSDK/SampleCode/PluginWinExe/WTL/atlgdi.h +++ b/ZbaSDK/SampleCode/PluginWinExe/WTL/atlgdi.h @@ -1,4 +1,4 @@ -// Windows Template Library - WTL version 9.10 +// Windows Template Library - WTL version 10.0 // Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. // // This file is a part of the Windows Template Library. @@ -28,10 +28,8 @@ #endif // _INC_WINDOWSX // required libraries -#if !defined(_ATL_NO_MSIMG) && !defined(_WIN32_WCE) - #pragma comment(lib, "msimg32.lib") -#endif -#if !defined(_ATL_NO_OPENGL) && !defined(_WIN32_WCE) +#pragma comment(lib, "msimg32.lib") +#if !defined(_ATL_NO_OPENGL) #pragma comment(lib, "opengl32.lib") #endif @@ -54,19 +52,6 @@ // CEnhMetaFileInfo // CEnhMetaFileT // CEnhMetaFileDC -// -// Global functions: -// AtlGetBitmapResourceInfo() -// AtlGetBitmapResourceBitsPerPixel() -// AtlIsAlphaBitmapResource() -// AtlIsDib16() -// AtlGetDibColorTableSize() -// AtlGetDibNumColors(), -// AtlGetDibBitmap() -// AtlCopyBitmap() -// AtlCreatePackedDib16() -// AtlSetClipboardDib16() -// AtlGetClipboardDib() namespace WTL @@ -127,7 +112,7 @@ public: ~CPenT() { - if(t_bManaged && m_hPen != NULL) + if(t_bManaged && (m_hPen != NULL)) DeleteObject(); } @@ -139,7 +124,7 @@ public: void Attach(HPEN hPen) { - if(t_bManaged && m_hPen != NULL && m_hPen != hPen) + if(t_bManaged && (m_hPen != NULL) && (m_hPen != hPen)) ::DeleteObject(m_hPen); m_hPen = hPen; } @@ -163,14 +148,12 @@ public: return m_hPen; } -#ifndef _WIN32_WCE HPEN CreatePen(int nPenStyle, int nWidth, const LOGBRUSH* pLogBrush, int nStyleCount = 0, const DWORD* lpStyle = NULL) { ATLASSERT(m_hPen == NULL); m_hPen = ::ExtCreatePen(nPenStyle, nWidth, pLogBrush, nStyleCount, lpStyle); return m_hPen; } -#endif // !_WIN32_WCE HPEN CreatePenIndirect(LPLOGPEN lpLogPen) { @@ -201,7 +184,6 @@ public: return (::GetObject(m_hPen, sizeof(LOGPEN), &LogPen) == sizeof(LOGPEN)); } -#ifndef _WIN32_WCE int GetExtLogPen(EXTLOGPEN* pLogPen, int nSize = sizeof(EXTLOGPEN)) const { ATLASSERT(m_hPen != NULL); @@ -214,7 +196,6 @@ public: int nRet = ::GetObject(m_hPen, nSize, &ExtLogPen); return ((nRet > 0) && (nRet <= nSize)); } -#endif // !_WIN32_WCE }; typedef CPenT CPenHandle; @@ -237,7 +218,7 @@ public: ~CBrushT() { - if(t_bManaged && m_hBrush != NULL) + if(t_bManaged && (m_hBrush != NULL)) DeleteObject(); } @@ -249,7 +230,7 @@ public: void Attach(HBRUSH hBrush) { - if(t_bManaged && m_hBrush != NULL && m_hBrush != hBrush) + if(t_bManaged && (m_hBrush != NULL) && (m_hBrush != hBrush)) ::DeleteObject(m_hBrush); m_hBrush = hBrush; } @@ -273,27 +254,19 @@ public: return m_hBrush; } -#ifndef _WIN32_WCE HBRUSH CreateHatchBrush(int nIndex, COLORREF crColor) { ATLASSERT(m_hBrush == NULL); m_hBrush = ::CreateHatchBrush(nIndex, crColor); return m_hBrush; } -#endif // !_WIN32_WCE -#if !defined(_WIN32_WCE) || (_ATL_VER >= 0x0800) HBRUSH CreateBrushIndirect(const LOGBRUSH* lpLogBrush) { ATLASSERT(m_hBrush == NULL); -#ifndef _WIN32_WCE m_hBrush = ::CreateBrushIndirect(lpLogBrush); -#else // CE specific - m_hBrush = ATL::CreateBrushIndirect(lpLogBrush); -#endif // _WIN32_WCE return m_hBrush; } -#endif // !defined(_WIN32_WCE) || (_ATL_VER >= 0x0800) HBRUSH CreatePatternBrush(HBITMAP hBitmap) { @@ -426,17 +399,12 @@ public: LONG GetDeciPointHeight(HDC hDC = NULL) const { HDC hDC1 = (hDC != NULL) ? hDC : ::GetDC(NULL); -#ifndef _WIN32_WCE POINT ptOrg = { 0, 0 }; ::DPtoLP(hDC1, &ptOrg, 1); POINT pt = { 0, 0 }; pt.y = abs(lfHeight) + ptOrg.y; - ::LPtoDP(hDC1, &pt,1); + ::LPtoDP(hDC1, &pt, 1); LONG nDeciPoint = ::MulDiv(pt.y, 720, ::GetDeviceCaps(hDC1, LOGPIXELSY)); // 72 points/inch, 10 decipoints/point -#else // CE specific - // DP and LP are always the same on CE - LONG nDeciPoint = ::MulDiv(abs(lfHeight), 720, ::GetDeviceCaps(hDC1, LOGPIXELSY)); // 72 points/inch, 10 decipoints/point -#endif // _WIN32_WCE if(hDC == NULL) ::ReleaseDC(NULL, hDC1); @@ -446,22 +414,16 @@ public: void SetHeightFromDeciPoint(LONG nDeciPtHeight, HDC hDC = NULL) { HDC hDC1 = (hDC != NULL) ? hDC : ::GetDC(NULL); -#ifndef _WIN32_WCE POINT pt = { 0, 0 }; pt.y = ::MulDiv(::GetDeviceCaps(hDC1, LOGPIXELSY), nDeciPtHeight, 720); // 72 points/inch, 10 decipoints/point ::DPtoLP(hDC1, &pt, 1); POINT ptOrg = { 0, 0 }; ::DPtoLP(hDC1, &ptOrg, 1); lfHeight = -abs(pt.y - ptOrg.y); -#else // CE specific - // DP and LP are always the same on CE - lfHeight = -abs(::MulDiv(::GetDeviceCaps(hDC1, LOGPIXELSY), nDeciPtHeight, 720)); // 72 points/inch, 10 decipoints/point -#endif // _WIN32_WCE if(hDC == NULL) ::ReleaseDC(NULL, hDC1); } -#ifndef _WIN32_WCE void SetCaptionFont() { NONCLIENTMETRICS ncm = { RunTimeHelper::SizeOf_NONCLIENTMETRICS() }; @@ -489,7 +451,6 @@ public: ATLVERIFY(::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(ncm), &ncm, 0)); Copy(&ncm.lfMessageFont); } -#endif // !_WIN32_WCE void Copy(const LOGFONT* pLogFont) { @@ -518,20 +479,20 @@ public: bool operator ==(const LOGFONT& logfont) const { - return(logfont.lfHeight == lfHeight && - logfont.lfWidth == lfWidth && - logfont.lfEscapement == lfEscapement && - logfont.lfOrientation == lfOrientation && - logfont.lfWeight == lfWeight && - logfont.lfItalic == lfItalic && - logfont.lfUnderline == lfUnderline && - logfont.lfStrikeOut == lfStrikeOut && - logfont.lfCharSet == lfCharSet && - logfont.lfOutPrecision == lfOutPrecision && - logfont.lfClipPrecision == lfClipPrecision && - logfont.lfQuality == lfQuality && - logfont.lfPitchAndFamily == lfPitchAndFamily && - lstrcmp(logfont.lfFaceName, lfFaceName) == 0); + return((logfont.lfHeight == lfHeight) && + (logfont.lfWidth == lfWidth) && + (logfont.lfEscapement == lfEscapement) && + (logfont.lfOrientation == lfOrientation) && + (logfont.lfWeight == lfWeight) && + (logfont.lfItalic == lfItalic) && + (logfont.lfUnderline == lfUnderline) && + (logfont.lfStrikeOut == lfStrikeOut) && + (logfont.lfCharSet == lfCharSet) && + (logfont.lfOutPrecision == lfOutPrecision) && + (logfont.lfClipPrecision == lfClipPrecision) && + (logfont.lfQuality == lfQuality) && + (logfont.lfPitchAndFamily == lfPitchAndFamily) && + (lstrcmp(logfont.lfFaceName, lfFaceName) == 0)); } }; @@ -549,7 +510,7 @@ public: ~CFontT() { - if(t_bManaged && m_hFont != NULL) + if(t_bManaged && (m_hFont != NULL)) DeleteObject(); } @@ -561,7 +522,7 @@ public: void Attach(HFONT hFont) { - if(t_bManaged && m_hFont != NULL && m_hFont != hFont) + if(t_bManaged && (m_hFont != NULL) && (m_hFont != hFont)) ::DeleteObject(m_hFont); m_hFont = hFont; } @@ -585,16 +546,13 @@ public: return m_hFont; } -#if !defined(_WIN32_WCE) && (_WIN32_WINNT >= 0x0500) HFONT CreateFontIndirectEx(CONST ENUMLOGFONTEXDV* penumlfex) { ATLASSERT(m_hFont == NULL); m_hFont = ::CreateFontIndirectEx(penumlfex); return m_hFont; } -#endif // !defined(_WIN32_WCE) && (_WIN32_WINNT >= 0x0500) -#if !defined(_WIN32_WCE) || (_ATL_VER >= 0x0800) HFONT CreateFont(int nHeight, int nWidth, int nEscapement, int nOrientation, int nWeight, BYTE bItalic, BYTE bUnderline, BYTE cStrikeOut, BYTE nCharSet, BYTE nOutPrecision, @@ -602,27 +560,19 @@ public: LPCTSTR lpszFacename) { ATLASSERT(m_hFont == NULL); -#ifndef _WIN32_WCE m_hFont = ::CreateFont(nHeight, nWidth, nEscapement, nOrientation, nWeight, bItalic, bUnderline, cStrikeOut, nCharSet, nOutPrecision, nClipPrecision, nQuality, nPitchAndFamily, lpszFacename); -#else // CE specific - m_hFont = ATL::CreateFont(nHeight, nWidth, nEscapement, - nOrientation, nWeight, bItalic, bUnderline, cStrikeOut, - nCharSet, nOutPrecision, nClipPrecision, nQuality, - nPitchAndFamily, lpszFacename); -#endif // _WIN32_WCE return m_hFont; } -#endif // !defined(_WIN32_WCE) || (_ATL_VER >= 0x0800) HFONT CreatePointFont(int nPointSize, LPCTSTR lpszFaceName, HDC hDC = NULL, bool bBold = false, bool bItalic = false) { - LOGFONT logFont = { 0 }; + LOGFONT logFont = {}; logFont.lfCharSet = DEFAULT_CHARSET; logFont.lfHeight = nPointSize; - SecureHelper::strncpy_x(logFont.lfFaceName, _countof(logFont.lfFaceName), lpszFaceName, _TRUNCATE); + ATL::Checked::tcsncpy_s(logFont.lfFaceName, _countof(logFont.lfFaceName), lpszFaceName, _TRUNCATE); if(bBold) logFont.lfWeight = FW_BOLD; @@ -638,17 +588,12 @@ public: // convert nPointSize to logical units based on hDC LOGFONT logFont = *lpLogFont; -#ifndef _WIN32_WCE POINT pt = { 0, 0 }; pt.y = ::MulDiv(::GetDeviceCaps(hDC1, LOGPIXELSY), logFont.lfHeight, 720); // 72 points/inch, 10 decipoints/point ::DPtoLP(hDC1, &pt, 1); POINT ptOrg = { 0, 0 }; ::DPtoLP(hDC1, &ptOrg, 1); logFont.lfHeight = -abs(pt.y - ptOrg.y); -#else // CE specific - // DP and LP are always the same on CE - logFont.lfHeight = -abs(::MulDiv(::GetDeviceCaps(hDC1, LOGPIXELSY), logFont.lfHeight, 720)); // 72 points/inch, 10 decipoints/point -#endif // _WIN32_WCE if(hDC == NULL) ::ReleaseDC(NULL, hDC1); @@ -699,7 +644,7 @@ public: ~CBitmapT() { - if(t_bManaged && m_hBitmap != NULL) + if(t_bManaged && (m_hBitmap != NULL)) DeleteObject(); } @@ -711,7 +656,7 @@ public: void Attach(HBITMAP hBitmap) { - if(t_bManaged && m_hBitmap != NULL&& m_hBitmap != hBitmap) + if(t_bManaged && (m_hBitmap != NULL) && (m_hBitmap != hBitmap)) ::DeleteObject(m_hBitmap); m_hBitmap = hBitmap; } @@ -742,14 +687,12 @@ public: return m_hBitmap; } -#ifndef _WIN32_WCE HBITMAP LoadMappedBitmap(UINT nIDBitmap, UINT nFlags = 0, LPCOLORMAP lpColorMap = NULL, int nMapSize = 0) { ATLASSERT(m_hBitmap == NULL); m_hBitmap = ::CreateMappedBitmap(ModuleHelper::GetResourceInstance(), nIDBitmap, (WORD)nFlags, lpColorMap, nMapSize); return m_hBitmap; } -#endif // !_WIN32_WCE HBITMAP CreateBitmap(int nWidth, int nHeight, UINT nPlanes, UINT nBitsPerPixel, const void* lpBits) { @@ -758,14 +701,12 @@ public: return m_hBitmap; } -#ifndef _WIN32_WCE HBITMAP CreateBitmapIndirect(LPBITMAP lpBitmap) { ATLASSERT(m_hBitmap == NULL); m_hBitmap = ::CreateBitmapIndirect(lpBitmap); return m_hBitmap; } -#endif // !_WIN32_WCE HBITMAP CreateCompatibleBitmap(HDC hDC, int nWidth, int nHeight) { @@ -774,14 +715,12 @@ public: return m_hBitmap; } -#ifndef _WIN32_WCE HBITMAP CreateDiscardableBitmap(HDC hDC, int nWidth, int nHeight) { ATLASSERT(m_hBitmap == NULL); m_hBitmap = ::CreateDiscardableBitmap(hDC, nWidth, nHeight); return m_hBitmap; } -#endif // !_WIN32_WCE BOOL DeleteObject() { @@ -808,7 +747,7 @@ public: bool GetSize(SIZE& size) const { ATLASSERT(m_hBitmap != NULL); - BITMAP bm = { 0 }; + BITMAP bm = {}; if(!GetBitmap(&bm)) return false; size.cx = bm.bmWidth; @@ -816,23 +755,18 @@ public: return true; } -#ifndef _WIN32_WCE DWORD GetBitmapBits(DWORD dwCount, LPVOID lpBits) const { ATLASSERT(m_hBitmap != NULL); return ::GetBitmapBits(m_hBitmap, dwCount, lpBits); } -#endif // !_WIN32_WCE -#if !defined(_WIN32_WCE) || (_WIN32_WCE >= 410) DWORD SetBitmapBits(DWORD dwCount, const void* lpBits) { ATLASSERT(m_hBitmap != NULL); return ::SetBitmapBits(m_hBitmap, dwCount, lpBits); } -#endif // !defined(_WIN32_WCE) || (_WIN32_WCE >= 410) -#ifndef _WIN32_WCE BOOL GetBitmapDimension(LPSIZE lpSize) const { ATLASSERT(m_hBitmap != NULL); @@ -852,7 +786,6 @@ public: m_hBitmap = ::CreateDIBitmap(hDC, lpbmih, dwInit, lpbInit, lpbmi, uColorUse); return m_hBitmap; } -#endif // !_WIN32_WCE HBITMAP CreateDIBSection(HDC hDC, CONST BITMAPINFO* lpbmi, UINT uColorUse, VOID** ppvBits, HANDLE hSection, DWORD dwOffset) { @@ -861,7 +794,6 @@ public: return m_hBitmap; } -#ifndef _WIN32_WCE int GetDIBits(HDC hDC, UINT uStartScan, UINT cScanLines, LPVOID lpvBits, LPBITMAPINFO lpbmi, UINT uColorUse) const { ATLASSERT(m_hBitmap != NULL); @@ -873,7 +805,6 @@ public: ATLASSERT(m_hBitmap != NULL); return ::SetDIBits(hDC, m_hBitmap, uStartScan, cScanLines, lpvBits, lpbmi, uColorUse); } -#endif // !_WIN32_WCE }; typedef CBitmapT CBitmapHandle; @@ -896,7 +827,7 @@ public: ~CPaletteT() { - if(t_bManaged && m_hPalette != NULL) + if(t_bManaged && (m_hPalette != NULL)) DeleteObject(); } @@ -908,7 +839,7 @@ public: void Attach(HPALETTE hPalette) { - if(t_bManaged && m_hPalette != NULL && m_hPalette != hPalette) + if(t_bManaged && (m_hPalette != NULL) && (m_hPalette != hPalette)) ::DeleteObject(m_hPalette); m_hPalette = hPalette; } @@ -932,7 +863,6 @@ public: return m_hPalette; } -#ifndef _WIN32_WCE HPALETTE CreateHalftonePalette(HDC hDC) { ATLASSERT(m_hPalette == NULL); @@ -940,7 +870,6 @@ public: m_hPalette = ::CreateHalftonePalette(hDC); return m_hPalette; } -#endif // !_WIN32_WCE BOOL DeleteObject() { @@ -973,7 +902,6 @@ public: } // Operations -#ifndef _WIN32_WCE void AnimatePalette(UINT nStartIndex, UINT nNumEntries, LPPALETTEENTRY lpPaletteColors) { ATLASSERT(m_hPalette != NULL); @@ -985,7 +913,6 @@ public: ATLASSERT(m_hPalette != NULL); return ::ResizePalette(m_hPalette, nNumEntries); } -#endif // !_WIN32_WCE UINT GetNearestPaletteIndex(COLORREF crColor) const { @@ -1014,7 +941,7 @@ public: ~CRgnT() { - if(t_bManaged && m_hRgn != NULL) + if(t_bManaged && (m_hRgn != NULL)) DeleteObject(); } @@ -1026,7 +953,7 @@ public: void Attach(HRGN hRgn) { - if(t_bManaged && m_hRgn != NULL && m_hRgn != hRgn) + if(t_bManaged && (m_hRgn != NULL) && (m_hRgn != hRgn)) ::DeleteObject(m_hRgn); m_hRgn = hRgn; } @@ -1057,7 +984,6 @@ public: return m_hRgn; } -#ifndef _WIN32_WCE HRGN CreateEllipticRgn(int x1, int y1, int x2, int y2) { ATLASSERT(m_hRgn == NULL); @@ -1072,14 +998,14 @@ public: return m_hRgn; } - HRGN CreatePolygonRgn(LPPOINT lpPoints, int nCount, int nMode) + HRGN CreatePolygonRgn(const POINT* lpPoints, int nCount, int nMode) { ATLASSERT(m_hRgn == NULL); m_hRgn = ::CreatePolygonRgn(lpPoints, nCount, nMode); return m_hRgn; } - HRGN CreatePolyPolygonRgn(LPPOINT lpPoints, LPINT lpPolyCounts, int nCount, int nPolyFillMode) + HRGN CreatePolyPolygonRgn(const POINT* lpPoints, const INT* lpPolyCounts, int nCount, int nPolyFillMode) { ATLASSERT(m_hRgn == NULL); m_hRgn = ::CreatePolyPolygonRgn(lpPoints, lpPolyCounts, nCount, nPolyFillMode); @@ -1107,7 +1033,6 @@ public: m_hRgn = ::ExtCreateRegion(lpXForm, nCount, pRgnData); return m_hRgn; } -#endif // !_WIN32_WCE BOOL DeleteObject() { @@ -1205,6 +1130,11 @@ typedef CRgnT CRgn; /////////////////////////////////////////////////////////////////////////////// // CDC - The device context class +template +class CDCT; +typedef CDCT CDCHandle; +typedef CDCT CDC; + template class CDCT { @@ -1219,7 +1149,7 @@ public: ~CDCT() { - if(t_bManaged && m_hDC != NULL) + if(t_bManaged && (m_hDC != NULL)) ::DeleteDC(Detach()); } @@ -1231,7 +1161,7 @@ public: void Attach(HDC hDC) { - if(t_bManaged && m_hDC != NULL && m_hDC != hDC) + if(t_bManaged && (m_hDC != NULL) && (m_hDC != hDC)) ::DeleteDC(m_hDC); m_hDC = hDC; } @@ -1248,13 +1178,11 @@ public: bool IsNull() const { return (m_hDC == NULL); } // Operations -#ifndef _WIN32_WCE HWND WindowFromDC() const { ATLASSERT(m_hDC != NULL); return ::WindowFromDC(m_hDC); } -#endif // !_WIN32_WCE CPenHandle GetCurrentPen() const { @@ -1329,7 +1257,6 @@ public: return ::GetDeviceCaps(m_hDC, nIndex); } -#ifndef _WIN32_WCE UINT SetBoundsRect(LPCRECT lpRectBounds, UINT flags) { ATLASSERT(m_hDC != NULL); @@ -1354,7 +1281,6 @@ public: ATLASSERT(m_hDC != NULL); return ::GetBrushOrgEx(m_hDC, lpPoint); } -#endif // !_WIN32_WCE BOOL SetBrushOrg(int x, int y, LPPOINT lpPoint = NULL) { @@ -1368,7 +1294,6 @@ public: return ::SetBrushOrgEx(m_hDC, point.x, point.y, lpPointRet); } -#ifndef _WIN32_WCE int EnumObjects(int nObjectType, int (CALLBACK* lpfn)(LPVOID, LPARAM), LPARAM lpData) { ATLASSERT(m_hDC != NULL); @@ -1378,45 +1303,40 @@ public: return ::EnumObjects(m_hDC, nObjectType, (GOBJENUMPROC)lpfn, (LPVOID)lpData); #endif } -#endif // !_WIN32_WCE // Type-safe selection helpers HPEN SelectPen(HPEN hPen) { ATLASSERT(m_hDC != NULL); -#ifndef _WIN32_WCE - ATLASSERT(hPen == NULL || ::GetObjectType(hPen) == OBJ_PEN || ::GetObjectType(hPen) == OBJ_EXTPEN); -#else // CE specific - ATLASSERT(hPen == NULL || ::GetObjectType(hPen) == OBJ_PEN); -#endif // _WIN32_WCE + ATLASSERT((hPen == NULL) || (::GetObjectType(hPen) == OBJ_PEN) || (::GetObjectType(hPen) == OBJ_EXTPEN)); return (HPEN)::SelectObject(m_hDC, hPen); } HBRUSH SelectBrush(HBRUSH hBrush) { ATLASSERT(m_hDC != NULL); - ATLASSERT(hBrush == NULL || ::GetObjectType(hBrush) == OBJ_BRUSH); + ATLASSERT((hBrush == NULL) || (::GetObjectType(hBrush) == OBJ_BRUSH)); return (HBRUSH)::SelectObject(m_hDC, hBrush); } HFONT SelectFont(HFONT hFont) { ATLASSERT(m_hDC != NULL); - ATLASSERT(hFont == NULL || ::GetObjectType(hFont) == OBJ_FONT); + ATLASSERT((hFont == NULL) || (::GetObjectType(hFont) == OBJ_FONT)); return (HFONT)::SelectObject(m_hDC, hFont); } HBITMAP SelectBitmap(HBITMAP hBitmap) { ATLASSERT(m_hDC != NULL); - ATLASSERT(hBitmap == NULL || ::GetObjectType(hBitmap) == OBJ_BITMAP); + ATLASSERT((hBitmap == NULL) || (::GetObjectType(hBitmap) == OBJ_BITMAP)); return (HBITMAP)::SelectObject(m_hDC, hBitmap); } int SelectRgn(HRGN hRgn) // special return for regions { ATLASSERT(m_hDC != NULL); - ATLASSERT(hRgn == NULL || ::GetObjectType(hRgn) == OBJ_REGION); + ATLASSERT((hRgn == NULL) || (::GetObjectType(hRgn) == OBJ_REGION)); return PtrToInt(::SelectObject(m_hDC, hRgn)); } @@ -1424,31 +1344,19 @@ public: HPEN SelectStockPen(int nPen) { ATLASSERT(m_hDC != NULL); -#if (_WIN32_WINNT >= 0x0500) - ATLASSERT(nPen == WHITE_PEN || nPen == BLACK_PEN || nPen == NULL_PEN || nPen == DC_PEN); -#else - ATLASSERT(nPen == WHITE_PEN || nPen == BLACK_PEN || nPen == NULL_PEN); -#endif // !(_WIN32_WINNT >= 0x0500) + ATLASSERT((nPen == WHITE_PEN) || (nPen == BLACK_PEN) || (nPen == NULL_PEN) || (nPen == DC_PEN)); return SelectPen((HPEN)::GetStockObject(nPen)); } HBRUSH SelectStockBrush(int nBrush) { -#if (_WIN32_WINNT >= 0x0500) - ATLASSERT((nBrush >= WHITE_BRUSH && nBrush <= HOLLOW_BRUSH) || nBrush == DC_BRUSH); -#else - ATLASSERT(nBrush >= WHITE_BRUSH && nBrush <= HOLLOW_BRUSH); -#endif // !(_WIN32_WINNT >= 0x0500) + ATLASSERT(((nBrush >= WHITE_BRUSH) && (nBrush <= HOLLOW_BRUSH)) || (nBrush == DC_BRUSH)); return SelectBrush((HBRUSH)::GetStockObject(nBrush)); } HFONT SelectStockFont(int nFont) { -#ifndef _WIN32_WCE - ATLASSERT((nFont >= OEM_FIXED_FONT && nFont <= SYSTEM_FIXED_FONT) || nFont == DEFAULT_GUI_FONT); -#else // CE specific - ATLASSERT(nFont == SYSTEM_FONT); -#endif // _WIN32_WCE + ATLASSERT(((nFont >= OEM_FIXED_FONT) && (nFont <= SYSTEM_FIXED_FONT)) || (nFont == DEFAULT_GUI_FONT)); return SelectFont((HFONT)::GetStockObject(nFont)); } @@ -1478,13 +1386,11 @@ public: return ::RealizePalette(m_hDC); } -#ifndef _WIN32_WCE void UpdateColors() { ATLASSERT(m_hDC != NULL); ::UpdateColors(m_hDC); } -#endif // !_WIN32_WCE // Drawing-Attribute Functions COLORREF GetBkColor() const @@ -1499,7 +1405,6 @@ public: return ::GetBkMode(m_hDC); } -#ifndef _WIN32_WCE int GetPolyFillMode() const { ATLASSERT(m_hDC != NULL); @@ -1517,7 +1422,6 @@ public: ATLASSERT(m_hDC != NULL); return ::GetStretchBltMode(m_hDC); } -#endif // !_WIN32_WCE COLORREF GetTextColor() const { @@ -1537,13 +1441,11 @@ public: return ::SetBkMode(m_hDC, nBkMode); } -#ifndef _WIN32_WCE int SetPolyFillMode(int nPolyFillMode) { ATLASSERT(m_hDC != NULL); return ::SetPolyFillMode(m_hDC, nPolyFillMode); } -#endif // !_WIN32_WCE int SetROP2(int nDrawMode) { @@ -1551,13 +1453,11 @@ public: return ::SetROP2(m_hDC, nDrawMode); } -#ifndef _WIN32_WCE int SetStretchBltMode(int nStretchMode) { ATLASSERT(m_hDC != NULL); return ::SetStretchBltMode(m_hDC, nStretchMode); } -#endif // !_WIN32_WCE COLORREF SetTextColor(COLORREF crColor) { @@ -1565,7 +1465,6 @@ public: return ::SetTextColor(m_hDC, crColor); } -#ifndef _WIN32_WCE BOOL GetColorAdjustment(LPCOLORADJUSTMENT lpColorAdjust) const { ATLASSERT(m_hDC != NULL); @@ -1596,7 +1495,6 @@ public: ATLASSERT(m_hDC != NULL); return ::SetMapMode(m_hDC, nMapMode); } -#endif // !_WIN32_WCE // Viewport Origin BOOL SetViewportOrg(int x, int y, LPPOINT lpPoint = NULL) @@ -1611,7 +1509,6 @@ public: return SetViewportOrg(point.x, point.y, lpPointRet); } -#ifndef _WIN32_WCE BOOL OffsetViewportOrg(int nWidth, int nHeight, LPPOINT lpPoint = NULL) { ATLASSERT(m_hDC != NULL); @@ -1642,10 +1539,8 @@ public: ATLASSERT(m_hDC != NULL); return ::ScaleViewportExtEx(m_hDC, xNum, xDenom, yNum, yDenom, lpSize); } -#endif // !_WIN32_WCE // Window Origin -#ifndef _WIN32_WCE BOOL GetWindowOrg(LPPOINT lpPoint) const { ATLASSERT(m_hDC != NULL); @@ -1710,10 +1605,10 @@ public: BOOL DPtoLP(LPSIZE lpSize) const { - SIZE sizeWinExt = { 0, 0 }; + SIZE sizeWinExt = {}; if(!GetWindowExt(&sizeWinExt)) return FALSE; - SIZE sizeVpExt = { 0, 0 }; + SIZE sizeVpExt = {}; if(!GetViewportExt(&sizeVpExt)) return FALSE; lpSize->cx = ::MulDiv(lpSize->cx, abs(sizeWinExt.cx), abs(sizeVpExt.cx)); @@ -1735,10 +1630,10 @@ public: BOOL LPtoDP(LPSIZE lpSize) const { - SIZE sizeWinExt = { 0, 0 }; + SIZE sizeWinExt = {}; if(!GetWindowExt(&sizeWinExt)) return FALSE; - SIZE sizeVpExt = { 0, 0 }; + SIZE sizeVpExt = {}; if(!GetViewportExt(&sizeVpExt)) return FALSE; lpSize->cx = ::MulDiv(lpSize->cx, abs(sizeVpExt.cx), abs(sizeWinExt.cx)); @@ -1749,62 +1644,61 @@ public: // Special Coordinate Functions (useful for dealing with metafiles and OLE) #define HIMETRIC_INCH 2540 // HIMETRIC units per inch - void DPtoHIMETRIC(LPSIZE lpSize) const + void DPtoHIMETRIC(LPSIZE lpSize) { ATLASSERT(m_hDC != NULL); - int nMapMode; - if((nMapMode = GetMapMode()) < MM_ISOTROPIC && nMapMode != MM_TEXT) + int nMapMode = GetMapMode(); + if((nMapMode < MM_ISOTROPIC) && (nMapMode != MM_TEXT)) { // when using a constrained map mode, map against physical inch - ((CDCHandle*)this)->SetMapMode(MM_HIMETRIC); + SetMapMode(MM_HIMETRIC); DPtoLP(lpSize); - ((CDCHandle*)this)->SetMapMode(nMapMode); + SetMapMode(nMapMode); } else { // map against logical inch for non-constrained mapping modes int cxPerInch = GetDeviceCaps(LOGPIXELSX); int cyPerInch = GetDeviceCaps(LOGPIXELSY); - ATLASSERT(cxPerInch != 0 && cyPerInch != 0); + ATLASSERT((cxPerInch != 0) && (cyPerInch != 0)); lpSize->cx = ::MulDiv(lpSize->cx, HIMETRIC_INCH, cxPerInch); lpSize->cy = ::MulDiv(lpSize->cy, HIMETRIC_INCH, cyPerInch); } } - void HIMETRICtoDP(LPSIZE lpSize) const + void HIMETRICtoDP(LPSIZE lpSize) { ATLASSERT(m_hDC != NULL); - int nMapMode; - if((nMapMode = GetMapMode()) < MM_ISOTROPIC && nMapMode != MM_TEXT) + int nMapMode = GetMapMode(); + if((nMapMode < MM_ISOTROPIC) && (nMapMode != MM_TEXT)) { // when using a constrained map mode, map against physical inch - ((CDCHandle*)this)->SetMapMode(MM_HIMETRIC); + SetMapMode(MM_HIMETRIC); LPtoDP(lpSize); - ((CDCHandle*)this)->SetMapMode(nMapMode); + SetMapMode(nMapMode); } else { // map against logical inch for non-constrained mapping modes int cxPerInch = GetDeviceCaps(LOGPIXELSX); int cyPerInch = GetDeviceCaps(LOGPIXELSY); - ATLASSERT(cxPerInch != 0 && cyPerInch != 0); + ATLASSERT((cxPerInch != 0) && (cyPerInch != 0)); lpSize->cx = ::MulDiv(lpSize->cx, cxPerInch, HIMETRIC_INCH); lpSize->cy = ::MulDiv(lpSize->cy, cyPerInch, HIMETRIC_INCH); } } - void LPtoHIMETRIC(LPSIZE lpSize) const + void LPtoHIMETRIC(LPSIZE lpSize) { LPtoDP(lpSize); DPtoHIMETRIC(lpSize); } - void HIMETRICtoLP(LPSIZE lpSize) const + void HIMETRICtoLP(LPSIZE lpSize) { HIMETRICtoDP(lpSize); DPtoLP(lpSize); } -#endif // !_WIN32_WCE // Region Functions BOOL FillRgn(HRGN hRgn, HBRUSH hBrush) @@ -1813,7 +1707,6 @@ public: return ::FillRgn(m_hDC, hRgn, hBrush); } -#ifndef _WIN32_WCE BOOL FrameRgn(HRGN hRgn, HBRUSH hBrush, int nWidth, int nHeight) { ATLASSERT(m_hDC != NULL); @@ -1831,7 +1724,6 @@ public: ATLASSERT(m_hDC != NULL); return ::PaintRgn(m_hDC, hRgn); } -#endif // !_WIN32_WCE // Clipping Functions int GetClipBox(LPRECT lpRect) const @@ -1853,7 +1745,6 @@ public: return nRet; } -#ifndef _WIN32_WCE BOOL PtVisible(int x, int y) const { ATLASSERT(m_hDC != NULL); @@ -1865,7 +1756,6 @@ public: ATLASSERT(m_hDC != NULL); return ::PtVisible(m_hDC, point.x, point.y); } -#endif // !_WIN32_WCE BOOL RectVisible(LPCRECT lpRect) const { @@ -1891,13 +1781,11 @@ public: return ::ExcludeClipRect(m_hDC, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom); } -#ifndef _WIN32_WCE int ExcludeUpdateRgn(HWND hWnd) { ATLASSERT(m_hDC != NULL); return ::ExcludeUpdateRgn(m_hDC, hWnd); } -#endif // !_WIN32_WCE int IntersectClipRect(int x1, int y1, int x2, int y2) { @@ -1911,7 +1799,6 @@ public: return ::IntersectClipRect(m_hDC, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom); } -#ifndef _WIN32_WCE int OffsetClipRgn(int x, int y) { ATLASSERT(m_hDC != NULL); @@ -1929,10 +1816,8 @@ public: ATLASSERT(m_hDC != NULL); return ::ExtSelectClipRgn(m_hDC, hRgn, nMode); } -#endif // !_WIN32_WCE // Line-Output Functions -#if !defined(_WIN32_WCE) || (_WIN32_WCE >= 400) BOOL GetCurrentPosition(LPPOINT lpPoint) const { ATLASSERT(m_hDC != NULL); @@ -1962,9 +1847,7 @@ public: ATLASSERT(m_hDC != NULL); return LineTo(point.x, point.y); } -#endif // !defined(_WIN32_WCE) || (_WIN32_WCE >= 400) -#ifndef _WIN32_WCE BOOL Arc(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) { ATLASSERT(m_hDC != NULL); @@ -1978,7 +1861,6 @@ public: lpRect->right, lpRect->bottom, ptStart.x, ptStart.y, ptEnd.x, ptEnd.y); } -#endif // !_WIN32_WCE BOOL Polyline(const POINT* lpPoints, int nCount) { @@ -1986,7 +1868,6 @@ public: return ::Polyline(m_hDC, lpPoints, nCount); } -#ifndef _WIN32_WCE BOOL AngleArc(int x, int y, int nRadius, float fStartAngle, float fSweepAngle) { ATLASSERT(m_hDC != NULL); @@ -2048,7 +1929,6 @@ public: ATLASSERT(m_hDC != NULL); return ::PolyBezierTo(m_hDC, lpPoints, nCount); } -#endif // !_WIN32_WCE // Simple Drawing Functions BOOL FillRect(LPCRECT lpRect, HBRUSH hBrush) @@ -2060,47 +1940,31 @@ public: BOOL FillRect(LPCRECT lpRect, int nColorIndex) { ATLASSERT(m_hDC != NULL); -#ifndef _WIN32_WCE return ::FillRect(m_hDC, lpRect, (HBRUSH)LongToPtr(nColorIndex + 1)); -#else // CE specific - return ::FillRect(m_hDC, lpRect, ::GetSysColorBrush(nColorIndex)); -#endif // _WIN32_WCE } -#ifndef _WIN32_WCE BOOL FrameRect(LPCRECT lpRect, HBRUSH hBrush) { ATLASSERT(m_hDC != NULL); return ::FrameRect(m_hDC, lpRect, hBrush); } -#endif // !_WIN32_WCE -#if !defined(_WIN32_WCE) || (_WIN32_WCE >= 420) BOOL InvertRect(LPCRECT lpRect) { ATLASSERT(m_hDC != NULL); return ::InvertRect(m_hDC, lpRect); } -#endif // !defined(_WIN32_WCE) || (_WIN32_WCE >= 420) BOOL DrawIcon(int x, int y, HICON hIcon) { ATLASSERT(m_hDC != NULL); -#ifndef _WIN32_WCE return ::DrawIcon(m_hDC, x, y, hIcon); -#else // CE specific - return ::DrawIconEx(m_hDC, x, y, hIcon, 0, 0, 0, NULL, DI_NORMAL); -#endif // _WIN32_WCE } BOOL DrawIcon(POINT point, HICON hIcon) { ATLASSERT(m_hDC != NULL); -#ifndef _WIN32_WCE return ::DrawIcon(m_hDC, point.x, point.y, hIcon); -#else // CE specific - return ::DrawIconEx(m_hDC, point.x, point.y, hIcon, 0, 0, 0, NULL, DI_NORMAL); -#endif // _WIN32_WCE } BOOL DrawIconEx(int x, int y, HICON hIcon, int cxWidth, int cyWidth, UINT uStepIfAniCur = 0, HBRUSH hbrFlickerFreeDraw = NULL, UINT uFlags = DI_NORMAL) @@ -2115,7 +1979,6 @@ public: return ::DrawIconEx(m_hDC, point.x, point.y, hIcon, size.cx, size.cy, uStepIfAniCur, hbrFlickerFreeDraw, uFlags); } -#ifndef _WIN32_WCE BOOL DrawState(POINT pt, SIZE size, HBITMAP hBitmap, UINT nFlags, HBRUSH hBrush = NULL) { ATLASSERT(m_hDC != NULL); @@ -2139,10 +2002,8 @@ public: ATLASSERT(m_hDC != NULL); return ::DrawState(m_hDC, hBrush, lpDrawProc, lData, 0, pt.x, pt.y, size.cx, size.cy, nFlags | DST_COMPLEX); } -#endif // !_WIN32_WCE // Ellipse and Polygon Functions -#ifndef _WIN32_WCE BOOL Chord(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) { ATLASSERT(m_hDC != NULL); @@ -2154,7 +2015,6 @@ public: ATLASSERT(m_hDC != NULL); return ::Chord(m_hDC, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom, ptStart.x, ptStart.y, ptEnd.x, ptEnd.y); } -#endif // !_WIN32_WCE void DrawFocusRect(LPCRECT lpRect) { @@ -2174,7 +2034,6 @@ public: return ::Ellipse(m_hDC, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom); } -#ifndef _WIN32_WCE BOOL Pie(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) { ATLASSERT(m_hDC != NULL); @@ -2186,7 +2045,6 @@ public: ATLASSERT(m_hDC != NULL); return ::Pie(m_hDC, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom, ptStart.x, ptStart.y, ptEnd.x, ptEnd.y); } -#endif // !_WIN32_WCE BOOL Polygon(const POINT* lpPoints, int nCount) { @@ -2194,13 +2052,11 @@ public: return ::Polygon(m_hDC, lpPoints, nCount); } -#ifndef _WIN32_WCE BOOL PolyPolygon(const POINT* lpPoints, const INT* lpPolyCounts, int nCount) { ATLASSERT(m_hDC != NULL); return ::PolyPolygon(m_hDC, lpPoints, lpPolyCounts, nCount); } -#endif // !_WIN32_WCE BOOL Rectangle(int x1, int y1, int x2, int y2) { @@ -2270,7 +2126,6 @@ public: return ::SetPixel(m_hDC, point.x, point.y, crColor); } -#ifndef _WIN32_WCE BOOL FloodFill(int x, int y, COLORREF crColor) { ATLASSERT(m_hDC != NULL); @@ -2282,7 +2137,6 @@ public: ATLASSERT(m_hDC != NULL); return ::ExtFloodFill(m_hDC, x, y, crColor, nFillType); } -#endif // !_WIN32_WCE BOOL MaskBlt(int x, int y, int nWidth, int nHeight, HDC hSrcDC, int xSrc, int ySrc, HBITMAP hMaskBitmap, int xMask, int yMask, DWORD dwRop) { @@ -2290,7 +2144,6 @@ public: return ::MaskBlt(m_hDC, x, y, nWidth, nHeight, hSrcDC, xSrc, ySrc, hMaskBitmap, xMask, yMask, dwRop); } -#ifndef _WIN32_WCE BOOL PlgBlt(LPPOINT lpPoint, HDC hSrcDC, int xSrc, int ySrc, int nWidth, int nHeight, HBITMAP hMaskBitmap, int xMask, int yMask) { ATLASSERT(m_hDC != NULL); @@ -2308,24 +2161,13 @@ public: ATLASSERT(m_hDC != NULL); return ::SetPixelV(m_hDC, point.x, point.y, crColor); } -#endif // !_WIN32_WCE -#if !defined(_ATL_NO_MSIMG) || defined(_WIN32_WCE) -#ifndef _WIN32_WCE BOOL TransparentBlt(int x, int y, int nWidth, int nHeight, HDC hSrcDC, int xSrc, int ySrc, int nSrcWidth, int nSrcHeight, UINT crTransparent) { ATLASSERT(m_hDC != NULL); return ::TransparentBlt(m_hDC, x, y, nWidth, nHeight, hSrcDC, xSrc, ySrc, nSrcWidth, nSrcHeight, crTransparent); } -#else // CE specific - BOOL TransparentImage(int x, int y, int nWidth, int nHeight, HDC hSrcDC, int xSrc, int ySrc, int nSrcWidth, int nSrcHeight, UINT crTransparent) - { - ATLASSERT(m_hDC != NULL); - return ::TransparentImage(m_hDC, x, y, nWidth, nHeight, hSrcDC, xSrc, ySrc, nSrcWidth, nSrcHeight, crTransparent); - } -#endif // _WIN32_WCE -#if (!defined(_WIN32_WCE) || (_WIN32_WCE >= 420)) BOOL GradientFill(const PTRIVERTEX pVertices, DWORD nVertices, void* pMeshElements, DWORD nMeshElements, DWORD dwMode) { ATLASSERT(m_hDC != NULL); @@ -2356,16 +2198,12 @@ public: return ::GradientFill(m_hDC, arrTvx, 2, &gr, 1, bHorizontal ? GRADIENT_FILL_RECT_H : GRADIENT_FILL_RECT_V); } -#endif // !defined(_WIN32_WCE) || (_WIN32_WCE >= 420) -#if !defined(_WIN32_WCE) || (_WIN32_WCE > 0x500) BOOL AlphaBlend(int x, int y, int nWidth, int nHeight, HDC hSrcDC, int xSrc, int ySrc, int nSrcWidth, int nSrcHeight, BLENDFUNCTION bf) { ATLASSERT(m_hDC != NULL); return ::AlphaBlend(m_hDC, x, y, nWidth, nHeight, hSrcDC, xSrc, ySrc, nSrcWidth, nSrcHeight, bf); } -#endif // !defined(_WIN32_WCE) || (_WIN32_WCE > 0x500) -#endif // !defined(_ATL_NO_MSIMG) || defined(_WIN32_WCE) // Extra bitmap functions // Helper function for painting a disabled toolbar or menu bitmap @@ -2376,17 +2214,17 @@ public: HBRUSH hBrush3DEffect = ::GetSysColorBrush(COLOR_3DHILIGHT), HBRUSH hBrushDisabledImage = ::GetSysColorBrush(COLOR_3DSHADOW)) { - ATLASSERT(m_hDC != NULL || hBitmap != NULL); - ATLASSERT(nWidth > 0 && nHeight > 0); + ATLASSERT((m_hDC != NULL) || (hBitmap != NULL)); + ATLASSERT((nWidth > 0) && (nHeight > 0)); // Create a generic DC for all BitBlts - CDCHandle dc = (hSrcDC != NULL) ? hSrcDC : ::CreateCompatibleDC(m_hDC); + CDCT dc = (hSrcDC != NULL) ? hSrcDC : ::CreateCompatibleDC(m_hDC); ATLASSERT(dc.m_hDC != NULL); if(dc.m_hDC == NULL) return FALSE; // Create a DC for the monochrome DIB section - CDC dcBW = ::CreateCompatibleDC(m_hDC); + CDCT dcBW = ::CreateCompatibleDC(m_hDC); ATLASSERT(dcBW.m_hDC != NULL); if(dcBW.m_hDC == NULL) { @@ -2426,8 +2264,8 @@ public: // Block: Dark gray removal: we want (128, 128, 128) pixels to become black and not white { - CDC dcTemp1 = ::CreateCompatibleDC(m_hDC); - CDC dcTemp2 = ::CreateCompatibleDC(m_hDC); + CDCT dcTemp1 = ::CreateCompatibleDC(m_hDC); + CDCT dcTemp2 = ::CreateCompatibleDC(m_hDC); CBitmap bmpTemp1; bmpTemp1.CreateCompatibleBitmap(dc, nWidth, nHeight); CBitmap bmpTemp2; @@ -2480,7 +2318,6 @@ public: } // Text Functions -#ifndef _WIN32_WCE BOOL TextOut(int x, int y, LPCTSTR lpszString, int nCount = -1) { ATLASSERT(m_hDC != NULL); @@ -2488,17 +2325,16 @@ public: nCount = lstrlen(lpszString); return ::TextOut(m_hDC, x, y, lpszString, nCount); } -#endif // !_WIN32_WCE - BOOL ExtTextOut(int x, int y, UINT nOptions, LPCRECT lpRect, LPCTSTR lpszString, UINT nCount = -1, LPINT lpDxWidths = NULL) + BOOL ExtTextOut(int x, int y, UINT nOptions, LPCRECT lpRect, LPCTSTR lpszString, int nCount = -1, LPINT lpDxWidths = NULL) { ATLASSERT(m_hDC != NULL); if(nCount == -1) nCount = lstrlen(lpszString); - return ::ExtTextOut(m_hDC, x, y, nOptions, lpRect, lpszString, nCount, lpDxWidths); + ATLASSERT((nCount >= 0) && (nCount <= 8192)); + return ::ExtTextOut(m_hDC, x, y, nOptions, lpRect, lpszString, (UINT)nCount, lpDxWidths); } -#ifndef _WIN32_WCE SIZE TabbedTextOut(int x, int y, LPCTSTR lpszString, int nCount = -1, int nTabPositions = 0, LPINT lpnTabStopPositions = NULL, int nTabOrigin = 0) { ATLASSERT(m_hDC != NULL); @@ -2508,14 +2344,11 @@ public: SIZE size = { GET_X_LPARAM(lRes), GET_Y_LPARAM(lRes) }; return size; } -#endif // !_WIN32_WCE int DrawText(LPCTSTR lpstrText, int cchText, LPRECT lpRect, UINT uFormat) { ATLASSERT(m_hDC != NULL); -#ifndef _WIN32_WCE ATLASSERT((uFormat & DT_MODIFYSTRING) == 0); -#endif // !_WIN32_WCE return ::DrawText(m_hDC, lpstrText, cchText, lpRect, uFormat); } @@ -2525,36 +2358,19 @@ public: return ::DrawText(m_hDC, lpstrText, cchText, lpRect, uFormat); } -#ifndef _WIN32_WCE int DrawTextEx(LPTSTR lpstrText, int cchText, LPRECT lpRect, UINT uFormat, LPDRAWTEXTPARAMS lpDTParams = NULL) { ATLASSERT(m_hDC != NULL); return ::DrawTextEx(m_hDC, lpstrText, cchText, lpRect, uFormat, lpDTParams); } -#endif // !_WIN32_WCE -#if (_WIN32_WINNT >= 0x0501) + // Note - ::DrawShadowText() is present only if comctl32.dll version 6 is loaded int DrawShadowText(LPCWSTR lpstrText, int cchText, LPRECT lpRect, DWORD dwFlags, COLORREF clrText, COLORREF clrShadow, int xOffset, int yOffset) { ATLASSERT(m_hDC != NULL); - // This function is present only if comctl32.dll version 6 is loaded; - // we use LoadLibrary/GetProcAddress to allow apps compiled with - // _WIN32_WINNT >= 0x0501 to run on older Windows/CommCtrl - int nRet = 0; - HMODULE hCommCtrlDLL = ::LoadLibrary(_T("comctl32.dll")); - ATLASSERT(hCommCtrlDLL != NULL); - if(hCommCtrlDLL != NULL) - { - typedef int (WINAPI *PFN_DrawShadowText)(HDC hDC, LPCWSTR lpstrText, UINT cchText, LPRECT lpRect, DWORD dwFlags, COLORREF clrText, COLORREF clrShadow, int xOffset, int yOffset); - PFN_DrawShadowText pfnDrawShadowText = (PFN_DrawShadowText)::GetProcAddress(hCommCtrlDLL, "DrawShadowText"); - ATLASSERT(pfnDrawShadowText != NULL); // this function requires CommCtrl6 - if(pfnDrawShadowText != NULL) - nRet = pfnDrawShadowText(m_hDC, lpstrText, cchText, lpRect, dwFlags, clrText, clrShadow, xOffset, yOffset); - ::FreeLibrary(hCommCtrlDLL); - } - return nRet; + ATLASSERT(lpRect != NULL); + return ::DrawShadowText(m_hDC, lpstrText, cchText, lpRect, dwFlags, clrText, clrShadow, xOffset, yOffset); } -#endif // (_WIN32_WINNT >= 0x0501) BOOL GetTextExtent(LPCTSTR lpszString, int nCount, LPSIZE lpSize) const { @@ -2570,7 +2386,6 @@ public: return ::GetTextExtentExPoint(m_hDC, lpszString, cchString, nMaxExtent, lpnFit, alpDx, lpSize); } -#ifndef _WIN32_WCE DWORD GetTabbedTextExtent(LPCTSTR lpszString, int nCount = -1, int nTabPositions = 0, LPINT lpnTabStopPositions = NULL) const { ATLASSERT(m_hDC != NULL); @@ -2584,9 +2399,7 @@ public: ATLASSERT(m_hDC != NULL); return ::GrayString(m_hDC, hBrush, (GRAYSTRINGPROC)lpfnOutput, lpData, nCount, x, y, nWidth, nHeight); } -#endif // !_WIN32_WCE -#if !defined(_WIN32_WCE) || (_WIN32_WCE >= 400) UINT GetTextAlign() const { ATLASSERT(m_hDC != NULL); @@ -2598,7 +2411,6 @@ public: ATLASSERT(m_hDC != NULL); return ::SetTextAlign(m_hDC, nFlags); } -#endif // !defined(_WIN32_WCE) || (_WIN32_WCE >= 400) int GetTextFace(LPTSTR lpszFacename, int nCount) const { @@ -2612,7 +2424,6 @@ public: return ::GetTextFace(m_hDC, 0, NULL); } -#ifndef _ATL_NO_COM #ifdef _OLEAUTO_H_ BOOL GetTextFace(BSTR& bstrFace) const { @@ -2624,7 +2435,7 @@ public: if(nLen == 0) return FALSE; - CTempBuffer buff; + ATL::CTempBuffer buff; LPTSTR lpszText = buff.Allocate(nLen); if(lpszText == NULL) return FALSE; @@ -2636,10 +2447,9 @@ public: return (bstrFace != NULL) ? TRUE : FALSE; } #endif -#endif // !_ATL_NO_COM -#if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) - int GetTextFace(_CSTRING_NS::CString& strFace) const +#ifdef __ATLSTR_H__ + int GetTextFace(ATL::CString& strFace) const { ATLASSERT(m_hDC != NULL); @@ -2654,7 +2464,7 @@ public: strFace.ReleaseBuffer(); return nRet; } -#endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) +#endif // __ATLSTR_H__ BOOL GetTextMetrics(LPTEXTMETRIC lpMetrics) const { @@ -2662,7 +2472,6 @@ public: return ::GetTextMetrics(m_hDC, lpMetrics); } -#ifndef _WIN32_WCE int SetTextJustification(int nBreakExtra, int nBreakCount) { ATLASSERT(m_hDC != NULL); @@ -2680,7 +2489,6 @@ public: ATLASSERT(m_hDC != NULL); return ::SetTextCharacterExtra(m_hDC, nCharExtra); } -#endif // !_WIN32_WCE // Advanced Drawing BOOL DrawEdge(LPRECT lpRect, UINT nEdge, UINT nFlags) @@ -2703,7 +2511,6 @@ public: } // Font Functions -#ifndef _WIN32_WCE BOOL GetCharWidth(UINT nFirstChar, UINT nLastChar, LPINT lpBuffer) const { ATLASSERT(m_hDC != NULL); @@ -2770,16 +2577,13 @@ public: ATLASSERT(m_hDC != NULL); return ::GetCharWidthFloat(m_hDC, nFirstChar, nLastChar, lpFloatBuffer); } -#endif // !_WIN32_WCE // Printer/Device Escape Functions -#ifndef _WIN32_WCE int Escape(int nEscape, int nCount, LPCSTR lpszInData, LPVOID lpOutData) { ATLASSERT(m_hDC != NULL); return ::Escape(m_hDC, nEscape, nCount, lpszInData, lpOutData); } -#endif // !_WIN32_WCE int Escape(int nEscape, int nInputSize, LPCSTR lpszInputData, int nOutputSize, LPSTR lpszOutputData) @@ -2788,19 +2592,16 @@ public: return ::ExtEscape(m_hDC, nEscape, nInputSize, lpszInputData, nOutputSize, lpszOutputData); } -#ifndef _WIN32_WCE int DrawEscape(int nEscape, int nInputSize, LPCSTR lpszInputData) { ATLASSERT(m_hDC != NULL); return ::DrawEscape(m_hDC, nEscape, nInputSize, lpszInputData); } -#endif // !_WIN32_WCE // Escape helpers -#if !defined(_WIN32_WCE) || ((_WIN32_WCE >= 200) && defined(StartDoc)) int StartDoc(LPCTSTR lpszDocName) // old Win3.0 version { - DOCINFO di = { 0 }; + DOCINFO di = {}; di.cbSize = sizeof(DOCINFO); di.lpszDocName = lpszDocName; return StartDoc(&di); @@ -2841,10 +2642,8 @@ public: ATLASSERT(m_hDC != NULL); return ::EndDoc(m_hDC); } -#endif // !defined(_WIN32_WCE) || ((_WIN32_WCE >= 200) && defined(StartDoc)) // MetaFile Functions -#ifndef _WIN32_WCE BOOL PlayMetaFile(HMETAFILE hMF) { ATLASSERT(m_hDC != NULL); @@ -2873,7 +2672,7 @@ public: // Special handling for metafile playback static int CALLBACK EnumMetaFileProc(HDC hDC, HANDLETABLE* pHandleTable, METARECORD* pMetaRec, int nHandles, LPARAM lParam) { - CDCHandle* pDC = (CDCHandle*)lParam; + CDCT* pDC = (CDCT*)lParam; switch (pMetaRec->rdFunction) { @@ -2957,10 +2756,8 @@ public: return 1; } -#endif // !_WIN32_WCE // Path Functions -#ifndef _WIN32_WCE BOOL AbortPath() { ATLASSERT(m_hDC != NULL); @@ -3038,13 +2835,12 @@ public: ATLASSERT(m_hDC != NULL); return ::SelectClipPath(m_hDC, nMode); } -#endif // !_WIN32_WCE // Misc Helper Functions static CBrushHandle PASCAL GetHalftoneBrush() { HBRUSH halftoneBrush = NULL; - WORD grayPattern[8] = { 0 }; + WORD grayPattern[8] = {}; for(int i = 0; i < 8; i++) grayPattern[i] = (WORD)(0x5555 << (i & 1)); HBITMAP grayBitmap = CreateBitmap(8, 8, 1, 1, &grayPattern); @@ -3097,7 +2893,7 @@ public: rgnUpdate.CombineRgn(rgnLast, rgnNew, RGN_XOR); } } - if(hBrush != hBrushLast && lpRectLast != NULL) + if((hBrush != hBrushLast) && (lpRectLast != NULL)) { // brushes are different -- erase old region first SelectClipRgn(rgnLast); @@ -3156,15 +2952,12 @@ public: } // DIB support -#if !defined(_WIN32_WCE) || (_WIN32_WCE >= 410) int SetDIBitsToDevice(int x, int y, DWORD dwWidth, DWORD dwHeight, int xSrc, int ySrc, UINT uStartScan, UINT cScanLines, CONST VOID* lpvBits, CONST BITMAPINFO* lpbmi, UINT uColorUse) { ATLASSERT(m_hDC != NULL); return ::SetDIBitsToDevice(m_hDC, x, y, dwWidth, dwHeight, xSrc, ySrc, uStartScan, cScanLines, lpvBits, lpbmi, uColorUse); } -#endif // !defined(_WIN32_WCE) || (_WIN32_WCE >= 410) -#if !defined(_WIN32_WCE) || (_WIN32_WCE >= 400) int StretchDIBits(int x, int y, int nWidth, int nHeight, int xSrc, int ySrc, int nSrcWidth, int nSrcHeight, CONST VOID* lpvBits, CONST BITMAPINFO* lpbmi, UINT uColorUse, DWORD dwRop) { ATLASSERT(m_hDC != NULL); @@ -3182,10 +2975,9 @@ public: ATLASSERT(m_hDC != NULL); return ::SetDIBColorTable(m_hDC, uStartIndex, cEntries, pColors); } -#endif // !defined(_WIN32_WCE) || (_WIN32_WCE >= 400) // OpenGL support -#if !defined(_ATL_NO_OPENGL) && !defined(_WIN32_WCE) +#if !defined(_ATL_NO_OPENGL) int ChoosePixelFormat(CONST PIXELFORMATDESCRIPTOR* ppfd) { ATLASSERT(m_hDC != NULL); @@ -3275,10 +3067,8 @@ public: ATLASSERT(m_hDC != NULL); return ::wglSwapLayerBuffers(m_hDC, uPlanes); } -#endif // !defined(_ATL_NO_OPENGL) && !defined(_WIN32_WCE) +#endif // !defined(_ATL_NO_OPENGL) -// New for Windows 2000 only -#if (_WIN32_WINNT >= 0x0500) COLORREF GetDCPenColor() const { ATLASSERT(m_hDC != NULL); @@ -3303,13 +3093,11 @@ public: return ::SetDCBrushColor(m_hDC, clr); } -#ifndef _WIN32_WCE DWORD GetFontUnicodeRanges(LPGLYPHSET lpgs) const { ATLASSERT(m_hDC != NULL); return ::GetFontUnicodeRanges(m_hDC, lpgs); } -#endif // !_WIN32_WCE DWORD GetGlyphIndices(LPCTSTR lpstr, int cch, LPWORD pgi, DWORD dwFlags) const { @@ -3340,21 +3128,14 @@ public: ATLASSERT(m_hDC != NULL); return ::GetCharABCWidthsI(m_hDC, giFirst, cgi, pgi, lpabc); } -#endif // (_WIN32_WINNT >= 0x0500) -// New for Windows 2000 and Windows 98 -#if (WINVER >= 0x0500) && !defined(_WIN32_WCE) BOOL ColorCorrectPalette(HPALETTE hPalette, DWORD dwFirstEntry, DWORD dwNumOfEntries) { ATLASSERT(m_hDC != NULL); return ::ColorCorrectPalette(m_hDC, hPalette, dwFirstEntry, dwNumOfEntries); } -#endif // (WINVER >= 0x0500) && !defined(_WIN32_WCE) }; -typedef CDCT CDCHandle; -typedef CDCT CDC; - /////////////////////////////////////////////////////////////////////////////// // CDC Helpers @@ -3392,7 +3173,7 @@ public: // Constructor/destructor CClientDC(HWND hWnd) { - ATLASSERT(hWnd == NULL || ::IsWindow(hWnd)); + ATLASSERT((hWnd == NULL) || ::IsWindow(hWnd)); m_hWnd = hWnd; m_hDC = ::GetDC(hWnd); } @@ -3413,7 +3194,7 @@ public: // Constructor/destructor CWindowDC(HWND hWnd) { - ATLASSERT(hWnd == NULL || ::IsWindow(hWnd)); + ATLASSERT((hWnd == NULL) || ::IsWindow(hWnd)); m_hWnd = hWnd; m_hDC = ::GetWindowDC(hWnd); } @@ -3457,8 +3238,6 @@ public: /////////////////////////////////////////////////////////////////////////////// // Enhanced metafile support -#ifndef _WIN32_WCE - class CEnhMetaFileInfo { public: @@ -3470,8 +3249,11 @@ public: PIXELFORMATDESCRIPTOR m_pfd; // Constructor/destructor - CEnhMetaFileInfo(HENHMETAFILE hEMF) : m_pBits(NULL), m_pDesc(NULL), m_hEMF(hEMF) - { } + CEnhMetaFileInfo(HENHMETAFILE hEMF) : m_hEMF(hEMF), m_pBits(NULL), m_pDesc(NULL) + { + memset(&m_header, 0, sizeof(m_header)); + memset(&m_pfd, 0, sizeof(m_pfd)); + } ~CEnhMetaFileInfo() { @@ -3538,7 +3320,7 @@ public: ~CEnhMetaFileT() { - if(t_bManaged && m_hEMF != NULL) + if(t_bManaged && (m_hEMF != NULL)) DeleteObject(); } @@ -3551,7 +3333,7 @@ public: void Attach(HENHMETAFILE hEMF) { - if(t_bManaged && m_hEMF != NULL && m_hEMF != hEMF) + if(t_bManaged && (m_hEMF != NULL) && (m_hEMF != hEMF)) DeleteObject(); m_hEMF = hEMF; } @@ -3658,232 +3440,6 @@ public: } }; -#endif // !_WIN32_WCE - - -/////////////////////////////////////////////////////////////////////////////// -// WinCE compatible clipboard CF_DIB format support functions - -#ifndef _WTL_NO_DIB16 - -#define DIBINFO16_BITFIELDS { 31744, 992, 31 } - -// DIBINFO16 - To avoid color table problems in WinCE we only create this type of Dib -struct DIBINFO16 // a BITMAPINFO with 2 additional color bitfields -{ - BITMAPINFOHEADER bmiHeader; - RGBQUAD bmiColors[3]; - - DIBINFO16(SIZE size) - { - BITMAPINFOHEADER bmih = { sizeof(BITMAPINFOHEADER), size.cx, size.cy, - 1, 16, BI_BITFIELDS, (DWORD)(2 * size.cx * size.cy), 0, 0, 3 }; - DWORD dw[3] = DIBINFO16_BITFIELDS ; - - bmiHeader = bmih; - SecureHelper::memcpy_x(bmiColors, sizeof(bmiColors), dw, 3 * sizeof(DWORD)); - } -}; - - -// AtlxxxDibxxx minimal packed DIB implementation and helpers to copy and paste CF_DIB - -inline bool AtlIsDib16(LPBITMAPINFOHEADER pbmih) -{ - return (pbmih->biBitCount == 16) && (pbmih->biCompression == BI_BITFIELDS); -} - -inline int AtlGetDibColorTableSize(LPBITMAPINFOHEADER pbmih) -{ - switch (pbmih->biBitCount) - { - case 2: - case 4: - case 8: - return pbmih->biClrUsed ? pbmih->biClrUsed : 1 << pbmih->biBitCount; - case 24: - break; - case 16: - case 32: - return pbmih->biCompression == BI_BITFIELDS ? 3 : 0; - default: - ATLASSERT(FALSE); // should never come here - } - - return 0; -} - -inline int AtlGetDibNumColors(LPBITMAPINFOHEADER pbmih) -{ - switch (pbmih->biBitCount) - { - case 2: - case 4: - case 8: - if (pbmih->biClrUsed) - return pbmih->biClrUsed; - else - break; - case 16: - if (pbmih->biCompression == BI_BITFIELDS ) - return 1 << 15; - else - break; - case 24: - break; - case 32: - if (pbmih->biCompression == BI_BITFIELDS ) - return 1 << 24; - else - break; - default: - ATLASSERT(FALSE); - } - - return 1 << pbmih->biBitCount; -} - -inline HBITMAP AtlGetDibBitmap(LPBITMAPINFO pbmi) -{ - CDC dc(NULL); - void* pBits = NULL; - - LPBYTE pDibBits = (LPBYTE)pbmi + sizeof(BITMAPINFOHEADER) + AtlGetDibColorTableSize(&pbmi->bmiHeader) * sizeof(RGBQUAD); - HBITMAP hbm = CreateDIBSection(dc, pbmi, DIB_RGB_COLORS, &pBits, NULL, NULL); - if (hbm != NULL) - { - int cbBits = pbmi->bmiHeader.biWidth * pbmi->bmiHeader.biHeight * pbmi->bmiHeader.biBitCount / 8; - SecureHelper::memcpy_x(pBits, cbBits, pDibBits, pbmi->bmiHeader.biSizeImage); - } - - return hbm; -} - -inline HBITMAP AtlCopyBitmap(HBITMAP hbm, SIZE sizeDst, bool bAsBitmap = false) -{ - CDC hdcSrc = CreateCompatibleDC(NULL); - CDC hdcDst = CreateCompatibleDC(NULL); - - CBitmapHandle hbmOld = NULL, hbmOld2 = NULL, bmSrc = hbm; - - CBitmap bmNew = NULL; - - SIZE sizeSrc = { 0 }; - bmSrc.GetSize(sizeSrc); - - hbmOld = hdcSrc.SelectBitmap(bmSrc); - - if (bAsBitmap) - { - bmNew.CreateCompatibleBitmap(hdcSrc, sizeDst.cx, sizeDst.cy); - } - else - { - DIBINFO16 dib16(sizeDst); - LPVOID pBits = NULL; - bmNew = CreateDIBSection(hdcDst, (const BITMAPINFO*)&dib16, DIB_RGB_COLORS, &pBits, NULL, NULL); - } - - ATLASSERT(!bmNew.IsNull()); - - hbmOld2 = hdcDst.SelectBitmap(bmNew); - BOOL bOK = FALSE; - - if ((sizeDst.cx == sizeSrc.cx) && (sizeDst.cy == sizeSrc.cy)) - bOK = hdcDst.BitBlt(0, 0, sizeDst.cx, sizeDst.cy, hdcSrc, 0, 0, SRCCOPY); - else - bOK = hdcDst.StretchBlt(0, 0, sizeDst.cx, sizeDst.cy, hdcSrc, 0, 0, sizeSrc.cx, sizeSrc.cy, SRCCOPY); - - hdcSrc.SelectBitmap(hbmOld); - hdcDst.SelectBitmap(hbmOld2); - - if (bOK == FALSE) - bmNew.DeleteObject(); - - return bmNew.Detach(); -} - -inline HLOCAL AtlCreatePackedDib16(HBITMAP hbm, SIZE size) -{ - DIBSECTION ds = { 0 }; - LPBYTE pDib = NULL; - bool bCopied = false; - - bool bOK = GetObject(hbm, sizeof(ds), &ds) == sizeof(ds); - if ((bOK == FALSE) || (ds.dsBm.bmBits == NULL) || (AtlIsDib16(&ds.dsBmih) == FALSE) || - (ds.dsBmih.biWidth != size.cx ) || (ds.dsBmih.biHeight != size.cy )) - { - if ((hbm = AtlCopyBitmap(hbm, size)) != NULL) - { - bCopied = true; - bOK = GetObject(hbm, sizeof(ds), &ds) == sizeof(ds); - } - else - { - bOK = FALSE; - } - } - - if((bOK != FALSE) && (AtlIsDib16(&ds.dsBmih) != FALSE) && (ds.dsBm.bmBits != NULL)) - { - pDib = (LPBYTE)LocalAlloc(LMEM_ZEROINIT, sizeof(DIBINFO16) + ds.dsBmih.biSizeImage); - if (pDib != NULL) - { - SecureHelper::memcpy_x(pDib, sizeof(DIBINFO16) + ds.dsBmih.biSizeImage, &ds.dsBmih, sizeof(DIBINFO16)); - SecureHelper::memcpy_x(pDib + sizeof(DIBINFO16), ds.dsBmih.biSizeImage, ds.dsBm.bmBits, ds.dsBmih.biSizeImage); - } - } - - if (bCopied == true) - DeleteObject(hbm); - - return (HLOCAL)pDib; -} - -inline bool AtlSetClipboardDib16(HBITMAP hbm, SIZE size, HWND hWnd) -{ - ATLASSERT(::IsWindow(hWnd)); - BOOL bOK = OpenClipboard(hWnd); - if (bOK != FALSE) - { - bOK = EmptyClipboard(); - if (bOK != FALSE) - { - HLOCAL hDib = AtlCreatePackedDib16(hbm, size); - if (hDib != NULL) - { - bOK = SetClipboardData(CF_DIB, hDib) != NULL; - if (bOK == FALSE) - LocalFree(hDib); - } - else - { - bOK = FALSE; - } - } - CloseClipboard(); - } - - return (bOK != FALSE); -} - -inline HBITMAP AtlGetClipboardDib(HWND hWnd) -{ - ATLASSERT(::IsWindow(hWnd) != FALSE); - HBITMAP hbm = NULL; - if (OpenClipboard(hWnd) != FALSE) - { - LPBITMAPINFO pbmi = (LPBITMAPINFO)GetClipboardData(CF_DIB); - if (pbmi != NULL) - hbm = AtlGetDibBitmap(pbmi); - CloseClipboard(); - } - - return hbm; -} - -#endif // _WTL_NO_DIB16 - -}; // namespace WTL +} // namespace WTL #endif // __ATLGDI_H__ diff --git a/ZbaSDK/SampleCode/PluginWinExe/WTL/atlmisc.h b/ZbaSDK/SampleCode/PluginWinExe/WTL/atlmisc.h index ea4bb4da563a9f4e73667fd88b73aa40156d2dd7..af94875b1f12550dbb762b2d83b3eee9a4554a8e 100644 --- a/ZbaSDK/SampleCode/PluginWinExe/WTL/atlmisc.h +++ b/ZbaSDK/SampleCode/PluginWinExe/WTL/atlmisc.h @@ -1,4 +1,4 @@ -// Windows Template Library - WTL version 9.10 +// Windows Template Library - WTL version 10.0 // Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. // // This file is a part of the Windows Template Library. @@ -15,2800 +15,68 @@ #error atlmisc.h requires atlapp.h to be included first #endif +#ifndef _WTL_NO_COMPATIBILITY_INCLUDES + #include + #include +#endif // _WTL_NO_COMPATIBILITY_INCLUDES -#ifdef _ATL_TMP_NO_CSTRING - #define _WTL_NO_CSTRING -#endif - -#if defined(_WTL_USE_CSTRING) && defined(_WTL_NO_CSTRING) - #error Conflicting options - both _WTL_USE_CSTRING and _WTL_NO_CSTRING are defined -#endif // defined(_WTL_USE_CSTRING) && defined(_WTL_NO_CSTRING) - -#if !defined(_WTL_USE_CSTRING) && !defined(_WTL_NO_CSTRING) - #define _WTL_USE_CSTRING -#endif // !defined(_WTL_USE_CSTRING) && !defined(_WTL_NO_CSTRING) - -#ifndef _WTL_NO_CSTRING - #if defined(_ATL_USE_CSTRING_FLOAT) && defined(_ATL_MIN_CRT) - #error Cannot use CString floating point formatting with _ATL_MIN_CRT defined - #endif // defined(_ATL_USE_CSTRING_FLOAT) && defined(_ATL_MIN_CRT) -#endif // !_WTL_NO_CSTRING - - -/////////////////////////////////////////////////////////////////////////////// -// Classes in this file: -// -// CSize -// CPoint -// CRect -// CString -// -// CRecentDocumentListBase -// CRecentDocumentList -// CFindFile -// -// Global functions: -// AtlGetStockPen() -// AtlGetStockBrush() -// AtlGetStockFont() -// AtlGetStockPalette() -// -// AtlCompactPath() - - -namespace WTL -{ - -#ifndef _WTL_NO_WTYPES - -// forward declarations -class CSize; -class CPoint; -class CRect; - -/////////////////////////////////////////////////////////////////////////////// -// CSize - Wrapper for Windows SIZE structure. - -class CSize : public SIZE -{ -public: -// Constructors - CSize() - { - cx = 0; - cy = 0; - } - - CSize(int initCX, int initCY) - { - cx = initCX; - cy = initCY; - } - - CSize(SIZE initSize) - { - *(SIZE*)this = initSize; - } - - CSize(POINT initPt) - { - *(POINT*)this = initPt; - } - - CSize(DWORD dwSize) - { - cx = (short)LOWORD(dwSize); - cy = (short)HIWORD(dwSize); - } - -// Operations - BOOL operator ==(SIZE size) const - { - return (cx == size.cx && cy == size.cy); - } - - BOOL operator !=(SIZE size) const - { - return (cx != size.cx || cy != size.cy); - } - - void operator +=(SIZE size) - { - cx += size.cx; - cy += size.cy; - } - - void operator -=(SIZE size) - { - cx -= size.cx; - cy -= size.cy; - } - - void SetSize(int CX, int CY) - { - cx = CX; - cy = CY; - } - -// Operators returning CSize values - CSize operator +(SIZE size) const - { - return CSize(cx + size.cx, cy + size.cy); - } - - CSize operator -(SIZE size) const - { - return CSize(cx - size.cx, cy - size.cy); - } - - CSize operator -() const - { - return CSize(-cx, -cy); - } - -// Operators returning CPoint values - CPoint operator +(POINT point) const; - CPoint operator -(POINT point) const; - -// Operators returning CRect values - CRect operator +(const RECT* lpRect) const; - CRect operator -(const RECT* lpRect) const; -}; - - -/////////////////////////////////////////////////////////////////////////////// -// CPoint - Wrapper for Windows POINT structure. - -class CPoint : public POINT -{ -public: -// Constructors - CPoint() - { - x = 0; - y = 0; - } - - CPoint(int initX, int initY) - { - x = initX; - y = initY; - } - - CPoint(POINT initPt) - { - *(POINT*)this = initPt; - } - - CPoint(SIZE initSize) - { - *(SIZE*)this = initSize; - } - - CPoint(DWORD dwPoint) - { - x = (short)LOWORD(dwPoint); - y = (short)HIWORD(dwPoint); - } - -// Operations - void Offset(int xOffset, int yOffset) - { - x += xOffset; - y += yOffset; - } - - void Offset(POINT point) - { - x += point.x; - y += point.y; - } - - void Offset(SIZE size) - { - x += size.cx; - y += size.cy; - } - - BOOL operator ==(POINT point) const - { - return (x == point.x && y == point.y); - } - - BOOL operator !=(POINT point) const - { - return (x != point.x || y != point.y); - } - - void operator +=(SIZE size) - { - x += size.cx; - y += size.cy; - } - - void operator -=(SIZE size) - { - x -= size.cx; - y -= size.cy; - } - - void operator +=(POINT point) - { - x += point.x; - y += point.y; - } - - void operator -=(POINT point) - { - x -= point.x; - y -= point.y; - } - - void SetPoint(int X, int Y) - { - x = X; - y = Y; - } - -// Operators returning CPoint values - CPoint operator +(SIZE size) const - { - return CPoint(x + size.cx, y + size.cy); - } - - CPoint operator -(SIZE size) const - { - return CPoint(x - size.cx, y - size.cy); - } - - CPoint operator -() const - { - return CPoint(-x, -y); - } - - CPoint operator +(POINT point) const - { - return CPoint(x + point.x, y + point.y); - } - -// Operators returning CSize values - CSize operator -(POINT point) const - { - return CSize(x - point.x, y - point.y); - } - -// Operators returning CRect values - CRect operator +(const RECT* lpRect) const; - CRect operator -(const RECT* lpRect) const; -}; - - -/////////////////////////////////////////////////////////////////////////////// -// CRect - Wrapper for Windows RECT structure. - -class CRect : public RECT -{ -public: -// Constructors - CRect() - { - left = 0; - top = 0; - right = 0; - bottom = 0; - } - - CRect(int l, int t, int r, int b) - { - left = l; - top = t; - right = r; - bottom = b; - } - - CRect(const RECT& srcRect) - { - ::CopyRect(this, &srcRect); - } - - CRect(LPCRECT lpSrcRect) - { - ::CopyRect(this, lpSrcRect); - } - - CRect(POINT point, SIZE size) - { - right = (left = point.x) + size.cx; - bottom = (top = point.y) + size.cy; - } - - CRect(POINT topLeft, POINT bottomRight) - { - left = topLeft.x; - top = topLeft.y; - right = bottomRight.x; - bottom = bottomRight.y; - } - -// Attributes (in addition to RECT members) - int Width() const - { - return right - left; - } - - int Height() const - { - return bottom - top; - } - - CSize Size() const - { - return CSize(right - left, bottom - top); - } - - CPoint& TopLeft() - { - return *((CPoint*)this); - } - - CPoint& BottomRight() - { - return *((CPoint*)this + 1); - } - - const CPoint& TopLeft() const - { - return *((CPoint*)this); - } - - const CPoint& BottomRight() const - { - return *((CPoint*)this + 1); - } - - CPoint CenterPoint() const - { - return CPoint((left + right) / 2, (top + bottom) / 2); - } - - // convert between CRect and LPRECT/LPCRECT (no need for &) - operator LPRECT() - { - return this; - } - - operator LPCRECT() const - { - return this; - } - - BOOL IsRectEmpty() const - { - return ::IsRectEmpty(this); - } - - BOOL IsRectNull() const - { - return (left == 0 && right == 0 && top == 0 && bottom == 0); - } - - BOOL PtInRect(POINT point) const - { - return ::PtInRect(this, point); - } - -// Operations - void SetRect(int x1, int y1, int x2, int y2) - { - ::SetRect(this, x1, y1, x2, y2); - } - - void SetRect(POINT topLeft, POINT bottomRight) - { - ::SetRect(this, topLeft.x, topLeft.y, bottomRight.x, bottomRight.y); - } - - void SetRectEmpty() - { - ::SetRectEmpty(this); - } - - void CopyRect(LPCRECT lpSrcRect) - { - ::CopyRect(this, lpSrcRect); - } - - BOOL EqualRect(LPCRECT lpRect) const - { - return ::EqualRect(this, lpRect); - } - - void InflateRect(int x, int y) - { - ::InflateRect(this, x, y); - } - - void InflateRect(SIZE size) - { - ::InflateRect(this, size.cx, size.cy); - } - - void InflateRect(LPCRECT lpRect) - { - left -= lpRect->left; - top -= lpRect->top; - right += lpRect->right; - bottom += lpRect->bottom; - } - - void InflateRect(int l, int t, int r, int b) - { - left -= l; - top -= t; - right += r; - bottom += b; - } - - void DeflateRect(int x, int y) - { - ::InflateRect(this, -x, -y); - } - - void DeflateRect(SIZE size) - { - ::InflateRect(this, -size.cx, -size.cy); - } - - void DeflateRect(LPCRECT lpRect) - { - left += lpRect->left; - top += lpRect->top; - right -= lpRect->right; - bottom -= lpRect->bottom; - } - - void DeflateRect(int l, int t, int r, int b) - { - left += l; - top += t; - right -= r; - bottom -= b; - } - - void OffsetRect(int x, int y) - { - ::OffsetRect(this, x, y); - } - void OffsetRect(SIZE size) - { - ::OffsetRect(this, size.cx, size.cy); - } - - void OffsetRect(POINT point) - { - ::OffsetRect(this, point.x, point.y); - } - - void NormalizeRect() - { - int nTemp; - if (left > right) - { - nTemp = left; - left = right; - right = nTemp; - } - if (top > bottom) - { - nTemp = top; - top = bottom; - bottom = nTemp; - } - } - - // absolute position of rectangle - void MoveToY(int y) - { - bottom = Height() + y; - top = y; - } - - void MoveToX(int x) - { - right = Width() + x; - left = x; - } - - void MoveToXY(int x, int y) - { - MoveToX(x); - MoveToY(y); - } - - void MoveToXY(POINT pt) - { - MoveToX(pt.x); - MoveToY(pt.y); - } - - // operations that fill '*this' with result - BOOL IntersectRect(LPCRECT lpRect1, LPCRECT lpRect2) - { - return ::IntersectRect(this, lpRect1, lpRect2); - } - - BOOL UnionRect(LPCRECT lpRect1, LPCRECT lpRect2) - { - return ::UnionRect(this, lpRect1, lpRect2); - } - - BOOL SubtractRect(LPCRECT lpRectSrc1, LPCRECT lpRectSrc2) - { - return ::SubtractRect(this, lpRectSrc1, lpRectSrc2); - } - -// Additional Operations - void operator =(const RECT& srcRect) - { - ::CopyRect(this, &srcRect); - } - - BOOL operator ==(const RECT& rect) const - { - return ::EqualRect(this, &rect); - } - - BOOL operator !=(const RECT& rect) const - { - return !::EqualRect(this, &rect); - } - - void operator +=(POINT point) - { - ::OffsetRect(this, point.x, point.y); - } - - void operator +=(SIZE size) - { - ::OffsetRect(this, size.cx, size.cy); - } - - void operator +=(LPCRECT lpRect) - { - InflateRect(lpRect); - } - - void operator -=(POINT point) - { - ::OffsetRect(this, -point.x, -point.y); - } - - void operator -=(SIZE size) - { - ::OffsetRect(this, -size.cx, -size.cy); - } - - void operator -=(LPCRECT lpRect) - { - DeflateRect(lpRect); - } - - void operator &=(const RECT& rect) - { - ::IntersectRect(this, this, &rect); - } - - void operator |=(const RECT& rect) - { - ::UnionRect(this, this, &rect); - } - -// Operators returning CRect values - CRect operator +(POINT pt) const - { - CRect rect(*this); - ::OffsetRect(&rect, pt.x, pt.y); - return rect; - } - - CRect operator -(POINT pt) const - { - CRect rect(*this); - ::OffsetRect(&rect, -pt.x, -pt.y); - return rect; - } - - CRect operator +(LPCRECT lpRect) const - { - CRect rect(this); - rect.InflateRect(lpRect); - return rect; - } - - CRect operator +(SIZE size) const - { - CRect rect(*this); - ::OffsetRect(&rect, size.cx, size.cy); - return rect; - } - - CRect operator -(SIZE size) const - { - CRect rect(*this); - ::OffsetRect(&rect, -size.cx, -size.cy); - return rect; - } - - CRect operator -(LPCRECT lpRect) const - { - CRect rect(this); - rect.DeflateRect(lpRect); - return rect; - } - - CRect operator &(const RECT& rect2) const - { - CRect rect; - ::IntersectRect(&rect, this, &rect2); - return rect; - } - - CRect operator |(const RECT& rect2) const - { - CRect rect; - ::UnionRect(&rect, this, &rect2); - return rect; - } - - CRect MulDiv(int nMultiplier, int nDivisor) const - { - return CRect( - ::MulDiv(left, nMultiplier, nDivisor), - ::MulDiv(top, nMultiplier, nDivisor), - ::MulDiv(right, nMultiplier, nDivisor), - ::MulDiv(bottom, nMultiplier, nDivisor)); - } -}; - - -// CSize implementation - -inline CPoint CSize::operator +(POINT point) const -{ return CPoint(cx + point.x, cy + point.y); } - -inline CPoint CSize::operator -(POINT point) const -{ return CPoint(cx - point.x, cy - point.y); } - -inline CRect CSize::operator +(const RECT* lpRect) const -{ return CRect(lpRect) + *this; } - -inline CRect CSize::operator -(const RECT* lpRect) const -{ return CRect(lpRect) - *this; } - - -// CPoint implementation - -inline CRect CPoint::operator +(const RECT* lpRect) const -{ return CRect(lpRect) + *this; } - -inline CRect CPoint::operator -(const RECT* lpRect) const -{ return CRect(lpRect) - *this; } - -#endif // !_WTL_NO_WTYPES - - -// WTL::CSize or ATL::CSize scalar operators - -#if !defined(_WTL_NO_SIZE_SCALAR) && (!defined(_WTL_NO_WTYPES) || defined(__ATLTYPES_H__)) - -template -inline CSize operator *(SIZE s, Num n) -{ - return CSize((int)(s.cx * n), (int)(s.cy * n)); -}; - -template -inline void operator *=(SIZE & s, Num n) -{ - s = s * n; -}; - -template -inline CSize operator /(SIZE s, Num n) -{ - return CSize((int)(s.cx / n), (int)(s.cy / n)); -}; - -template -inline void operator /=(SIZE & s, Num n) -{ - s = s / n; -}; - -#endif // !defined(_WTL_NO_SIZE_SCALAR) && (!defined(_WTL_NO_WTYPES) || defined(__ATLTYPES_H__)) - - -/////////////////////////////////////////////////////////////////////////////// -// CString - String class - -#ifndef _WTL_NO_CSTRING - -struct CStringData -{ - long nRefs; // reference count - int nDataLength; - int nAllocLength; - // TCHAR data[nAllocLength] - - TCHAR* data() - { return (TCHAR*)(this + 1); } -}; - -// Globals - -// For an empty string, m_pchData will point here -// (note: avoids special case of checking for NULL m_pchData) -// empty string data (and locked) -_declspec(selectany) int rgInitData[] = { -1, 0, 0, 0 }; -_declspec(selectany) CStringData* _atltmpDataNil = (CStringData*)&rgInitData; -_declspec(selectany) LPCTSTR _atltmpPchNil = (LPCTSTR)(((BYTE*)&rgInitData) + sizeof(CStringData)); - - -class CString -{ -public: -// Constructors - CString() - { - Init(); - } - - CString(const CString& stringSrc) - { - ATLASSERT(stringSrc.GetData()->nRefs != 0); - if (stringSrc.GetData()->nRefs >= 0) - { - ATLASSERT(stringSrc.GetData() != _atltmpDataNil); - m_pchData = stringSrc.m_pchData; - InterlockedIncrement(&GetData()->nRefs); - } - else - { - Init(); - *this = stringSrc.m_pchData; - } - } - - CString(TCHAR ch, int nRepeat = 1) - { - ATLASSERT(!_istlead(ch)); // can't create a lead byte string - Init(); - if (nRepeat >= 1) - { - if(AllocBuffer(nRepeat)) - { -#ifdef _UNICODE - for (int i = 0; i < nRepeat; i++) - m_pchData[i] = ch; -#else - memset(m_pchData, ch, nRepeat); -#endif - } - } - } - - CString(LPCTSTR lpsz) - { - Init(); - if (lpsz != NULL && HIWORD(lpsz) == NULL) - { - UINT nID = LOWORD((DWORD_PTR)lpsz); - if (!LoadString(nID)) - ATLTRACE2(atlTraceUI, 0, _T("Warning: implicit LoadString(%u) in CString failed\n"), nID); - } - else - { - int nLen = SafeStrlen(lpsz); - if (nLen != 0) - { - if(AllocBuffer(nLen)) - SecureHelper::memcpy_x(m_pchData, (nLen + 1) * sizeof(TCHAR), lpsz, nLen * sizeof(TCHAR)); - } - } - } - -#ifdef _UNICODE - CString(LPCSTR lpsz) - { - Init(); -#if defined(_WIN32_WCE) && (_ATL_VER >= 0x0800) - int nSrcLen = (lpsz != NULL) ? ATL::lstrlenA(lpsz) : 0; -#else - int nSrcLen = (lpsz != NULL) ? lstrlenA(lpsz) : 0; -#endif - if (nSrcLen != 0) - { - if(AllocBuffer(nSrcLen)) - { - _mbstowcsz(m_pchData, lpsz, nSrcLen + 1); - ReleaseBuffer(); - } - } - } -#else // !_UNICODE - CString(LPCWSTR lpsz) - { - Init(); - int nSrcLen = (lpsz != NULL) ? (int)wcslen(lpsz) : 0; - if (nSrcLen != 0) - { - if(AllocBuffer(nSrcLen * 2)) - { - _wcstombsz(m_pchData, lpsz, (nSrcLen * 2) + 1); - ReleaseBuffer(); - } - } - } -#endif // !_UNICODE - - CString(LPCTSTR lpch, int nLength) - { - Init(); - if (nLength != 0) - { - if(AllocBuffer(nLength)) - SecureHelper::memcpy_x(m_pchData, (nLength + 1) * sizeof(TCHAR), lpch, nLength * sizeof(TCHAR)); - } - } - -#ifdef _UNICODE - CString(LPCSTR lpsz, int nLength) - { - Init(); - if (nLength != 0) - { - if(AllocBuffer(nLength)) - { - int n = ::MultiByteToWideChar(CP_ACP, 0, lpsz, nLength, m_pchData, nLength + 1); - ReleaseBuffer((n >= 0) ? n : -1); - } - } - } -#else // !_UNICODE - CString(LPCWSTR lpsz, int nLength) - { - Init(); - if (nLength != 0) - { - if(((nLength * 2) > nLength) && AllocBuffer(nLength * 2)) - { - int n = ::WideCharToMultiByte(CP_ACP, 0, lpsz, nLength, m_pchData, (nLength * 2) + 1, NULL, NULL); - ReleaseBuffer((n >= 0) ? n : -1); - } - } - } -#endif // !_UNICODE - - CString(const unsigned char* lpsz) - { - Init(); - *this = (LPCSTR)lpsz; - } - -// Attributes & Operations - int GetLength() const // as an array of characters - { - return GetData()->nDataLength; - } - - BOOL IsEmpty() const - { - return GetData()->nDataLength == 0; - } - - void Empty() // free up the data - { - if (GetData()->nDataLength == 0) - return; - - if (GetData()->nRefs >= 0) - Release(); - else - *this = _T(""); - - ATLASSERT(GetData()->nDataLength == 0); - ATLASSERT(GetData()->nRefs < 0 || GetData()->nAllocLength == 0); - } - - TCHAR GetAt(int nIndex) const // 0 based - { - ATLASSERT(nIndex >= 0); - ATLASSERT(nIndex < GetData()->nDataLength); - return m_pchData[nIndex]; - } - - TCHAR operator [](int nIndex) const // same as GetAt - { - // same as GetAt - ATLASSERT(nIndex >= 0); - ATLASSERT(nIndex < GetData()->nDataLength); - return m_pchData[nIndex]; - } - - void SetAt(int nIndex, TCHAR ch) - { - ATLASSERT(nIndex >= 0); - ATLASSERT(nIndex < GetData()->nDataLength); - - CopyBeforeWrite(); - m_pchData[nIndex] = ch; - } - - operator LPCTSTR() const // as a C string - { - return m_pchData; - } - - // overloaded assignment - CString& operator =(const CString& stringSrc) - { - if (m_pchData != stringSrc.m_pchData) - { - if ((GetData()->nRefs < 0 && GetData() != _atltmpDataNil) || stringSrc.GetData()->nRefs < 0) - { - // actual copy necessary since one of the strings is locked - AssignCopy(stringSrc.GetData()->nDataLength, stringSrc.m_pchData); - } - else - { - // can just copy references around - Release(); - ATLASSERT(stringSrc.GetData() != _atltmpDataNil); - m_pchData = stringSrc.m_pchData; - InterlockedIncrement(&GetData()->nRefs); - } - } - return *this; - } - - CString& operator =(TCHAR ch) - { - ATLASSERT(!_istlead(ch)); // can't set single lead byte - AssignCopy(1, &ch); - return *this; - } - -#ifdef _UNICODE - CString& operator =(char ch) - { - *this = (TCHAR)ch; - return *this; - } -#endif - - CString& operator =(LPCTSTR lpsz) - { - ATLASSERT(lpsz == NULL || _IsValidString(lpsz)); - AssignCopy(SafeStrlen(lpsz), lpsz); - return *this; - } - -#ifdef _UNICODE - CString& operator =(LPCSTR lpsz) - { -#if defined(_WIN32_WCE) && (_ATL_VER >= 0x0800) - int nSrcLen = (lpsz != NULL) ? ATL::lstrlenA(lpsz) : 0; -#else - int nSrcLen = (lpsz != NULL) ? lstrlenA(lpsz) : 0; -#endif - if(AllocBeforeWrite(nSrcLen)) - { - _mbstowcsz(m_pchData, lpsz, nSrcLen + 1); - ReleaseBuffer(); - } - return *this; - } -#else // !_UNICODE - CString& operator =(LPCWSTR lpsz) - { - int nSrcLen = (lpsz != NULL) ? (int)wcslen(lpsz) : 0; - if(AllocBeforeWrite(nSrcLen * 2)) - { - _wcstombsz(m_pchData, lpsz, (nSrcLen * 2) + 1); - ReleaseBuffer(); - } - return *this; - } -#endif // !_UNICODE - - CString& operator =(const unsigned char* lpsz) - { - *this = (LPCSTR)lpsz; - return *this; - } - - // string concatenation - CString& operator +=(const CString& string) - { - ConcatInPlace(string.GetData()->nDataLength, string.m_pchData); - return *this; - } - - CString& operator +=(TCHAR ch) - { - ConcatInPlace(1, &ch); - return *this; - } - -#ifdef _UNICODE - CString& operator +=(char ch) - { - *this += (TCHAR)ch; - return *this; - } -#endif - - CString& operator +=(LPCTSTR lpsz) - { - ATLASSERT(lpsz == NULL || _IsValidString(lpsz)); - ConcatInPlace(SafeStrlen(lpsz), lpsz); - return *this; - } - - friend CString __stdcall operator +(const CString& string1, const CString& string2); - friend CString __stdcall operator +(const CString& string, TCHAR ch); - friend CString __stdcall operator +(TCHAR ch, const CString& string); -#ifdef _UNICODE - friend CString __stdcall operator +(const CString& string, char ch); - friend CString __stdcall operator +(char ch, const CString& string); -#endif - friend CString __stdcall operator +(const CString& string, LPCTSTR lpsz); - friend CString __stdcall operator +(LPCTSTR lpsz, const CString& string); - - // string comparison - int Compare(LPCTSTR lpsz) const // straight character (MBCS/Unicode aware) - { - return _cstrcmp(m_pchData, lpsz); - } - - int CompareNoCase(LPCTSTR lpsz) const // ignore case (MBCS/Unicode aware) - { - return _cstrcmpi(m_pchData, lpsz); - } - -#ifndef _WIN32_WCE - // CString::Collate is often slower than Compare but is MBSC/Unicode - // aware as well as locale-sensitive with respect to sort order. - int Collate(LPCTSTR lpsz) const // NLS aware - { - return _cstrcoll(m_pchData, lpsz); - } - - int CollateNoCase(LPCTSTR lpsz) const // ignore case - { - return _cstrcolli(m_pchData, lpsz); - } -#endif // !_WIN32_WCE - - // simple sub-string extraction - CString Mid(int nFirst, int nCount) const - { - // out-of-bounds requests return sensible things - if (nFirst < 0) - nFirst = 0; - if (nCount < 0) - nCount = 0; - - if (nFirst + nCount > GetData()->nDataLength) - nCount = GetData()->nDataLength - nFirst; - if (nFirst > GetData()->nDataLength) - nCount = 0; - - CString dest; - AllocCopy(dest, nCount, nFirst, 0); - return dest; - } - - CString Mid(int nFirst) const - { - return Mid(nFirst, GetData()->nDataLength - nFirst); - } - - CString Left(int nCount) const - { - if (nCount < 0) - nCount = 0; - else if (nCount > GetData()->nDataLength) - nCount = GetData()->nDataLength; - - CString dest; - AllocCopy(dest, nCount, 0, 0); - return dest; - } - - CString Right(int nCount) const - { - if (nCount < 0) - nCount = 0; - else if (nCount > GetData()->nDataLength) - nCount = GetData()->nDataLength; - - CString dest; - AllocCopy(dest, nCount, GetData()->nDataLength-nCount, 0); - return dest; - } - - CString SpanIncluding(LPCTSTR lpszCharSet) const // strspn equivalent - { - ATLASSERT(_IsValidString(lpszCharSet)); - return Left(_cstrspn(m_pchData, lpszCharSet)); - } - - CString SpanExcluding(LPCTSTR lpszCharSet) const // strcspn equivalent - { - ATLASSERT(_IsValidString(lpszCharSet)); - return Left(_cstrcspn(m_pchData, lpszCharSet)); - } - - // upper/lower/reverse conversion - void MakeUpper() - { - CopyBeforeWrite(); - CharUpper(m_pchData); - } - - void MakeLower() - { - CopyBeforeWrite(); - CharLower(m_pchData); - } - - void MakeReverse() - { - CopyBeforeWrite(); - _cstrrev(m_pchData); - } - - // trimming whitespace (either side) - void TrimRight() - { - CopyBeforeWrite(); - - // find beginning of trailing spaces by starting at beginning (DBCS aware) - LPTSTR lpsz = m_pchData; - LPTSTR lpszLast = NULL; - while (*lpsz != _T('\0')) - { - if (_cstrisspace(*lpsz)) - { - if (lpszLast == NULL) - lpszLast = lpsz; - } - else - { - lpszLast = NULL; - } - lpsz = ::CharNext(lpsz); - } - - if (lpszLast != NULL) - { - // truncate at trailing space start - *lpszLast = _T('\0'); - GetData()->nDataLength = (int)(DWORD_PTR)(lpszLast - m_pchData); - } - } - - void TrimLeft() - { - CopyBeforeWrite(); - - // find first non-space character - LPCTSTR lpsz = m_pchData; - while (_cstrisspace(*lpsz)) - lpsz = ::CharNext(lpsz); - - // fix up data and length - int nDataLength = GetData()->nDataLength - (int)(DWORD_PTR)(lpsz - m_pchData); - SecureHelper::memmove_x(m_pchData, (GetData()->nAllocLength + 1) * sizeof(TCHAR), lpsz, (nDataLength + 1) * sizeof(TCHAR)); - GetData()->nDataLength = nDataLength; - } - - // remove continuous occurrences of chTarget starting from right - void TrimRight(TCHAR chTarget) - { - // find beginning of trailing matches - // by starting at beginning (DBCS aware) - - CopyBeforeWrite(); - LPTSTR lpsz = m_pchData; - LPTSTR lpszLast = NULL; - - while (*lpsz != _T('\0')) - { - if (*lpsz == chTarget) - { - if (lpszLast == NULL) - lpszLast = lpsz; - } - else - lpszLast = NULL; - lpsz = ::CharNext(lpsz); - } - - if (lpszLast != NULL) - { - // truncate at left-most matching character - *lpszLast = _T('\0'); - GetData()->nDataLength = (int)(DWORD_PTR)(lpszLast - m_pchData); - } - } - - // remove continuous occcurrences of characters in passed string, starting from right - void TrimRight(LPCTSTR lpszTargetList) - { - // find beginning of trailing matches by starting at beginning (DBCS aware) - - CopyBeforeWrite(); - LPTSTR lpsz = m_pchData; - LPTSTR lpszLast = NULL; - - while (*lpsz != _T('\0')) - { - TCHAR* pNext = ::CharNext(lpsz); - if(pNext > lpsz + 1) - { - if (_cstrchr_db(lpszTargetList, *lpsz, *(lpsz + 1)) != NULL) - { - if (lpszLast == NULL) - lpszLast = lpsz; - } - else - { - lpszLast = NULL; - } - } - else - { - if (_cstrchr(lpszTargetList, *lpsz) != NULL) - { - if (lpszLast == NULL) - lpszLast = lpsz; - } - else - { - lpszLast = NULL; - } - } - - lpsz = pNext; - } - - if (lpszLast != NULL) - { - // truncate at left-most matching character - *lpszLast = _T('\0'); - GetData()->nDataLength = (int)(DWORD_PTR)(lpszLast - m_pchData); - } - } - - // remove continuous occurrences of chTarget starting from left - void TrimLeft(TCHAR chTarget) - { - // find first non-matching character - - CopyBeforeWrite(); - LPCTSTR lpsz = m_pchData; - - while (chTarget == *lpsz) - lpsz = ::CharNext(lpsz); - - if (lpsz != m_pchData) - { - // fix up data and length - int nDataLength = GetData()->nDataLength - (int)(DWORD_PTR)(lpsz - m_pchData); - SecureHelper::memmove_x(m_pchData, (GetData()->nAllocLength + 1) * sizeof(TCHAR), lpsz, (nDataLength + 1) * sizeof(TCHAR)); - GetData()->nDataLength = nDataLength; - } - } - - // remove continuous occcurrences of characters in passed string, starting from left - void TrimLeft(LPCTSTR lpszTargets) - { - // if we're not trimming anything, we're not doing any work - if (SafeStrlen(lpszTargets) == 0) - return; - - CopyBeforeWrite(); - LPCTSTR lpsz = m_pchData; - - while (*lpsz != _T('\0')) - { - TCHAR* pNext = ::CharNext(lpsz); - if(pNext > lpsz + 1) - { - if (_cstrchr_db(lpszTargets, *lpsz, *(lpsz + 1)) == NULL) - break; - } - else - { - if (_cstrchr(lpszTargets, *lpsz) == NULL) - break; - } - lpsz = pNext; - } - - if (lpsz != m_pchData) - { - // fix up data and length - int nDataLength = GetData()->nDataLength - (int)(DWORD_PTR)(lpsz - m_pchData); - SecureHelper::memmove_x(m_pchData, (GetData()->nAllocLength + 1) * sizeof(TCHAR), lpsz, (nDataLength + 1) * sizeof(TCHAR)); - GetData()->nDataLength = nDataLength; - } - } - - // advanced manipulation - // replace occurrences of chOld with chNew - int Replace(TCHAR chOld, TCHAR chNew) - { - int nCount = 0; - - // short-circuit the nop case - if (chOld != chNew) - { - // otherwise modify each character that matches in the string - CopyBeforeWrite(); - LPTSTR psz = m_pchData; - LPTSTR pszEnd = psz + GetData()->nDataLength; - while (psz < pszEnd) - { - // replace instances of the specified character only - if (*psz == chOld) - { - *psz = chNew; - nCount++; - } - psz = ::CharNext(psz); - } - } - return nCount; - } - - // replace occurrences of substring lpszOld with lpszNew; - // empty lpszNew removes instances of lpszOld - int Replace(LPCTSTR lpszOld, LPCTSTR lpszNew) - { - // can't have empty or NULL lpszOld - - int nSourceLen = SafeStrlen(lpszOld); - if (nSourceLen == 0) - return 0; - int nReplacementLen = SafeStrlen(lpszNew); - - // loop once to figure out the size of the result string - int nCount = 0; - LPTSTR lpszStart = m_pchData; - LPTSTR lpszEnd = m_pchData + GetData()->nDataLength; - LPTSTR lpszTarget = NULL; - while (lpszStart < lpszEnd) - { - while ((lpszTarget = (TCHAR*)_cstrstr(lpszStart, lpszOld)) != NULL) - { - nCount++; - lpszStart = lpszTarget + nSourceLen; - } - lpszStart += lstrlen(lpszStart) + 1; - } - - // if any changes were made, make them - if (nCount > 0) - { - CopyBeforeWrite(); - - // if the buffer is too small, just allocate a new buffer (slow but sure) - int nOldLength = GetData()->nDataLength; - int nNewLength = nOldLength + (nReplacementLen - nSourceLen) * nCount; - if (GetData()->nAllocLength < nNewLength || GetData()->nRefs > 1) - { - CStringData* pOldData = GetData(); - LPTSTR pstr = m_pchData; - if(!AllocBuffer(nNewLength)) - return -1; - SecureHelper::memcpy_x(m_pchData, (nNewLength + 1) * sizeof(TCHAR), pstr, pOldData->nDataLength * sizeof(TCHAR)); - CString::Release(pOldData); - } - // else, we just do it in-place - lpszStart = m_pchData; - lpszEnd = m_pchData + GetData()->nDataLength; - - // loop again to actually do the work - while (lpszStart < lpszEnd) - { - while ((lpszTarget = (TCHAR*)_cstrstr(lpszStart, lpszOld)) != NULL) - { - int nBalance = nOldLength - ((int)(DWORD_PTR)(lpszTarget - m_pchData) + nSourceLen); - int cchBuffLen = GetData()->nAllocLength - (int)(DWORD_PTR)(lpszTarget - m_pchData); - SecureHelper::memmove_x(lpszTarget + nReplacementLen, (cchBuffLen - nReplacementLen + 1) * sizeof(TCHAR), lpszTarget + nSourceLen, nBalance * sizeof(TCHAR)); - SecureHelper::memcpy_x(lpszTarget, (cchBuffLen + 1) * sizeof(TCHAR), lpszNew, nReplacementLen * sizeof(TCHAR)); - lpszStart = lpszTarget + nReplacementLen; - lpszStart[nBalance] = _T('\0'); - nOldLength += (nReplacementLen - nSourceLen); - } - lpszStart += lstrlen(lpszStart) + 1; - } - ATLASSERT(m_pchData[nNewLength] == _T('\0')); - GetData()->nDataLength = nNewLength; - } - - return nCount; - } - - // remove occurrences of chRemove - int Remove(TCHAR chRemove) - { - CopyBeforeWrite(); - - LPTSTR pstrSource = m_pchData; - LPTSTR pstrDest = m_pchData; - LPTSTR pstrEnd = m_pchData + GetData()->nDataLength; - - while (pstrSource < pstrEnd) - { - if (*pstrSource != chRemove) - { - *pstrDest = *pstrSource; - pstrDest = ::CharNext(pstrDest); - } - pstrSource = ::CharNext(pstrSource); - } - *pstrDest = _T('\0'); - int nCount = (int)(DWORD_PTR)(pstrSource - pstrDest); - GetData()->nDataLength -= nCount; - - return nCount; - } - - // insert character at zero-based index; concatenates if index is past end of string - int Insert(int nIndex, TCHAR ch) - { - CopyBeforeWrite(); - - if (nIndex < 0) - nIndex = 0; - - int nNewLength = GetData()->nDataLength; - if (nIndex > nNewLength) - nIndex = nNewLength; - nNewLength++; - - if (GetData()->nAllocLength < nNewLength) - { - CStringData* pOldData = GetData(); - LPTSTR pstr = m_pchData; - if(!AllocBuffer(nNewLength)) - return -1; - SecureHelper::memcpy_x(m_pchData, (nNewLength + 1) * sizeof(TCHAR), pstr, (pOldData->nDataLength + 1) * sizeof(TCHAR)); - CString::Release(pOldData); - } - - // move existing bytes down - SecureHelper::memmove_x(m_pchData + nIndex + 1, (GetData()->nAllocLength - nIndex) * sizeof(TCHAR), m_pchData + nIndex, (nNewLength - nIndex) * sizeof(TCHAR)); - m_pchData[nIndex] = ch; - GetData()->nDataLength = nNewLength; - - return nNewLength; - } - - // insert substring at zero-based index; concatenates if index is past end of string - int Insert(int nIndex, LPCTSTR pstr) - { - if (nIndex < 0) - nIndex = 0; - - int nInsertLength = SafeStrlen(pstr); - int nNewLength = GetData()->nDataLength; - if (nInsertLength > 0) - { - CopyBeforeWrite(); - if (nIndex > nNewLength) - nIndex = nNewLength; - nNewLength += nInsertLength; - - if (GetData()->nAllocLength < nNewLength) - { - CStringData* pOldData = GetData(); - LPTSTR pstrTmp = m_pchData; - if(!AllocBuffer(nNewLength)) - return -1; - SecureHelper::memcpy_x(m_pchData, (nNewLength + 1) * sizeof(TCHAR), pstrTmp, (pOldData->nDataLength + 1) * sizeof(TCHAR)); - CString::Release(pOldData); - } - - // move existing bytes down - SecureHelper::memmove_x(m_pchData + nIndex + nInsertLength, (GetData()->nAllocLength + 1 - nIndex - nInsertLength) * sizeof(TCHAR), m_pchData + nIndex, (nNewLength - nIndex - nInsertLength + 1) * sizeof(TCHAR)); - SecureHelper::memcpy_x(m_pchData + nIndex, (GetData()->nAllocLength + 1 - nIndex) * sizeof(TCHAR), pstr, nInsertLength * sizeof(TCHAR)); - GetData()->nDataLength = nNewLength; - } - - return nNewLength; - } - - // delete nCount characters starting at zero-based index - int Delete(int nIndex, int nCount = 1) - { - if (nIndex < 0) - nIndex = 0; - int nLength = GetData()->nDataLength; - if (nCount > 0 && nIndex < nLength) - { - if((nIndex + nCount) > nLength) - nCount = nLength - nIndex; - CopyBeforeWrite(); - int nBytesToCopy = nLength - (nIndex + nCount) + 1; - - SecureHelper::memmove_x(m_pchData + nIndex, (GetData()->nAllocLength + 1 - nIndex) * sizeof(TCHAR), m_pchData + nIndex + nCount, nBytesToCopy * sizeof(TCHAR)); - nLength -= nCount; - GetData()->nDataLength = nLength; - } - - return nLength; - } - - // searching (return starting index, or -1 if not found) - // look for a single character match - int Find(TCHAR ch) const // like "C" strchr - { - return Find(ch, 0); - } - - int ReverseFind(TCHAR ch) const - { - // find last single character - LPCTSTR lpsz = _cstrrchr(m_pchData, (_TUCHAR)ch); - - // return -1 if not found, distance from beginning otherwise - return (lpsz == NULL) ? -1 : (int)(lpsz - m_pchData); - } - - int Find(TCHAR ch, int nStart) const // starting at index - { - int nLength = GetData()->nDataLength; - if (nStart < 0 || nStart >= nLength) - return -1; - - // find first single character - LPCTSTR lpsz = _cstrchr(m_pchData + nStart, (_TUCHAR)ch); - - // return -1 if not found and index otherwise - return (lpsz == NULL) ? -1 : (int)(lpsz - m_pchData); - } - - int FindOneOf(LPCTSTR lpszCharSet) const - { - ATLASSERT(_IsValidString(lpszCharSet)); - LPCTSTR lpsz = _cstrpbrk(m_pchData, lpszCharSet); - return (lpsz == NULL) ? -1 : (int)(lpsz - m_pchData); - } - - // look for a specific sub-string - // find a sub-string (like strstr) - int Find(LPCTSTR lpszSub) const // like "C" strstr - { - return Find(lpszSub, 0); - } - - int Find(LPCTSTR lpszSub, int nStart) const // starting at index - { - ATLASSERT(_IsValidString(lpszSub)); - - int nLength = GetData()->nDataLength; - if (nStart < 0 || nStart > nLength) - return -1; - - // find first matching substring - LPCTSTR lpsz = _cstrstr(m_pchData + nStart, lpszSub); - - // return -1 for not found, distance from beginning otherwise - return (lpsz == NULL) ? -1 : (int)(lpsz - m_pchData); - } - - // Concatentation for non strings - CString& Append(int n) - { - const int cchBuff = 12; - TCHAR szBuffer[cchBuff] = { 0 }; - SecureHelper::wsprintf_x(szBuffer, cchBuff, _T("%d"), n); - ConcatInPlace(SafeStrlen(szBuffer), szBuffer); - return *this; - } - - // simple formatting - // formatting (using wsprintf style formatting) - BOOL __cdecl Format(LPCTSTR lpszFormat, ...) - { - ATLASSERT(_IsValidString(lpszFormat)); - - va_list argList; - va_start(argList, lpszFormat); - BOOL bRet = FormatV(lpszFormat, argList); - va_end(argList); - return bRet; - } - - BOOL __cdecl Format(UINT nFormatID, ...) - { - CString strFormat; - BOOL bRet = strFormat.LoadString(nFormatID); - ATLASSERT(bRet != 0); - - va_list argList; - va_start(argList, nFormatID); - bRet = FormatV(strFormat, argList); - va_end(argList); - return bRet; - } - - BOOL FormatV(LPCTSTR lpszFormat, va_list argList) - { - ATLASSERT(_IsValidString(lpszFormat)); - - enum _FormatModifiers - { - FORCE_ANSI = 0x10000, - FORCE_UNICODE = 0x20000, - FORCE_INT64 = 0x40000 - }; - - va_list argListSave = argList; - - // make a guess at the maximum length of the resulting string - int nMaxLen = 0; - for (LPCTSTR lpsz = lpszFormat; *lpsz != _T('\0'); lpsz = ::CharNext(lpsz)) - { - // handle '%' character, but watch out for '%%' - if (*lpsz != _T('%') || *(lpsz = ::CharNext(lpsz)) == _T('%')) - { - nMaxLen += (int)(::CharNext(lpsz) - lpsz); - continue; - } - - int nItemLen = 0; - - // handle '%' character with format - int nWidth = 0; - for (; *lpsz != _T('\0'); lpsz = ::CharNext(lpsz)) - { - // check for valid flags - if (*lpsz == _T('#')) - nMaxLen += 2; // for '0x' - else if (*lpsz == _T('*')) - nWidth = va_arg(argList, int); - else if (*lpsz == _T('-') || *lpsz == _T('+') || *lpsz == _T('0') || *lpsz == _T(' ')) - ; - else // hit non-flag character - break; - } - // get width and skip it - if (nWidth == 0) - { - // width indicated by - nWidth = _cstrtoi(lpsz); - for (; *lpsz != _T('\0') && _cstrisdigit(*lpsz); lpsz = ::CharNext(lpsz)) - ; - } - ATLASSERT(nWidth >= 0); - - int nPrecision = 0; - if (*lpsz == _T('.')) - { - // skip past '.' separator (width.precision) - lpsz = ::CharNext(lpsz); - - // get precision and skip it - if (*lpsz == _T('*')) - { - nPrecision = va_arg(argList, int); - lpsz = ::CharNext(lpsz); - } - else - { - nPrecision = _cstrtoi(lpsz); - for (; *lpsz != _T('\0') && _cstrisdigit(*lpsz); lpsz = ::CharNext(lpsz)) - ; - } - ATLASSERT(nPrecision >= 0); - } - - // should be on type modifier or specifier - int nModifier = 0; - if(lpsz[0] == _T('I')) - { - if((lpsz[1] == _T('6')) && (lpsz[2] == _T('4'))) - { - lpsz += 3; - nModifier = FORCE_INT64; - } - else if((lpsz[1] == _T('3')) && (lpsz[2] == _T('2'))) - { - lpsz += 3; - } - else - { - lpsz++; - if(sizeof(size_t) == 8) - nModifier = FORCE_INT64; - } - } - else - { - switch (*lpsz) - { - // modifiers that affect size - case _T('h'): - nModifier = FORCE_ANSI; - lpsz = ::CharNext(lpsz); - break; - case _T('l'): - nModifier = FORCE_UNICODE; - lpsz = ::CharNext(lpsz); - break; - - // modifiers that do not affect size - case _T('F'): - case _T('N'): - case _T('L'): - lpsz = ::CharNext(lpsz); - break; - } - } - - // now should be on specifier - switch (*lpsz | nModifier) - { - // single characters - case _T('c'): - case _T('C'): - nItemLen = 2; - va_arg(argList, TCHAR); - break; - case _T('c') | FORCE_ANSI: - case _T('C') | FORCE_ANSI: - nItemLen = 2; - va_arg(argList, char); - break; - case _T('c') | FORCE_UNICODE: - case _T('C') | FORCE_UNICODE: - nItemLen = 2; - va_arg(argList, WCHAR); - break; - - // strings - case _T('s'): - { - LPCTSTR pstrNextArg = va_arg(argList, LPCTSTR); - if (pstrNextArg == NULL) - { - nItemLen = 6; // "(null)" - } - else - { - nItemLen = lstrlen(pstrNextArg); - nItemLen = __max(1, nItemLen); - } - break; - } - - case _T('S'): - { -#ifndef _UNICODE - LPWSTR pstrNextArg = va_arg(argList, LPWSTR); - if (pstrNextArg == NULL) - { - nItemLen = 6; // "(null)" - } - else - { - nItemLen = (int)wcslen(pstrNextArg); - nItemLen = __max(1, nItemLen); - } -#else // _UNICODE - LPCSTR pstrNextArg = va_arg(argList, LPCSTR); - if (pstrNextArg == NULL) - { - nItemLen = 6; // "(null)" - } - else - { -#if defined(_WIN32_WCE) && (_ATL_VER >= 0x0800) - nItemLen = ATL::lstrlenA(pstrNextArg); -#else - nItemLen = lstrlenA(pstrNextArg); -#endif - nItemLen = __max(1, nItemLen); - } -#endif // _UNICODE - break; - } - - case _T('s') | FORCE_ANSI: - case _T('S') | FORCE_ANSI: - { - LPCSTR pstrNextArg = va_arg(argList, LPCSTR); - if (pstrNextArg == NULL) - { - nItemLen = 6; // "(null)" - } - else - { -#if defined(_WIN32_WCE) && (_ATL_VER >= 0x0800) - nItemLen = ATL::lstrlenA(pstrNextArg); -#else - nItemLen = lstrlenA(pstrNextArg); -#endif - nItemLen = __max(1, nItemLen); - } - break; - } - - case _T('s') | FORCE_UNICODE: - case _T('S') | FORCE_UNICODE: - { - LPWSTR pstrNextArg = va_arg(argList, LPWSTR); - if (pstrNextArg == NULL) - { - nItemLen = 6; // "(null)" - } - else - { - nItemLen = (int)wcslen(pstrNextArg); - nItemLen = __max(1, nItemLen); - } - break; - } - } - - // adjust nItemLen for strings - if (nItemLen != 0) - { - nItemLen = __max(nItemLen, nWidth); - if (nPrecision != 0) - nItemLen = __min(nItemLen, nPrecision); - } - else - { - switch (*lpsz) - { - // integers - case _T('d'): - case _T('i'): - case _T('u'): - case _T('x'): - case _T('X'): - case _T('o'): - if (nModifier & FORCE_INT64) - va_arg(argList, __int64); - else - va_arg(argList, int); - nItemLen = 32; - nItemLen = __max(nItemLen, nWidth + nPrecision); - break; - -#ifndef _ATL_USE_CSTRING_FLOAT - case _T('e'): - case _T('E'): - case _T('f'): - case _T('g'): - case _T('G'): - ATLASSERT(!"Floating point (%%e, %%E, %%f, %%g, and %%G) is not supported by the WTL::CString class."); -#ifndef _DEBUG - ::OutputDebugString(_T("Floating point (%%e, %%f, %%g, and %%G) is not supported by the WTL::CString class.")); -#ifndef _WIN32_WCE - ::DebugBreak(); -#else // CE specific - DebugBreak(); -#endif // _WIN32_WCE -#endif // !_DEBUG - break; -#else // _ATL_USE_CSTRING_FLOAT - case _T('e'): - case _T('E'): - case _T('g'): - case _T('G'): - va_arg(argList, double); - nItemLen = 128; - nItemLen = __max(nItemLen, nWidth + nPrecision); - break; - case _T('f'): - { - double f = va_arg(argList, double); - // 312 == strlen("-1+(309 zeroes).") - // 309 zeroes == max precision of a double - // 6 == adjustment in case precision is not specified, - // which means that the precision defaults to 6 - int cchLen = __max(nWidth, 312 + nPrecision + 6); - CTempBuffer buff; - LPTSTR pszTemp = buff.Allocate(cchLen); - if(pszTemp != NULL) - { - SecureHelper::sprintf_x(pszTemp, cchLen, _T("%*.*f"), nWidth, nPrecision + 6, f); - nItemLen = (int)_tcslen(pszTemp); - } - else - { - nItemLen = cchLen; - } - } - break; -#endif // _ATL_USE_CSTRING_FLOAT - - case _T('p'): - va_arg(argList, void*); - nItemLen = 32; - nItemLen = __max(nItemLen, nWidth + nPrecision); - break; - - // no output - case _T('n'): - va_arg(argList, int*); - break; - - default: - ATLASSERT(FALSE); // unknown formatting option - } - } - - // adjust nMaxLen for output nItemLen - nMaxLen += nItemLen; - } - - if(GetBuffer(nMaxLen) == NULL) - return FALSE; -#ifndef _ATL_USE_CSTRING_FLOAT - int nRet = SecureHelper::wvsprintf_x(m_pchData, GetAllocLength() + 1, lpszFormat, argListSave); -#else // _ATL_USE_CSTRING_FLOAT - int nRet = SecureHelper::vsprintf_x(m_pchData, GetAllocLength() + 1, lpszFormat, argListSave); -#endif // _ATL_USE_CSTRING_FLOAT - nRet; // ref - ATLASSERT(nRet <= GetAllocLength()); - ReleaseBuffer(); - - va_end(argListSave); - return TRUE; - } - - // formatting for localization (uses FormatMessage API) - // formatting (using FormatMessage style formatting) - BOOL __cdecl FormatMessage(LPCTSTR lpszFormat, ...) - { - // format message into temporary buffer lpszTemp - va_list argList; - va_start(argList, lpszFormat); - LPTSTR lpszTemp = NULL; - BOOL bRet = TRUE; - - if ((::FormatMessage(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ALLOCATE_BUFFER, - lpszFormat, 0, 0, (LPTSTR)&lpszTemp, 0, &argList) == 0) || (lpszTemp == NULL)) - bRet = FALSE; - - // assign lpszTemp into the resulting string and free the temporary - *this = lpszTemp; - LocalFree(lpszTemp); - va_end(argList); - return bRet; - } - - BOOL __cdecl FormatMessage(UINT nFormatID, ...) - { - // get format string from string table - CString strFormat; - BOOL bRetTmp = strFormat.LoadString(nFormatID); - bRetTmp; // ref - ATLASSERT(bRetTmp != 0); - - // format message into temporary buffer lpszTemp - va_list argList; - va_start(argList, nFormatID); - LPTSTR lpszTemp = NULL; - BOOL bRet = TRUE; - - if ((::FormatMessage(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ALLOCATE_BUFFER, - strFormat, 0, 0, (LPTSTR)&lpszTemp, 0, &argList) == 0) || (lpszTemp == NULL)) - bRet = FALSE; - - // assign lpszTemp into the resulting string and free lpszTemp - *this = lpszTemp; - LocalFree(lpszTemp); - va_end(argList); - return bRet; - } - - // Windows support - BOOL LoadString(UINT nID) // load from string resource (255 chars max.) - { -#ifdef _UNICODE - const int CHAR_FUDGE = 1; // one TCHAR unused is good enough -#else - const int CHAR_FUDGE = 2; // two BYTES unused for case of DBC last char -#endif - - // try fixed buffer first (to avoid wasting space in the heap) - TCHAR szTemp[256] = { 0 }; - int nCount = sizeof(szTemp) / sizeof(szTemp[0]); - int nLen = _LoadString(nID, szTemp, nCount); - if (nCount - nLen > CHAR_FUDGE) - { - *this = szTemp; - return (nLen > 0); - } - - // try buffer size of 512, then larger size until entire string is retrieved - int nSize = 256; - do - { - nSize += 256; - LPTSTR lpstr = GetBuffer(nSize - 1); - if(lpstr == NULL) - { - nLen = 0; - break; - } - nLen = _LoadString(nID, lpstr, nSize); - } while (nSize - nLen <= CHAR_FUDGE); - ReleaseBuffer(); - - return (nLen > 0); - } - -#ifndef _UNICODE - // ANSI <-> OEM support (convert string in place) - void AnsiToOem() - { - CopyBeforeWrite(); - ::AnsiToOem(m_pchData, m_pchData); - } - - void OemToAnsi() - { - CopyBeforeWrite(); - ::OemToAnsi(m_pchData, m_pchData); - } -#endif - -#ifndef _ATL_NO_COM - // OLE BSTR support (use for OLE automation) - BSTR AllocSysString() const - { -#if defined(_UNICODE) || defined(OLE2ANSI) - BSTR bstr = ::SysAllocStringLen(m_pchData, GetData()->nDataLength); -#else - int nLen = MultiByteToWideChar(CP_ACP, 0, m_pchData, - GetData()->nDataLength, NULL, NULL); - BSTR bstr = ::SysAllocStringLen(NULL, nLen); - if(bstr != NULL) - MultiByteToWideChar(CP_ACP, 0, m_pchData, GetData()->nDataLength, bstr, nLen); -#endif - return bstr; - } - - BSTR SetSysString(BSTR* pbstr) const - { -#if defined(_UNICODE) || defined(OLE2ANSI) - ::SysReAllocStringLen(pbstr, m_pchData, GetData()->nDataLength); -#else - int nLen = MultiByteToWideChar(CP_ACP, 0, m_pchData, - GetData()->nDataLength, NULL, NULL); - if(::SysReAllocStringLen(pbstr, NULL, nLen)) - MultiByteToWideChar(CP_ACP, 0, m_pchData, GetData()->nDataLength, *pbstr, nLen); -#endif - ATLASSERT(*pbstr != NULL); - return *pbstr; - } -#endif // !_ATL_NO_COM - - // Access to string implementation buffer as "C" character array - LPTSTR GetBuffer(int nMinBufLength) - { - ATLASSERT(nMinBufLength >= 0); - - if (GetData()->nRefs > 1 || nMinBufLength > GetData()->nAllocLength) - { - // we have to grow the buffer - CStringData* pOldData = GetData(); - int nOldLen = GetData()->nDataLength; // AllocBuffer will tromp it - if (nMinBufLength < nOldLen) - nMinBufLength = nOldLen; - - if(!AllocBuffer(nMinBufLength)) - return NULL; - - SecureHelper::memcpy_x(m_pchData, (nMinBufLength + 1) * sizeof(TCHAR), pOldData->data(), (nOldLen + 1) * sizeof(TCHAR)); - GetData()->nDataLength = nOldLen; - CString::Release(pOldData); - } - ATLASSERT(GetData()->nRefs <= 1); - - // return a pointer to the character storage for this string - ATLASSERT(m_pchData != NULL); - return m_pchData; - } - - void ReleaseBuffer(int nNewLength = -1) - { - CopyBeforeWrite(); // just in case GetBuffer was not called - - if (nNewLength == -1) - nNewLength = lstrlen(m_pchData); // zero terminated - - ATLASSERT(nNewLength <= GetData()->nAllocLength); - GetData()->nDataLength = nNewLength; - m_pchData[nNewLength] = _T('\0'); - } - - LPTSTR GetBufferSetLength(int nNewLength) - { - ATLASSERT(nNewLength >= 0); - - if(GetBuffer(nNewLength) == NULL) - return NULL; - - GetData()->nDataLength = nNewLength; - m_pchData[nNewLength] = _T('\0'); - return m_pchData; - } - - void FreeExtra() - { - ATLASSERT(GetData()->nDataLength <= GetData()->nAllocLength); - if (GetData()->nDataLength != GetData()->nAllocLength) - { - CStringData* pOldData = GetData(); - if(AllocBuffer(GetData()->nDataLength)) - { - SecureHelper::memcpy_x(m_pchData, (GetData()->nAllocLength + 1) * sizeof(TCHAR), pOldData->data(), pOldData->nDataLength * sizeof(TCHAR)); - ATLASSERT(m_pchData[GetData()->nDataLength] == _T('\0')); - CString::Release(pOldData); - } - } - ATLASSERT(GetData() != NULL); - } - - // Use LockBuffer/UnlockBuffer to turn refcounting off - LPTSTR LockBuffer() - { - LPTSTR lpsz = GetBuffer(0); - if(lpsz != NULL) - GetData()->nRefs = -1; - return lpsz; - } - - void UnlockBuffer() - { - ATLASSERT(GetData()->nRefs == -1); - if (GetData() != _atltmpDataNil) - GetData()->nRefs = 1; - } - -// Implementation -public: - ~CString() // free any attached data - { - if (GetData() != _atltmpDataNil) - { - if (InterlockedDecrement(&GetData()->nRefs) <= 0) - delete[] (BYTE*)GetData(); - } - } - - int GetAllocLength() const - { - return GetData()->nAllocLength; - } - - static BOOL __stdcall _IsValidString(LPCTSTR lpsz, int /*nLength*/ = -1) - { - return (lpsz != NULL) ? TRUE : FALSE; - } - -protected: - LPTSTR m_pchData; // pointer to ref counted string data - - // implementation helpers - CStringData* GetData() const - { - ATLASSERT(m_pchData != NULL); - return ((CStringData*)m_pchData) - 1; - } - - void Init() - { - m_pchData = _GetEmptyString().m_pchData; - } - - BOOL AllocCopy(CString& dest, int nCopyLen, int nCopyIndex, int nExtraLen) const - { - // will clone the data attached to this string - // allocating 'nExtraLen' characters - // Places results in uninitialized string 'dest' - // Will copy the part or all of original data to start of new string - - BOOL bRet = FALSE; - int nNewLen = nCopyLen + nExtraLen; - if (nNewLen == 0) - { - dest.Init(); - bRet = TRUE; - } - else if(nNewLen >= nCopyLen) - { - if(dest.AllocBuffer(nNewLen)) - { - SecureHelper::memcpy_x(dest.m_pchData, (nNewLen + 1) * sizeof(TCHAR), m_pchData + nCopyIndex, nCopyLen * sizeof(TCHAR)); - bRet = TRUE; - } - } - - return bRet; - } - - // always allocate one extra character for '\0' termination - // assumes [optimistically] that data length will equal allocation length - BOOL AllocBuffer(int nLen) - { - ATLASSERT(nLen >= 0); - ATLASSERT(nLen <= INT_MAX - 1); // max size (enough room for 1 extra) - - if (nLen == 0) - { - Init(); - } - else - { - CStringData* pData = NULL; - ATLTRY(pData = (CStringData*)new BYTE[sizeof(CStringData) + (nLen + 1) * sizeof(TCHAR)]); - if(pData == NULL) - return FALSE; - - pData->nRefs = 1; - pData->data()[nLen] = _T('\0'); - pData->nDataLength = nLen; - pData->nAllocLength = nLen; - m_pchData = pData->data(); - } - - return TRUE; - } - - // Assignment operators - // All assign a new value to the string - // (a) first see if the buffer is big enough - // (b) if enough room, copy on top of old buffer, set size and type - // (c) otherwise free old string data, and create a new one - // - // All routines return the new string (but as a 'const CString&' so that - // assigning it again will cause a copy, eg: s1 = s2 = "hi there". - // - void AssignCopy(int nSrcLen, LPCTSTR lpszSrcData) - { - if(AllocBeforeWrite(nSrcLen)) - { - SecureHelper::memcpy_x(m_pchData, (nSrcLen + 1) * sizeof(TCHAR), lpszSrcData, nSrcLen * sizeof(TCHAR)); - GetData()->nDataLength = nSrcLen; - m_pchData[nSrcLen] = _T('\0'); - } - } - - // Concatenation - // NOTE: "operator +" is done as friend functions for simplicity - // There are three variants: - // CString + CString - // and for ? = TCHAR, LPCTSTR - // CString + ? - // ? + CString - BOOL ConcatCopy(int nSrc1Len, LPCTSTR lpszSrc1Data, int nSrc2Len, LPCTSTR lpszSrc2Data) - { - // -- master concatenation routine - // Concatenate two sources - // -- assume that 'this' is a new CString object - - BOOL bRet = TRUE; - int nNewLen = nSrc1Len + nSrc2Len; - if(nNewLen < nSrc1Len || nNewLen < nSrc2Len) - { - bRet = FALSE; - } - else if(nNewLen != 0) - { - bRet = AllocBuffer(nNewLen); - if (bRet) - { - SecureHelper::memcpy_x(m_pchData, (nNewLen + 1) * sizeof(TCHAR), lpszSrc1Data, nSrc1Len * sizeof(TCHAR)); - SecureHelper::memcpy_x(m_pchData + nSrc1Len, (nNewLen + 1 - nSrc1Len) * sizeof(TCHAR), lpszSrc2Data, nSrc2Len * sizeof(TCHAR)); - } - } - return bRet; - } - - void ConcatInPlace(int nSrcLen, LPCTSTR lpszSrcData) - { - // -- the main routine for += operators - - // concatenating an empty string is a no-op! - if (nSrcLen == 0) - return; - - // if the buffer is too small, or we have a width mis-match, just - // allocate a new buffer (slow but sure) - if (GetData()->nRefs > 1 || GetData()->nDataLength + nSrcLen > GetData()->nAllocLength) - { - // we have to grow the buffer, use the ConcatCopy routine - CStringData* pOldData = GetData(); - if (ConcatCopy(GetData()->nDataLength, m_pchData, nSrcLen, lpszSrcData)) - { - ATLASSERT(pOldData != NULL); - CString::Release(pOldData); - } - } - else - { - // fast concatenation when buffer big enough - SecureHelper::memcpy_x(m_pchData + GetData()->nDataLength, (GetData()->nAllocLength + 1) * sizeof(TCHAR), lpszSrcData, nSrcLen * sizeof(TCHAR)); - GetData()->nDataLength += nSrcLen; - ATLASSERT(GetData()->nDataLength <= GetData()->nAllocLength); - m_pchData[GetData()->nDataLength] = _T('\0'); - } - } - - void CopyBeforeWrite() - { - if (GetData()->nRefs > 1) - { - CStringData* pData = GetData(); - Release(); - if(AllocBuffer(pData->nDataLength)) - SecureHelper::memcpy_x(m_pchData, (GetData()->nAllocLength + 1) * sizeof(TCHAR), pData->data(), (pData->nDataLength + 1) * sizeof(TCHAR)); - } - ATLASSERT(GetData()->nRefs <= 1); - } - - BOOL AllocBeforeWrite(int nLen) - { - BOOL bRet = TRUE; - if (GetData()->nRefs > 1 || nLen > GetData()->nAllocLength) - { - Release(); - bRet = AllocBuffer(nLen); - } - ATLASSERT(GetData()->nRefs <= 1); - return bRet; - } - - void Release() - { - if (GetData() != _atltmpDataNil) - { - ATLASSERT(GetData()->nRefs != 0); - if (InterlockedDecrement(&GetData()->nRefs) <= 0) - delete[] (BYTE*)GetData(); - Init(); - } - } - - static void PASCAL Release(CStringData* pData) - { - if (pData != _atltmpDataNil) - { - ATLASSERT(pData->nRefs != 0); - if (InterlockedDecrement(&pData->nRefs) <= 0) - delete[] (BYTE*)pData; - } - } - - static int PASCAL SafeStrlen(LPCTSTR lpsz) - { - return (lpsz == NULL) ? 0 : lstrlen(lpsz); - } - - static int __stdcall _LoadString(UINT nID, LPTSTR lpszBuf, UINT nMaxBuf) - { -#ifdef _DEBUG - // LoadString without annoying warning from the Debug kernel if the - // segment containing the string is not present - if (::FindResource(ModuleHelper::GetResourceInstance(), MAKEINTRESOURCE((nID >> 4) + 1), RT_STRING) == NULL) - { - lpszBuf[0] = _T('\0'); - return 0; // not found - } -#endif // _DEBUG - - int nLen = ::LoadString(ModuleHelper::GetResourceInstance(), nID, lpszBuf, nMaxBuf); - if (nLen == 0) - lpszBuf[0] = _T('\0'); - - return nLen; - } - - static const CString& __stdcall _GetEmptyString() - { - return *(CString*)&_atltmpPchNil; - } - -// CString conversion helpers - static int __cdecl _wcstombsz(char* mbstr, const wchar_t* wcstr, size_t count) - { - if (count == 0 && mbstr != NULL) - return 0; - - int result = ::WideCharToMultiByte(CP_ACP, 0, wcstr, -1, mbstr, (int)count, NULL, NULL); - ATLASSERT(mbstr == NULL || result <= (int)count); - if ((mbstr != NULL) && (result > 0)) - mbstr[result - 1] = 0; - return result; - } - - static int __cdecl _mbstowcsz(wchar_t* wcstr, const char* mbstr, size_t count) - { - if (count == 0 && wcstr != NULL) - return 0; - - int result = ::MultiByteToWideChar(CP_ACP, 0, mbstr, -1, wcstr, (int)count); - ATLASSERT(wcstr == NULL || result <= (int)count); - if ((wcstr != NULL) && (result > 0)) - wcstr[result - 1] = 0; - return result; - } - -// Helpers to avoid CRT startup code -#ifdef _ATL_MIN_CRT - static const TCHAR* _cstrchr(const TCHAR* p, TCHAR ch) - { - // strchr for '\0' should succeed - while (*p != 0) - { - if (*p == ch) - break; - p = ::CharNext(p); - } - return (*p == ch) ? p : NULL; - } - - static TCHAR* _cstrrev(TCHAR* pStr) - { - // optimize NULL, zero-length, and single-char case - if ((pStr == NULL) || (pStr[0] == _T('\0')) || (pStr[1] == _T('\0'))) - return pStr; - - TCHAR* p = pStr; - - while (*p != 0) - { - TCHAR* pNext = ::CharNext(p); - if(pNext > p + 1) - { - char p1 = *(char*)p; - *(char*)p = *(char*)(p + 1); - *(char*)(p + 1) = p1; - } - p = pNext; - } - - p--; - TCHAR* q = pStr; - - while (q < p) - { - TCHAR t = *q; - *q = *p; - *p = t; - q++; - p--; - } - return pStr; - } - - static const TCHAR* _cstrstr(const TCHAR* pStr, const TCHAR* pCharSet) - { - int nLen = lstrlen(pCharSet); - if (nLen == 0) - return (TCHAR*)pStr; - - const TCHAR* pRet = NULL; - const TCHAR* pCur = pStr; - while((pCur = _cstrchr(pCur, *pCharSet)) != NULL) - { - if(memcmp(pCur, pCharSet, nLen * sizeof(TCHAR)) == 0) - { - pRet = pCur; - break; - } - pCur = ::CharNext(pCur); - } - return pRet; - } - - static int _cstrspn(const TCHAR* pStr, const TCHAR* pCharSet) - { - int nRet = 0; - const TCHAR* p = pStr; - while (*p != 0) - { - const TCHAR* pNext = ::CharNext(p); - if(pNext > p + 1) - { - if(_cstrchr_db(pCharSet, *p, *(p + 1)) == NULL) - break; - nRet += 2; - } - else - { - if(_cstrchr(pCharSet, *p) == NULL) - break; - nRet++; - } - p = pNext; - } - return nRet; - } - - static int _cstrcspn(const TCHAR* pStr, const TCHAR* pCharSet) - { - int nRet = 0; - TCHAR* p = (TCHAR*)pStr; - while (*p != 0) - { - TCHAR* pNext = ::CharNext(p); - if(pNext > p + 1) - { - if(_cstrchr_db(pCharSet, *p, *(p + 1)) != NULL) - break; - nRet += 2; - } - else - { - if(_cstrchr(pCharSet, *p) != NULL) - break; - nRet++; - } - p = pNext; - } - return nRet; - } - - static const TCHAR* _cstrpbrk(const TCHAR* p, const TCHAR* lpszCharSet) - { - int n = _cstrcspn(p, lpszCharSet); - return (p[n] != 0) ? &p[n] : NULL; - } - - static int _cstrcmp(const TCHAR* pstrOne, const TCHAR* pstrOther) - { - return lstrcmp(pstrOne, pstrOther); - } - - static int _cstrcmpi(const TCHAR* pstrOne, const TCHAR* pstrOther) - { - return lstrcmpi(pstrOne, pstrOther); - } - - static int _cstrcoll(const TCHAR* pstrOne, const TCHAR* pstrOther) - { - int nRet = CompareString(GetThreadLocale(), 0, pstrOne, -1, pstrOther, -1); - ATLASSERT(nRet != 0); - return nRet - 2; // convert to strcmp convention - } - - static int _cstrcolli(const TCHAR* pstrOne, const TCHAR* pstrOther) - { - int nRet = CompareString(GetThreadLocale(), NORM_IGNORECASE, pstrOne, -1, pstrOther, -1); - ATLASSERT(nRet != 0); - return nRet - 2; // convert to strcmp convention - } -#else // !_ATL_MIN_CRT - static const TCHAR* _cstrchr(const TCHAR* p, TCHAR ch) - { - return _tcschr(p, ch); - } - - static TCHAR* _cstrrev(TCHAR* pStr) - { - return _tcsrev(pStr); - } - - static const TCHAR* _cstrstr(const TCHAR* pStr, const TCHAR* pCharSet) - { - return _tcsstr(pStr, pCharSet); - } - - static int _cstrspn(const TCHAR* pStr, const TCHAR* pCharSet) - { - return (int)_tcsspn(pStr, pCharSet); - } - - static int _cstrcspn(const TCHAR* pStr, const TCHAR* pCharSet) - { - return (int)_tcscspn(pStr, pCharSet); - } - - static const TCHAR* _cstrpbrk(const TCHAR* p, const TCHAR* lpszCharSet) - { - return _tcspbrk(p, lpszCharSet); - } - - static int _cstrcmp(const TCHAR* pstrOne, const TCHAR* pstrOther) - { - return _tcscmp(pstrOne, pstrOther); - } - - static int _cstrcmpi(const TCHAR* pstrOne, const TCHAR* pstrOther) - { - return _tcsicmp(pstrOne, pstrOther); - } - -#ifndef _WIN32_WCE - static int _cstrcoll(const TCHAR* pstrOne, const TCHAR* pstrOther) - { - return _tcscoll(pstrOne, pstrOther); - } - - static int _cstrcolli(const TCHAR* pstrOne, const TCHAR* pstrOther) - { - return _tcsicoll(pstrOne, pstrOther); - } -#endif // !_WIN32_WCE -#endif // !_ATL_MIN_CRT - - static const TCHAR* _cstrrchr(const TCHAR* p, TCHAR ch) - { - return MinCrtHelper::_strrchr(p, ch); - } - - static int _cstrisdigit(TCHAR ch) - { - return MinCrtHelper::_isdigit(ch); - } - - static int _cstrisspace(TCHAR ch) - { - return MinCrtHelper::_isspace(ch); - } - - static int _cstrtoi(const TCHAR* nptr) - { - return MinCrtHelper::_atoi(nptr); - } - - static const TCHAR* _cstrchr_db(const TCHAR* p, TCHAR ch1, TCHAR ch2) - { - const TCHAR* lpsz = NULL; - while (*p != 0) - { - if (*p == ch1 && *(p + 1) == ch2) - { - lpsz = p; - break; - } - p = ::CharNext(p); - } - return lpsz; - } -}; - - -// Compare helpers - -inline bool __stdcall operator ==(const CString& s1, const CString& s2) -{ return s1.Compare(s2) == 0; } - -inline bool __stdcall operator ==(const CString& s1, LPCTSTR s2) -{ return s1.Compare(s2) == 0; } - -inline bool __stdcall operator ==(LPCTSTR s1, const CString& s2) -{ return s2.Compare(s1) == 0; } - -inline bool __stdcall operator !=(const CString& s1, const CString& s2) -{ return s1.Compare(s2) != 0; } - -inline bool __stdcall operator !=(const CString& s1, LPCTSTR s2) -{ return s1.Compare(s2) != 0; } - -inline bool __stdcall operator !=(LPCTSTR s1, const CString& s2) -{ return s2.Compare(s1) != 0; } - -inline bool __stdcall operator <(const CString& s1, const CString& s2) -{ return s1.Compare(s2) < 0; } - -inline bool __stdcall operator <(const CString& s1, LPCTSTR s2) -{ return s1.Compare(s2) < 0; } - -inline bool __stdcall operator <(LPCTSTR s1, const CString& s2) -{ return s2.Compare(s1) > 0; } - -inline bool __stdcall operator >(const CString& s1, const CString& s2) -{ return s1.Compare(s2) > 0; } - -inline bool __stdcall operator >(const CString& s1, LPCTSTR s2) -{ return s1.Compare(s2) > 0; } - -inline bool __stdcall operator >(LPCTSTR s1, const CString& s2) -{ return s2.Compare(s1) < 0; } - -inline bool __stdcall operator <=(const CString& s1, const CString& s2) -{ return s1.Compare(s2) <= 0; } - -inline bool __stdcall operator <=(const CString& s1, LPCTSTR s2) -{ return s1.Compare(s2) <= 0; } - -inline bool __stdcall operator <=(LPCTSTR s1, const CString& s2) -{ return s2.Compare(s1) >= 0; } - -inline bool __stdcall operator >=(const CString& s1, const CString& s2) -{ return s1.Compare(s2) >= 0; } - -inline bool __stdcall operator >=(const CString& s1, LPCTSTR s2) -{ return s1.Compare(s2) >= 0; } - -inline bool __stdcall operator >=(LPCTSTR s1, const CString& s2) -{ return s2.Compare(s1) <= 0; } +/////////////////////////////////////////////////////////////////////////////// +// Classes in this file: +// +// CRecentDocumentListBase +// CRecentDocumentList +// CFindFile +// CRegProperty +// CRegPropertyImpl +// +// Global functions: +// AtlGetStockPen() +// AtlGetStockBrush() +// AtlGetStockFont() +// AtlGetStockPalette() +// +// AtlCompactPath() -// CString "operator +" functions -inline CString __stdcall operator +(const CString& string1, const CString& string2) +namespace WTL { - CString s; - s.ConcatCopy(string1.GetData()->nDataLength, string1.m_pchData, string2.GetData()->nDataLength, string2.m_pchData); - return s; -} -inline CString __stdcall operator +(const CString& string, TCHAR ch) -{ - CString s; - s.ConcatCopy(string.GetData()->nDataLength, string.m_pchData, 1, &ch); - return s; -} +/////////////////////////////////////////////////////////////////////////////// +// CSize scalar operators -inline CString __stdcall operator +(TCHAR ch, const CString& string) -{ - CString s; - s.ConcatCopy(1, &ch, string.GetData()->nDataLength, string.m_pchData); - return s; -} +#if !defined(_WTL_NO_SIZE_SCALAR) && defined(__ATLTYPES_H__) -#ifdef _UNICODE -inline CString __stdcall operator +(const CString& string, char ch) +template +inline CSize operator *(SIZE s, Num n) { - return string + (TCHAR)ch; -} + return CSize((int)(s.cx * n), (int)(s.cy * n)); +}; -inline CString __stdcall operator +(char ch, const CString& string) +template +inline void operator *=(SIZE & s, Num n) { - return (TCHAR)ch + string; -} -#endif // _UNICODE + s = s * n; +}; -inline CString __stdcall operator +(const CString& string, LPCTSTR lpsz) +template +inline CSize operator /(SIZE s, Num n) { - ATLASSERT(lpsz == NULL || CString::_IsValidString(lpsz)); - CString s; - s.ConcatCopy(string.GetData()->nDataLength, string.m_pchData, CString::SafeStrlen(lpsz), lpsz); - return s; -} + return CSize((int)(s.cx / n), (int)(s.cy / n)); +}; -inline CString __stdcall operator +(LPCTSTR lpsz, const CString& string) +template +inline void operator /=(SIZE & s, Num n) { - ATLASSERT(lpsz == NULL || CString::_IsValidString(lpsz)); - CString s; - s.ConcatCopy(CString::SafeStrlen(lpsz), lpsz, string.GetData()->nDataLength, string.m_pchData); - return s; -} + s = s / n; +}; -#endif // !_WTL_NO_CSTRING +#endif // !defined(_WTL_NO_SIZE_SCALAR) && defined(__ATLTYPES_H__) /////////////////////////////////////////////////////////////////////////////// // CRecentDocumentList - MRU List Support -#ifndef _WIN32_WCE - #ifndef _WTL_MRUEMPTY_TEXT #define _WTL_MRUEMPTY_TEXT _T("(empty)") #endif @@ -2847,8 +115,10 @@ public: int m_cchMaxItemLen; // Constructor - CRecentDocumentListBase() : m_hMenu(NULL), m_nMaxEntries(4), m_cchMaxItemLen(-1) + CRecentDocumentListBase() : m_nMaxEntries(4), m_hMenu(NULL), m_cchMaxItemLen(-1) { + m_szNoEntries[0] = 0; + // These ASSERTs verify values of the template arguments ATLASSERT(t_cchItemLen > m_cchMaxItemLen_Min); ATLASSERT(m_nMaxEntries_Max > m_nMaxEntries_Min); @@ -2862,13 +132,13 @@ public: void SetMenuHandle(HMENU hMenu) { - ATLASSERT(hMenu == NULL || ::IsMenu(hMenu)); + ATLASSERT((hMenu == NULL) || ::IsMenu(hMenu)); m_hMenu = hMenu; - if(m_hMenu == NULL || (::GetMenuString(m_hMenu, t_nFirstID, m_szNoEntries, t_cchItemLen, MF_BYCOMMAND) == 0)) + if((m_hMenu == NULL) || (::GetMenuString(m_hMenu, t_nFirstID, m_szNoEntries, t_cchItemLen, MF_BYCOMMAND) == 0)) { T* pT = static_cast(this); - pT; // avoid level 4 warning - SecureHelper::strncpy_x(m_szNoEntries, _countof(m_szNoEntries), pT->GetMRUEmptyText(), _TRUNCATE); + (void)pT; // avoid level 4 warning + ATL::Checked::tcsncpy_s(m_szNoEntries, _countof(m_szNoEntries), pT->GetMRUEmptyText(), _TRUNCATE); } } @@ -2879,7 +149,7 @@ public: void SetMaxEntries(int nMaxEntries) { - ATLASSERT(nMaxEntries >= m_nMaxEntries_Min && nMaxEntries <= m_nMaxEntries_Max); + ATLASSERT((nMaxEntries >= m_nMaxEntries_Min) && (nMaxEntries <= m_nMaxEntries_Max)); if(nMaxEntries < m_nMaxEntries_Min) nMaxEntries = m_nMaxEntries_Min; else if(nMaxEntries > m_nMaxEntries_Max) @@ -2894,7 +164,7 @@ public: void SetMaxItemLength(int cchMaxLen) { - ATLASSERT((cchMaxLen >= m_cchMaxItemLen_Min && cchMaxLen <= m_cchMaxItemLen_Max) || cchMaxLen == -1); + ATLASSERT(((cchMaxLen >= m_cchMaxItemLen_Min) && (cchMaxLen <= m_cchMaxItemLen_Max)) || (cchMaxLen == -1)); if(cchMaxLen != -1) { if(cchMaxLen < m_cchMaxItemLen_Min) @@ -2911,8 +181,8 @@ public: BOOL AddToList(LPCTSTR lpstrDocName) { _DocEntry de; - errno_t nRet = SecureHelper::strncpy_x(de.szDocName, _countof(de.szDocName), lpstrDocName, _TRUNCATE); - if(nRet != 0 && nRet != STRUNCATE) + errno_t nRet = ATL::Checked::tcsncpy_s(de.szDocName, _countof(de.szDocName), lpstrDocName, _TRUNCATE); + if((nRet != 0) && (nRet != STRUNCATE)) return FALSE; for(int i = 0; i < m_arrDocs.GetSize(); i++) @@ -2938,9 +208,7 @@ public: // This function is deprecated because it is not safe. // Use the version below that accepts the buffer length. -#if (_MSC_VER >= 1300) __declspec(deprecated) -#endif BOOL GetFromList(int /*nItemID*/, LPTSTR /*lpstrDocName*/) { ATLASSERT(FALSE); @@ -2950,25 +218,25 @@ public: BOOL GetFromList(int nItemID, LPTSTR lpstrDocName, int cchLength) { int nIndex = m_arrDocs.GetSize() - (nItemID - t_nFirstID) - 1; - if(nIndex < 0 || nIndex >= m_arrDocs.GetSize()) + if((nIndex < 0) || (nIndex >= m_arrDocs.GetSize())) return FALSE; if(lstrlen(m_arrDocs[nIndex].szDocName) >= cchLength) return FALSE; - SecureHelper::strcpy_x(lpstrDocName, cchLength, m_arrDocs[nIndex].szDocName); + ATL::Checked::tcscpy_s(lpstrDocName, cchLength, m_arrDocs[nIndex].szDocName); return TRUE; } -#if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) - BOOL GetFromList(int nItemID, _CSTRING_NS::CString& strDocName) +#ifdef __ATLSTR_H__ + BOOL GetFromList(int nItemID, ATL::CString& strDocName) { int nIndex = m_arrDocs.GetSize() - (nItemID - t_nFirstID) - 1; - if(nIndex < 0 || nIndex >= m_arrDocs.GetSize()) + if((nIndex < 0) || (nIndex >= m_arrDocs.GetSize())) return FALSE; strDocName = m_arrDocs[nIndex].szDocName; return TRUE; } -#endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) +#endif // __ATLSTR_H__ BOOL RemoveFromList(int nItemID) { @@ -2985,7 +253,7 @@ public: BOOL MoveToTop(int nItemID) { int nIndex = m_arrDocs.GetSize() - (nItemID - t_nFirstID) - 1; - if(nIndex < 0 || nIndex >= m_arrDocs.GetSize()) + if((nIndex < 0) || (nIndex >= m_arrDocs.GetSize())) return FALSE; _DocEntry de; de = m_arrDocs[nIndex]; @@ -3002,8 +270,8 @@ public: BOOL ReadFromRegistry(LPCTSTR lpstrRegKey) { T* pT = static_cast(this); - CRegKeyEx rkParent; - CRegKeyEx rk; + ATL::CRegKey rkParent; + ATL::CRegKey rk; LONG lRet = rkParent.Open(HKEY_CURRENT_USER, lpstrRegKey); if(lRet != ERROR_SUCCESS) @@ -3020,18 +288,18 @@ public: m_arrDocs.RemoveAll(); - TCHAR szRetString[t_cchItemLen] = { 0 }; + TCHAR szRetString[t_cchItemLen] = {}; _DocEntry de; for(int nItem = m_nMaxEntries; nItem > 0; nItem--) { - TCHAR szBuff[m_cchItemNameLen] = { 0 }; - SecureHelper::wsprintf_x(szBuff, m_cchItemNameLen, pT->GetRegItemName(), nItem); + TCHAR szBuff[m_cchItemNameLen] = {}; + _stprintf_s(szBuff, m_cchItemNameLen, pT->GetRegItemName(), nItem); ULONG ulCount = t_cchItemLen; lRet = rk.QueryStringValue(szBuff, szRetString, &ulCount); if(lRet == ERROR_SUCCESS) { - SecureHelper::strcpy_x(de.szDocName, _countof(de.szDocName), szRetString); + ATL::Checked::tcscpy_s(de.szDocName, _countof(de.szDocName), szRetString); m_arrDocs.Add(de); } } @@ -3045,9 +313,9 @@ public: BOOL WriteToRegistry(LPCTSTR lpstrRegKey) { T* pT = static_cast(this); - pT; // avoid level 4 warning - CRegKeyEx rkParent; - CRegKeyEx rk; + (void)pT; // avoid level 4 warning + ATL::CRegKey rkParent; + ATL::CRegKey rk; LONG lRet = rkParent.Create(HKEY_CURRENT_USER, lpstrRegKey); if(lRet != ERROR_SUCCESS) @@ -3063,9 +331,9 @@ public: int nItem; for(nItem = m_arrDocs.GetSize(); nItem > 0; nItem--) { - TCHAR szBuff[m_cchItemNameLen] = { 0 }; - SecureHelper::wsprintf_x(szBuff, m_cchItemNameLen, pT->GetRegItemName(), nItem); - TCHAR szDocName[t_cchItemLen] = { 0 }; + TCHAR szBuff[m_cchItemNameLen] = {}; + _stprintf_s(szBuff, m_cchItemNameLen, pT->GetRegItemName(), nItem); + TCHAR szDocName[t_cchItemLen] = {}; GetFromList(t_nFirstID + nItem - 1, szDocName, t_cchItemLen); lRet = rk.SetStringValue(szBuff, szDocName); ATLASSERT(lRet == ERROR_SUCCESS); @@ -3074,8 +342,8 @@ public: // delete unused keys for(nItem = m_arrDocs.GetSize() + 1; nItem <= m_nMaxEntries_Max; nItem++) { - TCHAR szBuff[m_cchItemNameLen] = { 0 }; - SecureHelper::wsprintf_x(szBuff, m_cchItemNameLen, pT->GetRegItemName(), nItem); + TCHAR szBuff[m_cchItemNameLen] = {}; + _stprintf_s(szBuff, m_cchItemNameLen, pT->GetRegItemName(), nItem); rk.DeleteValue(szBuff); } @@ -3106,7 +374,7 @@ public: } } - ATLASSERT(nInsertPoint < nItems && "You need a menu item with an ID = t_nFirstID"); + ATLASSERT((nInsertPoint < nItems) && "You need a menu item with an ID = t_nFirstID"); for(int j = t_nFirstID; j < (t_nFirstID + m_nMaxEntries); j++) { @@ -3115,7 +383,7 @@ public: ::DeleteMenu(m_hMenu, j, MF_BYCOMMAND); } - TCHAR szItemText[t_cchItemLen + 6] = { 0 }; // add space for &, 2 digits, and a space + TCHAR szItemText[t_cchItemLen + 6] = {}; // add space for &, 2 digits, and a space int nSize = m_arrDocs.GetSize(); int nItem = 0; if(nSize > 0) @@ -3124,17 +392,17 @@ public: { if(m_cchMaxItemLen == -1) { - SecureHelper::wsprintf_x(szItemText, t_cchItemLen + 6, _T("&%i %s"), nItem + 1, m_arrDocs[nSize - 1 - nItem].szDocName); + _stprintf_s(szItemText, t_cchItemLen + 6, _T("&%i %s"), nItem + 1, m_arrDocs[nSize - 1 - nItem].szDocName); } else { - TCHAR szBuff[t_cchItemLen] = { 0 }; + TCHAR szBuff[t_cchItemLen] = {}; T* pT = static_cast(this); - pT; // avoid level 4 warning + (void)pT; // avoid level 4 warning bool bRet = pT->CompactDocumentName(szBuff, m_arrDocs[nSize - 1 - nItem].szDocName, m_cchMaxItemLen); - bRet; // avoid level 4 warning + (void)bRet; // avoid level 4 warning ATLASSERT(bRet); - SecureHelper::wsprintf_x(szItemText, t_cchItemLen + 6, _T("&%i %s"), nItem + 1, szBuff); + _stprintf_s(szItemText, t_cchItemLen + 6, _T("&%i %s"), nItem + 1, szBuff); } ::InsertMenu(m_hMenu, nInsertPoint + nItem, MF_BYPOSITION | MF_STRING, t_nFirstID + nItem, szItemText); @@ -3188,8 +456,6 @@ public: // nothing here }; -#endif // _WIN32_WCE - /////////////////////////////////////////////////////////////////////////////// // CFindFile - file search helper class @@ -3198,15 +464,17 @@ class CFindFile { public: // Data members - WIN32_FIND_DATA m_fd; - TCHAR m_lpszRoot[MAX_PATH]; - TCHAR m_chDirSeparator; HANDLE m_hFind; + WIN32_FIND_DATA m_fd; + LPTSTR m_lpszRoot; + const TCHAR m_chDirSeparator; BOOL m_bFound; // Constructor/destructor - CFindFile() : m_hFind(NULL), m_chDirSeparator(_T('\\')), m_bFound(FALSE) - { } + CFindFile() : m_hFind(NULL), m_lpszRoot(NULL), m_chDirSeparator(_T('\\')), m_bFound(FALSE) + { + memset(&m_fd, 0, sizeof(m_fd)); + } ~CFindFile() { @@ -3218,8 +486,7 @@ public: { ATLASSERT(m_hFind != NULL); - ULARGE_INTEGER nFileSize = { 0 }; - + ULARGE_INTEGER nFileSize = {}; if(m_bFound) { nFileSize.LowPart = m_fd.nFileSizeLow; @@ -3240,7 +507,7 @@ public: return FALSE; if(m_bFound) - SecureHelper::strcpy_x(lpstrFileName, cchLength, m_fd.cFileName); + ATL::Checked::tcscpy_s(lpstrFileName, cchLength, m_fd.cFileName); return m_bFound; } @@ -3250,70 +517,61 @@ public: ATLASSERT(m_hFind != NULL); int nLen = lstrlen(m_lpszRoot); -#ifndef _WIN32_WCE ATLASSERT(nLen > 0); if(nLen == 0) return FALSE; - bool bAddSep = (m_lpszRoot[nLen - 1] != _T('\\') && m_lpszRoot[nLen - 1] !=_T('/')); -#else // CE specific - // allow diskless devices (nLen == 0) - bool bAddSep = ((nLen == 0) || (m_lpszRoot[nLen - 1] != _T('\\') && m_lpszRoot[nLen - 1] !=_T('/'))); -#endif // _WIN32_WCE + bool bAddSep = (m_lpszRoot[nLen - 1] != m_chDirSeparator); if((lstrlen(m_lpszRoot) + (bAddSep ? 1 : 0)) >= cchLength) return FALSE; - SecureHelper::strcpy_x(lpstrFilePath, cchLength, m_lpszRoot); + ATL::Checked::tcscpy_s(lpstrFilePath, cchLength, m_lpszRoot); if(bAddSep) { TCHAR szSeparator[2] = { m_chDirSeparator, 0 }; - SecureHelper::strcat_x(lpstrFilePath, cchLength, szSeparator); + ATL::Checked::tcscat_s(lpstrFilePath, cchLength, szSeparator); } - SecureHelper::strcat_x(lpstrFilePath, cchLength, m_fd.cFileName); + ATL::Checked::tcscat_s(lpstrFilePath, cchLength, m_fd.cFileName); return TRUE; } -#ifndef _WIN32_WCE BOOL GetFileTitle(LPTSTR lpstrFileTitle, int cchLength) const { ATLASSERT(m_hFind != NULL); - TCHAR szBuff[MAX_PATH] = { 0 }; + TCHAR szBuff[MAX_PATH] = {}; if(!GetFileName(szBuff, MAX_PATH)) return FALSE; - if(lstrlen(szBuff) >= cchLength || cchLength < 1) + if(lstrlen(szBuff) >= cchLength) return FALSE; // find the last dot - LPTSTR pstrDot = MinCrtHelper::_strrchr(szBuff, _T('.')); + LPTSTR pstrDot = _tcsrchr(szBuff, _T('.')); if(pstrDot != NULL) *pstrDot = 0; - SecureHelper::strcpy_x(lpstrFileTitle, cchLength, szBuff); + ATL::Checked::tcscpy_s(lpstrFileTitle, cchLength, szBuff); return TRUE; } -#endif // !_WIN32_WCE BOOL GetFileURL(LPTSTR lpstrFileURL, int cchLength) const { ATLASSERT(m_hFind != NULL); - TCHAR szBuff[MAX_PATH] = { 0 }; - if(!GetFilePath(szBuff, MAX_PATH)) - return FALSE; LPCTSTR lpstrFileURLPrefix = _T("file://"); - if(lstrlen(szBuff) + lstrlen(lpstrFileURLPrefix) >= cchLength) + const int cchPrefix = lstrlen(lpstrFileURLPrefix); + if(cchPrefix >= cchLength) return FALSE; - SecureHelper::strcpy_x(lpstrFileURL, cchLength, lpstrFileURLPrefix); - SecureHelper::strcat_x(lpstrFileURL, cchLength, szBuff); - return TRUE; + ATL::Checked::tcscpy_s(lpstrFileURL, cchLength, lpstrFileURLPrefix); + + return GetFilePath(&lpstrFileURL[cchPrefix], cchLength - cchPrefix); } BOOL GetRoot(LPTSTR lpstrRoot, int cchLength) const @@ -3322,81 +580,74 @@ public: if(lstrlen(m_lpszRoot) >= cchLength) return FALSE; - SecureHelper::strcpy_x(lpstrRoot, cchLength, m_lpszRoot); + ATL::Checked::tcscpy_s(lpstrRoot, cchLength, m_lpszRoot); return TRUE; } -#if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) - _CSTRING_NS::CString GetFileName() const +#ifdef __ATLSTR_H__ + ATL::CString GetFileName() const { ATLASSERT(m_hFind != NULL); - _CSTRING_NS::CString ret; + ATL::CString ret; if(m_bFound) ret = m_fd.cFileName; return ret; } - _CSTRING_NS::CString GetFilePath() const + ATL::CString GetFilePath() const { ATLASSERT(m_hFind != NULL); - _CSTRING_NS::CString strResult = m_lpszRoot; + ATL::CString strResult = m_lpszRoot; int nLen = strResult.GetLength(); -#ifndef _WIN32_WCE ATLASSERT(nLen > 0); if(nLen == 0) return strResult; - if((strResult[nLen - 1] != _T('\\')) && (strResult[nLen - 1] != _T('/'))) -#else // CE specific - // allow diskless devices (nLen == 0) - if((nLen == 0) || ((strResult[nLen - 1] != _T('\\')) && (strResult[nLen - 1] != _T('/')))) -#endif // _WIN32_WCE + if(strResult[nLen - 1] != m_chDirSeparator) strResult += m_chDirSeparator; strResult += GetFileName(); return strResult; } -#ifndef _WIN32_WCE - _CSTRING_NS::CString GetFileTitle() const + ATL::CString GetFileTitle() const { ATLASSERT(m_hFind != NULL); - _CSTRING_NS::CString strResult; + ATL::CString strResult; GetFileTitle(strResult.GetBuffer(MAX_PATH), MAX_PATH); strResult.ReleaseBuffer(); return strResult; } -#endif // !_WIN32_WCE - _CSTRING_NS::CString GetFileURL() const + ATL::CString GetFileURL() const { ATLASSERT(m_hFind != NULL); - _CSTRING_NS::CString strResult("file://"); + ATL::CString strResult("file://"); strResult += GetFilePath(); return strResult; } - _CSTRING_NS::CString GetRoot() const + ATL::CString GetRoot() const { ATLASSERT(m_hFind != NULL); - _CSTRING_NS::CString str = m_lpszRoot; + ATL::CString str = m_lpszRoot; return str; } -#endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) +#endif // __ATLSTR_H__ BOOL GetLastWriteTime(FILETIME* pTimeStamp) const { ATLASSERT(m_hFind != NULL); ATLASSERT(pTimeStamp != NULL); - if(m_bFound && pTimeStamp != NULL) + if(m_bFound && (pTimeStamp != NULL)) { *pTimeStamp = m_fd.ftLastWriteTime; return TRUE; @@ -3410,7 +661,7 @@ public: ATLASSERT(m_hFind != NULL); ATLASSERT(pTimeStamp != NULL); - if(m_bFound && pTimeStamp != NULL) + if(m_bFound && (pTimeStamp != NULL)) { *pTimeStamp = m_fd.ftLastAccessTime; return TRUE; @@ -3423,7 +674,7 @@ public: { ATLASSERT(m_hFind != NULL); - if(m_bFound && pTimeStamp != NULL) + if(m_bFound && (pTimeStamp != NULL)) { *pTimeStamp = m_fd.ftCreationTime; return TRUE; @@ -3452,7 +703,7 @@ public: BOOL bResult = FALSE; if(m_bFound && IsDirectory()) { - if(m_fd.cFileName[0] == _T('.') && (m_fd.cFileName[1] == _T('\0') || (m_fd.cFileName[1] == _T('.') && m_fd.cFileName[2] == _T('\0')))) + if((m_fd.cFileName[0] == _T('.')) && ((m_fd.cFileName[1] == _T('\0')) || ((m_fd.cFileName[1] == _T('.')) && (m_fd.cFileName[2] == _T('\0'))))) bResult = TRUE; } @@ -3500,33 +751,41 @@ public: } // Operations - BOOL FindFile(LPCTSTR pstrName = NULL) + BOOL FindFile(LPCTSTR pstrName = NULL, bool bAutoLongPath = false) { Close(); if(pstrName == NULL) - { pstrName = _T("*.*"); + + if(bAutoLongPath && (lstrlen(pstrName) >= MAX_PATH)) + { + LPCTSTR lpstrPrefix = _T("\\\\?\\"); + int cchLongPath = lstrlen(lpstrPrefix) + lstrlen(pstrName) + 1; + ATL::CTempBuffer buff; + LPTSTR lpstrLongPath = buff.Allocate(cchLongPath); + if(lpstrLongPath != NULL) + { + ATL::Checked::tcscpy_s(lpstrLongPath, cchLongPath, lpstrPrefix); + ATL::Checked::tcscat_s(lpstrLongPath, cchLongPath, pstrName); + m_hFind = ::FindFirstFile(lpstrLongPath, &m_fd); + } } - else if(lstrlen(pstrName) >= MAX_PATH) + else { - ATLASSERT(FALSE); - return FALSE; + m_hFind = ::FindFirstFile(pstrName, &m_fd); } - SecureHelper::strcpy_x(m_fd.cFileName, _countof(m_fd.cFileName), pstrName); - - m_hFind = ::FindFirstFile(pstrName, &m_fd); - if(m_hFind == INVALID_HANDLE_VALUE) return FALSE; -#ifndef _WIN32_WCE - bool bFullPath = (::GetFullPathName(pstrName, MAX_PATH, m_lpszRoot, NULL) != 0); -#else // CE specific - errno_t nRet = SecureHelper::strncpy_x(m_lpszRoot, _countof(m_lpszRoot), pstrName, _TRUNCATE); - bool bFullPath = (nRet == 0 || nRet == STRUNCATE); -#endif // _WIN32_WCE + int cchRoot = ::GetFullPathName(pstrName, 0, NULL, NULL); + if(cchRoot > 0) + ATLTRY(m_lpszRoot = new TCHAR[cchRoot]); + if(m_lpszRoot == NULL) + return FALSE; + + bool bFullPath = (::GetFullPathName(pstrName, cchRoot, m_lpszRoot, NULL) != 0); // passed name isn't a valid path but was found by the API ATLASSERT(bFullPath); @@ -3538,24 +797,10 @@ public: } else { - // find the last forward or backward whack - LPTSTR pstrBack = MinCrtHelper::_strrchr(m_lpszRoot, _T('\\')); - LPTSTR pstrFront = MinCrtHelper::_strrchr(m_lpszRoot, _T('/')); - - if(pstrFront != NULL || pstrBack != NULL) - { - if(pstrFront == NULL) - pstrFront = m_lpszRoot; - if(pstrBack == NULL) - pstrBack = m_lpszRoot; - - // from the start to the last whack is the root - - if(pstrFront >= pstrBack) - *pstrFront = _T('\0'); - else - *pstrBack = _T('\0'); - } + // find the last separator + LPTSTR pstrSep = _tcsrchr(m_lpszRoot, m_chDirSeparator); + if(pstrSep != NULL) + *pstrSep = _T('\0'); } m_bFound = TRUE; @@ -3582,7 +827,10 @@ public: { m_bFound = FALSE; - if(m_hFind != NULL && m_hFind != INVALID_HANDLE_VALUE) + delete [] m_lpszRoot; + m_lpszRoot = NULL; + + if((m_hFind != NULL) && (m_hFind != INVALID_HANDLE_VALUE)) { ::FindClose(m_hFind); m_hFind = NULL; @@ -3591,36 +839,383 @@ public: }; +/////////////////////////////////////////////////////////////////////////////// +// CRegProperty and CRegPropertyImpl<> - properties stored in registry + +// How to use: Derive a class from CRegPropertyImpl, add data members +// for properties, and add REGPROP map to map properties to registry value names. +// You can then call Read() and Write() methods to read and write properties to/from registry. +// You can also use CRegProperty class directly, for one time read/write, or for custom stuff. + +#define REGPROP_CURRENTUSER 0x0000 +#define REGPROP_LOCALMACHINE 0x0001 +#define REGPROP_READONLY 0x0002 +#define REGPROP_WRITEONLY 0x0004 + +class CRegProperty +{ +public: +// Type declarations + struct BinaryProp + { + void* pBinary; + ULONG uSize; // buffer size in bytes, used size after read + + BinaryProp() : pBinary(NULL), uSize(0U) + { } + }; + + struct CharArrayProp + { + LPTSTR lpstrText; + ULONG uSize; // buffer size in chars + + CharArrayProp() : lpstrText(NULL), uSize(0U) + { } + }; + +// Data members + ATL::CRegKey m_regkey; + WORD m_wFlags; + +// Constructor + CRegProperty() : m_wFlags(REGPROP_CURRENTUSER) + { } + +// Registry key methods + LSTATUS OpenRegKey(LPCTSTR lpstrRegKey, bool bWrite) + { + ATLASSERT(m_regkey.m_hKey == NULL); + + HKEY hKey = ((m_wFlags & REGPROP_LOCALMACHINE) != 0) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; + REGSAM sam = KEY_READ | KEY_WRITE; + LSTATUS lRet = -1; + if(bWrite) + lRet = m_regkey.Create(hKey, lpstrRegKey, NULL, 0, ((m_wFlags & REGPROP_WRITEONLY) != 0) ? KEY_WRITE : sam); + else + lRet = m_regkey.Open(hKey, lpstrRegKey, ((m_wFlags & REGPROP_READONLY) != 0) ? KEY_READ : sam); + + return lRet; + } + + void CloseRegKey() + { + LSTATUS lRet = m_regkey.Close(); + (void)lRet; // avoid level 4 warning + ATLASSERT(lRet == ERROR_SUCCESS); + } + +// Flag methods + WORD GetFlags() const + { + return m_wFlags; + } + + WORD SetFlags(WORD wFlags, WORD wMask = 0) + { + WORD wPrevFlags = m_wFlags; + if(wMask == 0) + m_wFlags = wFlags; + else + m_wFlags = (m_wFlags & ~wMask) | (wFlags & wMask); + + return wPrevFlags; + } + +// Generic read/write methods + template + LSTATUS ReadProp(LPCTSTR lpstrRegValue, TProp& prop) + { + ATLASSERT(m_regkey.m_hKey != NULL); + + DWORD dwRet = 0; + LSTATUS lRet = m_regkey.QueryDWORDValue(lpstrRegValue, dwRet); + if(lRet == ERROR_SUCCESS) + prop = static_cast(dwRet); + + return lRet; + } + + template + LSTATUS WriteProp(LPCTSTR lpstrRegValue, TProp& prop) + { + ATLASSERT(m_regkey.m_hKey != NULL); + + return m_regkey.SetDWORDValue(lpstrRegValue, (DWORD)prop); + } + +// Specialization for bool + template <> + LSTATUS ReadProp(LPCTSTR lpstrRegValue, bool& bProp) + { + ATLASSERT(m_regkey.m_hKey != NULL); + + DWORD dwRet = 0; + LSTATUS lRet = m_regkey.QueryDWORDValue(lpstrRegValue, dwRet); + if(lRet == ERROR_SUCCESS) + bProp = (dwRet != 0); + + return lRet; + } + + template <> + LSTATUS WriteProp(LPCTSTR lpstrRegValue, bool& bProp) + { + ATLASSERT(m_regkey.m_hKey != NULL); + + return m_regkey.SetDWORDValue(lpstrRegValue, bProp ? 1 : 0); + } + +// Specialization for HFONT + template <> + LSTATUS ReadProp(LPCTSTR lpstrRegValue, HFONT& hFont) + { + ATLASSERT(m_regkey.m_hKey != NULL); + + LOGFONT lf = {}; + ULONG uSize = sizeof(lf); + LSTATUS lRet = m_regkey.QueryBinaryValue(lpstrRegValue, &lf, &uSize); + if(lRet == ERROR_SUCCESS) + { + if(hFont != NULL) + ::DeleteObject(hFont); + + hFont = ::CreateFontIndirect(&lf); + if(hFont == NULL) + lRet = ERROR_INVALID_DATA; + } + + return lRet; + } + + template <> + LSTATUS WriteProp(LPCTSTR lpstrRegValue, HFONT& hFont) + { + ATLASSERT(m_regkey.m_hKey != NULL); + + CLogFont lf(hFont); + return m_regkey.SetBinaryValue(lpstrRegValue, &lf, sizeof(lf)); + } + +// Specialization for BinaryProp + template <> + LSTATUS ReadProp(LPCTSTR lpstrRegValue, BinaryProp& binProp) + { + ATLASSERT(m_regkey.m_hKey != NULL); + + ULONG uSize = 0U; + LSTATUS lRet = m_regkey.QueryBinaryValue(lpstrRegValue, NULL, &uSize); + if(lRet == ERROR_SUCCESS) + { + if(uSize <= binProp.uSize) + lRet = m_regkey.QueryBinaryValue(lpstrRegValue, binProp.pBinary, &binProp.uSize); + else + lRet = ERROR_OUTOFMEMORY; + } + + return lRet; + } + + template <> + LSTATUS WriteProp(LPCTSTR lpstrRegValue, BinaryProp& binProp) + { + ATLASSERT(m_regkey.m_hKey != NULL); + + return m_regkey.SetBinaryValue(lpstrRegValue, binProp.pBinary, binProp.uSize); + } + +// Specialization for CharArrayProp + template <> + LSTATUS ReadProp(LPCTSTR lpstrRegValue, CharArrayProp& caProp) + { + ATLASSERT(m_regkey.m_hKey != NULL); + + ULONG uSize = 0U; + LSTATUS lRet = m_regkey.QueryStringValue(lpstrRegValue, NULL, &uSize); + if(lRet == ERROR_SUCCESS) + { + if(uSize <= caProp.uSize) + lRet = m_regkey.QueryStringValue(lpstrRegValue, caProp.lpstrText, &caProp.uSize); + else + lRet = ERROR_OUTOFMEMORY; + } + + return lRet; + } + + template <> + LSTATUS WriteProp(LPCTSTR lpstrRegValue, CharArrayProp& caProp) + { + ATLASSERT(m_regkey.m_hKey != NULL); + + return m_regkey.SetStringValue(lpstrRegValue, caProp.lpstrText); + } + +// Specialization for CString +#ifdef __ATLSTR_H__ + template <> + LSTATUS ReadProp(LPCTSTR lpstrRegValue, ATL::CString& strProp) + { + ATLASSERT(m_regkey.m_hKey != NULL); + + ULONG uSize = 0U; + LSTATUS lRet = m_regkey.QueryStringValue(lpstrRegValue, NULL, &uSize); + if(lRet == ERROR_SUCCESS) + { + lRet = m_regkey.QueryStringValue(lpstrRegValue, strProp.GetBufferSetLength(uSize), &uSize); + strProp.ReleaseBuffer(); + } + + return lRet; + } + + template <> + LSTATUS WriteProp(LPCTSTR lpstrRegValue, ATL::CString& strProp) + { + ATLASSERT(m_regkey.m_hKey != NULL); + + return m_regkey.SetStringValue(lpstrRegValue, (LPCTSTR)strProp); + } +#endif // __ATLSTR_H__ + +// Static methods for one time read/write + template + static bool ReadOne(LPCTSTR lpstrRegKey, LPCTSTR lpstrRegValue, TProp& prop, WORD wFlags = REGPROP_CURRENTUSER) + { + CRegProperty rp; + rp.SetFlags(wFlags); + LSTATUS lRet = rp.OpenRegKey(lpstrRegKey, false); + if(lRet == ERROR_SUCCESS) + { + lRet = rp.ReadProp(lpstrRegValue, prop); + rp.CloseRegKey(); + } + + return (lRet == ERROR_SUCCESS) || (lRet == ERROR_FILE_NOT_FOUND); + } + + template + static bool WriteOne(LPCTSTR lpstrRegKey, LPCTSTR lpstrRegValue, TProp& prop, WORD wFlags = REGPROP_CURRENTUSER) + { + CRegProperty rp; + rp.SetFlags(wFlags); + LSTATUS lRet = rp.OpenRegKey(lpstrRegKey, true); + if(lRet == ERROR_SUCCESS) + { + lRet = rp.WriteProp(lpstrRegValue, prop); + rp.CloseRegKey(); + } + + return (lRet == ERROR_SUCCESS); + } +}; + + +#define BEGIN_REGPROP_MAP(class) \ + void ReadWriteAll(bool bWrite) \ + { + +#define REG_PROPERTY(name, prop) \ + this->ReadWriteProp(name, prop, bWrite); + +#define END_REGPROP_MAP() \ + } + +template +class CRegPropertyImpl : public CRegProperty +{ +public: +// Methods + void Read(LPCTSTR lpstrRegKey) + { + T* pT = static_cast(this); + LSTATUS lRet = pT->OpenRegKey(lpstrRegKey, false); + if(lRet == ERROR_SUCCESS) + { + pT->ReadWriteAll(false); + pT->OnRead(lpstrRegKey); + + pT->CloseRegKey(); + } + else if(lRet != ERROR_FILE_NOT_FOUND) + { + pT->OnReadError(NULL, lRet); + } + } + + void Write(LPCTSTR lpstrRegKey) + { + T* pT = static_cast(this); + LSTATUS lRet = pT->OpenRegKey(lpstrRegKey, true); + if(lRet == ERROR_SUCCESS) + { + pT->ReadWriteAll(true); + pT->OnWrite(lpstrRegKey); + + pT->CloseRegKey(); + } + else + { + pT->OnWriteError(NULL, lRet); + } + } + +// Implementation + template + void ReadWriteProp(LPCTSTR lpstrRegValue, TProp& prop, bool bWrite) + { + T* pT = static_cast(this); + if(bWrite) + { + LSTATUS lRet = pT->WriteProp(lpstrRegValue, prop); + if(lRet != ERROR_SUCCESS) + pT->OnWriteError(lpstrRegValue, lRet); + } + else + { + LSTATUS lRet = pT->ReadProp(lpstrRegValue, prop); + if((lRet != ERROR_SUCCESS) && (lRet != ERROR_FILE_NOT_FOUND)) + pT->OnReadError(lpstrRegValue, lRet); + } + } + +// Overrideable handlers + void OnRead(LPCTSTR /*lpstrRegKey*/) + { } + + void OnWrite(LPCTSTR /*lpstrRegKey*/) + { } + + void OnReadError(LPCTSTR /*lpstrRegValue*/, LSTATUS /*lError*/) + { + ATLASSERT(FALSE); + } + + void OnWriteError(LPCTSTR /*lpstrRegValue*/, LSTATUS /*lError*/) + { + ATLASSERT(FALSE); + } +}; + + /////////////////////////////////////////////////////////////////////////////// // Global functions for stock GDI objects inline HPEN AtlGetStockPen(int nPen) { -#if (_WIN32_WINNT >= 0x0500) && !defined(_WIN32_WCE) - ATLASSERT(nPen == WHITE_PEN || nPen == BLACK_PEN || nPen == NULL_PEN || nPen == DC_PEN); -#else - ATLASSERT(nPen == WHITE_PEN || nPen == BLACK_PEN || nPen == NULL_PEN); -#endif + ATLASSERT((nPen == WHITE_PEN) || (nPen == BLACK_PEN) || (nPen == NULL_PEN) || (nPen == DC_PEN)); return (HPEN)::GetStockObject(nPen); } inline HBRUSH AtlGetStockBrush(int nBrush) { -#if (_WIN32_WINNT >= 0x0500) && !defined(_WIN32_WCE) - ATLASSERT((nBrush >= WHITE_BRUSH && nBrush <= HOLLOW_BRUSH) || nBrush == DC_BRUSH); -#else - ATLASSERT(nBrush >= WHITE_BRUSH && nBrush <= HOLLOW_BRUSH); -#endif + ATLASSERT(((nBrush >= WHITE_BRUSH) && (nBrush <= HOLLOW_BRUSH)) || (nBrush == DC_BRUSH)); return (HBRUSH)::GetStockObject(nBrush); } inline HFONT AtlGetStockFont(int nFont) { -#ifndef _WIN32_WCE - ATLASSERT((nFont >= OEM_FIXED_FONT && nFont <= SYSTEM_FIXED_FONT) || nFont == DEFAULT_GUI_FONT); -#else // CE specific - ATLASSERT(nFont == SYSTEM_FONT); -#endif // _WIN32_WCE + ATLASSERT(((nFont >= OEM_FIXED_FONT) && (nFont <= SYSTEM_FIXED_FONT)) || (nFont == DEFAULT_GUI_FONT)); return (HFONT)::GetStockObject(nFont); } @@ -3646,7 +1241,8 @@ inline bool _IsDBCSTrailByte(LPCTSTR lpstr, int nChar) } return ((nChar > 0) && (((nChar - i) & 1) != 0)); #else // _UNICODE - lpstr; nChar; + (void)lpstr; // avoid level 4 warning + (void)nChar; // avoid level 4 warning return false; #endif // _UNICODE } @@ -3663,7 +1259,7 @@ inline bool AtlCompactPath(LPTSTR lpstrOut, LPCTSTR lpstrIn, int cchLen) if(lstrlen(lpstrIn) < cchLen) { - SecureHelper::strcpy_x(lpstrOut, cchLen, lpstrIn); + ATL::Checked::tcscpy_s(lpstrOut, cchLen, lpstrIn); return true; } @@ -3681,23 +1277,23 @@ inline bool AtlCompactPath(LPTSTR lpstrOut, LPCTSTR lpstrIn, int cchLen) LPCTSTR lpstrFileName = lpstrIn; for(LPCTSTR pPath = lpstrIn; *pPath; pPath = ::CharNext(pPath)) { - if((pPath[0] == _T('\\') || pPath[0] == _T(':') || pPath[0] == _T('/')) - && pPath[1] && pPath[1] != _T('\\') && pPath[1] != _T('/')) + if(((pPath[0] == _T('\\')) || (pPath[0] == _T(':')) || (pPath[0] == _T('/'))) + && pPath[1] && (pPath[1] != _T('\\')) && (pPath[1] != _T('/'))) lpstrFileName = pPath + 1; } int cchFileName = lstrlen(lpstrFileName); // handle just the filename without a path - if(lpstrFileName == lpstrIn && cchLen > cchEndEllipsis) + if((lpstrFileName == lpstrIn) && (cchLen > cchEndEllipsis)) { - bool bRet = (SecureHelper::strncpy_x(lpstrOut, cchLen, lpstrIn, cchLen - cchEndEllipsis - 1) == 0); + bool bRet = (ATL::Checked::tcsncpy_s(lpstrOut, cchLen, lpstrIn, cchLen - cchEndEllipsis - 1) == 0); if(bRet) { #ifndef _UNICODE if(_IsDBCSTrailByte(lpstrIn, cchLen - cchEndEllipsis)) lpstrOut[cchLen - cchEndEllipsis - 1] = 0; #endif // _UNICODE - SecureHelper::strcat_x(lpstrOut, cchLen, szEllipsis); + ATL::Checked::tcscat_s(lpstrOut, cchLen, szEllipsis); } return bRet; } @@ -3718,39 +1314,39 @@ inline bool AtlCompactPath(LPTSTR lpstrOut, LPCTSTR lpstrIn, int cchLen) cchToCopy = 0; #ifndef _UNICODE - if(cchToCopy > 0 && _IsDBCSTrailByte(lpstrIn, cchToCopy)) + if((cchToCopy > 0) && _IsDBCSTrailByte(lpstrIn, cchToCopy)) cchToCopy--; #endif // _UNICODE - bool bRet = (SecureHelper::strncpy_x(lpstrOut, cchLen, lpstrIn, cchToCopy) == 0); + bool bRet = (ATL::Checked::tcsncpy_s(lpstrOut, cchLen, lpstrIn, cchToCopy) == 0); if(!bRet) return false; // add ellipsis - SecureHelper::strcat_x(lpstrOut, cchLen, szEllipsis); + ATL::Checked::tcscat_s(lpstrOut, cchLen, szEllipsis); TCHAR szSlash[2] = { chSlash, 0 }; - SecureHelper::strcat_x(lpstrOut, cchLen, szSlash); + ATL::Checked::tcscat_s(lpstrOut, cchLen, szSlash); // add filename (and ellipsis, if needed) if(cchLen > (cchMidEllipsis + cchFileName)) { - SecureHelper::strcat_x(lpstrOut, cchLen, lpstrFileName); + ATL::Checked::tcscat_s(lpstrOut, cchLen, lpstrFileName); } else { cchToCopy = cchLen - cchMidEllipsis - cchEndEllipsis - 1; #ifndef _UNICODE - if(cchToCopy > 0 && _IsDBCSTrailByte(lpstrFileName, cchToCopy)) + if((cchToCopy > 0) && _IsDBCSTrailByte(lpstrFileName, cchToCopy)) cchToCopy--; #endif // _UNICODE - bRet = (SecureHelper::strncpy_x(&lpstrOut[cchMidEllipsis], cchLen - cchMidEllipsis, lpstrFileName, cchToCopy) == 0); + bRet = (ATL::Checked::tcsncpy_s(&lpstrOut[cchMidEllipsis], cchLen - cchMidEllipsis, lpstrFileName, cchToCopy) == 0); if(bRet) - SecureHelper::strcat_x(lpstrOut, cchLen, szEllipsis); + ATL::Checked::tcscat_s(lpstrOut, cchLen, szEllipsis); } return bRet; } -}; // namespace WTL +} // namespace WTL #endif // __ATLMISC_H__ diff --git a/ZbaSDK/SampleCode/PluginWinExe/WTL/atlprint.h b/ZbaSDK/SampleCode/PluginWinExe/WTL/atlprint.h index 5dc5ab5af6973d6d9a60e01f83b812c1e2c8af9a..743f2a8f3ad516e03bbafd348c39e79687c69868 100644 --- a/ZbaSDK/SampleCode/PluginWinExe/WTL/atlprint.h +++ b/ZbaSDK/SampleCode/PluginWinExe/WTL/atlprint.h @@ -1,4 +1,4 @@ -// Windows Template Library - WTL version 9.10 +// Windows Template Library - WTL version 10.0 // Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. // // This file is a part of the Windows Template Library. @@ -11,10 +11,6 @@ #pragma once -#ifdef _WIN32_WCE - #error atlprint.h is not supported on Windows CE -#endif - #ifndef __ATLAPP_H__ #error atlprint.h requires atlapp.h to be included first #endif @@ -23,6 +19,8 @@ #error atlprint.h requires atlwin.h to be included first #endif +#include + /////////////////////////////////////////////////////////////////////////////// // Classes in this file: @@ -60,11 +58,8 @@ template <> class _printer_info<4> { public: typedef PRINTER_INFO_4 infotype; }; template <> class _printer_info<5> { public: typedef PRINTER_INFO_5 infotype; }; template <> class _printer_info<6> { public: typedef PRINTER_INFO_6 infotype; }; template <> class _printer_info<7> { public: typedef PRINTER_INFO_7 infotype; }; -// these are not in the old (vc6.0) headers -#ifdef _ATL_USE_NEW_PRINTER_INFO template <> class _printer_info<8> { public: typedef PRINTER_INFO_8 infotype; }; template <> class _printer_info<9> { public: typedef PRINTER_INFO_9 infotype; }; -#endif // _ATL_USE_NEW_PRINTER_INFO template @@ -192,25 +187,18 @@ public: bool OpenDefaultPrinter(const DEVMODE* pDevMode = NULL) { ClosePrinter(); - const int cchBuff = 512; - TCHAR buffer[cchBuff] = { 0 }; - ::GetProfileString(_T("windows"), _T("device"), _T(",,,"), buffer, cchBuff); - int nLen = lstrlen(buffer); - if (nLen != 0) + + DWORD cchBuff = 0; + ::GetDefaultPrinter(NULL, &cchBuff); + TCHAR* pszBuff = new TCHAR[cchBuff]; + BOOL bRet = ::GetDefaultPrinter(pszBuff, &cchBuff); + if(bRet != FALSE) { - LPTSTR lpsz = buffer; - while (*lpsz) - { - if (*lpsz == _T(',')) - { - *lpsz = 0; - break; - } - lpsz = CharNext(lpsz); - } PRINTER_DEFAULTS pdefs = { NULL, (DEVMODE*)pDevMode, PRINTER_ACCESS_USE }; - ::OpenPrinter(buffer, &m_hPrinter, (pDevMode == NULL) ? NULL : &pdefs); + ::OpenPrinter(pszBuff, &m_hPrinter, (pDevMode == NULL) ? NULL : &pdefs); } + delete [] pszBuff; + return m_hPrinter != NULL; } @@ -233,31 +221,43 @@ public: HANDLE CopyToHDEVNAMES() const { - HANDLE h = NULL; + HANDLE hDevNames = NULL; CPrinterInfo<5> pinfon5; CPrinterInfo<2> pinfon2; LPTSTR lpszPrinterName = NULL; + LPTSTR lpszPortName = NULL; // Some printers fail for PRINTER_INFO_5 in some situations - if (pinfon5.GetPrinterInfo(m_hPrinter)) + if(pinfon5.GetPrinterInfo(m_hPrinter)) + { lpszPrinterName = pinfon5.m_pi->pPrinterName; - else if (pinfon2.GetPrinterInfo(m_hPrinter)) + lpszPortName = pinfon5.m_pi->pPortName; + } + else if(pinfon2.GetPrinterInfo(m_hPrinter)) + { lpszPrinterName = pinfon2.m_pi->pPrinterName; - if (lpszPrinterName != NULL) + lpszPortName = pinfon2.m_pi->pPortName; + } + + if(lpszPrinterName != NULL) { - int nLen = sizeof(DEVNAMES) + (lstrlen(lpszPrinterName) + 1) * sizeof(TCHAR); - h = ::GlobalAlloc(GMEM_MOVEABLE, nLen); - BYTE* pv = (BYTE*)::GlobalLock(h); + int nLen = sizeof(DEVNAMES) + (lstrlen(lpszPrinterName) + 1 + lstrlen(lpszPortName) + 1) * sizeof(TCHAR); + hDevNames = ::GlobalAlloc(GMEM_MOVEABLE, nLen); + BYTE* pv = (BYTE*)::GlobalLock(hDevNames); DEVNAMES* pdev = (DEVNAMES*)pv; - if (pv != NULL) + if(pv != NULL) { memset(pv, 0, nLen); pdev->wDeviceOffset = sizeof(DEVNAMES) / sizeof(TCHAR); pv = pv + sizeof(DEVNAMES); // now points to end - SecureHelper::strcpy_x((LPTSTR)pv, lstrlen(lpszPrinterName) + 1, lpszPrinterName); - ::GlobalUnlock(h); + ATL::Checked::tcscpy_s((LPTSTR)pv, lstrlen(lpszPrinterName) + 1, lpszPrinterName); + pdev->wOutputOffset = (WORD)(sizeof(DEVNAMES) / sizeof(TCHAR) + lstrlen(lpszPrinterName) + 1); + pv = pv + (lstrlen(lpszPrinterName) + 1) * sizeof(TCHAR); + ATL::Checked::tcscpy_s((LPTSTR)pv, lstrlen(lpszPortName) + 1, lpszPortName); + ::GlobalUnlock(hDevNames); } } - return h; + + return hDevNames; } HDC CreatePrinterDC(const DEVMODE* pdm = NULL) const @@ -377,7 +377,7 @@ public: if (h != NULL) { void* p = ::GlobalLock(h); - SecureHelper::memcpy_x(p, nSize, pdm, nSize); + ATL::Checked::memcpy_s(p, nSize, pdm, nSize); ::GlobalUnlock(h); } Attach(h); @@ -405,7 +405,7 @@ public: if (h != NULL) { void* p = ::GlobalLock(h); - SecureHelper::memcpy_x(p, nSize, m_pDevMode, nSize); + ATL::Checked::memcpy_s(p, nSize, m_pDevMode, nSize); ::GlobalUnlock(h); } return h; @@ -417,7 +417,7 @@ public: { bool bRet = false; LONG nLen = ::DocumentProperties(NULL, hPrinter, NULL, NULL, NULL, 0); - CTempBuffer buff; + ATL::CTempBuffer buff; DEVMODE* pdm = buff.AllocateBytes(nLen); if(pdm != NULL) { @@ -439,7 +439,7 @@ public: bool bRet = false; LONG nLen = ::DocumentProperties(hWnd, hPrinter, pi.m_pi->pName, NULL, NULL, 0); - CTempBuffer buff; + ATL::CTempBuffer buff; DEVMODE* pdm = buff.AllocateBytes(nLen); if(pdm != NULL) { @@ -531,6 +531,9 @@ public: class ATL_NO_VTABLE CPrintJobInfo : public IPrintJobInfo { public: + CPrintJobInfo() : m_nPJState(0) + { } + virtual void BeginPrintJob(HDC /*hDC*/) // allocate handles needed, etc { } @@ -581,8 +584,10 @@ public: unsigned long m_nEndPage; // Constructor/destructor - CPrintJob() : m_nJobID(0), m_bCancel(false), m_bComplete(true) - { } + CPrintJob() : m_pInfo(NULL), m_pDefDevMode(NULL), m_nJobID(0), m_bCancel(false), m_bComplete(true), m_nStartPage(0), m_nEndPage(0) + { + memset(&m_docinfo, 0, sizeof(m_docinfo)); + } ~CPrintJob() { @@ -625,7 +630,7 @@ public: // Create a thread and return DWORD dwThreadID = 0; -#if !defined(_ATL_MIN_CRT) && defined(_MT) +#ifdef _MT HANDLE hThread = (HANDLE)_beginthreadex(NULL, 0, (UINT (WINAPI*)(void*))StartProc, this, 0, (UINT*)&dwThreadID); #else HANDLE hThread = ::CreateThread(NULL, 0, StartProc, (void*)this, 0, &dwThreadID); @@ -711,8 +716,11 @@ public: DEVMODE* m_pCurDevMode; SIZE m_sizeCurPhysOffset; +// Implementation - data + int m_nCurPage; + // Constructor - CPrintPreview() : m_pInfo(NULL), m_pDefDevMode(NULL), m_pCurDevMode(NULL) + CPrintPreview() : m_pInfo(NULL), m_pDefDevMode(NULL), m_pCurDevMode(NULL), m_nCurPage(0) { m_sizeCurPhysOffset.cx = 0; m_sizeCurPhysOffset.cy = 0; @@ -769,6 +777,11 @@ public: CEnhMetaFileInfo emfinfo(m_meta); ENHMETAHEADER* pmh = emfinfo.GetEnhMetaFileHeader(); + if(pmh == NULL) + { + ATLASSERT(FALSE); + return; + } // Compute whether we are OK vertically or horizontally int x2 = pmh->szlDevice.cx; @@ -802,15 +815,18 @@ public: { CEnhMetaFileInfo emfinfo(m_meta); ENHMETAHEADER* pmh = emfinfo.GetEnhMetaFileHeader(); + if(pmh == NULL) + { + ATLASSERT(FALSE); + return; + } + int nOffsetX = MulDiv(m_sizeCurPhysOffset.cx, rc.right-rc.left, pmh->szlDevice.cx); int nOffsetY = MulDiv(m_sizeCurPhysOffset.cy, rc.bottom-rc.top, pmh->szlDevice.cy); dc.OffsetWindowOrg(-nOffsetX, -nOffsetY); dc.PlayMetaFile(m_meta, &rc); } - -// Implementation - data - int m_nCurPage; }; @@ -821,12 +837,12 @@ template , public CPrintPreview { public: - DECLARE_WND_CLASS_EX(NULL, CS_VREDRAW | CS_HREDRAW, -1) + DECLARE_WND_CLASS_EX2(NULL, T, CS_VREDRAW | CS_HREDRAW, -1) enum { m_cxOffset = 10, m_cyOffset = 10 }; // Constructor - CPrintPreviewWindowImpl() : m_nMaxPage(0), m_nMinPage(0) + CPrintPreviewWindowImpl() : m_nMinPage(0), m_nMaxPage(0) { } // Operations @@ -843,7 +859,7 @@ public: if (m_nCurPage == m_nMaxPage) return false; SetPage(m_nCurPage + 1); - Invalidate(); + this->Invalidate(); return true; } @@ -854,7 +870,7 @@ public: if (m_nCurPage == 0) return false; SetPage(m_nCurPage - 1); - Invalidate(); + this->Invalidate(); return true; } @@ -873,7 +889,7 @@ public: LRESULT OnPaint(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) { T* pT = static_cast(this); - RECT rc = { 0 }; + RECT rc = {}; if(wParam != NULL) { @@ -882,7 +898,7 @@ public: } else { - CPaintDC dc(m_hWnd); + CPaintDC dc(this->m_hWnd); pT->DoPrePaint(dc.m_hDC, rc); pT->DoPaint(dc.m_hDC, rc); } @@ -893,11 +909,11 @@ public: // Painting helper void DoPrePaint(CDCHandle dc, RECT& rc) { - RECT rcClient = { 0 }; - GetClientRect(&rcClient); + RECT rcClient = {}; + this->GetClientRect(&rcClient); RECT rcArea = rcClient; T* pT = static_cast(this); - pT; // avoid level 4 warning + (void)pT; // avoid level 4 warning ::InflateRect(&rcArea, -pT->m_cxOffset, -pT->m_cyOffset); if (rcArea.left > rcArea.right) rcArea.right = rcArea.left; @@ -940,7 +956,7 @@ public: CZoomPrintPreviewWindowImpl() { - SetScrollExtendedStyle(SCRL_DISABLENOSCROLL); + this->SetScrollExtendedStyle(SCRL_DISABLENOSCROLL); InitZoom(); } @@ -948,9 +964,9 @@ public: void InitZoom() { m_bSized = false; - m_nZoomMode = ZOOMMODE_OFF; - m_fZoomScaleMin = 1.0; - m_fZoomScale = 1.0; + this->m_nZoomMode = ZOOMMODE_OFF; + this->m_fZoomScaleMin = 1.0; + this->m_fZoomScale = 1.0; } BEGIN_MSG_MAP(CZoomPrintPreviewWindowImpl) @@ -958,9 +974,6 @@ public: MESSAGE_HANDLER(WM_VSCROLL, CScrollImpl< T >::OnVScroll) MESSAGE_HANDLER(WM_HSCROLL, CScrollImpl< T >::OnHScroll) MESSAGE_HANDLER(WM_MOUSEWHEEL, CScrollImpl< T >::OnMouseWheel) -#if !((_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)) - MESSAGE_HANDLER(m_uMsgMouseWheel, CScrollImpl< T >::OnMouseWheel) -#endif // !((_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)) MESSAGE_HANDLER(WM_MOUSEHWHEEL, CScrollImpl< T >::OnMouseHWheel) MESSAGE_HANDLER(WM_SETTINGCHANGE, CScrollImpl< T >::OnSettingChange) MESSAGE_HANDLER(WM_LBUTTONDOWN, CZoomScrollImpl< T >::OnLButtonDown) @@ -989,14 +1002,14 @@ public: LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { SIZE sizeClient = {GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)}; - POINT ptOffset = m_ptOffset; - SIZE sizeAll = m_sizeAll; - SetScrollSize(sizeClient); + POINT ptOffset = this->m_ptOffset; + SIZE sizeAll = this->m_sizeAll; + this->SetScrollSize(sizeClient); if(sizeAll.cx > 0) - ptOffset.x = ::MulDiv(ptOffset.x, m_sizeAll.cx, sizeAll.cx); + ptOffset.x = ::MulDiv(ptOffset.x, this->m_sizeAll.cx, sizeAll.cx); if(sizeAll.cy > 0) - ptOffset.y = ::MulDiv(ptOffset.y, m_sizeAll.cy, sizeAll.cy); - SetScrollOffset(ptOffset); + ptOffset.y = ::MulDiv(ptOffset.y, this->m_sizeAll.cy, sizeAll.cy); + this->SetScrollOffset(ptOffset); CScrollImpl< T >::OnSize(uMsg, wParam, lParam, bHandled); if(!m_bSized) { @@ -1016,7 +1029,7 @@ public: LRESULT OnPaint(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) { T* pT = static_cast(this); - RECT rc = { 0 }; + RECT rc = {}; if(wParam != NULL) { @@ -1024,11 +1037,11 @@ public: int nMapModeSav = dc.GetMapMode(); dc.SetMapMode(MM_ANISOTROPIC); SIZE szWindowExt = { 0, 0 }; - dc.SetWindowExt(m_sizeLogAll, &szWindowExt); + dc.SetWindowExt(this->m_sizeLogAll, &szWindowExt); SIZE szViewportExt = { 0, 0 }; - dc.SetViewportExt(m_sizeAll, &szViewportExt); + dc.SetViewportExt(this->m_sizeAll, &szViewportExt); POINT ptViewportOrg = { 0, 0 }; - dc.SetViewportOrg(-m_ptOffset.x, -m_ptOffset.y, &ptViewportOrg); + dc.SetViewportOrg(-this->m_ptOffset.x, -this->m_ptOffset.y, &ptViewportOrg); pT->DoPrePaint(dc, rc); pT->DoPaint(dc, rc); @@ -1057,17 +1070,17 @@ public: void DoPrePaint(CDCHandle dc, RECT& rc) { - RECT rcClient = { 0 }; - GetClientRect(&rcClient); + RECT rcClient = {}; + this->GetClientRect(&rcClient); RECT rcArea = rcClient; T* pT = static_cast(this); - pT; // avoid level 4 warning + (void)pT; // avoid level 4 warning ::InflateRect(&rcArea, -pT->m_cxOffset, -pT->m_cyOffset); if (rcArea.left > rcArea.right) rcArea.right = rcArea.left; if (rcArea.top > rcArea.bottom) rcArea.bottom = rcArea.top; - GetPageRect(rcArea, &rc); + this->GetPageRect(rcArea, &rc); HBRUSH hbrOld = dc.SelectBrush(::GetSysColorBrush(COLOR_BTNSHADOW)); dc.PatBlt(rcClient.left, rcClient.top, rc.left - rcClient.left, rcClient.bottom - rcClient.top, PATCOPY); dc.PatBlt(rc.left, rcClient.top, rc.right - rc.left, rc.top - rcClient.top, PATCOPY); @@ -1083,13 +1096,19 @@ public: void DoPaint(CDCHandle dc, RECT& rc) { - CEnhMetaFileInfo emfinfo(m_meta); + CEnhMetaFileInfo emfinfo(this->m_meta); ENHMETAHEADER* pmh = emfinfo.GetEnhMetaFileHeader(); - int nOffsetX = MulDiv(m_sizeCurPhysOffset.cx, rc.right-rc.left, pmh->szlDevice.cx); - int nOffsetY = MulDiv(m_sizeCurPhysOffset.cy, rc.bottom-rc.top, pmh->szlDevice.cy); + if(pmh == NULL) + { + ATLASSERT(FALSE); + return; + } + + int nOffsetX = MulDiv(this->m_sizeCurPhysOffset.cx, rc.right-rc.left, pmh->szlDevice.cx); + int nOffsetY = MulDiv(this->m_sizeCurPhysOffset.cy, rc.bottom-rc.top, pmh->szlDevice.cy); dc.OffsetWindowOrg(-nOffsetX, -nOffsetY); - dc.PlayMetaFile(m_meta, &rc); + dc.PlayMetaFile(this->m_meta, &rc); } }; @@ -1101,6 +1120,6 @@ public: #endif // __ATLSCRL_H__ -}; // namespace WTL +} // namespace WTL #endif // __ATLPRINT_H__ diff --git a/ZbaSDK/SampleCode/PluginWinExe/WTL/atlres.h b/ZbaSDK/SampleCode/PluginWinExe/WTL/atlres.h index 32544d7b8b0024f584ebde2d574d6fa772de3172..aed58f13466138b369d7852f7478a1ced8aa80b3 100644 --- a/ZbaSDK/SampleCode/PluginWinExe/WTL/atlres.h +++ b/ZbaSDK/SampleCode/PluginWinExe/WTL/atlres.h @@ -1,4 +1,4 @@ -// Windows Template Library - WTL version 9.10 +// Windows Template Library - WTL version 10.0 // Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. // // This file is a part of the Windows Template Library. @@ -11,33 +11,27 @@ #pragma once -#if defined(_WIN32_WCE) && !defined(__ATLRESCE_H__) - #error Use atlresCE.h instead of atlres.h for Windows CE -#endif - #ifdef RC_INVOKED #ifndef _INC_WINDOWS #define _INC_WINDOWS - #ifndef _WIN32_WCE - #define VS_VERSION_INFO 1 + #define VS_VERSION_INFO 1 - #ifdef APSTUDIO_INVOKED - #define APSTUDIO_HIDDEN_SYMBOLS // Ignore following symbols - #endif // APSTUDIO_INVOKED + #ifdef APSTUDIO_INVOKED + #define APSTUDIO_HIDDEN_SYMBOLS // Ignore following symbols + #endif // APSTUDIO_INVOKED - #ifndef WINVER - #define WINVER 0x0400 // default to Windows Version 4.0 - #endif // !WINVER + #ifndef WINVER + #define WINVER 0x0500 + #endif // !WINVER - #include + #include // operation messages sent to DLGINIT - #define LB_ADDSTRING (WM_USER+1) - #define CB_ADDSTRING (WM_USER+3) - #endif // !_WIN32_WCE + #define LB_ADDSTRING (WM_USER+1) + #define CB_ADDSTRING (WM_USER+3) #ifdef APSTUDIO_INVOKED #undef APSTUDIO_HIDDEN_SYMBOLS diff --git a/ZbaSDK/SampleCode/PluginWinExe/WTL/atlribbon.h b/ZbaSDK/SampleCode/PluginWinExe/WTL/atlribbon.h index bbcb7d517cd28af781f0638e4ff62f83d1acd737..0d52f65fc3098109bf18d98698985c85cc110b22 100644 --- a/ZbaSDK/SampleCode/PluginWinExe/WTL/atlribbon.h +++ b/ZbaSDK/SampleCode/PluginWinExe/WTL/atlribbon.h @@ -1,4 +1,4 @@ -// Windows Template Library - WTL version 9.10 +// Windows Template Library - WTL version 10.0 // Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. // // This file is a part of the Windows Template Library. @@ -23,25 +23,16 @@ #error atlribbon.h requires the Windows 7 SDK or higher #endif -#ifdef _WIN32_WCE - #error atlribbon.h is not supported on Windows CE -#endif - #ifndef __ATLAPP_H__ #error atlribbon.h requires atlapp.h to be included first #endif -#if (_ATL_VER < 0x0700) - #include - #pragma comment(lib, "shlwapi.lib") -#endif - #include // for RecentDocumentList classes #include // for Frame and UpdateUI classes #include // required for atlctrlw.h #include // for CCommandBarCtrl -#if !defined(_WTL_USE_CSTRING) && !defined(__ATLSTR_H__) +#ifndef __ATLSTR_H__ #pragma warning(push) #pragma warning(disable: 4530) // unwind semantics not enabled #include @@ -51,8 +42,8 @@ #include #pragma comment(lib, "dwmapi.lib") -#include -#include +#include "UIRibbon.h" +#include "UIRibbonPropertyHelpers.h" #pragma comment(lib, "propsys.lib") #include // for CHARFORMAT2 @@ -134,17 +125,17 @@ public: UPDUI_PERSIST = 0x0020 }; - bool IsRibbonElement(const _AtlUpdateUIMap& UIMap) + bool IsRibbonElement(const CUpdateUIBase::_AtlUpdateUIMap& UIMap) { return (UIMap.m_wType & UPDUI_RIBBON) != 0; } bool IsRibbonID(UINT nID) { - for(int i = 0; i < m_arrUIMap.GetSize(); i++) + for(int i = 0; i < this->m_arrUIMap.GetSize(); i++) { - if(m_arrUIMap[i].m_nID == nID) - return IsRibbonElement(m_arrUIMap[i]); + if(this->m_arrUIMap[i].m_nID == nID) + return IsRibbonElement(this->m_arrUIMap[i]); } return false; @@ -153,19 +144,19 @@ public: // Element bool UIAddRibbonElement(UINT nID) { - return UIAddElement(nID); + return this->UIAddElement(nID); } bool UIRemoveRibbonElement(UINT nID) { - return UIRemoveElement(nID); + return this->UIRemoveElement(nID); } bool UIPersistElement(UINT nID, bool bPersist = true) { return bPersist ? - UIAddElement(nID) : - UIRemoveElement(nID); + this->UIAddElement(nID) : + this->UIRemoveElement(nID); } // methods for Ribbon elements @@ -180,8 +171,8 @@ public: BOOL UISetText(int nID, UINT uIdResource, BOOL bForceUpdate = FALSE) { - CTempBuffer sText(RIBBONUI_MAX_TEXT); - int nRet = AtlLoadString(uIdResource, sText, RIBBONUI_MAX_TEXT); + ATL::CTempBuffer sText(RIBBONUI_MAX_TEXT); + int nRet = ATL::AtlLoadString(uIdResource, sText, RIBBONUI_MAX_TEXT); if(nRet > 0) UISetText(nID, sText, bForceUpdate); return (nRet > 0) ? TRUE : FALSE; @@ -190,12 +181,12 @@ public: LPCTSTR UIGetText(int nID) { T* pT = static_cast(this); - LPCTSTR sUI = CAutoUpdateUI::UIGetText(nID); + LPCTSTR sUI = CAutoUpdateUI::UIGetText(nID); // replace 'tab' by 'space' for RibbonUI elements if (sUI && pT->IsRibbonUI() && IsRibbonID(nID) && wcschr(sUI, L'\t')) { - static WCHAR sText[RIBBONUI_MAX_TEXT] = { 0 }; + static WCHAR sText[RIBBONUI_MAX_TEXT] = {}; wcscpy_s(sText, sUI); WCHAR* pch = wcschr(sText, L'\t'); if (pch != NULL) @@ -244,8 +235,8 @@ namespace RibbonUI { // Minimal string allocation support for various PROPERTYKEY values -#if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) - typedef _CSTRING_NS::CString Text; +#ifdef __ATLSTR_H__ + typedef ATL::CString Text; #else class Text : public std::wstring { @@ -269,7 +260,7 @@ namespace RibbonUI return static_cast(std::wstring::operator =(s)); } }; -#endif +#endif // __ATLSTR_H__ // PROPERTYKEY enum and helpers enum k_KEY @@ -382,13 +373,14 @@ struct CharFormat : CHARFORMAT2 // Copy constructor CharFormat(const CharFormat& cf) { - ::CopyMemory(this, &cf, sizeof(CHARFORMAT2)); + this->CharFormat::CharFormat(); + ::CopyMemory(this, &cf, sizeof(CharFormat)); } // Assign operator CharFormat& operator =(const CharFormat& cf) { - ::CopyMemory(this, &cf, sizeof(CHARFORMAT2)); + ::CopyMemory(this, &cf, sizeof(CharFormat)); return (*this); } @@ -410,15 +402,15 @@ struct CharFormat : CHARFORMAT2 { &CharFormat::Getk_Family, &CharFormat::Getk_FontProperties_Size, - &CharFormat::Getk_MaskEffect, - &CharFormat::Getk_MaskEffect, - &CharFormat::Getk_MaskEffect, - &CharFormat::Getk_MaskEffect, - &CharFormat::Getk_VerticalPositioning, - &CharFormat::Getk_Color, - &CharFormat::Getk_Color, - &CharFormat::Getk_ColorType, - &CharFormat::Getk_ColorType, + &CharFormat::Getk_MaskEffectBold, + &CharFormat::Getk_MaskEffectItalic, + &CharFormat::Getk_MaskEffectUnderline, + &CharFormat::Getk_MaskEffectStrikeout, + &CharFormat::Getk_VerticalPositioning, + &CharFormat::Getk_Color, + &CharFormat::Getk_ColorBack, + &CharFormat::Getk_ColorType, + &CharFormat::Getk_ColorTypeBack, }; DWORD nProps = 0; @@ -474,7 +466,7 @@ private: { if (SUCCEEDED(pStore->GetValue(UI_PKEY_FontProperties_Size, &propvar))) { - DECIMAL decSize = { 0 }; + DECIMAL decSize = {}; UIPropertyToDecimal(UI_PKEY_FontProperties_Size, propvar, &decSize); DOUBLE dSize = 0; VarR8FromDec(&decSize, &dSize); @@ -486,18 +478,37 @@ private: } } - template - void Getk_MaskEffect(IPropertyStore* pStore) + void Getk_MaskEffectBold(IPropertyStore* pStore) + { + Getk_MaskEffectAll(pStore, CFM_BOLD, CFE_BOLD, UI_PKEY_FontProperties_Bold); + } + + void Getk_MaskEffectItalic(IPropertyStore* pStore) + { + Getk_MaskEffectAll(pStore, CFM_ITALIC, CFE_ITALIC, UI_PKEY_FontProperties_Italic); + } + + void Getk_MaskEffectUnderline(IPropertyStore* pStore) + { + Getk_MaskEffectAll(pStore, CFM_UNDERLINE, CFE_UNDERLINE, UI_PKEY_FontProperties_Underline); + } + + void Getk_MaskEffectStrikeout(IPropertyStore* pStore) + { + Getk_MaskEffectAll(pStore, CFM_STRIKEOUT, CFE_STRIKEOUT, UI_PKEY_FontProperties_Strikethrough); + } + + void Getk_MaskEffectAll(IPropertyStore* pStore, DWORD _dwMask, DWORD _dwEffects, REFPROPERTYKEY key) { if (SUCCEEDED(pStore->GetValue(key, &propvar))) { UIPropertyToUInt32(key, propvar, &uValue); if ((UI_FONTPROPERTIES)uValue != UI_FONTPROPERTIES_NOTAVAILABLE) { - dwMask |= t_dwMask; - dwEffects |= ((UI_FONTPROPERTIES) uValue == UI_FONTPROPERTIES_SET) ? t_dwEffects : 0; + dwMask |= _dwMask; + dwEffects |= ((UI_FONTPROPERTIES)uValue == UI_FONTPROPERTIES_SET) ? _dwEffects : 0; } - } + } } void Getk_VerticalPositioning(IPropertyStore* pStore) @@ -517,32 +528,51 @@ private: } } - template void Getk_Color(IPropertyStore* pStore) + { + Getk_ColorAll(pStore, CFM_COLOR, UI_PKEY_FontProperties_ForegroundColor); + } + + void Getk_ColorBack(IPropertyStore* pStore) + { + Getk_ColorAll(pStore, CFM_BACKCOLOR, UI_PKEY_FontProperties_BackgroundColor); + } + + void Getk_ColorAll(IPropertyStore* pStore, DWORD _dwMask, REFPROPERTYKEY key) { UINT32 color = 0; if (SUCCEEDED(pStore->GetValue(key, &propvar))) { UIPropertyToUInt32(key, propvar, &color); - dwMask |= t_dwMask; + dwMask |= _dwMask; - if (t_dwMask == CFM_COLOR) + if (_dwMask == CFM_COLOR) crTextColor = color; else crBackColor = color; } } - template void Getk_ColorType(IPropertyStore* pStore) + { + Getk_ColorTypeAll(pStore, CFM_COLOR, CFE_AUTOCOLOR, UI_SWATCHCOLORTYPE_AUTOMATIC, UI_PKEY_FontProperties_ForegroundColor); + + } + + void Getk_ColorTypeBack(IPropertyStore* pStore) + { + Getk_ColorTypeAll(pStore, CFM_BACKCOLOR, CFE_AUTOBACKCOLOR, UI_SWATCHCOLORTYPE_NOCOLOR, UI_PKEY_FontProperties_BackgroundColor); + } + + void Getk_ColorTypeAll(IPropertyStore* pStore, DWORD _dwMask, DWORD _dwEffects, UI_SWATCHCOLORTYPE _type, REFPROPERTYKEY key) { if (SUCCEEDED(pStore->GetValue(key, &propvar))) { UIPropertyToUInt32(key, propvar, &uValue); - if (t_type == (UI_SWATCHCOLORTYPE)uValue) + if (_type == (UI_SWATCHCOLORTYPE)uValue) { - dwMask |= t_dwMask; - dwEffects |= t_dwEffects; + dwMask |= _dwMask; + dwEffects |= _dwEffects; } } } @@ -686,6 +716,9 @@ public: CtrlImpl() : m_pWndRibbon(T::pWndRibbon) { } + virtual ~CtrlImpl() + { } + WndRibbon& GetWndRibbon() { return *m_pWndRibbon; @@ -778,7 +811,7 @@ public: m_hbm[k_(key) - k_LargeImage].Attach(hbm); return bUpdate ? - GetWndRibbon().InvalidateProperty(GetID(), key) : + this->GetWndRibbon().InvalidateProperty(this->GetID(), key) : S_OK; } @@ -789,7 +822,7 @@ public: const INT iImage = k_(key) - k_LargeImage; if (m_hbm[iImage].IsNull()) - m_hbm[iImage] = GetWndRibbon().OnRibbonQueryImage(GetID(), key); + m_hbm[iImage] = this->GetWndRibbon().OnRibbonQueryImage(this->GetID(), key); return m_hbm[iImage].IsNull() ? E_NOTIMPL : @@ -799,11 +832,11 @@ public: virtual HRESULT DoUpdateProperty(UINT nCmdID, REFPROPERTYKEY key, const PROPVARIANT* ppropvarCurrentValue, PROPVARIANT* ppropvarNewValue) { - ATLASSERT (nCmdID == GetID()); + ATLASSERT (nCmdID == this->GetID()); return (k_(key) <= k_SmallHighContrastImage) && (k_(key) >= k_LargeImage) ? OnGetImage(key, ppropvarNewValue) : - CtrlImpl::DoUpdateProperty(nCmdID, key, ppropvarCurrentValue, ppropvarNewValue); + CtrlImpl::DoUpdateProperty(nCmdID, key, ppropvarCurrentValue, ppropvarNewValue); } }; @@ -871,6 +904,7 @@ class CollectionImplBase public: CollectionImplBase() { + memset(&m_apItems, 0, sizeof(m_apItems)); for (int i = 0; i < t_size; i++) m_apItems[i] = new ItemProperty(i, static_cast(this)); } @@ -951,7 +985,7 @@ public: { if (m_auItemCat[uItem] == UI_COLLECTION_INVALIDINDEX) { - TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); + typename TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); m_auItemCat[uItem] = ribbon.OnRibbonQueryItemCategory(TCtrl::GetID(), uItem); } uCat = m_auItemCat[uItem]; @@ -969,7 +1003,7 @@ public: case k_Label: if (m_asCatName[uCat].IsEmpty()) { - TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); + typename TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); m_asCatName[uCat] = ribbon.OnRibbonQueryCategoryText(TCtrl::GetID(), uCat); } hr = SetPropertyVal(key, (LPCWSTR)m_asCatName[uCat], value); @@ -999,7 +1033,7 @@ public: const PROPVARIANT* ppropvarCurrentValue, PROPVARIANT* /*ppropvarNewValue*/) { ATLASSERT(nCmdID == TCtrl::GetID()); - nCmdID; // avoid level 4 warning + (void)nCmdID; // avoid level 4 warning HRESULT hr = E_NOTIMPL; switch (k_(key)) @@ -1011,7 +1045,7 @@ public: hr = pIUICollection->Clear(); for (UINT i = 0; i < m_size; i++) { - if FAILED(hr = pIUICollection->Add(m_apItems[i])) + if FAILED(hr = pIUICollection->Add(this->m_apItems[i])) break; } ATLASSERT(SUCCEEDED(hr)); @@ -1025,7 +1059,7 @@ public: hr = pIUICategory->Clear(); for (UINT i = t_items; i < (t_items + t_categories); i++) { - if FAILED(hr = pIUICategory->Add(m_apItems[i])) + if FAILED(hr = pIUICategory->Add(this->m_apItems[i])) break; } ATLASSERT(SUCCEEDED(hr)); @@ -1059,7 +1093,7 @@ public: m_asText[uItem] = sText; - return bUpdate ? InvalidateItems() : S_OK; + return bUpdate ? this->InvalidateItems() : S_OK; } UINT GetSelected() @@ -1073,7 +1107,7 @@ public: m_uSelected = uItem; - TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); + typename TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); return bUpdate ? ribbon.SetProperty(TCtrl::GetID(), UI_PKEY_SelectedItem, uItem) : S_OK; @@ -1088,14 +1122,14 @@ public: { if (m_asText[uItem].IsEmpty()) { - TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); + typename TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); m_asText[uItem] = ribbon.OnRibbonQueryItemText(TCtrl::GetID(), uItem); } return SetPropertyVal(key, (LPCWSTR)m_asText[uItem], value); } else { - return Collection::DoGetItem(uItem, key, value); + return CollectionImpl::Collection::DoGetItem(uItem, key, value); } } @@ -1106,7 +1140,7 @@ public: if (k_(key) == k_SelectedItem) { - TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); + typename TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); UINT uSel = UI_COLLECTION_INVALIDINDEX; if ((m_uSelected == UI_COLLECTION_INVALIDINDEX) && ribbon.OnRibbonQuerySelectedItem(TCtrl::GetID(), uSel)) @@ -1116,7 +1150,7 @@ public: } else { - return Collection::DoUpdateProperty(nCmdID, key, ppropvarCurrentValue, ppropvarNewValue); + return CollectionImpl::Collection::DoUpdateProperty(nCmdID, key, ppropvarCurrentValue, ppropvarNewValue); } } }; @@ -1130,11 +1164,6 @@ class ItemCollectionImpl : public TextCollectionImplInvalidateItems() : S_OK; } // Implementation @@ -1156,7 +1185,7 @@ public: { if (m_aBitmap[uItem].IsNull()) { - TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); + typename TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); m_aBitmap[uItem] = ribbon.OnRibbonQueryItemImage(TCtrl::GetID(), uItem); } return m_aBitmap[uItem].IsNull() ? @@ -1165,7 +1194,7 @@ public: } else { - return TextCollection::DoGetItem(uItem, key, value); + return TextCollectionImpl::TextCollection::DoGetItem(uItem, key, value); } } }; @@ -1182,7 +1211,7 @@ public: // Operations HRESULT SetComboText(LPCWSTR sText) { - TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); + typename TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); return ribbon.IsRibbonUI() ? ribbon.SetProperty(TCtrl::GetID(), UI_PKEY_StringValue, sText) : S_OK; @@ -1190,13 +1219,15 @@ public: LPCWSTR GetComboText() { - static WCHAR sCombo[RIBBONUI_MAX_TEXT] = { 0 }; - TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); + static WCHAR sCombo[RIBBONUI_MAX_TEXT] = {}; + typename TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); PROPVARIANT var; if (ribbon.IsRibbonUI()) { HRESULT hr = ribbon.GetIUIFrameworkPtr()->GetUICommandProperty(TCtrl::GetID(), UI_PKEY_StringValue, &var); + ATLASSERT(SUCCEEDED(hr)); hr = PropVariantToString(var, sCombo, RIBBONUI_MAX_TEXT); + ATLASSERT(SUCCEEDED(hr)); return sCombo; } return NULL; @@ -1229,13 +1260,13 @@ public: if (uCommandID == m_auCmd[uItem]) return S_OK; - TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); + typename TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); m_auCmd[uItem] = uCommandID; if (uCommandID != 0) ribbon.UIAddRibbonElement(uCommandID); - return bUpdate ? InvalidateItems() : S_OK; + return bUpdate ? this->InvalidateItems() : S_OK; } HRESULT SetItemCommandType(UINT uItem, UI_COMMANDTYPE type, bool bUpdate = false) @@ -1244,14 +1275,14 @@ public: m_aCmdType[uItem] = (BYTE)type; - return bUpdate ? InvalidateItems() : S_OK; + return bUpdate ? this->InvalidateItems() : S_OK; } // Implementation HRESULT DoGetItem(UINT uItem, REFPROPERTYKEY key, PROPVARIANT *value) { ATLASSERT(uItem < t_items); - TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); + typename TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); HRESULT hr = E_FAIL; switch (k_(key)) @@ -1268,7 +1299,7 @@ public: break; case k_CategoryId: default: - hr = Collection::DoGetItem(uItem, key, value); + hr = CollectionImpl::Collection::DoGetItem(uItem, key, value); break; } @@ -1296,7 +1327,7 @@ public: HRESULT OnGetItem(UINT uItem, REFPROPERTYKEY key, PROPVARIANT *value) { ATLASSERT(uItem < t_size); - TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); + typename TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); HRESULT hr = E_NOTIMPL; switch (k_(key)) @@ -1345,7 +1376,7 @@ public: virtual HRESULT DoUpdateProperty(UINT nCmdID, REFPROPERTYKEY key, const PROPVARIANT* ppropvarCurrentValue, PROPVARIANT* ppropvarNewValue) { - ATLASSERT(nCmdID == GetID()); + ATLASSERT(nCmdID == this->GetID()); ATLASSERT(ppropvarNewValue); HRESULT hr = Collection::DoUpdateProperty(nCmdID, key, ppropvarCurrentValue, ppropvarNewValue); @@ -1359,12 +1390,12 @@ public: const PROPERTYKEY* key, const PROPVARIANT* ppropvarValue, IUISimplePropertySet* /*pCommandExecutionProperties*/) { - ATLASSERT (nCmdID == GetID()); - nCmdID; // avoid level4 warning + ATLASSERT (nCmdID == this->GetID()); + (void)nCmdID; // avoid level4 warning if (key == NULL) // gallery button pressed { - GetWndRibbon().OnRibbonItemSelected(GetID(), UI_EXECUTIONVERB_EXECUTE, UI_COLLECTION_INVALIDINDEX); + this->GetWndRibbon().OnRibbonItemSelected(this->GetID(), UI_EXECUTIONVERB_EXECUTE, UI_COLLECTION_INVALIDINDEX); return S_OK; } @@ -1377,7 +1408,7 @@ public: if (SUCCEEDED(hr)) { - if (GetWndRibbon().OnRibbonItemSelected(GetID(), verb, uSel)) + if (this->GetWndRibbon().OnRibbonItemSelected(this->GetID(), verb, uSel)) TCollection::Select(uSel); } @@ -1405,28 +1436,28 @@ public: { if (pItems[i] != 0) { - m_aCmdType[j] = UI_COMMANDTYPE_ACTION; - m_auCmd[j++] = pItems[i]; + this->m_aCmdType[j] = UI_COMMANDTYPE_ACTION; + this->m_auCmd[j++] = pItems[i]; } } if (j < t_size) - Resize(j); + this->Resize(j); } HRESULT DoGetItem(UINT uItem, REFPROPERTYKEY key, PROPVARIANT *value) { - ATLASSERT(uItem < m_size); - ATLASSERT(m_auCmd[uItem]); + ATLASSERT(uItem < this->m_size); + ATLASSERT(this->m_auCmd[uItem]); HRESULT hr = E_FAIL; switch (k_(key)) { case k_CommandId: - hr = SetPropertyVal(key, m_auCmd[uItem], value); + hr = SetPropertyVal(key, this->m_auCmd[uItem], value); break; case k_CommandType: - hr = SetPropertyVal(key, UINT32(m_aCmdType[uItem]), value); + hr = SetPropertyVal(key, UINT32(this->m_aCmdType[uItem]), value); break; case k_CategoryId: hr = SetPropertyVal(key, UI_COLLECTION_INVALIDINDEX, value); @@ -1464,7 +1495,7 @@ public: m_uSelected = uItem; return bUpdate ? - GetWndRibbon().SetProperty(GetID(), UI_PKEY_SelectedItem, uItem) : + this->GetWndRibbon().SetProperty(this->GetID(), UI_PKEY_SelectedItem, uItem) : S_OK; } @@ -1472,7 +1503,7 @@ public: virtual HRESULT DoUpdateProperty(UINT nCmdID, REFPROPERTYKEY key, const PROPVARIANT* ppropvarCurrentValue, PROPVARIANT* ppropvarNewValue) { - ATLASSERT(nCmdID == GetID()); + ATLASSERT(nCmdID == this->GetID()); ATLASSERT(ppropvarNewValue != NULL); HRESULT hr = S_OK; @@ -1485,7 +1516,7 @@ public: hr = pIUICollection->Clear(); for (UINT i = 0; i < t_size; i++) { - if FAILED(hr = pIUICollection->Add(m_apItems[i])) + if FAILED(hr = pIUICollection->Add(this->m_apItems[i])) break; } ATLASSERT(SUCCEEDED(hr)); @@ -1495,7 +1526,7 @@ public: hr = SetPropertyVal(UI_PKEY_SelectedItem, m_uSelected, ppropvarNewValue); break; default: - hr = CommandCtrlImpl::DoUpdateProperty(nCmdID, key, ppropvarCurrentValue, ppropvarNewValue); + hr = CommandCtrlImpl::DoUpdateProperty(nCmdID, key, ppropvarCurrentValue, ppropvarNewValue); break; } @@ -1506,20 +1537,20 @@ public: const PROPERTYKEY* key, const PROPVARIANT* ppropvarValue, IUISimplePropertySet* /*pCommandExecutionProperties*/) { - ATLASSERT (nCmdID == GetID()); - nCmdID; // avoid level 4 warning + ATLASSERT (nCmdID == this->GetID()); + (void)nCmdID; // avoid level 4 warning HRESULT hr = S_OK; if (key == NULL) // gallery button pressed { - GetWndRibbon().OnRibbonItemSelected(GetID(), UI_EXECUTIONVERB_EXECUTE, UI_COLLECTION_INVALIDINDEX); + this->GetWndRibbon().OnRibbonItemSelected(this->GetID(), UI_EXECUTIONVERB_EXECUTE, UI_COLLECTION_INVALIDINDEX); return hr; } ATLASSERT(k_(*key) == k_SelectedItem); ATLASSERT(ppropvarValue); if SUCCEEDED(hr = UIPropertyToUInt32(*key, *ppropvarValue, &m_uSelected)) - GetWndRibbon().OnRibbonItemSelected(GetID(), verb, m_uSelected); + this->GetWndRibbon().OnRibbonItemSelected(this->GetID(), verb, m_uSelected); return hr; } @@ -1540,14 +1571,14 @@ public: // Implementation HRESULT OnGetItem(UINT uItem, REFPROPERTYKEY key, PROPVARIANT *value) { - ATLASSERT((INT)uItem < GetMaxEntries()); + ATLASSERT((INT)uItem < this->GetMaxEntries()); - LPCWSTR sPath = m_arrDocs[uItem].szDocName; + LPCWSTR sPath = this->m_arrDocs[uItem].szDocName; HRESULT hr = E_NOTIMPL; switch (k_(key)) { case k_Label: - hr = SetPropertyVal(key, GetWndRibbon().OnRibbonQueryRecentItemName(sPath), value); + hr = SetPropertyVal(key, this->GetWndRibbon().OnRibbonQueryRecentItemName(sPath), value); break; case k_LabelDescription: hr = SetPropertyVal(key, sPath, value); @@ -1563,25 +1594,25 @@ public: virtual HRESULT DoUpdateProperty(UINT nCmdID, REFPROPERTYKEY key, const PROPVARIANT* ppropvarCurrentValue, PROPVARIANT* ppropvarNewValue) { - ATLASSERT(nCmdID == GetID()); + ATLASSERT(nCmdID == this->GetID()); ATLASSERT(ppropvarNewValue); HRESULT hr = S_OK; switch (k_(key)) { case k_RecentItems: - if (SAFEARRAY* psa = SafeArrayCreateVector(VT_UNKNOWN, 0, m_arrDocs.GetSize())) + if (SAFEARRAY* psa = SafeArrayCreateVector(VT_UNKNOWN, 0, this->m_arrDocs.GetSize())) { - const int iLastIndex = m_arrDocs.GetSize() - 1; + const int iLastIndex = this->m_arrDocs.GetSize() - 1; for (LONG i = 0; i <= iLastIndex; i++) - SafeArrayPutElement(psa, &i, m_apItems[iLastIndex - i]); // reverse order + SafeArrayPutElement(psa, &i, this->m_apItems[iLastIndex - i]); // reverse order hr = SetPropertyVal(key, psa, ppropvarNewValue); SafeArrayDestroy(psa); } break; default: - hr = CtrlImpl::DoUpdateProperty(nCmdID, key, ppropvarCurrentValue, ppropvarNewValue); + hr = CtrlImpl::DoUpdateProperty(nCmdID, key, ppropvarCurrentValue, ppropvarNewValue); break; } @@ -1592,10 +1623,10 @@ public: const PROPERTYKEY* key, const PROPVARIANT* ppropvarValue, IUISimplePropertySet* /*pCommandExecutionProperties*/) { - ATLASSERT(nCmdID == GetID()); - nCmdID; // avoid level 4 warning + ATLASSERT(nCmdID == this->GetID()); + (void)nCmdID; // avoid level 4 warning ATLASSERT(verb == UI_EXECUTIONVERB_EXECUTE); - verb; // avoid level 4 warning + (void)verb; // avoid level 4 warning ATLASSERT((key) && (k_(*key) == k_SelectedItem)); ATLASSERT(ppropvarValue); @@ -1603,8 +1634,8 @@ public: HRESULT hr = UIPropertyToUInt32(*key, *ppropvarValue, &uSel); if SUCCEEDED(hr) { - ATLASSERT(uSel < (UINT)GetMaxEntries()); - GetWndRibbon().DefCommandExecute(ID_FILE_MRU_FIRST + uSel); + ATLASSERT(uSel < (UINT)this->GetMaxEntries()); + this->GetWndRibbon().DefCommandExecute(ID_FILE_MRU_FIRST + uSel); } return hr; @@ -1629,10 +1660,10 @@ public: const PROPERTYKEY* key, const PROPVARIANT* ppropvarValue, IUISimplePropertySet* pCommandExecutionProperties) { - ATLASSERT (nCmdID == GetID()); - nCmdID; // avoid level 4 warning + ATLASSERT (nCmdID == this->GetID()); + (void)nCmdID; // avoid level 4 warning ATLASSERT ((key) && (k_(*key) == k_FontProperties)); - key; // avoid level 4 warning + (void)key; // avoid level 4 warning HRESULT hr = E_INVALIDARG; switch (verb) @@ -1656,7 +1687,7 @@ public: } if (SUCCEEDED(hr)) - GetWndRibbon().OnRibbonFontCtrlExecute(GetID(), verb, &m_cf); + this->GetWndRibbon().OnRibbonFontCtrlExecute(this->GetID(), verb, &m_cf); else ATLASSERT(FALSE); @@ -1666,7 +1697,7 @@ public: virtual HRESULT DoUpdateProperty(UINT nCmdID, REFPROPERTYKEY key, const PROPVARIANT* ppropvarCurrentValue, PROPVARIANT* ppropvarNewValue) { - if ((k_(key) == k_FontProperties) && (GetWndRibbon().OnRibbonQueryFont(t_ID, m_cf))) + if ((k_(key) == k_FontProperties) && (this->GetWndRibbon().OnRibbonQueryFont(t_ID, m_cf))) { ATL::CComQIPtr pStore(ppropvarCurrentValue->punkVal); m_cf >> pStore; @@ -1674,7 +1705,7 @@ public: } else { - return CtrlImpl::DoUpdateProperty(nCmdID, key, ppropvarCurrentValue, ppropvarNewValue); + return CtrlImpl::DoUpdateProperty(nCmdID, key, ppropvarCurrentValue, ppropvarNewValue); } } }; @@ -1688,8 +1719,8 @@ public: ColorCtrlImpl() : m_colorType(UI_SWATCHCOLORTYPE_NOCOLOR), m_color(0x800080) /*MAGENTA*/ { } - COLORREF m_color; UINT32 m_colorType; // value in UI_SWATCHCOLORTYPE + COLORREF m_color; Text m_sLabels[6]; // k_MoreColorsLabel to k_ThemeColorsCategoryLabel ATL::CSimpleArray m_aColors[2]; ATL::CSimpleArray m_aTooltips[2]; @@ -1700,20 +1731,20 @@ public: if (m_colorType != UI_SWATCHCOLORTYPE_RGB) SetColorType(UI_SWATCHCOLORTYPE_RGB, bUpdate); m_color = color; - return bUpdate ? SetProperty(UI_PKEY_Color, color) : S_OK; + return bUpdate ? this->SetProperty(UI_PKEY_Color, color) : S_OK; } HRESULT SetColorType(UI_SWATCHCOLORTYPE type, bool bUpdate = false) { m_colorType = type; - return bUpdate ? SetProperty(UI_PKEY_ColorType, type) : S_OK; + return bUpdate ? this->SetProperty(UI_PKEY_ColorType, type) : S_OK; } HRESULT SetColorLabel(REFPROPERTYKEY key, LPCWSTR sLabel, bool bUpdate = false) { ATLASSERT((k_(key) >= k_ThemeColorsCategoryLabel) && (k_(key) <= k_MoreColorsLabel)); m_sLabels[k_(key) - k_ThemeColorsCategoryLabel] = sLabel; - return bUpdate ? SetProperty(key, sLabel) : S_OK; + return bUpdate ? this->SetProperty(key, sLabel) : S_OK; } HRESULT SetColorArray(REFPROPERTYKEY key, COLORREF* pColor, bool bUpdate = false) @@ -1729,7 +1760,7 @@ public: { PROPVARIANT var; if SUCCEEDED(InitPropVariantFromUInt32Vector(m_aColors[ic].GetData(), m_aColors[ic].GetSize(), &var)) - return SetProperty(key, var); + return this->SetProperty(key, var); else return E_INVALIDARG; } @@ -1752,7 +1783,7 @@ public: { PROPVARIANT var; if SUCCEEDED(InitPropVariantFromStringVector(m_aTooltips[ic].GetData(), m_aTooltips[ic].GetSize(), &var)) - return SetProperty(key, var); + return this->SetProperty(key, var); else return E_INVALIDARG; } @@ -1767,10 +1798,10 @@ public: const PROPERTYKEY* key, const PROPVARIANT* ppropvarValue, IUISimplePropertySet* pCommandExecutionProperties) { - ATLASSERT (nCmdID == GetID()); - nCmdID; // avoid level 4 warning + ATLASSERT (nCmdID == this->GetID()); + (void)nCmdID; // avoid level 4 warning ATLASSERT (key && (k_(*key) == k_ColorType)); - key; // avoid level 4 warning + (void)key; // avoid level 4 warning ATLASSERT (ppropvarValue); HRESULT hr = PropVariantToUInt32(*ppropvarValue, &m_colorType); @@ -1785,7 +1816,7 @@ public: } if SUCCEEDED(hr) - GetWndRibbon().OnRibbonColorCtrlExecute(GetID(), verb, (UI_SWATCHCOLORTYPE)m_colorType/*uType*/, m_color); + this->GetWndRibbon().OnRibbonColorCtrlExecute(this->GetID(), verb, (UI_SWATCHCOLORTYPE)m_colorType/*uType*/, m_color); else ATLASSERT(FALSE); // something was wrong @@ -1795,7 +1826,7 @@ public: virtual HRESULT DoUpdateProperty(UINT nCmdID, REFPROPERTYKEY key, const PROPVARIANT* ppropvarCurrentValue, PROPVARIANT* ppropvarNewValue) { - ATLASSERT (nCmdID == GetID()); + ATLASSERT (nCmdID == this->GetID()); HRESULT hr = E_NOTIMPL; @@ -1806,7 +1837,7 @@ public: break; case k_Color: if (m_color == 0x800080) /*MAGENTA*/ - m_color = GetWndRibbon().OnRibbonQueryColor(GetID()); + m_color = this->GetWndRibbon().OnRibbonQueryColor(this->GetID()); hr = SetPropertyVal(key, m_color, ppropvarNewValue); break; case k_ColorMode: @@ -1820,7 +1851,7 @@ public: { const UINT iLabel = k_(key) - k_ThemeColorsCategoryLabel; if (m_sLabels[iLabel].IsEmpty()) - if (LPCWSTR psLabel = GetWndRibbon().OnRibbonQueryColorLabel(GetID(), key)) + if (LPCWSTR psLabel = this->GetWndRibbon().OnRibbonQueryColorLabel(this->GetID(), key)) m_sLabels[iLabel] = psLabel; if (!m_sLabels[iLabel].IsEmpty()) hr = SetPropertyVal(key, (LPCWSTR)m_sLabels[iLabel], ppropvarNewValue); @@ -1831,7 +1862,7 @@ public: { const INT ic = k_(key) - k_ThemeColors; if (!m_aColors[ic].GetSize()) - if (COLORREF* pColor = GetWndRibbon().OnRibbonQueryColorArray(GetID(), key)) + if (COLORREF* pColor = this->GetWndRibbon().OnRibbonQueryColorArray(this->GetID(), key)) SetColorArray(key, pColor); if (INT iMax = m_aColors[ic].GetSize()) hr = InitPropVariantFromUInt32Vector(m_aColors[ic].GetData(), iMax, ppropvarNewValue); @@ -1842,14 +1873,14 @@ public: { const INT ic = k_(key) - k_ThemeColorsTooltips; if (m_aTooltips[ic].GetSize() == 0) - if (LPCWSTR* ppsTT = GetWndRibbon().OnRibbonQueryColorTooltips(GetID(), key)) + if (LPCWSTR* ppsTT = this->GetWndRibbon().OnRibbonQueryColorTooltips(this->GetID(), key)) SetColorTooltips(key, ppsTT); if (INT iMax = m_aTooltips[ic].GetSize()) hr = InitPropVariantFromStringVector(m_aTooltips[ic].GetData(), iMax, ppropvarNewValue); } break; default: - hr = CommandCtrlImpl::DoUpdateProperty(nCmdID, key, ppropvarCurrentValue, ppropvarNewValue); + hr = CommandCtrlImpl::DoUpdateProperty(nCmdID, key, ppropvarCurrentValue, ppropvarNewValue); break; } @@ -1928,7 +1959,7 @@ public: } return bUpdate ? - GetWndRibbon().InvalidateProperty(GetID(), key) : + this->GetWndRibbon().InvalidateProperty(this->GetID(), key) : S_OK; } @@ -1945,11 +1976,11 @@ public: { DECIMAL decVal; InitDecimal(val, &decVal); - return SetProperty(key, &decVal); + return this->SetProperty(key, &decVal); } else { - return GetWndRibbon().InvalidateProperty(GetID(), key); + return this->GetWndRibbon().InvalidateProperty(this->GetID(), key); } } else @@ -1960,12 +1991,12 @@ public: HRESULT QueryValue(REFPROPERTYKEY key, LONG* plVal) { - return GetWndRibbon().OnRibbonQuerySpinnerValue(GetID(), key, plVal) ? S_OK : S_FALSE; + return this->GetWndRibbon().OnRibbonQuerySpinnerValue(this->GetID(), key, plVal) ? S_OK : S_FALSE; } HRESULT QueryValue(REFPROPERTYKEY key, DOUBLE* pdVal) { - return GetWndRibbon().OnRibbonQueryFloatSpinnerValue(GetID(), key, pdVal) ? S_OK : S_FALSE; + return this->GetWndRibbon().OnRibbonQueryFloatSpinnerValue(this->GetID(), key, pdVal) ? S_OK : S_FALSE; } HRESULT OnGetValue(REFPROPERTYKEY key, PROPVARIANT* ppv) @@ -1990,7 +2021,7 @@ public: HRESULT OnGetText(REFPROPERTYKEY key, Text& sVal, PROPVARIANT* ppv) { - if (LPCWSTR sNew = GetWndRibbon().OnRibbonQueryText(GetID(), key)) + if (LPCWSTR sNew = this->GetWndRibbon().OnRibbonQueryText(this->GetID(), key)) sVal = sNew; return SetPropertyVal(key, (LPCWSTR)sVal, ppv); } @@ -1999,19 +2030,21 @@ public: const PROPERTYKEY* key, const PROPVARIANT* ppropvarValue, IUISimplePropertySet* /*pCommandExecutionProperties*/) { - ATLASSERT (nCmdID == GetID()); - nCmdID; // avoid level 4 warning + ATLASSERT (nCmdID == this->GetID()); + (void)nCmdID; // avoid level 4 warning ATLASSERT (key && (k_(*key) == k_DecimalValue)); - key; // avoid level 4 warning + (void)key; // avoid level 4 warning ATLASSERT (verb == UI_EXECUTIONVERB_EXECUTE); - verb; // avoid level 4 warning + (void)verb; // avoid level 4 warning DECIMAL decVal; HRESULT hr = UIPropertyToDecimal(UI_PKEY_DecimalValue, *ppropvarValue, &decVal); + ATLASSERT(SUCCEEDED(hr)); hr = InitVal(m_Values[0], &decVal); + ATLASSERT(SUCCEEDED(hr)); - GetWndRibbon().OnRibbonSpinnerCtrlExecute(GetID(), &m_Values[0]); + this->GetWndRibbon().OnRibbonSpinnerCtrlExecute(this->GetID(), &m_Values[0]); return hr; } @@ -2019,7 +2052,7 @@ public: virtual HRESULT DoUpdateProperty(UINT nCmdID, REFPROPERTYKEY key, const PROPVARIANT* ppropvarCurrentValue, PROPVARIANT* ppropvarNewValue) { - ATLASSERT (nCmdID == GetID()); + ATLASSERT (nCmdID == this->GetID()); HRESULT hr = E_NOTIMPL; switch (k_(key)) @@ -2032,15 +2065,13 @@ public: hr = OnGetValue(key, ppropvarNewValue); break; case k_FormatString: - if (m_FormatString.IsEmpty()) - return OnGetText(key, m_FormatString, ppropvarNewValue); + hr = OnGetText(key, m_FormatString, ppropvarNewValue); break; case k_RepresentativeString: - if (m_RepresentativeString.IsEmpty()) - return OnGetText(key, m_RepresentativeString, ppropvarNewValue); + hr = OnGetText(key, m_RepresentativeString, ppropvarNewValue); break; default: - hr = CtrlImpl::DoUpdateProperty(nCmdID, key, ppropvarCurrentValue, ppropvarNewValue); + hr = CtrlImpl::DoUpdateProperty(nCmdID, key, ppropvarCurrentValue, ppropvarNewValue); break; } @@ -2102,7 +2133,7 @@ public: ATLASSERT(SUCCEEDED(hr)); } - ~CRibbonImpl() + virtual ~CRibbonImpl() { ::GlobalFree(m_hgRibbonSettings); m_pIUIFramework.Release(); @@ -2115,8 +2146,8 @@ public: } ATL::CComPtr m_pIUIFramework; - HGLOBAL m_hgRibbonSettings; bool m_bRibbonUI; + HGLOBAL m_hgRibbonSettings; bool IsRibbonUI() { @@ -2194,7 +2225,7 @@ public: HRESULT hr = E_FAIL; if (ATL::CComPtr pIUIRibbon = GetRibbonPtr()) { - const LARGE_INTEGER li0 = { 0 }; + const LARGE_INTEGER li0 = {}; pIStream->Seek(li0, STREAM_SEEK_SET, NULL); hr = pIUIRibbon->SaveSettingsToStream(pIStream); pIStream->Commit(STGC_DEFAULT); @@ -2211,7 +2242,7 @@ public: HRESULT hr = E_FAIL; if (ATL::CComPtr pIUIRibbon = GetRibbonPtr()) { - const LARGE_INTEGER li0 = { 0 }; + const LARGE_INTEGER li0 = {}; pIStream->Seek(li0, STREAM_SEEK_SET, NULL); hr = pIUIRibbon->LoadSettingsFromStream(pIStream); } @@ -2482,10 +2513,10 @@ public: UI_CONTEXTAVAILABILITY OnRibbonQueryTabAvail(UINT nCmdID) { - DWORD dwState = UIGetState(nCmdID); - return ((dwState & UPDUI_DISABLED) == UPDUI_DISABLED) ? + DWORD dwState = this->UIGetState(nCmdID); + return ((dwState & CUpdateUIBase::UPDUI_DISABLED) == CUpdateUIBase::UPDUI_DISABLED) ? UI_CONTEXTAVAILABILITY_NOTAVAILABLE : - (((dwState & UPDUI_CHECKED) == UPDUI_CHECKED) ? + (((dwState & CUpdateUIBase::UPDUI_CHECKED) == CUpdateUIBase::UPDUI_CHECKED) ? UI_CONTEXTAVAILABILITY_ACTIVE : UI_CONTEXTAVAILABILITY_AVAILABLE); } @@ -2609,15 +2640,15 @@ public: bool DefRibbonQueryState(UINT nCmdID, REFPROPERTYKEY key) { - DWORD dwState = UIGetState(nCmdID); + DWORD dwState = this->UIGetState(nCmdID); bool bRet = false; switch (k_(key)) { case k_BooleanValue: - bRet = (dwState & UPDUI_CHECKED) == UPDUI_CHECKED; + bRet = (dwState & CUpdateUIBase::UPDUI_CHECKED) == CUpdateUIBase::UPDUI_CHECKED; break; case k_Enabled: - bRet = (dwState & UPDUI_DISABLED) != UPDUI_DISABLED; + bRet = (dwState & CUpdateUIBase::UPDUI_DISABLED) != CUpdateUIBase::UPDUI_DISABLED; break; default: ATLASSERT(FALSE); @@ -2629,12 +2660,12 @@ public: LPCTSTR DefRibbonQueryText(UINT nCmdID, REFPROPERTYKEY key) { - static WCHAR sText[RIBBONUI_MAX_TEXT] = { 0 }; + static WCHAR sText[RIBBONUI_MAX_TEXT] = {}; if (k_(key) == k_Label) - return UIGetText(nCmdID); + return this->UIGetText(nCmdID); - if (AtlLoadString(nCmdID, sText, RIBBONUI_MAX_TEXT)) + if (ATL::AtlLoadString(nCmdID, sText, RIBBONUI_MAX_TEXT)) { PWCHAR pTitle = wcschr(sText, L'\n'); switch (k_(key)) @@ -2756,6 +2787,8 @@ public: SaveRibbonSettings(); m_bRibbonUI = false; break; + default: + break; } return S_OK; @@ -2763,7 +2796,7 @@ public: STDMETHODIMP OnCreateUICommand(UINT32 nCmdID, UI_COMMANDTYPE typeID, IUICommandHandler** ppCommandHandler) { - UIAddRibbonElement(nCmdID); + this->UIAddRibbonElement(nCmdID); if (typeID == UI_COMMANDTYPE_CONTEXT) CUpdateUIBase::UIEnable(nCmdID, false); *ppCommandHandler = this; @@ -2772,7 +2805,7 @@ public: STDMETHODIMP OnDestroyUICommand(UINT32 nCmdID, UI_COMMANDTYPE, IUICommandHandler*) { - UIRemoveRibbonElement(nCmdID); + this->UIRemoveRibbonElement(nCmdID); return S_OK; } @@ -2874,7 +2907,7 @@ public: } ATLASSERT(verb == UI_EXECUTIONVERB_EXECUTE); - verb; // avoid level 4 warning + (void)verb; // avoid level 4 warning static_cast(this)->OnRibbonCommandExecute(nCmdID); @@ -3001,7 +3034,7 @@ public: public: CRibbonFloatSpinnerCtrl() { - m_Values[4] = 1; // 1 decimal + this->m_Values[4] = 1; // 1 decimal } }; @@ -3031,7 +3064,7 @@ typedef struct } _ribbonCtrl; #pragma warning(pop) -}; // namespace RibbonUI +} // namespace RibbonUI /////////////////////////////////////////////////////////////////////////////// @@ -3058,7 +3091,7 @@ typedef struct // Control message map macros #define RIBBON_GALLERY_CONTROL_HANDLER(id, func) \ - if(uMsg == WM_COMMAND && id == LOWORD(wParam)) \ + if((uMsg == WM_COMMAND) && (id == LOWORD(wParam))) \ { \ bHandled = TRUE; \ lResult = func((UI_EXECUTIONVERB)HIWORD(wParam), LOWORD(wParam), (UINT)lParam, bHandled); \ @@ -3070,7 +3103,7 @@ typedef struct RIBBON_GALLERY_CONTROL_HANDLER(id, func) #define RIBBON_FONT_CONTROL_HANDLER(id, func) \ - if(uMsg == WM_COMMAND && id == LOWORD(wParam)) \ + if((uMsg == WM_COMMAND) && (id == LOWORD(wParam))) \ { \ bHandled = TRUE; \ lResult = func((UI_EXECUTIONVERB)HIWORD(wParam), LOWORD(wParam), (CHARFORMAT2*)lParam, bHandled); \ @@ -3079,7 +3112,7 @@ typedef struct } #define RIBBON_COLOR_CONTROL_HANDLER(id, func) \ - if(uMsg == WM_COMMAND && id == LOWORD(wParam)) \ + if((uMsg == WM_COMMAND) && (id == LOWORD(wParam))) \ { \ bHandled = TRUE; \ lResult = func((UI_EXECUTIONVERB)HIWORD(wParam), LOWORD(wParam), (COLORREF)lParam, bHandled); \ @@ -3088,7 +3121,7 @@ typedef struct } #define RIBBON_SPINNER_CONTROL_HANDLER(id, func) \ - if(uMsg == WM_COMMAND && id == wParam) \ + if((uMsg == WM_COMMAND) && (id == wParam)) \ { \ bHandled = TRUE; \ lResult = func((WORD)wParam, (LONG)lParam, bHandled); \ @@ -3097,7 +3130,7 @@ typedef struct } #define RIBBON_FLOATSPINNER_CONTROL_HANDLER(id, func) \ - if(uMsg == WM_COMMAND && id == wParam) \ + if((uMsg == WM_COMMAND) && (id == wParam)) \ { \ bHandled = TRUE; \ lResult = func((WORD)wParam, (DOUBLE*)lParam, bHandled); \ @@ -3142,15 +3175,15 @@ public: // Win7 Aero fix helpers void ResetFrame() { - const MARGINS margins = { 0 }; - ::DwmExtendFrameIntoClientArea(m_hWnd, &margins); + const MARGINS margins = { 0, 0, 0, 0 }; + ::DwmExtendFrameIntoClientArea(this->m_hWnd, &margins); } INT CalcWin7Fix() { ResetFrame(); - RECT rc = { 0 }; - ::AdjustWindowRectEx(&rc, T::GetWndStyle(0), GetMenu() != NULL, T::GetWndExStyle(0)); + RECT rc = {}; + ::AdjustWindowRectEx(&rc, T::GetWndStyle(0), this->GetMenu() != NULL, T::GetWndExStyle(0)); return -rc.top; } @@ -3169,7 +3202,7 @@ public: } __if_not_exists(T::m_CmdBar) { - bUse; // avoid level 4 warning + (void)bUse; // avoid level 4 warning return false; } } @@ -3179,45 +3212,45 @@ public: if (!RunTimeHelper::IsRibbonUIAvailable()) return false; - ATLASSERT(GetIUIFrameworkPtr()); + ATLASSERT(this->GetIUIFrameworkPtr()); - if (IsRibbonUI() == bShow) + if (this->IsRibbonUI() == bShow) return bShow; - bool bVisible = (IsWindowVisible() != FALSE); + bool bVisible = (this->IsWindowVisible() != FALSE); if(bVisible && !bShow) - SetRedraw(FALSE); + this->SetRedraw(FALSE); - if (bShow && ::IsWindow(m_hWndToolBar)) + if (bShow && ::IsWindow(this->m_hWndToolBar)) { - ::ShowWindow(m_hWndToolBar, SW_HIDE); + ::ShowWindow(this->m_hWndToolBar, SW_HIDE); UpdateLayout(); } m_bWin7Fix = !bShow; - HRESULT hr = bShow ? CreateRibbon(sResName) : DestroyRibbon(); + HRESULT hr = bShow ? this->CreateRibbon(sResName) : this->DestroyRibbon(); m_bWin7Fix = SUCCEEDED(hr) && !bShow; if (SUCCEEDED(hr)) { - if(::IsWindow(m_hWndToolBar) && !bShow) + if(::IsWindow(this->m_hWndToolBar) && !bShow) { - ::ShowWindow(m_hWndToolBar, SW_SHOWNA); + ::ShowWindow(this->m_hWndToolBar, SW_SHOWNA); UpdateLayout(); } else if (bShow) { - PostMessage(WM_SIZE); - SetRibbonModes(imodes); + this->PostMessage(WM_SIZE); + this->SetRibbonModes(imodes); } } if(bVisible && !bShow) { - SetRedraw(TRUE); - RedrawWindow(NULL, NULL, RDW_FRAME | RDW_ERASE | RDW_INVALIDATE | RDW_UPDATENOW | RDW_ALLCHILDREN); + this->SetRedraw(TRUE); + this->RedrawWindow(NULL, NULL, RDW_FRAME | RDW_ERASE | RDW_INVALIDATE | RDW_UPDATENOW | RDW_ALLCHILDREN); } return SUCCEEDED(hr) ? bShow : !bShow; @@ -3232,11 +3265,11 @@ public: return (HBITMAP)::CopyImage(hbm, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION); } - return DefRibbonQueryImage(nCmdID); + return this->DefRibbonQueryImage(nCmdID); } BEGIN_MSG_MAP(CRibbonFrameWindowImplBase) - if (!IsRibbonUI() && NeedWin7Fix()) + if (!this->IsRibbonUI() && NeedWin7Fix()) { MESSAGE_HANDLER(WM_SIZING, OnSizing) MESSAGE_HANDLER(WM_SIZE, OnSize) @@ -3255,10 +3288,10 @@ public: case WMSZ_TOP: case WMSZ_TOPLEFT: case WMSZ_TOPRIGHT: - SetWindowPos(NULL, (LPRECT)lParam, SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED); + this->SetWindowPos(NULL, (LPRECT)lParam, SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED); break; default: - DefWindowProc(); + this->DefWindowProc(); break; } @@ -3268,7 +3301,7 @@ public: LRESULT OnSize(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) { if (wParam != SIZE_MINIMIZED) - SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); + this->SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); bHandled = FALSE; return 1; @@ -3277,7 +3310,7 @@ public: LRESULT OnActivate(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) { if(wParam != WA_INACTIVE) - SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); + this->SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); bHandled = FALSE; return 1; @@ -3285,9 +3318,9 @@ public: LRESULT OnNCCalcSize(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) { - ATLASSERT(!IsRibbonUI() && NeedWin7Fix()); + ATLASSERT(!this->IsRibbonUI() && NeedWin7Fix()); - LRESULT lRet = DefWindowProc(); + LRESULT lRet = this->DefWindowProc(); if(wParam) { @@ -3301,24 +3334,24 @@ public: // Overrides void UpdateLayout(BOOL bResizeBars = TRUE) { - RECT rect = { 0 }; - GetClientRect(&rect); + RECT rect = {}; + this->GetClientRect(&rect); - if (IsRibbonUI() && !IsRibbonHidden()) + if (this->IsRibbonUI() && !this->IsRibbonHidden()) { - rect.top += GetRibbonHeight(); + rect.top += this->GetRibbonHeight(); } - else if (!IsRibbonUI() && NeedWin7Fix()) + else if (!this->IsRibbonUI() && NeedWin7Fix()) { ResetFrame(); } // position bars and offset their dimensions - UpdateBarsPosition(rect, bResizeBars); + this->UpdateBarsPosition(rect, bResizeBars); // resize client window - if(m_hWndClient != NULL) - ::SetWindowPos(m_hWndClient, NULL, rect.left, rect.top, + if(this->m_hWndClient != NULL) + ::SetWindowPos(this->m_hWndClient, NULL, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_NOZORDER | SWP_NOACTIVATE); } @@ -3335,7 +3368,7 @@ public: } __if_not_exists (T::m_CmdBar) { - nCmdID; // avoid level 4 warning + (void)nCmdID; // avoid level 4 warning return NULL; } } @@ -3367,11 +3400,11 @@ public: ATLASSERT(m_Key.m_hKey); } - CRegKeyEx m_Key; + ATL::CRegKey m_Key; LONG Save(bool bRibbonUI, HGLOBAL hgSettings = NULL) { - CRegKeyEx key; + ATL::CRegKey key; const DWORD dwUI = bRibbonUI; LONG lRet = key.Create(m_Key, L"Ribbon"); @@ -3403,7 +3436,7 @@ public: { ATLASSERT(hgSettings == NULL); - CRegKeyEx key; + ATL::CRegKey key; LONG lRet = key.Open(m_Key, L"Ribbon"); if(lRet != ERROR_SUCCESS) diff --git a/ZbaSDK/SampleCode/PluginWinExe/WTL/atlscrl.h b/ZbaSDK/SampleCode/PluginWinExe/WTL/atlscrl.h index ae483719d150f5d6c01e163e573e1978e715caec..74240c87f29323043ec570017591290816da5863 100644 --- a/ZbaSDK/SampleCode/PluginWinExe/WTL/atlscrl.h +++ b/ZbaSDK/SampleCode/PluginWinExe/WTL/atlscrl.h @@ -1,4 +1,4 @@ -// Windows Template Library - WTL version 9.10 +// Windows Template Library - WTL version 10.0 // Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. // // This file is a part of the Windows Template Library. @@ -19,14 +19,6 @@ #error atlscrl.h requires atlwin.h to be included first #endif -#if !((_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)) && !defined(_WIN32_WCE) - #include -#endif - -#ifndef GET_WHEEL_DELTA_WPARAM - #define GET_WHEEL_DELTA_WPARAM(wParam) ((short)HIWORD(wParam)) -#endif - /////////////////////////////////////////////////////////////////////////////// // Classes in this file: @@ -51,9 +43,7 @@ namespace WTL #define SCRL_SCROLLCHILDREN 0x00000001 #define SCRL_ERASEBACKGROUND 0x00000002 #define SCRL_NOTHUMBTRACKING 0x00000004 -#if (WINVER >= 0x0500) #define SCRL_SMOOTHSCROLL 0x00000008 -#endif // (WINVER >= 0x0500) #define SCRL_DISABLENOSCROLLV 0x00000010 #define SCRL_DISABLENOSCROLLH 0x00000020 #define SCRL_DISABLENOSCROLL (SCRL_DISABLENOSCROLLV | SCRL_DISABLENOSCROLLH) @@ -72,10 +62,6 @@ public: SIZE m_sizeClient; int m_zDelta; // current wheel value int m_nWheelLines; // number of lines to scroll on wheel -#if !((_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)) && !defined(_WIN32_WCE) - // Note that this message must be forwarded from a top level window - UINT m_uMsgMouseWheel; // MSH_MOUSEWHEEL -#endif // !((_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)) && !defined(_WIN32_WCE) int m_zHDelta; // current horizontal wheel value int m_nHWheelChars; // number of chars to scroll on horizontal wheel UINT m_uScrollFlags; @@ -83,9 +69,6 @@ public: // Constructor CScrollImpl() : m_zDelta(0), m_nWheelLines(3), -#if !((_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)) && !defined(_WIN32_WCE) - m_uMsgMouseWheel(0U), -#endif // !((_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)) && !defined(_WIN32_WCE) m_zHDelta(0), m_nHWheelChars(3), m_uScrollFlags(0U), m_dwExtendedStyle(0) { @@ -118,11 +101,9 @@ public: m_dwExtendedStyle = (m_dwExtendedStyle & ~dwMask) | (dwExtendedStyle & dwMask); // cache scroll flags T* pT = static_cast(this); - pT; // avoid level 4 warning + (void)pT; // avoid level 4 warning m_uScrollFlags = pT->uSCROLL_FLAGS | (IsScrollingChildren() ? SW_SCROLLCHILDREN : 0) | (IsErasingBackground() ? SW_ERASE : 0); -#if (WINVER >= 0x0500) && !defined(_WIN32_WCE) m_uScrollFlags |= (IsSmoothScroll() ? SW_SMOOTHSCROLL : 0); -#endif // (WINVER >= 0x0500) && !defined(_WIN32_WCE) return dwPrevStyle; } @@ -160,11 +141,11 @@ public: } // Move all children if needed - if(IsScrollingChildren() && (dx != 0 || dy != 0)) + if(IsScrollingChildren() && ((dx != 0) || (dy != 0))) { for(HWND hWndChild = ::GetWindow(pT->m_hWnd, GW_CHILD); hWndChild != NULL; hWndChild = ::GetWindow(hWndChild, GW_HWNDNEXT)) { - RECT rect = { 0 }; + RECT rect = {}; ::GetWindowRect(hWndChild, &rect); ::MapWindowPoints(NULL, pT->m_hWnd, (LPPOINT)&rect, 1); ::SetWindowPos(hWndChild, NULL, rect.left + dx, rect.top + dy, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE); @@ -235,11 +216,11 @@ public: } // Move all children if needed - if(IsScrollingChildren() && (dx != 0 || dy != 0)) + if(IsScrollingChildren() && ((dx != 0) || (dy != 0))) { for(HWND hWndChild = ::GetWindow(pT->m_hWnd, GW_CHILD); hWndChild != NULL; hWndChild = ::GetWindow(hWndChild, GW_HWNDNEXT)) { - RECT rect = { 0 }; + RECT rect = {}; ::GetWindowRect(hWndChild, &rect); ::MapWindowPoints(NULL, pT->m_hWnd, (LPPOINT)&rect, 1); ::SetWindowPos(hWndChild, NULL, rect.left + dx, rect.top + dy, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE); @@ -266,8 +247,8 @@ public: // line operations void SetScrollLine(int cxLine, int cyLine) { - ATLASSERT(cxLine >= 0 && cyLine >= 0); - ATLASSERT(m_sizeAll.cx != 0 && m_sizeAll.cy != 0); + ATLASSERT((cxLine >= 0) && (cyLine >= 0)); + ATLASSERT((m_sizeAll.cx != 0) && (m_sizeAll.cy != 0)); m_sizeLine.cx = T::CalcLineOrPage(cxLine, m_sizeAll.cx, 100); m_sizeLine.cy = T::CalcLineOrPage(cyLine, m_sizeAll.cy, 100); @@ -286,8 +267,8 @@ public: // page operations void SetScrollPage(int cxPage, int cyPage) { - ATLASSERT(cxPage >= 0 && cyPage >= 0); - ATLASSERT(m_sizeAll.cx != 0 && m_sizeAll.cy != 0); + ATLASSERT((cxPage >= 0) && (cyPage >= 0)); + ATLASSERT((m_sizeAll.cx != 0) && (m_sizeAll.cy != 0)); m_sizePage.cx = T::CalcLineOrPage(cxPage, m_sizeAll.cx, 10); m_sizePage.cy = T::CalcLineOrPage(cyPage, m_sizeAll.cy, 10); @@ -402,7 +383,7 @@ public: T* pT = static_cast(this); ATLASSERT(::IsWindow(pT->m_hWnd)); - RECT rcClient = { 0 }; + RECT rcClient = {}; pT->GetClientRect(&rcClient); int x = m_ptOffset.x; @@ -425,7 +406,7 @@ public: T* pT = static_cast(this); ATLASSERT(::IsWindow(pT->m_hWnd)); - RECT rect = { 0 }; + RECT rect = {}; ::GetWindowRect(hWnd, &rect); ::OffsetRect(&rect, m_ptOffset.x, m_ptOffset.y); ::MapWindowPoints(NULL, pT->m_hWnd, (LPPOINT)&rect, 2); @@ -437,16 +418,11 @@ public: MESSAGE_HANDLER(WM_VSCROLL, OnVScroll) MESSAGE_HANDLER(WM_HSCROLL, OnHScroll) MESSAGE_HANDLER(WM_MOUSEWHEEL, OnMouseWheel) -#if !((_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)) && !defined(_WIN32_WCE) - MESSAGE_HANDLER(m_uMsgMouseWheel, OnMouseWheel) -#endif // !((_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)) && !defined(_WIN32_WCE) MESSAGE_HANDLER(WM_MOUSEHWHEEL, OnMouseHWheel) MESSAGE_HANDLER(WM_SETTINGCHANGE, OnSettingChange) MESSAGE_HANDLER(WM_SIZE, OnSize) MESSAGE_HANDLER(WM_PAINT, OnPaint) -#ifndef _WIN32_WCE MESSAGE_HANDLER(WM_PRINTCLIENT, OnPaint) -#endif // !_WIN32_WCE // standard scroll commands ALT_MSG_MAP(1) COMMAND_ID_HANDLER(ID_SCROLL_UP, OnScrollUp) @@ -488,17 +464,12 @@ public: return 0; } - LRESULT OnMouseWheel(UINT uMsg, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) + LRESULT OnMouseWheel(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) { T* pT = static_cast(this); ATLASSERT(::IsWindow(pT->m_hWnd)); -#if (_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400) || defined(_WIN32_WCE) - uMsg; int zDelta = (int)GET_WHEEL_DELTA_WPARAM(wParam); -#else - int zDelta = (uMsg == WM_MOUSEWHEEL) ? (int)GET_WHEEL_DELTA_WPARAM(wParam) : (int)wParam; -#endif // !((_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400) || defined(_WIN32_WCE)) int nScrollCode = (m_nWheelLines == WHEEL_PAGESCROLL) ? ((zDelta > 0) ? SB_PAGEUP : SB_PAGEDOWN) : ((zDelta > 0) ? SB_LINEUP : SB_LINEDOWN); m_zDelta += zDelta; // cumulative int zTotal = (m_nWheelLines == WHEEL_PAGESCROLL) ? abs(m_zDelta) : abs(m_zDelta) * m_nWheelLines; @@ -710,7 +681,7 @@ public: void DoScroll(int nType, int nScrollCode, int& cxyOffset, int cxySizeAll, int cxySizePage, int cxySizeLine) { T* pT = static_cast(this); - RECT rect = { 0 }; + RECT rect = {}; pT->GetClientRect(&rect); int cxyClient = (nType == SB_VERT) ? rect.bottom : rect.right; int cxyMax = cxySizeAll - cxyClient; @@ -799,7 +770,7 @@ public: break; } - if(bUpdate && cxyScroll != 0) + if(bUpdate && (cxyScroll != 0)) { pT->SetScrollPos(nType, cxyOffset, TRUE); if(nType == SB_VERT) @@ -842,35 +813,17 @@ public: else if(y < 0) y = 0; - return (x != xOld || y != yOld); + return ((x != xOld) || (y != yOld)); } void GetSystemSettings() { -#ifndef _WIN32_WCE -#ifndef SPI_GETWHEELSCROLLLINES - const UINT SPI_GETWHEELSCROLLLINES = 104; -#endif // !SPI_GETWHEELSCROLLLINES ::SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &m_nWheelLines, 0); #ifndef SPI_GETWHEELSCROLLCHARS const UINT SPI_GETWHEELSCROLLCHARS = 0x006C; -#endif // !SPI_GETWHEELSCROLLCHARS +#endif ::SystemParametersInfo(SPI_GETWHEELSCROLLCHARS, 0, &m_nHWheelChars, 0); - -#if !((_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)) - if(m_uMsgMouseWheel != 0) - m_uMsgMouseWheel = ::RegisterWindowMessage(MSH_MOUSEWHEEL); - - HWND hWndWheel = FindWindow(MSH_WHEELMODULE_CLASS, MSH_WHEELMODULE_TITLE); - if(::IsWindow(hWndWheel)) - { - UINT uMsgScrollLines = ::RegisterWindowMessage(MSH_SCROLL_LINES); - if(uMsgScrollLines != 0) - m_nWheelLines = (int)::SendMessage(hWndWheel, uMsgScrollLines, 0, 0L); - } -#endif // !((_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)) -#endif // !_WIN32_WCE } bool IsScrollingChildren() const @@ -888,12 +841,10 @@ public: return (m_dwExtendedStyle & SCRL_NOTHUMBTRACKING) != 0; } -#if (WINVER >= 0x0500) bool IsSmoothScroll() const { return (m_dwExtendedStyle & SCRL_SMOOTHSCROLL) != 0; } -#endif // (WINVER >= 0x0500) }; @@ -906,19 +857,14 @@ class ATL_NO_VTABLE CScrollWindowImpl : public ATL::CWindowImpl= 1300) BOOL bRet = ATL::CWindowImpl< T, TBase, TWinTraits >::SubclassWindow(hWnd); -#else // !(_MSC_VER >= 1300) - typedef ATL::CWindowImpl< T, TBase, TWinTraits > _baseClass; - BOOL bRet = _baseClass::SubclassWindow(hWnd); -#endif // !(_MSC_VER >= 1300) if(bRet != FALSE) { T* pT = static_cast(this); pT->GetSystemSettings(); - RECT rect = { 0 }; - GetClientRect(&rect); + RECT rect = {}; + this->GetClientRect(&rect); pT->DoSize(rect.right, rect.bottom); } @@ -929,16 +875,11 @@ public: MESSAGE_HANDLER(WM_VSCROLL, CScrollImpl< T >::OnVScroll) MESSAGE_HANDLER(WM_HSCROLL, CScrollImpl< T >::OnHScroll) MESSAGE_HANDLER(WM_MOUSEWHEEL, CScrollImpl< T >::OnMouseWheel) -#if !((_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)) && !defined(_WIN32_WCE) - MESSAGE_HANDLER(m_uMsgMouseWheel, CScrollImpl< T >::OnMouseWheel) -#endif // !((_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)) && !defined(_WIN32_WCE) MESSAGE_HANDLER(WM_MOUSEHWHEEL, CScrollImpl< T >::OnMouseHWheel) MESSAGE_HANDLER(WM_SETTINGCHANGE, CScrollImpl< T >::OnSettingChange) MESSAGE_HANDLER(WM_SIZE, CScrollImpl< T >::OnSize) MESSAGE_HANDLER(WM_PAINT, CScrollImpl< T >::OnPaint) -#ifndef _WIN32_WCE MESSAGE_HANDLER(WM_PRINTCLIENT, CScrollImpl< T >::OnPaint) -#endif // !_WIN32_WCE ALT_MSG_MAP(1) COMMAND_ID_HANDLER(ID_SCROLL_UP, CScrollImpl< T >::OnScrollUp) COMMAND_ID_HANDLER(ID_SCROLL_DOWN, CScrollImpl< T >::OnScrollDown) @@ -959,8 +900,6 @@ public: /////////////////////////////////////////////////////////////////////////////// // CMapScrollImpl - Provides mapping and scrolling support to any window -#ifndef _WIN32_WCE - template class CMapScrollImpl : public CScrollImpl< T > { @@ -984,20 +923,20 @@ public: // mapping mode operations void SetScrollMapMode(int nMapMode) { - ATLASSERT(nMapMode >= MM_MIN && nMapMode <= MM_MAX_FIXEDSCALE); + ATLASSERT((nMapMode >= MM_MIN) && (nMapMode <= MM_MAX_FIXEDSCALE)); m_nMapMode = nMapMode; } int GetScrollMapMode() const { - ATLASSERT(m_nMapMode >= MM_MIN && m_nMapMode <= MM_MAX_FIXEDSCALE); + ATLASSERT((m_nMapMode >= MM_MIN) && (m_nMapMode <= MM_MAX_FIXEDSCALE)); return m_nMapMode; } // offset operations void SetScrollOffset(int x, int y, BOOL bRedraw = TRUE) { - ATLASSERT(m_nMapMode >= MM_MIN && m_nMapMode <= MM_MAX_FIXEDSCALE); + ATLASSERT((m_nMapMode >= MM_MIN) && (m_nMapMode <= MM_MAX_FIXEDSCALE)); POINT ptOff = { x, y }; // block: convert logical to device units { @@ -1015,8 +954,8 @@ public: void GetScrollOffset(POINT& ptOffset) const { - ATLASSERT(m_nMapMode >= MM_MIN && m_nMapMode <= MM_MAX_FIXEDSCALE); - ptOffset = m_ptOffset; + ATLASSERT((m_nMapMode >= MM_MIN) && (m_nMapMode <= MM_MAX_FIXEDSCALE)); + ptOffset = this->m_ptOffset; // block: convert device to logical units { CWindowDC dc(NULL); @@ -1028,12 +967,12 @@ public: // size operations void SetScrollSize(int xMin, int yMin, int xMax, int yMax, BOOL bRedraw = TRUE, bool bResetOffset = true) { - ATLASSERT(xMax > xMin && yMax > yMin); - ATLASSERT(m_nMapMode >= MM_MIN && m_nMapMode <= MM_MAX_FIXEDSCALE); + ATLASSERT((xMax > xMin) && (yMax > yMin)); + ATLASSERT((m_nMapMode >= MM_MIN) && (m_nMapMode <= MM_MAX_FIXEDSCALE)); ::SetRect(&m_rectLogAll, xMin, yMin, xMax, yMax); - SIZE sizeAll = { 0 }; + SIZE sizeAll = {}; sizeAll.cx = xMax - xMin + 1; sizeAll.cy = yMax - yMin + 1; // block: convert logical to device units @@ -1064,15 +1003,15 @@ public: void GetScrollSize(RECT& rcScroll) const { - ATLASSERT(m_nMapMode >= MM_MIN && m_nMapMode <= MM_MAX_FIXEDSCALE); + ATLASSERT((m_nMapMode >= MM_MIN) && (m_nMapMode <= MM_MAX_FIXEDSCALE)); rcScroll = m_rectLogAll; } // line operations void SetScrollLine(int cxLine, int cyLine) { - ATLASSERT(cxLine >= 0 && cyLine >= 0); - ATLASSERT(m_nMapMode >= MM_MIN && m_nMapMode <= MM_MAX_FIXEDSCALE); + ATLASSERT((cxLine >= 0) && (cyLine >= 0)); + ATLASSERT((m_nMapMode >= MM_MIN) && (m_nMapMode <= MM_MAX_FIXEDSCALE)); m_sizeLogLine.cx = cxLine; m_sizeLogLine.cy = cyLine; @@ -1093,15 +1032,15 @@ public: void GetScrollLine(SIZE& sizeLine) const { - ATLASSERT(m_nMapMode >= MM_MIN && m_nMapMode <= MM_MAX_FIXEDSCALE); + ATLASSERT((m_nMapMode >= MM_MIN) && (m_nMapMode <= MM_MAX_FIXEDSCALE)); sizeLine = m_sizeLogLine; } // page operations void SetScrollPage(int cxPage, int cyPage) { - ATLASSERT(cxPage >= 0 && cyPage >= 0); - ATLASSERT(m_nMapMode >= MM_MIN && m_nMapMode <= MM_MAX_FIXEDSCALE); + ATLASSERT((cxPage >= 0) && (cyPage >= 0)); + ATLASSERT((m_nMapMode >= MM_MIN) && (m_nMapMode <= MM_MAX_FIXEDSCALE)); m_sizeLogPage.cx = cxPage; m_sizeLogPage.cy = cyPage; @@ -1122,7 +1061,7 @@ public: void GetScrollPage(SIZE& sizePage) const { - ATLASSERT(m_nMapMode >= MM_MIN && m_nMapMode <= MM_MAX_FIXEDSCALE); + ATLASSERT((m_nMapMode >= MM_MIN) && (m_nMapMode <= MM_MAX_FIXEDSCALE)); sizePage = m_sizeLogPage; } @@ -1130,9 +1069,6 @@ public: MESSAGE_HANDLER(WM_VSCROLL, CScrollImpl< T >::OnVScroll) MESSAGE_HANDLER(WM_HSCROLL, CScrollImpl< T >::OnHScroll) MESSAGE_HANDLER(WM_MOUSEWHEEL, CScrollImpl< T >::OnMouseWheel) -#if !((_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)) - MESSAGE_HANDLER(m_uMsgMouseWheel, CScrollImpl< T >::OnMouseWheel) -#endif // !((_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)) MESSAGE_HANDLER(WM_MOUSEHWHEEL, CScrollImpl< T >::OnMouseHWheel) MESSAGE_HANDLER(WM_SETTINGCHANGE, CScrollImpl< T >::OnSettingChange) MESSAGE_HANDLER(WM_SIZE, CScrollImpl< T >::OnSize) @@ -1164,9 +1100,9 @@ public: dc.SetMapMode(m_nMapMode); POINT ptViewportOrg = { 0, 0 }; if(m_nMapMode == MM_TEXT) - dc.SetViewportOrg(-m_ptOffset.x, -m_ptOffset.y, &ptViewportOrg); + dc.SetViewportOrg(-this->m_ptOffset.x, -this->m_ptOffset.y, &ptViewportOrg); else - dc.SetViewportOrg(-m_ptOffset.x, -m_ptOffset.y + m_sizeAll.cy, &ptViewportOrg); + dc.SetViewportOrg(-this->m_ptOffset.x, -this->m_ptOffset.y + this->m_sizeAll.cy, &ptViewportOrg); POINT ptWindowOrg = { 0, 0 }; dc.SetWindowOrg(m_rectLogAll.left, m_rectLogAll.top, &ptWindowOrg); @@ -1181,9 +1117,9 @@ public: CPaintDC dc(pT->m_hWnd); dc.SetMapMode(m_nMapMode); if(m_nMapMode == MM_TEXT) - dc.SetViewportOrg(-m_ptOffset.x, -m_ptOffset.y); + dc.SetViewportOrg(-this->m_ptOffset.x, -this->m_ptOffset.y); else - dc.SetViewportOrg(-m_ptOffset.x, -m_ptOffset.y + m_sizeAll.cy); + dc.SetViewportOrg(-this->m_ptOffset.x, -this->m_ptOffset.y + this->m_sizeAll.cy); dc.SetWindowOrg(m_rectLogAll.left, m_rectLogAll.top); pT->DoPaint(dc.m_hDC); } @@ -1191,33 +1127,24 @@ public: } }; -#endif // !_WIN32_WCE - /////////////////////////////////////////////////////////////////////////////// // CMapScrollWindowImpl - Implements scrolling window with mapping -#ifndef _WIN32_WCE - template class ATL_NO_VTABLE CMapScrollWindowImpl : public ATL::CWindowImpl< T, TBase, TWinTraits >, public CMapScrollImpl< T > { public: BOOL SubclassWindow(HWND hWnd) { -#if (_MSC_VER >= 1300) BOOL bRet = ATL::CWindowImpl< T, TBase, TWinTraits >::SubclassWindow(hWnd); -#else // !(_MSC_VER >= 1300) - typedef ATL::CWindowImpl< T, TBase, TWinTraits > _baseClass; - BOOL bRet = _baseClass::SubclassWindow(hWnd); -#endif // !(_MSC_VER >= 1300) if(bRet != FALSE) { T* pT = static_cast(this); pT->GetSystemSettings(); - RECT rect = { 0 }; - GetClientRect(&rect); + RECT rect = {}; + this->GetClientRect(&rect); pT->DoSize(rect.right, rect.bottom); } @@ -1228,9 +1155,6 @@ public: MESSAGE_HANDLER(WM_VSCROLL, CScrollImpl< T >::OnVScroll) MESSAGE_HANDLER(WM_HSCROLL, CScrollImpl< T >::OnHScroll) MESSAGE_HANDLER(WM_MOUSEWHEEL, CScrollImpl< T >::OnMouseWheel) -#if !((_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)) - MESSAGE_HANDLER(m_uMsgMouseWheel, CScrollImpl< T >::OnMouseWheel) -#endif // !((_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)) MESSAGE_HANDLER(WM_MOUSEHWHEEL, CScrollImpl< T >::OnMouseHWheel) MESSAGE_HANDLER(WM_SETTINGCHANGE, CScrollImpl< T >::OnSettingChange) MESSAGE_HANDLER(WM_SIZE, CScrollImpl< T >::OnSize) @@ -1252,13 +1176,11 @@ public: END_MSG_MAP() }; -#endif // !_WIN32_WCE - /////////////////////////////////////////////////////////////////////////////// // CFSBWindow - Use as a base instead of CWindow to get flat scroll bar support -#if defined(__ATLCTRLS_H__) && (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) +#ifdef __ATLCTRLS_H__ template class CFSBWindowT : public TBase, public CFlatScrollBarImpl > @@ -1270,7 +1192,7 @@ public: CFSBWindowT< TBase >& operator =(HWND hWnd) { - m_hWnd = hWnd; + this->m_hWnd = hWnd; return *this; } @@ -1278,33 +1200,31 @@ public: // (only those methods that are used by scroll window classes) int SetScrollPos(int nBar, int nPos, BOOL bRedraw = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return FlatSB_SetScrollPos(nBar, nPos, bRedraw); + ATLASSERT(::IsWindow(this->m_hWnd)); + return this->FlatSB_SetScrollPos(nBar, nPos, bRedraw); } BOOL GetScrollInfo(int nBar, LPSCROLLINFO lpScrollInfo) { - ATLASSERT(::IsWindow(m_hWnd)); - return FlatSB_GetScrollInfo(nBar, lpScrollInfo); + ATLASSERT(::IsWindow(this->m_hWnd)); + return this->FlatSB_GetScrollInfo(nBar, lpScrollInfo); } BOOL SetScrollInfo(int nBar, LPSCROLLINFO lpScrollInfo, BOOL bRedraw = TRUE) { - ATLASSERT(::IsWindow(m_hWnd)); - return FlatSB_SetScrollInfo(nBar, lpScrollInfo, bRedraw); + ATLASSERT(::IsWindow(this->m_hWnd)); + return this->FlatSB_SetScrollInfo(nBar, lpScrollInfo, bRedraw); } }; typedef CFSBWindowT CFSBWindow; -#endif // defined(__ATLCTRLS_H__) && (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) +#endif // __ATLCTRLS_H__ /////////////////////////////////////////////////////////////////////////////// // CZoomScrollImpl - Provides zooming and scrolling support to any window -#ifndef _WIN32_WCE - // The zoom modes that can be set with the SetZoomMode method enum { @@ -1365,7 +1285,7 @@ public: // size operations void SetScrollSize(int cxLog, int cyLog, BOOL bRedraw = TRUE, bool bResetOffset = true) { - ATLASSERT(cxLog >= 0 && cyLog >= 0); + ATLASSERT((cxLog >= 0) && (cyLog >= 0)); // Set up the defaults if((cxLog == 0) && (cyLog == 0)) @@ -1376,7 +1296,7 @@ public: m_sizeLogAll.cx = cxLog; m_sizeLogAll.cy = cyLog; - SIZE sizeAll = { 0 }; + SIZE sizeAll = {}; sizeAll.cx = (int)((float)m_sizeLogAll.cx * m_fZoomScale); sizeAll.cy = (int)((float)m_sizeLogAll.cy * m_fZoomScale); @@ -1396,12 +1316,12 @@ public: // line operations void SetScrollLine(int cxLogLine, int cyLogLine) { - ATLASSERT(cxLogLine >= 0 && cyLogLine >= 0); + ATLASSERT((cxLogLine >= 0) && (cyLogLine >= 0)); m_sizeLogLine.cx = cxLogLine; m_sizeLogLine.cy = cyLogLine; - SIZE sizeLine = { 0 }; + SIZE sizeLine = {}; sizeLine.cx = (int)((float)m_sizeLogLine.cx * m_fZoomScale); sizeLine.cy = (int)((float)m_sizeLogLine.cy * m_fZoomScale); CScrollImpl< T >::SetScrollLine(sizeLine); @@ -1425,7 +1345,7 @@ public: m_sizeLogPage.cx = cxLogPage; m_sizeLogPage.cy = cyLogPage; - SIZE sizePage = { 0 }; + SIZE sizePage = {}; sizePage.cx = (int)((float)m_sizeLogPage.cx * m_fZoomScale); sizePage.cy = (int)((float)m_sizeLogPage.cy * m_fZoomScale); @@ -1521,11 +1441,11 @@ public: { for(HWND hWndChild = ::GetWindow(pT->m_hWnd, GW_CHILD); hWndChild != NULL; hWndChild = ::GetWindow(hWndChild, GW_HWNDNEXT)) { - RECT rect = { 0 }; + RECT rect = {}; ::GetWindowRect(hWndChild, &rect); ::MapWindowPoints(NULL, pT->m_hWnd, (LPPOINT)&rect, 2); - _ChildPlacement cp = { 0 }; + _ChildPlacement cp = {}; cp.hWnd = hWndChild; cp.x = rect.left; cp.y = rect.top; @@ -1574,7 +1494,7 @@ public: pT->NormalizeRect(rcZoom); SIZE size = { rcZoom.right - rcZoom.left, rcZoom.bottom - rcZoom.top }; POINT pt = { rcZoom.left + size.cx / 2, rcZoom.top + size.cy / 2 }; - if(size.cx < m_cxyMinZoomRect || size.cy < m_cxyMinZoomRect) + if((size.cx < m_cxyMinZoomRect) || (size.cy < m_cxyMinZoomRect)) { pT->Zoom(pt, m_fZoomScale + m_fZoomDelta); return; @@ -1582,8 +1502,8 @@ public: ATLASSERT((size.cx > 0) && (size.cy > 0)); - float fScaleH = (float)(m_sizeClient.cx + 1) / (float)size.cx; - float fScaleV = (float)(m_sizeClient.cy + 1) / (float)size.cy; + float fScaleH = (float)(this->m_sizeClient.cx + 1) / (float)size.cx; + float fScaleV = (float)(this->m_sizeClient.cy + 1) / (float)size.cy; float fZoomScale = __min(fScaleH, fScaleV) * m_fZoomScale; pT->Zoom(pt, fZoomScale); } @@ -1599,10 +1519,10 @@ public: fZoomScale = m_fZoomScaleMax; T* pT = static_cast(this); - POINT pt = { 0 }; + POINT pt = { 0, 0 }; if(bCenter) { - RECT rcClient = { 0 }; + RECT rcClient = {}; ::GetClientRect(pT->m_hWnd, &rcClient); pt.x = rcClient.right / 2; pt.y = rcClient.bottom / 2; @@ -1610,7 +1530,7 @@ public: } // Modify the Viewport extent - SIZE sizeAll = { 0 }; + SIZE sizeAll = {}; sizeAll.cx = (int)((float)m_sizeLogAll.cx * fZoomScale); sizeAll.cy = (int)((float)m_sizeLogAll.cy * fZoomScale); @@ -1640,14 +1560,32 @@ public: pT->CenterOnLogicalPoint(pt); } + void ZoomIn(bool bCenter = true) + { + T* pT = static_cast(this); + pT->Zoom(m_fZoomScale + m_fZoomDelta, bCenter); + } + + void ZoomOut(bool bCenter = true) + { + T* pT = static_cast(this); + pT->Zoom(m_fZoomScale - m_fZoomDelta, bCenter); + } + + void ZoomDefault(bool bCenter = true) + { + T* pT = static_cast(this); + pT->Zoom(1.0f, bCenter); + } + // Helper functions void PrepareDC(CDCHandle dc) { - ATLASSERT(m_sizeAll.cx >= 0 && m_sizeAll.cy >= 0); + ATLASSERT((this->m_sizeAll.cx >= 0) && (this->m_sizeAll.cy >= 0)); dc.SetMapMode(MM_ANISOTROPIC); - dc.SetWindowExt(m_sizeLogAll); - dc.SetViewportExt(m_sizeAll); - dc.SetViewportOrg(-m_ptOffset.x, -m_ptOffset.y); + dc.SetWindowExt(this->m_sizeLogAll); + dc.SetViewportExt(this->m_sizeAll); + dc.SetViewportOrg(-this->m_ptOffset.x, -this->m_ptOffset.y); } void ViewDPtoLP(LPPOINT lpPoints, int nCount = 1) @@ -1674,42 +1612,42 @@ public: void ClientToDevice(POINT &pt) { - pt.x += m_ptOffset.x; - pt.y += m_ptOffset.y; + pt.x += this->m_ptOffset.x; + pt.y += this->m_ptOffset.y; } void DeviceToClient(POINT &pt) { - pt.x -= m_ptOffset.x; - pt.y -= m_ptOffset.y; + pt.x -= this->m_ptOffset.x; + pt.y -= this->m_ptOffset.y; } void CenterOnPoint(POINT pt) { T* pT = static_cast(this); - RECT rect = { 0 }; + RECT rect = {}; pT->GetClientRect(&rect); - int xOfs = pt.x - (rect.right / 2) + m_ptOffset.x; + int xOfs = pt.x - (rect.right / 2) + this->m_ptOffset.x; if(xOfs < 0) { xOfs = 0; } else { - int xMax = __max((int)(m_sizeAll.cx - rect.right), 0); + int xMax = __max((int)(this->m_sizeAll.cx - rect.right), 0); if(xOfs > xMax) xOfs = xMax; } - int yOfs = pt.y - (rect.bottom / 2) + m_ptOffset.y; + int yOfs = pt.y - (rect.bottom / 2) + this->m_ptOffset.y; if(yOfs < 0) { yOfs = 0; } else { - int yMax = __max((int)(m_sizeAll.cy - rect.bottom), 0); + int yMax = __max((int)(this->m_sizeAll.cy - rect.bottom), 0); if(yOfs > yMax) yOfs = yMax; } @@ -1727,8 +1665,8 @@ public: BOOL PtInDevRect(POINT pt) { - RECT rc = { 0, 0, m_sizeAll.cx, m_sizeAll.cy }; - ::OffsetRect(&rc, -m_ptOffset.x, -m_ptOffset.y); + RECT rc = { 0, 0, this->m_sizeAll.cx, this->m_sizeAll.cy }; + ::OffsetRect(&rc, -this->m_ptOffset.x, -this->m_ptOffset.y); return ::PtInRect(&rc, pt); } @@ -1752,13 +1690,12 @@ public: void DrawTrackRect() { T* pT = static_cast(this); - const SIZE sizeLines = { 2, 2 }; RECT rc = m_rcTrack; pT->NormalizeRect(rc); if(!::IsRectEmpty(&rc)) { - ::MapWindowPoints(pT->m_hWnd, NULL, (LPPOINT)&rc, 2); - CWindowDC dc(NULL); + const SIZE sizeLines = { 2, 2 }; + CClientDC dc(pT->m_hWnd); dc.DrawDragRect(&rc, sizeLines, NULL, sizeLines); } } @@ -1771,14 +1708,19 @@ public: ::SendMessage(pT->GetParent(), WM_NOTIFY, (WPARAM)nId, (LPARAM)&nmhdr); } + void DoWheelZoom(int zDelta) + { + float fZoomScale = m_fZoomScale + ((zDelta > 0) ? m_fZoomDelta : -m_fZoomDelta); + T* pT = static_cast(this); + pT->Zoom(fZoomScale); + pT->NotifyParentZoomChanged(); + } + BEGIN_MSG_MAP(CZoomScrollImpl) MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor) MESSAGE_HANDLER(WM_VSCROLL, CScrollImpl< T >::OnVScroll) MESSAGE_HANDLER(WM_HSCROLL, CScrollImpl< T >::OnHScroll) - MESSAGE_HANDLER(WM_MOUSEWHEEL, CScrollImpl< T >::OnMouseWheel) -#if !((_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)) - MESSAGE_HANDLER(m_uMsgMouseWheel, CScrollImpl< T >::OnMouseWheel) -#endif // !((_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)) + MESSAGE_HANDLER(WM_MOUSEWHEEL, OnMouseWheel) MESSAGE_HANDLER(WM_MOUSEHWHEEL, CScrollImpl< T >::OnMouseHWheel) MESSAGE_HANDLER(WM_SETTINGCHANGE, CScrollImpl< T >::OnSettingChange) MESSAGE_HANDLER(WM_SIZE, CScrollImpl< T >::OnSize) @@ -1803,12 +1745,50 @@ public: COMMAND_ID_HANDLER(ID_SCROLL_ALL_RIGHT, CScrollImpl< T >::OnScrollAllRight) END_MSG_MAP() + LRESULT OnSetCursor(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled) + { + if((LOWORD(lParam) == HTCLIENT) && (m_nZoomMode != ZOOMMODE_OFF)) + { + T* pT = static_cast(this); + if((HWND)wParam == pT->m_hWnd) + { + DWORD dwPos = ::GetMessagePos(); + POINT pt = { GET_X_LPARAM(dwPos), GET_Y_LPARAM(dwPos) }; + pT->ScreenToClient(&pt); + if(pT->PtInDevRect(pt)) + { + ::SetCursor(::LoadCursor(NULL, IDC_CROSS)); + return 1; + } + } + } + + bHandled = FALSE; + return 0; + } + + LRESULT OnMouseWheel(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) + { + if((GET_KEYSTATE_WPARAM(wParam) & MK_CONTROL) != 0) // handle zoom if Ctrl is pressed + { + int zDelta = (int)GET_WHEEL_DELTA_WPARAM(wParam); + T* pT = static_cast(this); + pT->DoWheelZoom(zDelta); + } + else + { + CScrollImpl< T >::OnMouseWheel(uMsg, wParam, lParam, bHandled); + } + + return 0; + } + LRESULT OnPaint(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) { T* pT = static_cast(this); ATLASSERT(::IsWindow(pT->m_hWnd)); ATLASSERT((m_sizeLogAll.cx >= 0) && (m_sizeLogAll.cy >= 0)); - ATLASSERT((m_sizeAll.cx >= 0) && (m_sizeAll.cy >= 0)); + ATLASSERT((this->m_sizeAll.cx >= 0) && (this->m_sizeAll.cy >= 0)); if(wParam != NULL) { @@ -1818,9 +1798,9 @@ public: SIZE szWindowExt = { 0, 0 }; dc.SetWindowExt(m_sizeLogAll, &szWindowExt); SIZE szViewportExt = { 0, 0 }; - dc.SetViewportExt(m_sizeAll, &szViewportExt); + dc.SetViewportExt(this->m_sizeAll, &szViewportExt); POINT ptViewportOrg = { 0, 0 }; - dc.SetViewportOrg(-m_ptOffset.x, -m_ptOffset.y, &ptViewportOrg); + dc.SetViewportOrg(-this->m_ptOffset.x, -this->m_ptOffset.y, &ptViewportOrg); pT->DoPaint(dc); @@ -1841,7 +1821,7 @@ public: LRESULT OnLButtonDown(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled) { - if(m_nZoomMode == ZOOMMODE_IN && !m_bTracking) + if((m_nZoomMode == ZOOMMODE_IN) && !m_bTracking) { T* pT = static_cast(this); POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; @@ -1850,6 +1830,18 @@ public: pT->SetCapture(); m_bTracking = true; ::SetRect(&m_rcTrack, pt.x, pt.y, pt.x, pt.y); + + RECT rcClip; + pT->GetClientRect(&rcClip); + if((this->m_ptOffset.x == 0) && (this->m_ptOffset.y == 0)) + { + if(rcClip.right > this->m_sizeAll.cx) + rcClip.right = this->m_sizeAll.cx; + if(rcClip.bottom > this->m_sizeAll.cy) + rcClip.bottom = this->m_sizeAll.cy; + } + ::MapWindowPoints(pT->m_hWnd, NULL, (LPPOINT)&rcClip, 2); + ::ClipCursor(&rcClip); } } @@ -1866,8 +1858,8 @@ public: if(pT->PtInDevRect(pt)) { pT->DrawTrackRect(); - m_rcTrack.right = pt.x; - m_rcTrack.bottom = pt.y; + m_rcTrack.right = pt.x + 1; + m_rcTrack.bottom = pt.y + 1; pT->DrawTrackRect(); } } @@ -1900,33 +1892,12 @@ public: pT->Zoom(m_rcTrack); pT->NotifyParentZoomChanged(); ::SetRectEmpty(&m_rcTrack); + ::ClipCursor(NULL); } bHandled = FALSE; return 0; } - - LRESULT OnSetCursor(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled) - { - if(LOWORD(lParam) == HTCLIENT && m_nZoomMode != ZOOMMODE_OFF) - { - T* pT = static_cast(this); - if((HWND)wParam == pT->m_hWnd) - { - DWORD dwPos = ::GetMessagePos(); - POINT pt = { GET_X_LPARAM(dwPos), GET_Y_LPARAM(dwPos) }; - pT->ScreenToClient(&pt); - if(pT->PtInDevRect(pt)) - { - ::SetCursor(::LoadCursor(NULL, IDC_CROSS)); - return 1; - } - } - } - - bHandled = FALSE; - return 0; - } }; /////////////////////////////////////////////////////////////////////////////// @@ -1938,19 +1909,14 @@ class ATL_NO_VTABLE CZoomScrollWindowImpl : public ATL::CWindowImpl< T, TBase, T public: BOOL SubclassWindow(HWND hWnd) { -#if (_MSC_VER >= 1300) BOOL bRet = ATL::CWindowImpl< T, TBase, TWinTraits >::SubclassWindow(hWnd); -#else // !(_MSC_VER >= 1300) - typedef ATL::CWindowImpl< T, TBase, TWinTraits > _baseClass; - BOOL bRet = _baseClass::SubclassWindow(hWnd); -#endif // !(_MSC_VER >= 1300) if(bRet != FALSE) { T* pT = static_cast(this); pT->GetSystemSettings(); - RECT rect = { 0 }; - GetClientRect(&rect); + RECT rect = {}; + this->GetClientRect(&rect); pT->DoSize(rect.right, rect.bottom); } @@ -1961,10 +1927,7 @@ public: MESSAGE_HANDLER(WM_SETCURSOR, CZoomScrollImpl< T >::OnSetCursor) MESSAGE_HANDLER(WM_VSCROLL, CScrollImpl< T >::OnVScroll) MESSAGE_HANDLER(WM_HSCROLL, CScrollImpl< T >::OnHScroll) - MESSAGE_HANDLER(WM_MOUSEWHEEL, CScrollImpl< T >::OnMouseWheel) -#if !((_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)) - MESSAGE_HANDLER(m_uMsgMouseWheel, CScrollImpl< T >::OnMouseWheel) -#endif // !((_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)) + MESSAGE_HANDLER(WM_MOUSEWHEEL, CZoomScrollImpl< T >::OnMouseWheel) MESSAGE_HANDLER(WM_MOUSEHWHEEL, CScrollImpl< T >::OnMouseHWheel) MESSAGE_HANDLER(WM_SETTINGCHANGE, CScrollImpl< T >::OnSettingChange) MESSAGE_HANDLER(WM_SIZE, CScrollImpl< T >::OnSize) @@ -1990,8 +1953,6 @@ public: END_MSG_MAP() }; -#endif // !_WIN32_WCE - /////////////////////////////////////////////////////////////////////////////// // CScrollContainer @@ -2000,7 +1961,7 @@ template { public: - DECLARE_WND_CLASS_EX(NULL, 0, -1) + DECLARE_WND_CLASS_EX2(NULL, T, 0, -1) typedef CScrollWindowImpl< T, TBase, TWinTraits > _baseClass; @@ -2013,7 +1974,7 @@ public: CScrollContainerImpl() : m_bAutoSizeClient(true), m_bDrawEdgeIfEmpty(false) { // Set CScrollWindowImpl extended style - SetScrollExtendedStyle(SCRL_SCROLLCHILDREN); + this->SetScrollExtendedStyle(SCRL_SCROLLCHILDREN); } // Attributes @@ -2024,13 +1985,13 @@ public: HWND SetClient(HWND hWndClient, bool bClientSizeAsMin = true) { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); HWND hWndOldClient = m_wndClient; m_wndClient = hWndClient; - SetRedraw(FALSE); - SetScrollSize(1, 1, FALSE); + this->SetRedraw(FALSE); + this->SetScrollSize(1, 1, FALSE); if(m_wndClient.m_hWnd != NULL) { @@ -2038,18 +1999,18 @@ public: if(bClientSizeAsMin) { - RECT rect = { 0 }; + RECT rect = {}; m_wndClient.GetWindowRect(&rect); - if((rect.right - rect.left) > 0 && (rect.bottom - rect.top) > 0) - SetScrollSize(rect.right - rect.left, rect.bottom - rect.top, FALSE); + if(((rect.right - rect.left) > 0) && ((rect.bottom - rect.top) > 0)) + this->SetScrollSize(rect.right - rect.left, rect.bottom - rect.top, FALSE); } T* pT = static_cast(this); pT->UpdateLayout(); } - SetRedraw(TRUE); - RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_UPDATENOW | RDW_ALLCHILDREN); + this->SetRedraw(TRUE); + this->RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_UPDATENOW | RDW_ALLCHILDREN); return hWndOldClient; } @@ -2088,13 +2049,13 @@ public: void DoPaint(CDCHandle dc) { - if(!m_bAutoSizeClient || m_wndClient.m_hWnd == NULL) + if(!m_bAutoSizeClient || (m_wndClient.m_hWnd == NULL)) { T* pT = static_cast(this); - RECT rect = { 0 }; + RECT rect = {}; pT->GetContainerRect(rect); - if(m_bDrawEdgeIfEmpty && m_wndClient.m_hWnd == NULL) + if(m_bDrawEdgeIfEmpty && (m_wndClient.m_hWnd == NULL)) dc.DrawEdge(&rect, EDGE_SUNKEN, BF_RECT | BF_ADJUST); dc.FillRect(&rect, COLOR_APPWORKSPACE); @@ -2114,11 +2075,11 @@ public: void ScrollToView(HWND hWnd) // client window coordinates { T* pT = static_cast(this); - pT; // avoid level 4 warning + (void)pT; // avoid level 4 warning ATLASSERT(::IsWindow(pT->m_hWnd)); ATLASSERT(m_wndClient.IsWindow()); - RECT rect = { 0 }; + RECT rect = {}; ::GetWindowRect(hWnd, &rect); ::MapWindowPoints(NULL, m_wndClient.m_hWnd, (LPPOINT)&rect, 2); ScrollToView(rect); @@ -2127,31 +2088,31 @@ public: // Implementation - overrideable methods void UpdateLayout() { - ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(this->m_hWnd)); - if(m_bAutoSizeClient && m_wndClient.m_hWnd != NULL) + if(m_bAutoSizeClient && (m_wndClient.m_hWnd != NULL)) { T* pT = static_cast(this); - RECT rect = { 0 }; + RECT rect = {}; pT->GetContainerRect(rect); m_wndClient.SetWindowPos(NULL, &rect, SWP_NOZORDER | SWP_NOMOVE); } else { - Invalidate(); + this->Invalidate(); } } void GetContainerRect(RECT& rect) { - GetClientRect(&rect); + this->GetClientRect(&rect); - if(rect.right < m_sizeAll.cx) - rect.right = m_sizeAll.cx; + if(rect.right < this->m_sizeAll.cx) + rect.right = this->m_sizeAll.cx; - if(rect.bottom < m_sizeAll.cy) - rect.bottom = m_sizeAll.cy; + if(rect.bottom < this->m_sizeAll.cy) + rect.bottom = this->m_sizeAll.cy; } }; @@ -2161,6 +2122,6 @@ public: DECLARE_WND_CLASS_EX(_T("WTL_ScrollContainer"), 0, -1) }; -}; // namespace WTL +} // namespace WTL #endif // __ATLSCRL_H__ diff --git a/ZbaSDK/SampleCode/PluginWinExe/WTL/atlsplit.h b/ZbaSDK/SampleCode/PluginWinExe/WTL/atlsplit.h index 00a419d494e1d18c251c0d01145e46b269ab9bbf..714269c0bcac94a1dd4c26ad3fe082469d40066f 100644 --- a/ZbaSDK/SampleCode/PluginWinExe/WTL/atlsplit.h +++ b/ZbaSDK/SampleCode/PluginWinExe/WTL/atlsplit.h @@ -1,4 +1,4 @@ -// Windows Template Library - WTL version 9.10 +// Windows Template Library - WTL version 10.0 // Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. // // This file is a part of the Windows Template Library. @@ -47,18 +47,19 @@ namespace WTL #define SPLIT_RIGHTALIGNED 0x00000004 #define SPLIT_BOTTOMALIGNED SPLIT_RIGHTALIGNED #define SPLIT_GRADIENTBAR 0x00000008 +#define SPLIT_FLATBAR 0x00000020 #define SPLIT_FIXEDBARSIZE 0x00000010 // Note: SPLIT_PROPORTIONAL and SPLIT_RIGHTALIGNED/SPLIT_BOTTOMALIGNED are // mutually exclusive. If both are set, splitter defaults to SPLIT_PROPORTIONAL. -// SPLIT_GRADIENTBAR doesn't work with _ATL_NO_MSIMG +// Also, SPLIT_FLATBAR overrides SPLIT_GRADIENTBAR if both are set. template class CSplitterImpl { public: - enum { m_nPanesCount = 2, m_nPropMax = 10000, m_cxyStep = 10 }; + enum { m_nPanesCount = 2, m_nPropMax = INT_MAX, m_cxyStep = 10 }; bool m_bVertical; HWND m_hWndPane[m_nPanesCount]; @@ -201,7 +202,7 @@ public: int GetSplitterPosPct() const { int cxyTotal = m_bVertical ? (m_rcSplitter.right - m_rcSplitter.left - m_cxySplitBar - m_cxyBarEdge) : (m_rcSplitter.bottom - m_rcSplitter.top - m_cxySplitBar - m_cxyBarEdge); - return ((cxyTotal > 0) && (m_xySplitterPos >= 0)) ? (::MulDiv(m_xySplitterPos, m_nPropMax, cxyTotal) / 100) : -1; + return ((cxyTotal > 0) && (m_xySplitterPos >= 0)) ? ::MulDiv(m_xySplitterPos, 100, cxyTotal) : -1; } bool SetSinglePaneMode(int nPane = SPLIT_PANE_NONE) @@ -471,13 +472,28 @@ public: // Overrideables void DrawSplitterBar(CDCHandle dc) { - RECT rect = { 0 }; + RECT rect = {}; if(GetSplitterBarRect(&rect)) { dc.FillRect(&rect, COLOR_3DFACE); -#if (!defined(_WIN32_WCE) && !defined(_ATL_NO_MSIMG)) || (_WIN32_WCE >= 420) - if((m_dwExtendedStyle & SPLIT_GRADIENTBAR) != 0) + if((m_dwExtendedStyle & SPLIT_FLATBAR) != 0) + { + RECT rect1 = rect; + if(m_bVertical) + rect1.right = rect1.left + 1; + else + rect1.bottom = rect1.top + 1; + dc.FillRect(&rect1, COLOR_WINDOW); + + rect1 = rect; + if(m_bVertical) + rect1.left = rect1.right - 1; + else + rect1.top = rect1.bottom - 1; + dc.FillRect(&rect1, COLOR_3DSHADOW); + } + else if((m_dwExtendedStyle & SPLIT_GRADIENTBAR) != 0) { RECT rect2 = rect; if(m_bVertical) @@ -487,7 +503,6 @@ public: dc.GradientFillRect(rect2, ::GetSysColor(COLOR_3DFACE), ::GetSysColor(COLOR_3DSHADOW), m_bVertical); } -#endif // (!defined(_WIN32_WCE) && !defined(_ATL_NO_MSIMG)) || (_WIN32_WCE >= 420) // draw 3D edge if needed T* pT = static_cast(this); @@ -499,7 +514,7 @@ public: // called only if pane is empty void DrawSplitterPane(CDCHandle dc, int nPane) { - RECT rect = { 0 }; + RECT rect = {}; if(GetSplitterPaneRect(nPane, &rect)) { T* pT = static_cast(this); @@ -513,9 +528,7 @@ public: BEGIN_MSG_MAP(CSplitterImpl) MESSAGE_HANDLER(WM_CREATE, OnCreate) MESSAGE_HANDLER(WM_PAINT, OnPaint) -#ifndef _WIN32_WCE MESSAGE_HANDLER(WM_PRINTCLIENT, OnPaint) -#endif // !_WIN32_WCE if(IsInteractive()) { MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor) @@ -527,9 +540,7 @@ public: MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown) } MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus) -#ifndef _WIN32_WCE MESSAGE_HANDLER(WM_MOUSEACTIVATE, OnMouseActivate) -#endif // !_WIN32_WCE MESSAGE_HANDLER(WM_SETTINGCHANGE, OnSettingChange) END_MSG_MAP() @@ -698,6 +709,7 @@ public: { case VK_RETURN: m_xySplitterPosNew = m_xySplitterPos; + // FALLTHROUGH case VK_ESCAPE: ::ReleaseCapture(); break; @@ -705,7 +717,7 @@ public: case VK_RIGHT: if(m_bVertical) { - POINT pt = { 0, 0 }; + POINT pt = {}; ::GetCursorPos(&pt); int xyPos = m_xySplitterPos + ((wParam == VK_LEFT) ? -pT->m_cxyStep : pT->m_cxyStep); int cxyMax = m_rcSplitter.right - m_rcSplitter.left; @@ -721,7 +733,7 @@ public: case VK_DOWN: if(!m_bVertical) { - POINT pt = { 0, 0 }; + POINT pt = {}; ::GetCursorPos(&pt); int xyPos = m_xySplitterPos + ((wParam == VK_UP) ? -pT->m_cxyStep : pT->m_cxyStep); int cxyMax = m_rcSplitter.bottom - m_rcSplitter.top; @@ -765,7 +777,6 @@ public: return 1; } -#ifndef _WIN32_WCE LRESULT OnMouseActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) { T* pT = static_cast(this); @@ -775,7 +786,7 @@ public: DWORD dwPos = ::GetMessagePos(); POINT pt = { GET_X_LPARAM(dwPos), GET_Y_LPARAM(dwPos) }; pT->ScreenToClient(&pt); - RECT rcPane = { 0 }; + RECT rcPane = {}; for(int nPane = 0; nPane < m_nPanesCount; nPane++) { if(GetSplitterPaneRect(nPane, &rcPane) && (::PtInRect(&rcPane, pt) != FALSE)) @@ -788,7 +799,6 @@ public: return lRet; } -#endif // !_WIN32_WCE LRESULT OnSettingChange(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { @@ -813,7 +823,7 @@ public: return; T* pT = static_cast(this); - RECT rect = { 0 }; + RECT rect = {}; if(m_nSinglePane == SPLIT_PANE_NONE) { if(GetSplitterBarRect(&rect)) @@ -923,8 +933,8 @@ public: bool IsOverSplitterRect(int x, int y) const { // -1 == don't check - return ((x == -1 || (x >= m_rcSplitter.left && x <= m_rcSplitter.right)) && - (y == -1 || (y >= m_rcSplitter.top && y <= m_rcSplitter.bottom))); + return (((x == -1) || ((x >= m_rcSplitter.left) && (x <= m_rcSplitter.right))) && + ((y == -1) || ((y >= m_rcSplitter.top) && (y <= m_rcSplitter.bottom)))); } bool IsOverSplitterBar(int x, int y) const @@ -936,26 +946,26 @@ public: int xy = m_bVertical ? x : y; int xyOff = m_bVertical ? m_rcSplitter.left : m_rcSplitter.top; - return ((xy >= (xyOff + m_xySplitterPos)) && (xy < xyOff + m_xySplitterPos + m_cxySplitBar + m_cxyBarEdge)); + return ((xy >= (xyOff + m_xySplitterPos)) && (xy < (xyOff + m_xySplitterPos + m_cxySplitBar + m_cxyBarEdge))); } void DrawGhostBar() { - RECT rect = { 0 }; + RECT rect = {}; if(GetSplitterBarRect(&rect)) { // convert client to window coordinates T* pT = static_cast(this); - RECT rcWnd = { 0 }; + RECT rcWnd = {}; pT->GetWindowRect(&rcWnd); ::MapWindowPoints(NULL, pT->m_hWnd, (LPPOINT)&rcWnd, 2); ::OffsetRect(&rect, -rcWnd.left, -rcWnd.top); // invert the brush pattern (looks just like frame window sizing) - CWindowDC dc(pT->m_hWnd); - CBrush brush = CDCHandle::GetHalftoneBrush(); + CBrush brush(CDCHandle::GetHalftoneBrush()); if(brush.m_hBrush != NULL) { + CWindowDC dc(pT->m_hWnd); CBrushHandle brushOld = dc.SelectBrush(brush); dc.PatBlt(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, PATINVERT); dc.SelectBrush(brushOld); @@ -967,11 +977,7 @@ public: { if((m_dwExtendedStyle & SPLIT_FIXEDBARSIZE) == 0) { -#ifndef _WIN32_WCE m_cxySplitBar = ::GetSystemMetrics(m_bVertical ? SM_CXSIZEFRAME : SM_CYSIZEFRAME); -#else // CE specific - m_cxySplitBar = 2 * ::GetSystemMetrics(m_bVertical ? SM_CXEDGE : SM_CYEDGE); -#endif // _WIN32_WCE } T* pT = static_cast(this); @@ -986,9 +992,7 @@ public: m_cxyMin = 2 * ::GetSystemMetrics(m_bVertical ? SM_CXEDGE : SM_CYEDGE); } -#ifndef _WIN32_WCE ::SystemParametersInfo(SPI_GETDRAGFULLWINDOWS, 0, &m_bFullDrag, 0); -#endif // !_WIN32_WCE if(bUpdate) UpdateSplitterLayout(); @@ -1061,25 +1065,20 @@ template , public CSplitterImpl< T > { public: - DECLARE_WND_CLASS_EX(NULL, CS_DBLCLKS, COLOR_WINDOW) + DECLARE_WND_CLASS_EX2(NULL, T, CS_DBLCLKS, COLOR_WINDOW) CSplitterWindowImpl(bool bVertical = true) : CSplitterImpl< T >(bVertical) { } BOOL SubclassWindow(HWND hWnd) { -#if (_MSC_VER >= 1300) BOOL bRet = ATL::CWindowImpl< T, TBase, TWinTraits >::SubclassWindow(hWnd); -#else // !(_MSC_VER >= 1300) - typedef ATL::CWindowImpl< T, TBase, TWinTraits > _baseClass; - BOOL bRet = _baseClass::SubclassWindow(hWnd); -#endif // !(_MSC_VER >= 1300) if(bRet != FALSE) { T* pT = static_cast(this); pT->Init(); - SetSplitterRect(); + this->SetSplitterRect(); } return bRet; @@ -1101,7 +1100,7 @@ public: LRESULT OnSize(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) { if(wParam != SIZE_MINIMIZED) - SetSplitterRect(); + this->SetSplitterRect(); bHandled = FALSE; return 1; @@ -1116,7 +1115,7 @@ template class CSplitterWindowT : public CSplitterWindowImpl > { public: - DECLARE_WND_CLASS_EX(_T("WTL_SplitterWindow"), CS_DBLCLKS, COLOR_WINDOW) + DECLARE_WND_CLASS_EX2(_T("WTL_SplitterWindow"), CSplitterWindowT, CS_DBLCLKS, COLOR_WINDOW) CSplitterWindowT() : CSplitterWindowImpl >(t_bVertical) { } @@ -1125,6 +1124,6 @@ public: typedef CSplitterWindowT CSplitterWindow; typedef CSplitterWindowT CHorSplitterWindow; -}; // namespace WTL +} // namespace WTL #endif // __ATLSPLIT_H__ diff --git a/ZbaSDK/SampleCode/PluginWinExe/WTL/atltheme.h b/ZbaSDK/SampleCode/PluginWinExe/WTL/atltheme.h index b453a41bccf62f603acb86ee33faf2d35a651a8a..9855f0014c81329f10de6ff2efd48403ccba956c 100644 --- a/ZbaSDK/SampleCode/PluginWinExe/WTL/atltheme.h +++ b/ZbaSDK/SampleCode/PluginWinExe/WTL/atltheme.h @@ -1,4 +1,4 @@ -// Windows Template Library - WTL version 9.10 +// Windows Template Library - WTL version 10.0 // Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. // // This file is a part of the Windows Template Library. @@ -11,10 +11,6 @@ #pragma once -#ifdef _WIN32_WCE - #error atltheme.h is not supported on Windows CE -#endif - #ifndef __ATLAPP_H__ #error atltheme.h requires atlapp.h to be included first #endif @@ -23,20 +19,7 @@ #error atltheme.h requires atlwin.h to be included first #endif -#if (_WIN32_WINNT < 0x0501) - #error atltheme.h requires _WIN32_WINNT >= 0x0501 -#endif // (_WIN32_WINNT < 0x0501) - -#if defined(_WTL_USE_VSSYM32) || (defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_LONGHORN)) - #include -#else - #ifndef TMSCHEMA_H - #include - #endif -#endif - -#include -#pragma comment(lib, "uxtheme.lib") +#include // Note: To create an application that also runs on older versions of Windows, // use delay load of uxtheme.dll and ensure that no calls to the Theme API are @@ -56,20 +39,6 @@ // Delay load is NOT AUTOMATIC for VC++ 7, you have to link to delayimp.lib, // and add uxtheme.dll in the Linker.Input.Delay Loaded DLLs section of the // project properties. -#if (_MSC_VER < 1300) && !defined(_WTL_NO_THEME_DELAYLOAD) - #pragma comment(lib, "delayimp.lib") - #pragma comment(linker, "/delayload:uxtheme.dll") -#endif // (_MSC_VER < 1300) && !defined(_WTL_NO_THEME_DELAYLOAD) - -// Hack: Signatures in uxtheme.h changed - the only way to check which variant of uxtheme.h -// is included is to check for presence of new defines MAX_THEMECOLOR and MAX_THEMESIZE -// Note: In WinSDK 7.0 (and higher) they are defined with #if (_WIN32_WINNT >= 0x0600), -// so you have to compile with _WTL_NEW_UXTHEME defined for _WIN32_WINNT < 0x0600 -#ifndef _WTL_NEW_UXTHEME - #if defined(MAX_THEMECOLOR) && defined(MAX_THEMESIZE) - #define _WTL_NEW_UXTHEME - #endif // defined(MAX_THEMECOLOR) && defined(MAX_THEMESIZE) -#endif // _WTL_NEW_UXTHEME /////////////////////////////////////////////////////////////////////////////// @@ -224,12 +193,7 @@ public: HRESULT GetThemePartSize(HDC hDC, int nPartID, int nStateID, LPCRECT pRect, enum THEMESIZE eSize, LPSIZE pSize) const { ATLASSERT(m_hTheme != NULL); -#ifdef _WTL_NEW_UXTHEME return ::GetThemePartSize(m_hTheme, hDC, nPartID, nStateID, pRect, eSize, pSize); -#else // !_WTL_NEW_UXTHEME - // Note: The cast to LPRECT is because uxtheme.h incorrectly uses it instead of LPCRECT - return ::GetThemePartSize(m_hTheme, hDC, nPartID, nStateID, (LPRECT)pRect, eSize, pSize); -#endif // !_WTL_NEW_UXTHEME } HRESULT GetThemeTextExtent(HDC hDC, int nPartID, int nStateID, LPCWSTR pszText, int nCharCount, DWORD dwTextFlags, LPCRECT pBoundingRect, LPRECT pExtentRect) const @@ -241,12 +205,7 @@ public: HRESULT GetThemeTextMetrics(HDC hDC, int nPartID, int nStateID, PTEXTMETRICW pTextMetric) const { ATLASSERT(m_hTheme != NULL); -#ifdef _WTL_NEW_UXTHEME return ::GetThemeTextMetrics(m_hTheme, hDC, nPartID, nStateID, pTextMetric); -#else // !_WTL_NEW_UXTHEME - // Note: The cast to PTEXTMETRIC is because uxtheme.h incorrectly uses it instead of PTEXTMETRICW - return ::GetThemeTextMetrics(m_hTheme, hDC, nPartID, nStateID, (PTEXTMETRIC)pTextMetric); -#endif // !_WTL_NEW_UXTHEME } HRESULT GetThemeBackgroundRegion(HDC hDC, int nPartID, int nStateID, LPCRECT pRect, HRGN* pRegion) const @@ -331,23 +290,13 @@ public: HRESULT GetThemeFont(int nPartID, HDC hDC, int nStateID, int nPropID, LOGFONTW* pFont) const { ATLASSERT(m_hTheme != NULL); -#ifdef _WTL_NEW_UXTHEME return ::GetThemeFont(m_hTheme, hDC, nPartID, nStateID, nPropID, pFont); -#else // !_WTL_NEW_UXTHEME - // Note: The cast to LOGFONT* is because uxtheme.h incorrectly uses it instead of LOGFONTW* - return ::GetThemeFont(m_hTheme, hDC, nPartID, nStateID, nPropID, (LOGFONT*)pFont); -#endif // !_WTL_NEW_UXTHEME } HRESULT GetThemeFont(HDC hDC, int nPartID, int nStateID, int nPropID, LOGFONTW* pFont) const { ATLASSERT(m_hTheme != NULL); -#ifdef _WTL_NEW_UXTHEME return ::GetThemeFont(m_hTheme, hDC, nPartID, nStateID, nPropID, pFont); -#else // !_WTL_NEW_UXTHEME - // Note: The cast to LOGFONT* is because uxtheme.h incorrectly uses it instead of LOGFONTW* - return ::GetThemeFont(m_hTheme, hDC, nPartID, nStateID, nPropID, (LOGFONT*)pFont); -#endif // !_WTL_NEW_UXTHEME } HRESULT GetThemeRect(int nPartID, int nStateID, int nPropID, LPRECT pRect) const @@ -407,12 +356,7 @@ public: HRESULT GetThemeSysFont(int nFontID, LOGFONTW* plf) const { ATLASSERT(m_hTheme != NULL); -#ifdef _WTL_NEW_UXTHEME return ::GetThemeSysFont(m_hTheme, nFontID, plf); -#else // !_WTL_NEW_UXTHEME - // Note: The cast to LOGFONT* is because uxtheme.h incorrectly uses it instead of LOGFONTW* - return ::GetThemeSysFont(m_hTheme, nFontID, (LOGFONT*)plf); -#endif // !_WTL_NEW_UXTHEME } HRESULT GetThemeSysString(int nStringID, LPWSTR pszStringBuff, int cchMaxStringChars) const @@ -427,7 +371,6 @@ public: return ::GetThemeSysInt(m_hTheme, nIntID, pnValue); } -#ifdef _WTL_NEW_UXTHEME HTHEME OpenThemeDataEx(HWND hWnd, LPCWSTR pszClassList, DWORD dwFlags) { if(!IsThemingSupported()) @@ -451,7 +394,6 @@ public: return ::GetThemeTransitionDuration(m_hTheme, nPartID, nFromStateID, nToStateID, nPropID, &dwDuration); } #endif // (_WIN32_WINNT >= 0x0600) -#endif // _WTL_NEW_UXTHEME #if (_WIN32_WINNT >= 0x0600) HRESULT GetThemeBitmap(int nPartID, int nStateID, int nPropID, ULONG uFlags, HBITMAP& hBitmap) @@ -525,7 +467,7 @@ inline bool AtlDrawThemeClientEdge(HTHEME hTheme, HWND hWnd, HRGN hRgnUpdate = N if(SUCCEEDED(::GetThemeInt(hTheme, nPartID, nStateID, TMT_SIZINGBORDERWIDTH, &cxBorder))) cyBorder = cxBorder; - RECT rect = { 0 }; + RECT rect = {}; ::GetWindowRect(hWnd, &rect); // Remove the client edge from the update region @@ -552,12 +494,7 @@ inline bool AtlDrawThemeClientEdge(HTHEME hTheme, HWND hWnd, HRGN hRgnUpdate = N if((cxBorder < cxEdge) && (cyBorder < cyEdge)) { if(hBrush == NULL) -// need conditional code because types don't match in winuser.h -#ifdef _WIN64 hBrush = (HBRUSH)::GetClassLongPtr(hWnd, GCLP_HBRBACKGROUND); -#else - hBrush = (HBRUSH)UlongToPtr(::GetClassLongPtr(hWnd, GCLP_HBRBACKGROUND)); -#endif ::InflateRect(&rect, cxBorder - cxEdge, cyBorder - cyEdge); dc.FillRect(&rect, hBrush); @@ -607,7 +544,7 @@ public: if(m_lpstrThemeClassList == NULL) return false; - SecureHelper::strcpyW_x(m_lpstrThemeClassList, cchLen, lpstrThemeClassList); + ATL::Checked::wcscpy_s(m_lpstrThemeClassList, cchLen, lpstrThemeClassList); return true; } @@ -618,7 +555,7 @@ public: if(cchListBuffer < cchLen) return false; - SecureHelper::strcpyW_x(lpstrThemeClassList, cchListBuffer, m_lpstrThemeClassList); + ATL::Checked::wcscpy_s(lpstrThemeClassList, cchListBuffer, m_lpstrThemeClassList); return true; } @@ -652,7 +589,7 @@ public: ATLASSERT(m_lpstrThemeClassList != NULL); if(m_lpstrThemeClassList == NULL) return NULL; - CloseThemeData(); + this->CloseThemeData(); return TBase::OpenThemeData(pT->m_hWnd, m_lpstrThemeClassList); } @@ -667,7 +604,7 @@ public: HRESULT SetWindowTheme(LPCWSTR pszSubAppName, LPCWSTR pszSubIDList) { - if(!IsThemingSupported()) + if(!this->IsThemingSupported()) return S_FALSE; T* pT = static_cast(this); @@ -677,7 +614,7 @@ public: HTHEME GetWindowTheme() const { - if(!IsThemingSupported()) + if(!this->IsThemingSupported()) return NULL; const T* pT = static_cast(this); @@ -687,7 +624,7 @@ public: HRESULT EnableThemeDialogTexture(DWORD dwFlags) { - if(!IsThemingSupported()) + if(!this->IsThemingSupported()) return S_FALSE; T* pT = static_cast(this); @@ -697,7 +634,7 @@ public: BOOL IsThemeDialogTextureEnabled() const { - if(!IsThemingSupported()) + if(!this->IsThemingSupported()) return FALSE; const T* pT = static_cast(this); @@ -707,22 +644,18 @@ public: HRESULT DrawThemeParentBackground(HDC hDC, const RECT* pRect = NULL) { - if(!IsThemingSupported()) + if(!this->IsThemingSupported()) return S_FALSE; T* pT = static_cast(this); ATLASSERT(::IsWindow(pT->m_hWnd)); -#ifdef _WTL_NEW_UXTHEME return ::DrawThemeParentBackground(pT->m_hWnd, hDC, pRect); -#else - return ::DrawThemeParentBackground(pT->m_hWnd, hDC, (RECT*)pRect); -#endif } -#if defined(_WTL_NEW_UXTHEME) && (_WIN32_WINNT >= 0x0600) +#if (_WIN32_WINNT >= 0x0600) HRESULT SetWindowThemeAttribute(WINDOWTHEMEATTRIBUTETYPE type, PVOID pvAttribute, DWORD cbAttribute) { - if(!IsThemingSupported()) + if(!this->IsThemingSupported()) return S_FALSE; T* pT = static_cast(this); @@ -732,7 +665,7 @@ public: HRESULT SetWindowThemeNonClientAttributes(DWORD dwAttributes, DWORD dwMask) { - if(!IsThemingSupported()) + if(!this->IsThemingSupported()) return S_FALSE; T* pT = static_cast(this); @@ -743,14 +676,14 @@ public: HRESULT DrawThemeParentBackgroundEx(HDC hDC, DWORD dwFlags, const RECT* lpRect = NULL) { - if(!IsThemingSupported()) + if(!this->IsThemingSupported()) return S_FALSE; T* pT = static_cast(this); ATLASSERT(::IsWindow(pT->m_hWnd)); return ::DrawThemeParentBackgroundEx(pT->m_hWnd, hDC, dwFlags, lpRect); } -#endif // defined(_WTL_NEW_UXTHEME) && (_WIN32_WINNT >= 0x0600) +#endif // (_WIN32_WINNT >= 0x0600) // Message map and handlers // Note: If you handle any of these messages in your derived class, @@ -773,7 +706,7 @@ public: LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) { - CloseThemeData(); + this->CloseThemeData(); bHandled = FALSE; return 1; @@ -781,9 +714,9 @@ public: LRESULT OnThemeChanged(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) { - CloseThemeData(); + this->CloseThemeData(); if(m_lpstrThemeClassList != NULL) - OpenThemeData(); + this->OpenThemeData(); bHandled = FALSE; return 1; @@ -795,14 +728,14 @@ public: ATLASSERT(::IsWindow(pT->m_hWnd)); LRESULT lRet = 0; bHandled = FALSE; - if(IsThemingSupported() && ((pT->GetExStyle() & WS_EX_CLIENTEDGE) != 0)) + if(this->IsThemingSupported() && ((pT->GetExStyle() & WS_EX_CLIENTEDGE) != 0)) { if((m_dwExtendedStyle & THEME_EX_3DCLIENTEDGE) != 0) { lRet = ::DefWindowProc(pT->m_hWnd, uMsg, wParam, lParam); bHandled = TRUE; } - else if((m_hTheme != NULL) && ((m_dwExtendedStyle & THEME_EX_THEMECLIENTEDGE) != 0)) + else if((this->m_hTheme != NULL) && ((m_dwExtendedStyle & THEME_EX_THEMECLIENTEDGE) != 0)) { HRGN hRgn = (wParam != 1) ? (HRGN)wParam : NULL; if(pT->DrawThemeClientEdge(hRgn)) @@ -817,14 +750,14 @@ public: bool DrawThemeClientEdge(HRGN hRgnUpdate) { T* pT = static_cast(this); - return AtlDrawThemeClientEdge(m_hTheme, pT->m_hWnd, hRgnUpdate, NULL, 0, 0); + return AtlDrawThemeClientEdge(this->m_hTheme, pT->m_hWnd, hRgnUpdate, NULL, 0, 0); } }; /////////////////////////////////////////////////////////////////////////////// // Buffered Paint and Animation -#if defined(_WTL_NEW_UXTHEME) && (_WIN32_WINNT >= 0x0600) +#if (_WIN32_WINNT >= 0x0600) /////////////////////////////////////////////////////////////////////////////// // CBufferedPaintBase - Buffered Paint support for othe classes @@ -989,7 +922,7 @@ public: T* pT = static_cast(this); if(wParam != NULL) { - RECT rect = { 0 }; + RECT rect = {}; pT->GetClientRect(&rect); pT->DoPaint((HDC)wParam, rect); } @@ -1164,7 +1097,7 @@ public: T* pT = static_cast(this); if(wParam != NULL) { - RECT rect = { 0 }; + RECT rect = {}; pT->GetClientRect(&rect); pT->DoPaint((HDC)wParam, rect, m_NewState); } @@ -1250,8 +1183,8 @@ public: END_MSG_MAP() }; -#endif // defined(_WTL_NEW_UXTHEME) && (_WIN32_WINNT >= 0x0600) +#endif // (_WIN32_WINNT >= 0x0600) -}; // namespace WTL +} // namespace WTL #endif // __ATLTHEME_H__ diff --git a/ZbaSDK/SampleCode/PluginWinExe/WTL/atluser.h b/ZbaSDK/SampleCode/PluginWinExe/WTL/atluser.h index 24b9bd21767e75cbd04cedf3a6a56af3aee17b9f..9f8e0f4a3f121618cf74cd2ee0791d0ab84cd882 100644 --- a/ZbaSDK/SampleCode/PluginWinExe/WTL/atluser.h +++ b/ZbaSDK/SampleCode/PluginWinExe/WTL/atluser.h @@ -1,4 +1,4 @@ -// Windows Template Library - WTL version 9.10 +// Windows Template Library - WTL version 10.0 // Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. // // This file is a part of the Windows Template Library. @@ -54,7 +54,7 @@ namespace WTL inline int AtlMessageBox(HWND hWndOwner, ATL::_U_STRINGorID message, ATL::_U_STRINGorID title = (LPCTSTR)NULL, UINT uType = MB_OK | MB_ICONINFORMATION) { - ATLASSERT(hWndOwner == NULL || ::IsWindow(hWndOwner)); + ATLASSERT((hWndOwner == NULL) || ::IsWindow(hWndOwner)); LPTSTR lpstrMessage = NULL; if(IS_INTRESOURCE(message.m_lpstr)) @@ -78,7 +78,7 @@ inline int AtlMessageBox(HWND hWndOwner, ATL::_U_STRINGorID message, ATL::_U_STR } LPTSTR lpstrTitle = NULL; - if(IS_INTRESOURCE(title.m_lpstr) && LOWORD(title.m_lpstr) != 0) + if(IS_INTRESOURCE(title.m_lpstr) && (LOWORD(title.m_lpstr) != 0)) { for(int nLen = 256; ; nLen *= 2) { @@ -110,19 +110,6 @@ inline int AtlMessageBox(HWND hWndOwner, ATL::_U_STRINGorID message, ATL::_U_STR /////////////////////////////////////////////////////////////////////////////// // CMenu -#if (WINVER >= 0x0500) - #ifndef MII_SIZEOF_STRUCT - #define MII_SIZEOF_STRUCT(structname, member) (((int)((LPBYTE)(&((structname*)0)->member) - ((LPBYTE)((structname*)0)))) + sizeof(((structname*)0)->member)) - #endif - #define MENUITEMINFO_SIZE_VERSION_400A MII_SIZEOF_STRUCT(MENUITEMINFOA, cch) - #define MENUITEMINFO_SIZE_VERSION_400W MII_SIZEOF_STRUCT(MENUITEMINFOW, cch) - #ifdef UNICODE - #define MENUITEMINFO_SIZE_VERSION_400 MENUITEMINFO_SIZE_VERSION_400W - #else - #define MENUITEMINFO_SIZE_VERSION_400 MENUITEMINFO_SIZE_VERSION_400A - #endif // !UNICODE -#endif // (WINVER >= 0x0500) - class CMenuItemInfo : public MENUITEMINFO { public: @@ -130,14 +117,6 @@ public: { memset(this, 0, sizeof(MENUITEMINFO)); cbSize = sizeof(MENUITEMINFO); -#if (WINVER >= 0x0500) - // adjust struct size if running on older version of Windows - if(AtlIsOldWindows()) - { - ATLASSERT(cbSize > MENUITEMINFO_SIZE_VERSION_400); // must be - cbSize = MENUITEMINFO_SIZE_VERSION_400; - } -#endif // (WINVER >= 0x0500) } }; @@ -161,7 +140,7 @@ public: ~CMenuT() { - if(t_bManaged && m_hMenu != NULL) + if(t_bManaged && (m_hMenu != NULL)) DestroyMenu(); } @@ -174,7 +153,7 @@ public: void Attach(HMENU hMenuNew) { ATLASSERT(::IsMenu(hMenuNew)); - if(t_bManaged && m_hMenu != NULL && m_hMenu != hMenuNew) + if(t_bManaged && (m_hMenu != NULL) && (m_hMenu != hMenuNew)) ::DestroyMenu(m_hMenu); m_hMenu = hMenuNew; } @@ -217,14 +196,12 @@ public: return (m_hMenu != NULL) ? TRUE : FALSE; } -#ifndef _WIN32_WCE BOOL LoadMenuIndirect(const void* lpMenuTemplate) { ATLASSERT(m_hMenu == NULL); m_hMenu = ::LoadMenuIndirect(lpMenuTemplate); return (m_hMenu != NULL) ? TRUE : FALSE; } -#endif // !_WIN32_WCE BOOL DestroyMenu() { @@ -246,27 +223,17 @@ public: BOOL TrackPopupMenu(UINT nFlags, int x, int y, HWND hWnd, LPCRECT lpRect = NULL) { ATLASSERT(::IsMenu(m_hMenu)); -#ifndef _WIN32_WCE -#if (WINVER >= 0x0500) x = _FixTrackMenuPopupX(x, y); -#endif // !(WINVER >= 0x0500) return ::TrackPopupMenu(m_hMenu, nFlags, x, y, 0, hWnd, lpRect); -#else // CE specific - lpRect; - return ::TrackPopupMenuEx(m_hMenu, nFlags, x, y, hWnd, NULL); -#endif // _WIN32_WCE } BOOL TrackPopupMenuEx(UINT uFlags, int x, int y, HWND hWnd, LPTPMPARAMS lptpm = NULL) { ATLASSERT(::IsMenu(m_hMenu)); -#if (WINVER >= 0x0500) && !defined(_WIN32_WCE) x = _FixTrackMenuPopupX(x, y); -#endif // (WINVER >= 0x0500) && !defined(_WIN32_WCE) return ::TrackPopupMenuEx(m_hMenu, uFlags, x, y, hWnd, lptpm); } -#if (WINVER >= 0x0500) && !defined(_WIN32_WCE) // helper that fixes popup menu X position when it's off-screen static int _FixTrackMenuPopupX(int x, int y) { @@ -302,7 +269,6 @@ public: ATLASSERT(::IsMenu(m_hMenu)); return ::SetMenuInfo(m_hMenu, lpMenuInfo); } -#endif // (WINVER >= 0x0500) && !defined(_WIN32_WCE) // Menu Item Operations BOOL AppendMenu(UINT nFlags, UINT_PTR nIDNewItem = 0, LPCTSTR lpszNewItem = NULL) @@ -318,7 +284,6 @@ public: return ::AppendMenu(m_hMenu, nFlags | MF_POPUP, (UINT_PTR)hSubMenu, lpszNewItem); } -#ifndef _WIN32_WCE BOOL AppendMenu(UINT nFlags, UINT_PTR nIDNewItem, HBITMAP hBmp) { ATLASSERT(::IsMenu(m_hMenu)); @@ -331,7 +296,6 @@ public: ATLASSERT(::IsMenu(hSubMenu)); return ::AppendMenu(m_hMenu, nFlags | (MF_BITMAP | MF_POPUP), (UINT_PTR)hSubMenu, (LPCTSTR)hBmp); } -#endif // !_WIN32_WCE UINT CheckMenuItem(UINT nIDCheckItem, UINT nCheck) { @@ -345,7 +309,6 @@ public: return ::EnableMenuItem(m_hMenu, nIDEnableItem, nEnable); } -#ifndef _WIN32_WCE BOOL HiliteMenuItem(HWND hWnd, UINT uIDHiliteItem, UINT uHilite) { ATLASSERT(::IsMenu(m_hMenu)); @@ -382,7 +345,6 @@ public: return ::GetMenuString(m_hMenu, nIDItem, NULL, 0, nFlags); } -#ifndef _ATL_NO_COM BOOL GetMenuString(UINT nIDItem, BSTR& bstrText, UINT nFlags) const { USES_CONVERSION; @@ -397,7 +359,7 @@ public: } nLen++; // increment to include terminating NULL char - CTempBuffer buff; + ATL::CTempBuffer buff; LPTSTR lpszText = buff.Allocate(nLen); if(lpszText == NULL) return FALSE; @@ -408,42 +370,9 @@ public: bstrText = ::SysAllocString(T2OLE(lpszText)); return (bstrText != NULL) ? TRUE : FALSE; } -#endif // !_ATL_NO_COM - -#elif (_ATL_VER >= 0x0800) - int GetMenuItemCount() const - { - ATLASSERT(::IsMenu(m_hMenu)); - return ATL::GetMenuItemCount(m_hMenu); - } - - UINT GetMenuItemID(int nPos) const - { - ATLASSERT(::IsMenu(m_hMenu)); - return ATL::GetMenuItemID(m_hMenu, nPos); - } - - UINT GetMenuState(UINT nID, UINT nFlags) const - { - ATLASSERT(::IsMenu(m_hMenu)); - return ATL::GetMenuState(m_hMenu, nID, nFlags); - } - int GetMenuString(UINT nIDItem, LPTSTR lpString, int nMaxCount, UINT nFlags) const - { - ATLASSERT(::IsMenu(m_hMenu)); - return ATL::GetMenuString(m_hMenu, nIDItem, lpString, nMaxCount, nFlags); - } - - int GetMenuStringLen(UINT nIDItem, UINT nFlags) const - { - ATLASSERT(::IsMenu(m_hMenu)); - return ATL::GetMenuString(m_hMenu, nIDItem, NULL, 0, nFlags); - } -#endif // (_ATL_VER >= 0x0800) - -#if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) - int GetMenuString(UINT nIDItem, _CSTRING_NS::CString& strText, UINT nFlags) const +#ifdef __ATLSTR_H__ + int GetMenuString(UINT nIDItem, ATL::CString& strText, UINT nFlags) const { ATLASSERT(::IsMenu(m_hMenu)); @@ -459,7 +388,7 @@ public: strText.ReleaseBuffer(); return nRet; } -#endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) +#endif // __ATLSTR_H__ CMenuHandle GetSubMenu(int nPos) const { @@ -480,7 +409,6 @@ public: return ::InsertMenu(m_hMenu, nPosition, nFlags | MF_POPUP, (UINT_PTR)hSubMenu, lpszNewItem); } -#ifndef _WIN32_WCE BOOL InsertMenu(UINT nPosition, UINT nFlags, UINT_PTR nIDNewItem, HBITMAP hBmp) { ATLASSERT(::IsMenu(m_hMenu)); @@ -519,7 +447,6 @@ public: ATLASSERT(::IsMenu(hSubMenu)); return ::ModifyMenu(m_hMenu, nPosition, nFlags | (MF_BITMAP | MF_POPUP), (UINT_PTR)hSubMenu, (LPCTSTR)hBmp); } -#endif // !_WIN32_WCE BOOL RemoveMenu(UINT nPosition, UINT nFlags) { @@ -527,13 +454,11 @@ public: return ::RemoveMenu(m_hMenu, nPosition, nFlags); } -#ifndef _WIN32_WCE BOOL SetMenuItemBitmaps(UINT nPosition, UINT nFlags, HBITMAP hBmpUnchecked, HBITMAP hBmpChecked) { ATLASSERT(::IsMenu(m_hMenu)); return ::SetMenuItemBitmaps(m_hMenu, nPosition, nFlags, hBmpUnchecked, hBmpChecked); } -#endif // !_WIN32_WCE BOOL CheckMenuRadioItem(UINT nIDFirst, UINT nIDLast, UINT nIDItem, UINT nFlags) { @@ -553,7 +478,6 @@ public: return (BOOL)::SetMenuItemInfo(m_hMenu, uItem, bByPosition, lpmii); } -#ifndef _WIN32_WCE BOOL InsertMenuItem(UINT uItem, BOOL bByPosition, LPMENUITEMINFO lpmii) { ATLASSERT(::IsMenu(m_hMenu)); @@ -596,7 +520,6 @@ public: ATLASSERT(::IsMenu(m_hMenu)); return ::GetMenuContextHelpId(m_hMenu); } -#endif // !_WIN32_WCE }; @@ -615,7 +538,7 @@ public: ~CAcceleratorT() { - if(t_bManaged && m_hAccel != NULL) + if(t_bManaged && (m_hAccel != NULL)) ::DestroyAcceleratorTable(m_hAccel); } @@ -627,7 +550,7 @@ public: void Attach(HACCEL hAccel) { - if(t_bManaged && m_hAccel != NULL) + if(t_bManaged && (m_hAccel != NULL)) ::DestroyAcceleratorTable(m_hAccel); m_hAccel = hAccel; } @@ -669,7 +592,6 @@ public: } // Operations -#ifndef _WIN32_WCE int CopyAcceleratorTable(LPACCEL lpAccelDst, int cEntries) { ATLASSERT(m_hAccel != NULL); @@ -682,7 +604,6 @@ public: ATLASSERT(m_hAccel != NULL); return ::CopyAcceleratorTable(m_hAccel, NULL, 0); } -#endif // !_WIN32_WCE BOOL TranslateAccelerator(HWND hWnd, LPMSG pMsg) { @@ -712,7 +633,7 @@ public: ~CIconT() { - if(t_bManaged && m_hIcon != NULL) + if(t_bManaged && (m_hIcon != NULL)) ::DestroyIcon(m_hIcon); } @@ -724,7 +645,7 @@ public: void Attach(HICON hIcon) { - if(t_bManaged && m_hIcon != NULL) + if(t_bManaged && (m_hIcon != NULL)) ::DestroyIcon(m_hIcon); m_hIcon = hIcon; } @@ -755,7 +676,6 @@ public: return m_hIcon; } -#ifndef _WIN32_WCE HICON LoadOEMIcon(LPCTSTR lpstrIconName) { ATLASSERT(m_hIcon == NULL); @@ -789,7 +709,6 @@ public: m_hIcon = ::CreateIconFromResourceEx(pbBits, cbBits, TRUE, dwVersion, cxDesired, cyDesired, uFlags); return m_hIcon; } -#endif // !_WIN32_WCE HICON CreateIconIndirect(PICONINFO pIconInfo) { @@ -799,7 +718,6 @@ public: return m_hIcon; } -#ifndef _WIN32_WCE HICON ExtractIcon(LPCTSTR lpszExeFileName, UINT nIconIndex) { ATLASSERT(m_hIcon == NULL); @@ -816,7 +734,6 @@ public: m_hIcon = ::ExtractAssociatedIcon(hInst, lpIconPath, lpiIcon); return m_hIcon; } -#endif // !_WIN32_WCE BOOL DestroyIcon() { @@ -828,7 +745,6 @@ public: } // Operations -#ifndef _WIN32_WCE HICON CopyIcon() { ATLASSERT(m_hIcon != NULL); @@ -840,26 +756,17 @@ public: ATLASSERT(m_hIcon != NULL); return ::DuplicateIcon(NULL, m_hIcon); } -#endif // !_WIN32_WCE BOOL DrawIcon(HDC hDC, int x, int y) { ATLASSERT(m_hIcon != NULL); -#ifndef _WIN32_WCE return ::DrawIcon(hDC, x, y, m_hIcon); -#else // CE specific - return ::DrawIconEx(hDC, x, y, m_hIcon, 0, 0, 0, NULL, DI_NORMAL); -#endif // _WIN32_WCE } BOOL DrawIcon(HDC hDC, POINT pt) { ATLASSERT(m_hIcon != NULL); -#ifndef _WIN32_WCE return ::DrawIcon(hDC, pt.x, pt.y, m_hIcon); -#else // CE specific - return ::DrawIconEx(hDC, pt.x, pt.y, m_hIcon, 0, 0, 0, NULL, DI_NORMAL); -#endif // _WIN32_WCE } BOOL DrawIconEx(HDC hDC, int x, int y, int cxWidth, int cyWidth, UINT uStepIfAniCur = 0, HBRUSH hbrFlickerFreeDraw = NULL, UINT uFlags = DI_NORMAL) @@ -874,7 +781,6 @@ public: return ::DrawIconEx(hDC, pt.x, pt.y, m_hIcon, size.cx, size.cy, uStepIfAniCur, hbrFlickerFreeDraw, uFlags); } -#ifndef _WIN32_WCE BOOL GetIconInfo(PICONINFO pIconInfo) const { ATLASSERT(m_hIcon != NULL); @@ -921,22 +827,19 @@ public: return ::LoadIconWithScaleDown(NULL, (LPCWSTR)lpstrIconName, cx, cy, &m_hIcon); } #endif // defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_LONGHORN) -#endif // !_WIN32_WCE // Helper -#ifndef _WIN32_WCE static bool IsOEMIcon(LPCTSTR lpstrIconName) { #if (WINVER >= 0x0600) - return (lpstrIconName == IDI_APPLICATION || lpstrIconName == IDI_ASTERISK || lpstrIconName == IDI_EXCLAMATION || - lpstrIconName == IDI_HAND || lpstrIconName == IDI_QUESTION || lpstrIconName == IDI_WINLOGO || - lpstrIconName == IDI_SHIELD); + return ((lpstrIconName == IDI_APPLICATION) || (lpstrIconName == IDI_ASTERISK) || (lpstrIconName == IDI_EXCLAMATION) || + (lpstrIconName == IDI_HAND) || (lpstrIconName == IDI_QUESTION) || (lpstrIconName == IDI_WINLOGO) || + (lpstrIconName == IDI_SHIELD)); #else // !(WINVER >= 0x0600) - return (lpstrIconName == IDI_APPLICATION || lpstrIconName == IDI_ASTERISK || lpstrIconName == IDI_EXCLAMATION || - lpstrIconName == IDI_HAND || lpstrIconName == IDI_QUESTION || lpstrIconName == IDI_WINLOGO); + return ((lpstrIconName == IDI_APPLICATION) || (lpstrIconName == IDI_ASTERISK) || (lpstrIconName == IDI_EXCLAMATION) || + (lpstrIconName == IDI_HAND) || (lpstrIconName == IDI_QUESTION) || (lpstrIconName == IDI_WINLOGO)); #endif // !(WINVER >= 0x0600) } -#endif // !_WIN32_WCE }; typedef CIconT CIconHandle; @@ -963,7 +866,7 @@ public: ~CCursorT() { - if(t_bManaged && m_hCursor != NULL) + if(t_bManaged && (m_hCursor != NULL)) DestroyCursor(); } @@ -975,7 +878,7 @@ public: void Attach(HCURSOR hCursor) { - if(t_bManaged && m_hCursor != NULL) + if(t_bManaged && (m_hCursor != NULL)) DestroyCursor(); m_hCursor = hCursor; } @@ -1002,20 +905,12 @@ public: HCURSOR LoadSysCursor(LPCTSTR lpstrCursorName) { ATLASSERT(m_hCursor == NULL); -#if (WINVER >= 0x0500) - ATLASSERT(lpstrCursorName == IDC_ARROW || lpstrCursorName == IDC_IBEAM || lpstrCursorName == IDC_WAIT || - lpstrCursorName == IDC_CROSS || lpstrCursorName == IDC_UPARROW || lpstrCursorName == IDC_SIZE || - lpstrCursorName == IDC_ICON || lpstrCursorName == IDC_SIZENWSE || lpstrCursorName == IDC_SIZENESW || - lpstrCursorName == IDC_SIZEWE || lpstrCursorName == IDC_SIZENS || lpstrCursorName == IDC_SIZEALL || - lpstrCursorName == IDC_NO || lpstrCursorName == IDC_APPSTARTING || lpstrCursorName == IDC_HELP || - lpstrCursorName == IDC_HAND); -#else // !(WINVER >= 0x0500) - ATLASSERT(lpstrCursorName == IDC_ARROW || lpstrCursorName == IDC_IBEAM || lpstrCursorName == IDC_WAIT || - lpstrCursorName == IDC_CROSS || lpstrCursorName == IDC_UPARROW || lpstrCursorName == IDC_SIZE || - lpstrCursorName == IDC_ICON || lpstrCursorName == IDC_SIZENWSE || lpstrCursorName == IDC_SIZENESW || - lpstrCursorName == IDC_SIZEWE || lpstrCursorName == IDC_SIZENS || lpstrCursorName == IDC_SIZEALL || - lpstrCursorName == IDC_NO || lpstrCursorName == IDC_APPSTARTING || lpstrCursorName == IDC_HELP); -#endif // !(WINVER >= 0x0500) + ATLASSERT((lpstrCursorName == IDC_ARROW) || (lpstrCursorName == IDC_IBEAM) || (lpstrCursorName == IDC_WAIT) || + (lpstrCursorName == IDC_CROSS) || (lpstrCursorName == IDC_UPARROW) || (lpstrCursorName == IDC_SIZE) || + (lpstrCursorName == IDC_ICON) || (lpstrCursorName == IDC_SIZENWSE) || (lpstrCursorName == IDC_SIZENESW) || + (lpstrCursorName == IDC_SIZEWE) || (lpstrCursorName == IDC_SIZENS) || (lpstrCursorName == IDC_SIZEALL) || + (lpstrCursorName == IDC_NO) || (lpstrCursorName == IDC_APPSTARTING) || (lpstrCursorName == IDC_HELP) || + (lpstrCursorName == IDC_HAND)); m_hCursor = ::LoadCursor(NULL, lpstrCursorName); return m_hCursor; } @@ -1033,7 +928,6 @@ public: return m_hCursor; } -#ifndef _WIN32_WCE HCURSOR LoadCursorFromFile(LPCTSTR pstrFilename) { ATLASSERT(m_hCursor == NULL); @@ -1041,18 +935,14 @@ public: m_hCursor = ::LoadCursorFromFile(pstrFilename); return m_hCursor; } -#endif // !_WIN32_WCE -#if !defined(_WIN32_WCE) || ((_WIN32_WCE >= 0x400) && !(defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP))) HCURSOR CreateCursor(int xHotSpot, int yHotSpot, int nWidth, int nHeight, CONST VOID *pvANDPlane, CONST VOID *pvXORPlane) { ATLASSERT(m_hCursor == NULL); m_hCursor = ::CreateCursor(ModuleHelper::GetResourceInstance(), xHotSpot, yHotSpot, nWidth, nHeight, pvANDPlane, pvXORPlane); return m_hCursor; } -#endif // !defined(_WIN32_WCE) || ((_WIN32_WCE >= 0x400) && !(defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP))) -#ifndef _WIN32_WCE HCURSOR CreateCursorFromResource(PBYTE pBits, DWORD dwResSize, DWORD dwVersion = 0x00030000) { ATLASSERT(m_hCursor == NULL); @@ -1069,39 +959,29 @@ public: m_hCursor = (HCURSOR)::CreateIconFromResourceEx(pbBits, cbBits, FALSE, dwVersion, cxDesired, cyDesired, uFlags); return m_hCursor; } -#endif // !_WIN32_WCE BOOL DestroyCursor() { ATLASSERT(m_hCursor != NULL); -#if !defined(_WIN32_WCE) || ((_WIN32_WCE >= 0x400) && !(defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP))) BOOL bRet = ::DestroyCursor(m_hCursor); if(bRet != FALSE) m_hCursor = NULL; return bRet; -#else // !(!defined(_WIN32_WCE) || ((_WIN32_WCE >= 0x400) && !(defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP)))) - ATLTRACE2(atlTraceUI, 0, _T("Warning: This version of Windows CE does not have ::DestroyCursor()\n")); - return FALSE; -#endif // !(!defined(_WIN32_WCE) || ((_WIN32_WCE >= 0x400) && !(defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP)))) } // Operations -#ifndef _WIN32_WCE HCURSOR CopyCursor() { ATLASSERT(m_hCursor != NULL); return (HCURSOR)::CopyIcon((HICON)m_hCursor); } -#endif // !_WIN32_WCE -#if (WINVER >= 0x0500) && !defined(_WIN32_WCE) BOOL GetCursorInfo(LPCURSORINFO pCursorInfo) { ATLASSERT(m_hCursor != NULL); ATLASSERT(pCursorInfo != NULL); return ::GetCursorInfo(pCursorInfo); } -#endif // (WINVER >= 0x0500) && !defined(_WIN32_WCE) }; typedef CCursorT CCursorHandle; @@ -1148,7 +1028,6 @@ public: return true; } -#ifndef _WIN32_WCE bool LoadEx(ATL::_U_STRINGorID ID, ATL::_U_STRINGorID Type, WORD wLanguage) { ATLASSERT(m_hResource == NULL); @@ -1167,7 +1046,6 @@ public: return true; } -#endif // !_WIN32_WCE // Misc. operations DWORD GetSize() const @@ -1235,7 +1113,7 @@ inline HBITMAP AtlLoadSysBitmap(ATL::_U_STRINGorID bitmap) { #ifdef _DEBUG WORD wID = LOWORD(bitmap.m_lpstr); - ATLASSERT(wID >= 32734 && wID <= 32767); + ATLASSERT((wID >= 32734) && (wID <= 32767)); #endif // _DEBUG return ::LoadBitmap(NULL, bitmap.m_lpstr); } @@ -1248,20 +1126,12 @@ inline HCURSOR AtlLoadCursor(ATL::_U_STRINGorID cursor) inline HCURSOR AtlLoadSysCursor(LPCTSTR lpCursorName) { -#if (WINVER >= 0x0500) - ATLASSERT(lpCursorName == IDC_ARROW || lpCursorName == IDC_IBEAM || lpCursorName == IDC_WAIT || - lpCursorName == IDC_CROSS || lpCursorName == IDC_UPARROW || lpCursorName == IDC_SIZE || - lpCursorName == IDC_ICON || lpCursorName == IDC_SIZENWSE || lpCursorName == IDC_SIZENESW || - lpCursorName == IDC_SIZEWE || lpCursorName == IDC_SIZENS || lpCursorName == IDC_SIZEALL || - lpCursorName == IDC_NO || lpCursorName == IDC_APPSTARTING || lpCursorName == IDC_HELP || - lpCursorName == IDC_HAND); -#else // !(WINVER >= 0x0500) - ATLASSERT(lpCursorName == IDC_ARROW || lpCursorName == IDC_IBEAM || lpCursorName == IDC_WAIT || - lpCursorName == IDC_CROSS || lpCursorName == IDC_UPARROW || lpCursorName == IDC_SIZE || - lpCursorName == IDC_ICON || lpCursorName == IDC_SIZENWSE || lpCursorName == IDC_SIZENESW || - lpCursorName == IDC_SIZEWE || lpCursorName == IDC_SIZENS || lpCursorName == IDC_SIZEALL || - lpCursorName == IDC_NO || lpCursorName == IDC_APPSTARTING || lpCursorName == IDC_HELP); -#endif // !(WINVER >= 0x0500) + ATLASSERT((lpCursorName == IDC_ARROW) || (lpCursorName == IDC_IBEAM) || (lpCursorName == IDC_WAIT) || + (lpCursorName == IDC_CROSS) || (lpCursorName == IDC_UPARROW) || (lpCursorName == IDC_SIZE) || + (lpCursorName == IDC_ICON) || (lpCursorName == IDC_SIZENWSE) || (lpCursorName == IDC_SIZENESW) || + (lpCursorName == IDC_SIZEWE) || (lpCursorName == IDC_SIZENS) || (lpCursorName == IDC_SIZEALL) || + (lpCursorName == IDC_NO) || (lpCursorName == IDC_APPSTARTING) || (lpCursorName == IDC_HELP) || + (lpCursorName == IDC_HAND)); return ::LoadCursor(NULL, lpCursorName); } @@ -1270,20 +1140,18 @@ inline HICON AtlLoadIcon(ATL::_U_STRINGorID icon) return ::LoadIcon(ModuleHelper::GetResourceInstance(), icon.m_lpstr); } -#ifndef _WIN32_WCE inline HICON AtlLoadSysIcon(LPCTSTR lpIconName) { #if (WINVER >= 0x0600) - ATLASSERT(lpIconName == IDI_APPLICATION || lpIconName == IDI_ASTERISK || lpIconName == IDI_EXCLAMATION || - lpIconName == IDI_HAND || lpIconName == IDI_QUESTION || lpIconName == IDI_WINLOGO || - lpIconName == IDI_SHIELD); + ATLASSERT((lpIconName == IDI_APPLICATION) || (lpIconName == IDI_ASTERISK) || (lpIconName == IDI_EXCLAMATION) || + (lpIconName == IDI_HAND) || (lpIconName == IDI_QUESTION) || (lpIconName == IDI_WINLOGO) || + (lpIconName == IDI_SHIELD)); #else // !(WINVER >= 0x0600) - ATLASSERT(lpIconName == IDI_APPLICATION || lpIconName == IDI_ASTERISK || lpIconName == IDI_EXCLAMATION || - lpIconName == IDI_HAND || lpIconName == IDI_QUESTION || lpIconName == IDI_WINLOGO); + ATLASSERT((lpIconName == IDI_APPLICATION) || (lpIconName == IDI_ASTERISK) || (lpIconName == IDI_EXCLAMATION) || + (lpIconName == IDI_HAND) || (lpIconName == IDI_QUESTION) || (lpIconName == IDI_WINLOGO)); #endif // !(WINVER >= 0x0600) return ::LoadIcon(NULL, lpIconName); } -#endif // !_WIN32_WCE inline HBITMAP AtlLoadBitmapImage(ATL::_U_STRINGorID bitmap, UINT fuLoad = LR_DEFAULTCOLOR) { @@ -1303,7 +1171,7 @@ inline HICON AtlLoadIconImage(ATL::_U_STRINGorID icon, UINT fuLoad = LR_DEFAULTC #ifdef OEMRESOURCE inline HBITMAP AtlLoadSysBitmapImage(WORD wBitmapID, UINT fuLoad = LR_DEFAULTCOLOR) { - ATLASSERT(wBitmapID >= 32734 && wBitmapID <= 32767); + ATLASSERT((wBitmapID >= 32734) && (wBitmapID <= 32767)); ATLASSERT((fuLoad & LR_LOADFROMFILE) == 0); // this one doesn't load from a file return (HBITMAP)::LoadImage(NULL, MAKEINTRESOURCE(wBitmapID), IMAGE_BITMAP, 0, 0, fuLoad); } @@ -1313,7 +1181,7 @@ inline HCURSOR AtlLoadSysCursorImage(ATL::_U_STRINGorID cursor, UINT fuLoad = LR { #ifdef _DEBUG WORD wID = LOWORD(cursor.m_lpstr); - ATLASSERT((wID >= 32512 && wID <= 32516) || (wID >= 32640 && wID <= 32648) || (wID == 32650) || (wID == 32651)); + ATLASSERT(((wID >= 32512) && (wID <= 32516)) || ((wID >= 32640) && (wID <= 32648)) || (wID == 32650) || (wID == 32651)); ATLASSERT((fuLoad & LR_LOADFROMFILE) == 0); // this one doesn't load from a file #endif // _DEBUG return (HCURSOR)::LoadImage(NULL, cursor.m_lpstr, IMAGE_CURSOR, cxDesired, cyDesired, fuLoad); @@ -1323,36 +1191,12 @@ inline HICON AtlLoadSysIconImage(ATL::_U_STRINGorID icon, UINT fuLoad = LR_DEFAU { #ifdef _DEBUG WORD wID = LOWORD(icon.m_lpstr); - ATLASSERT(wID >= 32512 && wID <= 32517); + ATLASSERT((wID >= 32512) && (wID <= 32517)); ATLASSERT((fuLoad & LR_LOADFROMFILE) == 0); // this one doesn't load from a file #endif // _DEBUG return (HICON)::LoadImage(NULL, icon.m_lpstr, IMAGE_ICON, cxDesired, cyDesired, fuLoad); } -#if (_ATL_VER < 0x0700) -inline int AtlLoadString(UINT uID, LPTSTR lpBuffer, int nBufferMax) -{ - return ::LoadString(ModuleHelper::GetResourceInstance(), uID, lpBuffer, nBufferMax); -} -#else - -using ATL::AtlLoadString; - -#endif // (_ATL_VER < 0x0700) - -#ifdef _WIN32_WCE // CE only direct access to the resource -inline LPCTSTR AtlLoadString(UINT uID) -{ - LPCTSTR s = (LPCTSTR)::LoadString(ModuleHelper::GetResourceInstance(), uID, NULL, 0); -#ifdef DEBUG // Check for null-termination - if(s != NULL) - // Note: RC -n compiles null-terminated resource strings - ATLASSERT(s[*((WORD*)s -1) - 1] == L'\0'); -#endif - return s; -} -#endif // _WIN32_WCE - inline bool AtlLoadString(UINT uID, BSTR& bstrText) { USES_CONVERSION; @@ -1382,6 +1226,6 @@ inline bool AtlLoadString(UINT uID, BSTR& bstrText) return (bstrText != NULL) ? true : false; } -}; // namespace WTL +} // namespace WTL #endif // __ATLUSER_H__ diff --git a/ZbaSDK/SampleCode/PluginWinExe/WTL/atlwinx.h b/ZbaSDK/SampleCode/PluginWinExe/WTL/atlwinx.h index e6873a3f0a6684d5af9f61560996c3327c9d191f..b89c513782be1e29f7f7a1b05e13c3e143d1a721 100644 --- a/ZbaSDK/SampleCode/PluginWinExe/WTL/atlwinx.h +++ b/ZbaSDK/SampleCode/PluginWinExe/WTL/atlwinx.h @@ -1,4 +1,4 @@ -// Windows Template Library - WTL version 9.10 +// Windows Template Library - WTL version 10.0 // Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. // // This file is a part of the Windows Template Library. @@ -15,17 +15,45 @@ #error atlwinx.h requires atlapp.h to be included first #endif -#if (_ATL_VER >= 0x0700) - #include -#endif // (_ATL_VER >= 0x0700) +#include /////////////////////////////////////////////////////////////////////////////// // Classes in this file: // -// _U_RECT -// _U_MENUorID -// _U_STRINGorID +// CWindowEx + + +///////////////////////////////////////////////////////////////////////////// +// Additional macros needed for template classes + +#ifndef DECLARE_WND_CLASS_EX2 + #define DECLARE_WND_CLASS_EX2(WndClassName, EnclosingClass, style, bkgnd) \ + static ATL::CWndClassInfo& GetWndClassInfo() \ + { \ + static ATL::CWndClassInfo wc = \ + { \ + { sizeof(WNDCLASSEX), style, EnclosingClass::StartWindowProc, \ + 0, 0, NULL, NULL, NULL, (HBRUSH)(bkgnd + 1), NULL, WndClassName, NULL }, \ + NULL, NULL, IDC_ARROW, TRUE, 0, _T("") \ + }; \ + return wc; \ + } +#endif // DECLARE_WND_CLASS_EX2 + +#ifndef DECLARE_WND_SUPERCLASS2 + #define DECLARE_WND_SUPERCLASS2(WndClassName, EnclosingClass, OrigWndClassName) \ + static ATL::CWndClassInfo& GetWndClassInfo() \ + { \ + static ATL::CWndClassInfo wc = \ + { \ + { sizeof(WNDCLASSEX), 0, EnclosingClass::StartWindowProc, \ + 0, 0, NULL, NULL, NULL, NULL, NULL, WndClassName, NULL }, \ + OrigWndClassName, NULL, NULL, TRUE, 0, _T("") \ + }; \ + return wc; \ + } +#endif // DECLARE_WND_SUPERCLASS2 /////////////////////////////////////////////////////////////////////////////// @@ -85,7 +113,6 @@ inline LRESULT WtlReflectNotificationsFiltered(HWND hWndParent, UINT uMsg, WPARA hWndChild = ((LPNMHDR)lParam)->hwndFrom; idFrom = ((LPNMHDR)lParam)->idFrom; break; -#ifndef _WIN32_WCE case WM_PARENTNOTIFY: switch(LOWORD(wParam)) { @@ -100,7 +127,6 @@ inline LRESULT WtlReflectNotificationsFiltered(HWND hWndParent, UINT uMsg, WPARA break; } break; -#endif // !_WIN32_WCE case WM_DRAWITEM: if(wParam) // not from a menu { @@ -133,9 +159,6 @@ inline LRESULT WtlReflectNotificationsFiltered(HWND hWndParent, UINT uMsg, WPARA case WM_CHARTOITEM: case WM_HSCROLL: case WM_VSCROLL: - hWndChild = (HWND)lParam; - idFrom = (UINT_PTR)::GetDlgCtrlID(hWndChild); - break; case WM_CTLCOLORBTN: case WM_CTLCOLORDLG: case WM_CTLCOLOREDIT: @@ -178,14 +201,14 @@ inline LRESULT WtlReflectNotificationsFiltered(HWND hWndParent, UINT uMsg, WPARA return lResult; } -}; // namespace WTL +} // namespace WTL // Try to prevent problems with WM_CTLCOLOR* messages when // the message wasn't really handled #define REFLECT_NOTIFICATIONS_EX() \ { \ bHandled = TRUE; \ - lResult = ReflectNotifications(uMsg, wParam, lParam, bHandled); \ + lResult = this->ReflectNotifications(uMsg, wParam, lParam, bHandled); \ if((lResult == 0) && (uMsg >= WM_CTLCOLORMSGBOX) && (uMsg <= WM_CTLCOLORSTATIC)) \ bHandled = FALSE; \ if(bHandled) \ @@ -195,7 +218,7 @@ inline LRESULT WtlReflectNotificationsFiltered(HWND hWndParent, UINT uMsg, WPARA #define REFLECT_NOTIFICATIONS_MSG_FILTERED(uMsgFilter) \ { \ bHandled = TRUE; \ - lResult = WTL::WtlReflectNotificationsFiltered(m_hWnd, uMsg, wParam, lParam, bHandled, uMsgFilter, 0, NULL); \ + lResult = WTL::WtlReflectNotificationsFiltered(this->m_hWnd, uMsg, wParam, lParam, bHandled, uMsgFilter, 0, NULL); \ if(bHandled) \ return TRUE; \ } @@ -203,7 +226,7 @@ inline LRESULT WtlReflectNotificationsFiltered(HWND hWndParent, UINT uMsg, WPARA #define REFLECT_NOTIFICATIONS_ID_FILTERED(idFromFilter) \ { \ bHandled = TRUE; \ - lResult = WTL::WtlReflectNotificationsFiltered(m_hWnd, uMsg, wParam, lParam, bHandled, WM_NULL, idFromFilter, NULL); \ + lResult = WTL::WtlReflectNotificationsFiltered(this->m_hWnd, uMsg, wParam, lParam, bHandled, WM_NULL, idFromFilter, NULL); \ if(bHandled) \ return TRUE; \ } @@ -211,7 +234,7 @@ inline LRESULT WtlReflectNotificationsFiltered(HWND hWndParent, UINT uMsg, WPARA #define REFLECT_NOTIFICATIONS_HWND_FILTERED(hWndChildFilter) \ { \ bHandled = TRUE; \ - lResult = WTL::WtlReflectNotificationsFiltered(m_hWnd, uMsg, wParam, lParam, bHandled, WM_NULL, 0, hWndChildFilter); \ + lResult = WTL::WtlReflectNotificationsFiltered(this->m_hWnd, uMsg, wParam, lParam, bHandled, WM_NULL, 0, hWndChildFilter); \ if(bHandled) \ return TRUE; \ } @@ -219,7 +242,7 @@ inline LRESULT WtlReflectNotificationsFiltered(HWND hWndParent, UINT uMsg, WPARA #define REFLECT_NOTIFICATIONS_MSG_ID_FILTERED(uMsgFilter, idFromFilter) \ { \ bHandled = TRUE; \ - lResult = WTL::WtlReflectNotificationsFiltered(m_hWnd, uMsg, wParam, lParam, bHandled, uMsgFilter, idFromFilter, NULL); \ + lResult = WTL::WtlReflectNotificationsFiltered(this->m_hWnd, uMsg, wParam, lParam, bHandled, uMsgFilter, idFromFilter, NULL); \ if(bHandled) \ return TRUE; \ } @@ -227,296 +250,374 @@ inline LRESULT WtlReflectNotificationsFiltered(HWND hWndParent, UINT uMsg, WPARA #define REFLECT_NOTIFICATIONS_MSG_HWND_FILTERED(uMsgFilter, hWndChildFilter) \ { \ bHandled = TRUE; \ - lResult = WTL::WtlReflectNotificationsFiltered(m_hWnd, uMsg, wParam, lParam, bHandled, uMsgFilter, 0, hWndChildFilter); \ + lResult = WTL::WtlReflectNotificationsFiltered(this->m_hWnd, uMsg, wParam, lParam, bHandled, uMsgFilter, 0, hWndChildFilter); \ if(bHandled) \ return TRUE; \ } #define REFLECT_COMMAND(id, code) \ - if(uMsg == WM_COMMAND && id == LOWORD(wParam) && code == HIWORD(wParam)) \ + if((uMsg == WM_COMMAND) && (id == LOWORD(wParam)) && (code == HIWORD(wParam))) \ { \ bHandled = TRUE; \ - lResult = ReflectNotifications(uMsg, wParam, lParam, bHandled); \ + lResult = this->ReflectNotifications(uMsg, wParam, lParam, bHandled); \ if(bHandled) \ return TRUE; \ } #define REFLECT_COMMAND_ID(id) \ - if(uMsg == WM_COMMAND && id == LOWORD(wParam)) \ + if((uMsg == WM_COMMAND) && (id == LOWORD(wParam))) \ { \ bHandled = TRUE; \ - lResult = ReflectNotifications(uMsg, wParam, lParam, bHandled); \ + lResult = this->ReflectNotifications(uMsg, wParam, lParam, bHandled); \ if(bHandled) \ return TRUE; \ } #define REFLECT_COMMAND_CODE(code) \ - if(uMsg == WM_COMMAND && code == HIWORD(wParam)) \ + if((uMsg == WM_COMMAND) && (code == HIWORD(wParam))) \ { \ bHandled = TRUE; \ - lResult = ReflectNotifications(uMsg, wParam, lParam, bHandled); \ + lResult = this->ReflectNotifications(uMsg, wParam, lParam, bHandled); \ if(bHandled) \ return TRUE; \ } #define REFLECT_COMMAND_RANGE(idFirst, idLast) \ - if(uMsg == WM_COMMAND && LOWORD(wParam) >= idFirst && LOWORD(wParam) <= idLast) \ + if((uMsg == WM_COMMAND) && (LOWORD(wParam) >= idFirst) && (LOWORD(wParam) <= idLast)) \ { \ bHandled = TRUE; \ - lResult = ReflectNotifications(uMsg, wParam, lParam, bHandled); \ + lResult = this->ReflectNotifications(uMsg, wParam, lParam, bHandled); \ if(bHandled) \ return TRUE; \ } #define REFLECT_COMMAND_RANGE_CODE(idFirst, idLast, code) \ - if(uMsg == WM_COMMAND && code == HIWORD(wParam) && LOWORD(wParam) >= idFirst && LOWORD(wParam) <= idLast) \ + if((uMsg == WM_COMMAND) && (code == HIWORD(wParam)) && (LOWORD(wParam) >= idFirst) && (LOWORD(wParam) <= idLast)) \ { \ bHandled = TRUE; \ - lResult = ReflectNotifications(uMsg, wParam, lParam, bHandled); \ + lResult = this->ReflectNotifications(uMsg, wParam, lParam, bHandled); \ if(bHandled) \ return TRUE; \ } #define REFLECT_NOTIFY(id, cd) \ - if(uMsg == WM_NOTIFY && id == ((LPNMHDR)lParam)->idFrom && cd == ((LPNMHDR)lParam)->code) \ + if((uMsg == WM_NOTIFY) && (id == ((LPNMHDR)lParam)->idFrom) && (cd == ((LPNMHDR)lParam)->code)) \ { \ bHandled = TRUE; \ - lResult = ReflectNotifications(uMsg, wParam, lParam, bHandled); \ + lResult = this->ReflectNotifications(uMsg, wParam, lParam, bHandled); \ if(bHandled) \ return TRUE; \ } #define REFLECT_NOTIFY_ID(id) \ - if(uMsg == WM_NOTIFY && id == ((LPNMHDR)lParam)->idFrom) \ + if((uMsg == WM_NOTIFY) && (id == ((LPNMHDR)lParam)->idFrom)) \ { \ bHandled = TRUE; \ - lResult = ReflectNotifications(uMsg, wParam, lParam, bHandled); \ + lResult = this->ReflectNotifications(uMsg, wParam, lParam, bHandled); \ if(bHandled) \ return TRUE; \ } #define REFLECT_NOTIFY_CODE(cd) \ - if(uMsg == WM_NOTIFY && cd == ((LPNMHDR)lParam)->code) \ + if((uMsg == WM_NOTIFY) && (cd == ((LPNMHDR)lParam)->code)) \ { \ bHandled = TRUE; \ - lResult = ReflectNotifications(uMsg, wParam, lParam, bHandled); \ + lResult = this->ReflectNotifications(uMsg, wParam, lParam, bHandled); \ if(bHandled) \ return TRUE; \ } #define REFLECT_NOTIFY_RANGE(idFirst, idLast) \ - if(uMsg == WM_NOTIFY && ((LPNMHDR)lParam)->idFrom >= idFirst && ((LPNMHDR)lParam)->idFrom <= idLast) \ + if((uMsg == WM_NOTIFY) && (((LPNMHDR)lParam)->idFrom >= idFirst) && (((LPNMHDR)lParam)->idFrom <= idLast)) \ { \ bHandled = TRUE; \ - lResult = ReflectNotifications(uMsg, wParam, lParam, bHandled); \ + lResult = this->ReflectNotifications(uMsg, wParam, lParam, bHandled); \ if(bHandled) \ return TRUE; \ } #define REFLECT_NOTIFY_RANGE_CODE(idFirst, idLast, cd) \ - if(uMsg == WM_NOTIFY && cd == ((LPNMHDR)lParam)->code && ((LPNMHDR)lParam)->idFrom >= idFirst && ((LPNMHDR)lParam)->idFrom <= idLast) \ + if((uMsg == WM_NOTIFY) && (cd == ((LPNMHDR)lParam)->code) && (((LPNMHDR)lParam)->idFrom >= idFirst) && (((LPNMHDR)lParam)->idFrom <= idLast)) \ { \ bHandled = TRUE; \ - lResult = ReflectNotifications(uMsg, wParam, lParam, bHandled); \ + lResult = this->ReflectNotifications(uMsg, wParam, lParam, bHandled); \ if(bHandled) \ return TRUE; \ } /////////////////////////////////////////////////////////////////////////////// -// Reflected message handler macros for message maps (for ATL 3.0) +// GetClassLong/SetClassLong redefinition to avoid problems with class members + +#ifdef SetClassLongPtrA + #undef SetClassLongPtrA + inline LONG_PTR SetClassLongPtrA(HWND hWnd, int nIndex, LONG_PTR dwNewLong) + { + return ::SetClassLongA(hWnd, nIndex, LONG(dwNewLong)); + } +#endif -#if (_ATL_VER < 0x0700) +#ifdef SetClassLongPtrW + #undef SetClassLongPtrW + inline LONG_PTR SetClassLongPtrW(HWND hWnd, int nIndex, LONG_PTR dwNewLong) + { + return ::SetClassLongW(hWnd, nIndex, LONG(dwNewLong)); + } +#endif -#define REFLECTED_COMMAND_HANDLER(id, code, func) \ - if(uMsg == OCM_COMMAND && id == LOWORD(wParam) && code == HIWORD(wParam)) \ - { \ - bHandled = TRUE; \ - lResult = func(HIWORD(wParam), LOWORD(wParam), (HWND)lParam, bHandled); \ - if(bHandled) \ - return TRUE; \ +#ifdef GetClassLongPtrA + #undef GetClassLongPtrA + inline LONG_PTR GetClassLongPtrA(HWND hWnd, int nIndex) + { + return ::GetClassLongA(hWnd, nIndex); + } +#endif + +#ifdef GetClassLongPtrW + #undef GetClassLongPtrW + inline LONG_PTR GetClassLongPtrW(HWND hWnd, int nIndex) + { + return ::GetClassLongW(hWnd, nIndex); + } +#endif + + +/////////////////////////////////////////////////////////////////////////////// +// CWindowEx - extension of ATL::CWindow + +namespace WTL +{ + +class CWindowEx : public ATL::CWindow +{ +public: + CWindowEx(HWND hWnd = NULL) : ATL::CWindow(hWnd) + { } + + CWindowEx& operator =(HWND hWnd) + { + m_hWnd = hWnd; + return *this; } -#define REFLECTED_COMMAND_ID_HANDLER(id, func) \ - if(uMsg == OCM_COMMAND && id == LOWORD(wParam)) \ - { \ - bHandled = TRUE; \ - lResult = func(HIWORD(wParam), LOWORD(wParam), (HWND)lParam, bHandled); \ - if(bHandled) \ - return TRUE; \ + operator HWND() const + { + return m_hWnd; } -#define REFLECTED_COMMAND_CODE_HANDLER(code, func) \ - if(uMsg == OCM_COMMAND && code == HIWORD(wParam)) \ - { \ - bHandled = TRUE; \ - lResult = func(HIWORD(wParam), LOWORD(wParam), (HWND)lParam, bHandled); \ - if(bHandled) \ - return TRUE; \ +// Methods + BOOL PrintWindow(HDC hDC, UINT uFlags = 0) + { + ATLASSERT(::IsWindow(m_hWnd)); + return ::PrintWindow(m_hWnd, hDC, uFlags); } -#define REFLECTED_COMMAND_RANGE_HANDLER(idFirst, idLast, func) \ - if(uMsg == OCM_COMMAND && LOWORD(wParam) >= idFirst && LOWORD(wParam) <= idLast) \ - { \ - bHandled = TRUE; \ - lResult = func(HIWORD(wParam), LOWORD(wParam), (HWND)lParam, bHandled); \ - if(bHandled) \ - return TRUE; \ + BOOL DragDetect(POINT pt) + { + ATLASSERT(::IsWindow(m_hWnd)); + return ::DragDetect(m_hWnd, pt); } -#define REFLECTED_COMMAND_RANGE_CODE_HANDLER(idFirst, idLast, code, func) \ - if(uMsg == OCM_COMMAND && code == HIWORD(wParam) && LOWORD(wParam) >= idFirst && LOWORD(wParam) <= idLast) \ - { \ - bHandled = TRUE; \ - lResult = func(HIWORD(wParam), LOWORD(wParam), (HWND)lParam, bHandled); \ - if(bHandled) \ - return TRUE; \ + BOOL DragDetect() + { + ATLASSERT(::IsWindow(m_hWnd)); + + POINT pt = {}; + ::GetCursorPos(&pt); + return ::DragDetect(m_hWnd, pt); } -#define REFLECTED_NOTIFY_HANDLER(id, cd, func) \ - if(uMsg == OCM_NOTIFY && id == ((LPNMHDR)lParam)->idFrom && cd == ((LPNMHDR)lParam)->code) \ - { \ - bHandled = TRUE; \ - lResult = func((int)wParam, (LPNMHDR)lParam, bHandled); \ - if(bHandled) \ - return TRUE; \ + CWindowEx GetAncestor(UINT uFlags) const + { + ATLASSERT(::IsWindow(m_hWnd)); + return CWindowEx(::GetAncestor(m_hWnd, uFlags)); } -#define REFLECTED_NOTIFY_ID_HANDLER(id, func) \ - if(uMsg == OCM_NOTIFY && id == ((LPNMHDR)lParam)->idFrom) \ - { \ - bHandled = TRUE; \ - lResult = func((int)wParam, (LPNMHDR)lParam, bHandled); \ - if(bHandled) \ - return TRUE; \ + // Note: Does not work properly on Vista Aero and above + BOOL AnimateWindow(DWORD dwFlags, DWORD dwTime = 200) + { + ATLASSERT(::IsWindow(m_hWnd)); + return ::AnimateWindow(m_hWnd, dwTime, dwFlags); } -#define REFLECTED_NOTIFY_CODE_HANDLER(cd, func) \ - if(uMsg == OCM_NOTIFY && cd == ((LPNMHDR)lParam)->code) \ - { \ - bHandled = TRUE; \ - lResult = func((int)wParam, (LPNMHDR)lParam, bHandled); \ - if(bHandled) \ - return TRUE; \ + BOOL FlashWindowEx(DWORD dwFlags, UINT uCount, DWORD dwTimeout = 0) + { + ATLASSERT(::IsWindow(m_hWnd)); + + FLASHWINFO fi = { sizeof(FLASHWINFO) }; + fi.hwnd = m_hWnd; + fi.dwFlags = dwFlags; + fi.uCount = uCount; + fi.dwTimeout = dwTimeout; + return ::FlashWindowEx(&fi); } -#define REFLECTED_NOTIFY_RANGE_HANDLER(idFirst, idLast, func) \ - if(uMsg == OCM_NOTIFY && ((LPNMHDR)lParam)->idFrom >= idFirst && ((LPNMHDR)lParam)->idFrom <= idLast) \ - { \ - bHandled = TRUE; \ - lResult = func((int)wParam, (LPNMHDR)lParam, bHandled); \ - if(bHandled) \ - return TRUE; \ + BOOL StopFlashWindowEx() + { + ATLASSERT(::IsWindow(m_hWnd)); + + FLASHWINFO fi = { sizeof(FLASHWINFO) }; + fi.hwnd = m_hWnd; + fi.dwFlags = FLASHW_STOP; + return ::FlashWindowEx(&fi); } -#define REFLECTED_NOTIFY_RANGE_CODE_HANDLER(idFirst, idLast, cd, func) \ - if(uMsg == OCM_NOTIFY && cd == ((LPNMHDR)lParam)->code && ((LPNMHDR)lParam)->idFrom >= idFirst && ((LPNMHDR)lParam)->idFrom <= idLast) \ - { \ - bHandled = TRUE; \ - lResult = func((int)wParam, (LPNMHDR)lParam, bHandled); \ - if(bHandled) \ - return TRUE; \ +// Class long properties + DWORD GetClassLong(int nIndex) const + { + ATLASSERT(::IsWindow(m_hWnd)); + return ::GetClassLong(m_hWnd, nIndex); } -#endif // (_ATL_VER < 0x0700) + DWORD SetClassLong(int nIndex, LONG dwNewLong) + { + ATLASSERT(::IsWindow(m_hWnd)); + return ::SetClassLong(m_hWnd, nIndex, dwNewLong); + } + ULONG_PTR GetClassLongPtr(int nIndex) const + { + ATLASSERT(::IsWindow(m_hWnd)); + return ::GetClassLongPtr(m_hWnd, nIndex); + } -/////////////////////////////////////////////////////////////////////////////// -// Dual argument helper classes (for ATL 3.0) + ULONG_PTR SetClassLongPtr(int nIndex, LONG_PTR dwNewLong) + { + ATLASSERT(::IsWindow(m_hWnd)); + return ::SetClassLongPtr(m_hWnd, nIndex, dwNewLong); + } -#if (_ATL_VER < 0x0700) +// Layered windows + BOOL SetLayeredWindowAttributes(COLORREF crlKey, BYTE byteAlpha, DWORD dwFlags) + { + ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT((GetExStyle() & WS_EX_LAYERED) != 0); -namespace ATL -{ + return ::SetLayeredWindowAttributes(m_hWnd, crlKey, byteAlpha, dwFlags); + } -class _U_RECT -{ -public: - _U_RECT(LPRECT lpRect) : m_lpRect(lpRect) - { } - _U_RECT(RECT& rc) : m_lpRect(&rc) - { } - LPRECT m_lpRect; -}; + BOOL UpdateLayeredWindow(HDC hdcDst, LPPOINT pptDst, LPSIZE psize, HDC hdcSrc, LPPOINT pptSrc, COLORREF crlKey, BLENDFUNCTION* pblend, DWORD dwFlags) + { + ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT((GetExStyle() & WS_EX_LAYERED) != 0); -class _U_MENUorID -{ -public: - _U_MENUorID(HMENU hMenu) : m_hMenu(hMenu) - { } - _U_MENUorID(UINT nID) : m_hMenu((HMENU)LongToHandle(nID)) - { } - HMENU m_hMenu; -}; + return ::UpdateLayeredWindow(m_hWnd, hdcDst, pptDst, psize, hdcSrc, pptSrc, crlKey, pblend, dwFlags); + } -class _U_STRINGorID -{ -public: - _U_STRINGorID(LPCTSTR lpString) : m_lpstr(lpString) - { } - _U_STRINGorID(UINT nID) : m_lpstr(MAKEINTRESOURCE(nID)) - { } - LPCTSTR m_lpstr; -}; + BOOL UpdateLayeredWindow(LPPOINT pptDst = NULL) + { + ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT((GetExStyle() & WS_EX_LAYERED) != 0); -}; // namespace ATL + return ::UpdateLayeredWindow(m_hWnd, NULL, pptDst, NULL, NULL, NULL, CLR_NONE, NULL, 0); + } -#endif // (_ATL_VER < 0x0700) + BOOL GetLayeredWindowAttributes(COLORREF* pcrlKey, BYTE* pbyteAlpha, DWORD* pdwFlags) const + { + ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT((GetExStyle() & WS_EX_LAYERED) != 0); + return ::GetLayeredWindowAttributes(m_hWnd, pcrlKey, pbyteAlpha, pdwFlags); + } -namespace WTL -{ +// Mouse tracking + BOOL StartTrackMouseLeave() + { + ATLASSERT(::IsWindow(m_hWnd)); -/////////////////////////////////////////////////////////////////////////////// -// Forward notifications support for message maps (for ATL 3.0) + TRACKMOUSEEVENT tme = {}; + tme.cbSize = sizeof(TRACKMOUSEEVENT); + tme.dwFlags = TME_LEAVE; + tme.hwndTrack = m_hWnd; + return ::TrackMouseEvent(&tme); + } -#if (_ATL_VER < 0x0700) + BOOL StartTrackMouse(DWORD dwFlags, DWORD dwHoverTime = HOVER_DEFAULT) + { + ATLASSERT(::IsWindow(m_hWnd)); -// forward notifications support -#define FORWARD_NOTIFICATIONS() \ - { \ - bHandled = TRUE; \ - lResult = WTL::Atl3ForwardNotifications(m_hWnd, uMsg, wParam, lParam, bHandled); \ - if(bHandled) \ - return TRUE; \ + TRACKMOUSEEVENT tme = {}; + tme.cbSize = sizeof(TRACKMOUSEEVENT); + tme.dwFlags = dwFlags; + tme.hwndTrack = m_hWnd; + tme.dwHoverTime = dwHoverTime; + return ::TrackMouseEvent(&tme); } -static LRESULT Atl3ForwardNotifications(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) -{ - LRESULT lResult = 0; - switch(uMsg) + BOOL CancelTrackMouse(DWORD dwType) { - case WM_COMMAND: - case WM_NOTIFY: -#ifndef _WIN32_WCE - case WM_PARENTNOTIFY: -#endif // !_WIN32_WCE - case WM_DRAWITEM: - case WM_MEASUREITEM: - case WM_COMPAREITEM: - case WM_DELETEITEM: - case WM_VKEYTOITEM: - case WM_CHARTOITEM: - case WM_HSCROLL: - case WM_VSCROLL: - case WM_CTLCOLORBTN: - case WM_CTLCOLORDLG: - case WM_CTLCOLOREDIT: - case WM_CTLCOLORLISTBOX: - case WM_CTLCOLORMSGBOX: - case WM_CTLCOLORSCROLLBAR: - case WM_CTLCOLORSTATIC: - lResult = ::SendMessage(::GetParent(hWnd), uMsg, wParam, lParam); - break; - default: - bHandled = FALSE; - break; + ATLASSERT(::IsWindow(m_hWnd)); + + TRACKMOUSEEVENT tme = {}; + tme.cbSize = sizeof(TRACKMOUSEEVENT); + tme.dwFlags = TME_CANCEL | dwType; + tme.hwndTrack = m_hWnd; + return ::TrackMouseEvent(&tme); } - return lResult; -} -#endif // (_ATL_VER < 0x0700) +// CString support +#ifdef __ATLSTR_H__ + int GetWindowText(ATL::CString& strText) const + { + int nLength = GetWindowTextLength(); + LPTSTR pszText = strText.GetBuffer(nLength + 1); + nLength = ::GetWindowText(m_hWnd, pszText, nLength + 1); + strText.ReleaseBuffer(nLength); + + return nLength; + } + + UINT GetDlgItemText(int nID, ATL::CString& strText) const + { + ATLASSERT(::IsWindow(m_hWnd)); + + HWND hItem = GetDlgItem(nID); + if(hItem != NULL) + { + int nLength = ::GetWindowTextLength(hItem); + LPTSTR pszText = strText.GetBuffer(nLength + 1); + nLength = ::GetWindowText(hItem, pszText, nLength + 1); + strText.ReleaseBuffer(nLength); + + return nLength; + } + else + { + strText.Empty(); + + return 0; + } + } +#endif // __ATLSTR_H__ + +// Dialog window only + UINT DlgGetDefID() const + { + ATLASSERT(::IsWindow(m_hWnd)); + + LRESULT lRet = ::SendMessage(m_hWnd, DM_GETDEFID, 0, 0L); + UINT uID = 0U; + if(HIWORD(lRet) == DC_HASDEFID) + uID = LOWORD(lRet); + + return uID; + } + + void DlgSetDefID(UINT uID) + { + ATLASSERT(::IsWindow(m_hWnd)); + + ::SendMessage(m_hWnd, DM_SETDEFID, uID, 0L); + } + + void DlgReposition() + { + ATLASSERT(::IsWindow(m_hWnd)); + + ::SendMessage(m_hWnd, DM_REPOSITION, 0, 0L); + } +}; -}; // namespace WTL +} // namespace WTL #endif // __ATLWINX_H__ diff --git a/ZbaSDK/SampleCode/PluginWinExe/stdafx.h b/ZbaSDK/SampleCode/PluginWinExe/stdafx.h index a98bccce4db56ea7c43a1ae15d2b244dda8d9ec1..71bce6b7ea49a4717a5dc1e7095491f27a0b68c1 100644 --- a/ZbaSDK/SampleCode/PluginWinExe/stdafx.h +++ b/ZbaSDK/SampleCode/PluginWinExe/stdafx.h @@ -6,11 +6,13 @@ #pragma once // Change these values to use different versions -#define WINVER 0x0502 -#define _WIN32_WINNT 0x0502 -#define _WIN32_IE 0x0600 +#define WINVER 0x0501 +#define _WIN32_WINNT 0x0501 +#define _WIN32_IE 0x0800 #define _RICHEDIT_VER 0x0500 +#define _CRT_SECURE_NO_WARNINGS + #include /// ʹATLCString #define _CSTRING_NS ATL @@ -49,5 +51,8 @@ using namespace ATL; #pragma warning( disable : 4610 ) #pragma warning( disable : 4206 ) +#include +#include + #import "..\\Bin\\ZbaEngine.dll" no_namespace, raw_interfaces_only, raw_native_types, named_guids -#import "..\\Bin\\ZbaBase.dll" no_namespace, raw_interfaces_only, raw_native_types, named_guids +#import "..\\Bin\\ZbaBase.dll" no_namespace, raw_interfaces_only, raw_native_types, named_guids \ No newline at end of file