éåžžããæ°ãããèšèªãžã®ããŒã«ã©ã€ãºã¯åçŽãªåé¡ã§ãïŒéçºçšïŒã1ã€ãŸãã¯2ã€ã®å®æ°ãååŸãããã«ãã·ã¹ãã ã調æŽããŸããäžè¬çã«ã¯ããã ãã§ãã æ®ãã¯æè¡è ãšç¿»èš³è ã®è©ã«ããã£ãŠããŸãã ããããã¢ã©ãã¢èªã§ã¯å³ããå·Šã«æžããããã€ã³ã¿ãŒãã§ã€ã¹ã«å€ãã®å€æŽãå¿ èŠã«ãªããŸãã ãã®çµéšã«ã€ããŠã¯èšäºã§èª¬æããŸãã
ãã¹ãŠãå±éããïŒå®éã«ã¯ããã§ã¯ãªãïŒ
ã¢ã©ãã¢èªã«ç¿»èš³ãããæåã®è¡ã翻蚳ããæ¥ããã£ãšåã«ãç§ã¯RTLïŒå³ããå·ŠãžïŒæ²ããããªããã®çšèªã®è¯ããã·ã¢èªã®ç¿»èš³ãæãã€ããŸããã§ããïŒã€ã³ã¿ãŒãã§ãŒã¹ãæ±ããŸããã å®éãããŒã¿ãŒãŠã£ã³ããŠã®äœçœ®ã¯æžã蟌ã¿ã®æ¹åã«åŸããŸãããŠã£ã³ããŠãéãããã¯ãã¹ããšã¹ã¯ããŒã©ãŒãå·Šã«æŒããã¡ã€ã³ã¡ãã¥ãŒãå³ã«æŒããé²è¡ç¶æ³ããŒãå³ããå·Šã«å®è¡ããŸãã äžè¬çã«ããã¹ãŠãéããŸã§ãã ãã®åäœãå®çŸããæãç°¡åãªæ¹æ³ã¯ãåæåã³ãŒãã«æ¬¡ã®åŒã³åºããæ¿å ¥ããããšã§ãïŒæåã®ãŠã£ã³ããŠãäœæããåã«ïŒã
SetProcessDefaultLayoutïŒLAYOUT_RTLïŒ;
ãã®åŸãçŸåšã®ããã»ã¹ã§äœæããããã¹ãŠã®ãããã¬ãã«ãŠã£ã³ããŠãWS_EX_LAYOUTRTLã¹ã¿ã€ã«ã§äœæãããŸãã ãã®ã¹ã¿ã€ã«ã¯ããã¹ãŠã®åãŠã£ã³ããŠã«ãç¶æ¿ãããŸãïŒãã¹ãŠã§ã¯ãããŸããããæåã®è¿äŒŒãšããŠç¶æ¿ãããŸãïŒã ãšããã§ããã©ãŒåãããåäœãå®çŸããæãç°¡åãªæ¹æ³ã¯ãäœææã«WS_EX_LAYOUTRTLããã¹ãŠã®ãããã¬ãã«ãŠã£ã³ããŠã«èšå®ããããšã§ã¯ãããŸããã ãããã«ããŠãã次ã®ããã«ãªããŸãã
ããã«å¯ŸåŠããå¿ èŠãããå€ãã®åé¡ã確èªã§ããŸãïŒããŒã«ããŒã®ãã©ãŒã¢ã€ã³ã³ïŒ1ïŒãšãã¿ã³ïŒ2ïŒãæ¡åŒµããã¹ãïŒ3ïŒãã¿ã¹ã¯ã®äžã®äžèŽããªãèæ¯ïŒ4ïŒèŠåºããå¥èªç¹ãééã£ãæ¹æ³ïŒ5ïŒããã³t .pã
å®éãWS_EX_LAYOUTRTLã¹ã¿ã€ã«ã¯ã¯ã©ã€ã¢ã³ã座æšïŒããã³WM_NCPAINTã§äœ¿çšããã座æšïŒãæ¡åŒµããŸãã ããã§ããããã¯å³äžç¹ã®å§ãŸãã«ãªãã暪座æšã¯å³ããå·Šã«å¢å ããŸãã ãŸãããã®ãŠã£ã³ããŠã«é¢é£ä»ããããŠãããã¹ãŠã®ããã€ã¹ã³ã³ããã¹ãïŒHDCïŒã¯LAYOUT_RTLïŒç°¡åãªèª¬æã¯ãã¡ã ïŒã«ãªããŸãã
ãŠã£ã³ããŠåº§æšãå€æãã
Windowsã®RTLã®äžçã§ã¯ã ã¯ã©ã€ã¢ã³ã座æšã®ã¿ãå±éãããŸãã ãŠã£ã³ããŠïŒãã¹ã¯ãããïŒã¯éåžžã®LTRã®åãã®ãŸãŸã§ãã ãã®ç¶æ³ã§æåã«ç ç²ã«ãªãã®ã¯ãClientToScreenã¡ãœãããšScreenToClientã¡ãœããã§ãïŒãã®èšäºã®ã解説ãã»ã¯ã·ã§ã³ïŒã ãããã®ã¡ãœãããçŽæ¥äœ¿çšããªããããRTLã®ç¶æ³ãåŠçããæ¹æ³ãã©ãããŒã«æããã®ã«ååã§ããããšãå€æããŸããã Windowséçºè ãåãããšãã§ããªãã£ãçç±ãèŠã€ããã®ã楜ããããšããããŸãã ãšããã§ãMSDNã®æšå¥šäºé ã¯ãMapWindowPointsã¡ãœããã䜿çšããããšã§ãã æ°ããæžãããã³ãŒãã§ã¯ãããããããšãæã ãã£ãã®ã§ãããããŸããã
ïŒãããžã§ã¯ãã§ã®åçŽãªæ€çŽ¢ã§ã¯æ€åºãããªãããïŒããã«äžæå¿«ãªã®ã¯ããŠã£ã³ããŠãšã¯ã©ã€ã¢ã³ãã®åº§æšã®èšç®ã«æ··åããããšã§ãã äŸã¯ããããã³ã°åº§æšã»ã¯ã·ã§ã³ã«ãããŸãã 幞ããªããšã«ãããã¯ç§ãã¡ã®ãããžã§ã¯ãã«ã¯åœãŠã¯ãŸããŸããã§ããïŒãã¹ãŠã®çãããå Žæã調ã¹ãŸãããããã¹ãã§ã¯åé¡ã¯èŠã€ãããŸããã§ããïŒã ç§ã¯äœãèšãããšãã§ããŸãïŒã¡ããã©ãããããªãã§ãã ããã
ããã¹ãããã©ãŒãªã³ã°ãããçç±ã®æ²ããç©èª
ããªãã«ãŒã«å¯ŸåŠããããã«ãæšæºã®ãããã¡ãªã³ã°æ¹æ³ã䜿çšããŸãããã¹ãŠã®æç»ã¯ã¡ã¢ãªå ã®BITMAPã§è¡ãããæçµçã«ã¯BitBltã䜿çšããŠããã€ã¹ã³ã³ããã¹ãã«åçŽã«ã³ããŒãããŸãã åé¡ã®åå ã¯ãããã€ãã®CreateCompatibleDCã¡ãœãããšSelectObjectã¡ãœããïŒ/*..*/ãããããããïŒã§äœ¿çšããã©ãããŒãã€ãŸããæ¢å®ã®ãã©ã¡ãŒã¿ãŒãæã€ã³ã³ã¹ãã©ã¯ã¿ãŒãæã€ã¯ã©ã¹ã«ãããŸããã
æ瀺çãªCBitmapDCïŒHBITMAPãããããããHDC compatibleWith = 0ïŒ;
ãã®ã³ã³ã¹ãã©ã¯ã¿ãŒã¯ã³ãŒãã®ããããå Žæã§äœ¿çšãããããããŸãã«ããã©ã«ããã©ã¡ãŒã¿ãŒã§çºçããããšã§ãã çµæãšããŠãçµæã®ããã€ã¹ã³ã³ããã¹ãã¯ãã¹ã¯ããããšäºææ§ãããïŒãã¹ã¯ããã座æšãšåæ§ã«LTRã®ãŸãŸã§ãïŒããã€ã³ããããŠã£ã³ããŠãšã¯äºææ§ããããŸããã§ããã ããã©ã«ãã®ãªãã·ã§ã³ã奜ãã§ã¯ãªãã£ãã ãã®èª€è§£ãä¿®æ£ããåŸãã¯ããã«è¯ããªããŸããã
ãšããã§ãããã¹ããé 眮ããããã®ãã©ã°ãå€æŽããªãã£ãã«ããããããïŒDT_LEFTã䜿çšïŒãããã¹ãã¯å³ã«ããã·ã¥ãããŸãã ããŸãããã ãã§ãããã¯çŽ æŽãããããšã§ãã
çµµãæãã ãªã圌ãã¯å¥œè»¢ãã
åã®ã¹ã¯ãªãŒã³ã·ã§ãããããããããã«ãã€ã¡ãŒãžã®ãã©ãŒãªã³ã°ã«é¢ããåé¡ã¯æªè§£æ±ºã®ãŸãŸã§ãã å®éã«ã¯ããã®ã»ã¯ã·ã§ã³ããã€ã¡ãŒãžãªã¹ã-æ°ã«ããªãããã«ããšåŒã¶æ¹ãæ£ããã§ãããã å®éã補åå ã®åé¡ã®ããã°ã©ãã£ãã¯ã¯ãã¹ãŠHIMAGELISTã®åœ¢åŒã§è¡šç€ºãããŸãã ãããŠãããã§ã®åé¡ã¯1ã€ã«ã¯ã»ã©é ãã
æç»äžã«ã€ã¡ãŒãžãªã¹ãã®ã¢ã€ã³ã³ãæ¡å€§ããªãããã«ãMSDNã¯ã€ã¡ãŒãžãªã¹ãã®äœææã«ILC_MIRRORããã³ILC_PERITEMMIRRORãã©ã°ã䜿çšããããšããå§ãããŸãã Windows XPïŒWindows XP SP3ã®æå°ãµããŒãããŒãžã§ã³ã¯ã·ã¹ãã èŠä»¶ã§æå®ãããŠããŸãïŒä»¥éãILC_MIRRORãã©ã°ã®åäœãšãããã®ãã©ã°ã®çµåã®åäœã«éãã¯èŠãããŸããã§ããã ãããã«ããããã®ãã©ã°ãè¿œå ããŠãã»ãšãã©åé¡ã¯è§£æ±ºããŸããã§ããã
補åã®ã»ãšãã©ãã¹ãŠã®ã°ã©ãã£ãã¯ã¹ã«ã¯ãã·ã¹ãã ãã¬ããã®8ããããšã¢ã«ãã¡ãã£ã³ãã«ã®32ãããã®2ã€ã®ããŒãžã§ã³ããããŸãã ããã¯ãä»ã®ãã¹ãŠã®äººã®ãçŸããããç¶æããªããããããå¿ èŠãšãã人ã®ããã®äœè²ã¢ãŒãã§ã®éåžžã®æäœã«å¯ŸããŠè¡ãããŸãã ãŸããäžèšã®ãã©ãŒãªã³ã°ã®åŠçæ¹æ³ã¯ã8ãããã¢ã€ã³ã³ã§ã®ã¿æ©èœããŸããã ããã¯ãã·ã¹ãã ã¡ãœããImageList_Drawã䜿çšããŠåéæã®ã¢ã€ã³ã³ãæç»ããã®ã§ã¯ãªããç¬èªã®å®è£ ã§ãããããããã€ã¹ã³ã³ããã¹ãè¡šçŸãDIBã«çŽæ¥æç»ããããã§ãã ã¡ãªã¿ã«ãDIBã¯RTLã«ã€ããŠäœãèªèããŠãããããã®äžã®ãã¯ã»ã«ã¯éåžžã©ããå·Šããå³ã«ã€ã³ããã¯ã¹ä»ããããŠããŸãã ãããã£ãŠãåé¡ã¯ãªãã¯ãã§ãã å°æ¥ã®RTLã«åããŠãå ±æã©ã€ãã©ãªãæ åœããããŒã ãæªåé«ããã©ãŒãªã³ã°ãæç»ã³ãŒãã«è¿œå ããŠããªããã°ããããã¯èµ·ãããŸããã§ããã ç§ãç解ããŠããããã«ããã®çç±ã¯ãRTLã§ã°ã©ãã£ãã¯ãæäœããæ¹æ³ããŸã ç解ãããŠããªãã£ãããã§ãïŒãã®åé¡ã®è§£æ±ºçã®1ã€ãšããŠã®MSDNã¯ãç»åãšãã£ã¿ã§ã°ã©ãã£ãã¯ããã©ãŒãªã³ã°ããŠãåãã©ãŒãªã³ã°åŸã«æ£ãã衚瀺ãããããšãææ¡ããŠããŸãïŒ ã ããŠãç§ãã¡ã®ã°ã©ãã£ãã¯ã®äœè ã®æèŠãè¿°ã¹ãŸã-ãã®äºéãã©ãŒãªã³ã°ãªãã§äœæ¥ããæ¹ãã¯ããã«äŸ¿å©ã§ãã ã°ã©ãã£ãã¯ã«3çªç®ã®åé¡ãããããã§ãã
RTLçšã«åå¥ã®ã°ã©ãã£ãã¯ã¹ãå¿ èŠã§ããïŒ
äžè¬çãªå Žåãçãã¯ãã¯ããå¿ èŠã§ããã§ãã åãã¹ã¯ãªãŒã³ã·ã§ããã«æ»ããŸãããã Wãéã«ãªã£ãŠããã«ãããããããã¢ã€ã³ã³ã«ã¯1ã€ã®éèŠãªå©ç¹ããããŸããç¢å°ã¯å³æ¹åïŒRTLã®å ŽåïŒã«èŠããŸãã ã¯ããã¢ã©ã人ïŒããã³ã€ã¹ã©ãšã«äººïŒã«ãšã£ãŠããåæ¹ãã®æ¹åã¯å³ã§ã¯ãªãå·Šã§ãã ããšãã°ãæ¯èŒçšã®è±èªïŒå·ŠïŒãšã¢ã©ãã¢èªïŒå³ïŒUIãåããWindowsäžã®Internet ExplorerïŒ
ç¢å°ã«å ããŠãé察称å¥èªç¹ãç»åå ã«ããå Žåããããããã©ãŒãªã³ã°ããå¿ èŠããããŸãã ã»ãšãã©ã®å Žåãããã¯çå笊ã«ã®ã¿é©çšãããŸãã
ã¡ãªã¿ã«ãæåã®ã¹ã¯ãªãŒã³ã·ã§ããã®ã¿ã¹ã¯ããããŒã®èæ¯ã«ã¯ãå¥ã®ã°ã©ãã£ãã¯ïŒãŸãã¯æç»æã®ãã©ãŒãªã³ã°ïŒãå¿ èŠã§ãã
ãã€ã¢ãã°ããã®ä»ã®ãããã¢ããã¯ã©ãã§ããïŒ
åè¿°ããããã«ãSetProcessDefaultLayoutãåŒã³åºãã ãã§ããŠã£ã³ããŠãæ¡åŒµã§ããŸãã ãã ããæäžäœãŠã£ã³ããŠïŒã€ãŸããç¥å ãšããŠ0ãæã€WS_POPUPãŠã£ã³ããŠïŒã«å ããŠãä»ã®ãããã¢ãããŠã£ã³ããŠããããŸãã ããšãã°ããã€ã¢ãã°ã 圌ãã¯èªåçã«WS_EX_LAYOUTRTLãåãåããŸããã ããããããã§ã¯ãã¹ãŠãã·ã³ãã«ã§ãããªãœãŒã¹ã§ãã®ã¹ã¿ã€ã«ãæå®ããã ãã§ãããããªãœãŒã¹ãããããã¢ããïŒWS_POPUPïŒãŠã£ã³ããŠãäœæãããªãå Žåã¯ãäœææã«ãã®ãã©ã°ãè¿œå ããŸãã ããšãã°ããã®ãããªã¹ã¿ã€ã«ã芪ãŠã£ã³ããŠã«ååšãããšããæ¡ä»¶ã®äžã§ã ãªããã€ã¯ããœãããéäžã§åæ¢ããã®ããšæãããšããããŸããïŒ
å®éã«ã¯ãäœæã®ãŠã£ã³ããŠãã©ã°ãåžžã«å¶åŸ¡ãããšã¯éããŸããã ãŸããããããã£ããŒãžãšãŠã£ã¶ãŒãã®å Žåããã¹ãŠãåçŽãªå Žåãã¬ã€ã¢ãŠãã®æ¹åã¯è¿œå ãããæåã®ããŒãžã«ãã£ãŠæ±ºãŸããã¡ãã»ãŒãžãŠã£ã³ããŠãšæšæºãã€ã¢ãã°ã§ã¯ããè€éã«ãªããŸãã
ãŸããMessageBoxã¡ãœããã«ãã£ãŠè¡šç€ºãããã¡ãã»ãŒãžããã¯ã¹ã«ã€ããŠã å転ããã«ã¯ããã©ã°ã®çµã¿åããã䜿çšããã ãã§ååã§ãMB_RIGHT | MB_RTLREADINGã ãã®ããã«ã ãã¡ãããã·ã¹ãã ã³ãŒã«ãçŽæ¥ã§ã¯ãªããã©ãããŒã䜿çšããŠäœ¿çšããã°ç°¡åã§ãã ãã以å€ã®å Žåã¯ããããã®ãã©ã°ãåMessageBoxåŒã³åºãã«è¿œå ããå¿ èŠããããŸãïŒãããŠãã¢ã©ãã¢èªãšããã©ã€èªãå¯äžã®ããŒã«ã©ã€ãºèšèªã§ã¯ãªãå Žåãç¹å®ã®æ¡ä»¶ã§ãããè¡ããŸãïŒã
æšæºã®ãã€ã¢ãã°ã§ã¯ããã¹ãŠãããè€éã§ã·ã³ãã«ã§ãã ã¬ã€ã¢ãŠãããªãã¬ãŒãã£ã³ã°ã·ã¹ãã ã®ããŒã«ã©ã€ãºã®ã¿ã«äŸåãããããããç°¡åã§ãã ãã£ãšé£ãã-åãçç±ã§ã äœããã®çç±ã§ã¢ããªã±ãŒã·ã§ã³å šäœãRTLã§ããããšãéèŠãªå ŽåãæŸèæã¯ãããªãã§ã¯å®è¡ã§ããŸããã ã¡ãªã¿ã«ãåãããšããæ°ããããã¡ã€ã«ãã€ã¢ãã°ïŒIFileDialogïŒã«ãåœãŠã¯ãŸããŸãã ç§ãã¡ã®ã±ãŒã¹ã§ã¯ãåé¡ããªãããšãèæ ®ããŠãããããã®ãŸãŸã«ããŸããã
åãŠã£ã³ããŠïŒWS_CHILDïŒãWS_EX_LAYOUTRTLãã©ã°ãå¿ èŠãšããªãå Žåã®å¯ŸåŠæ¹æ³
åã«èšã£ãããã«ãåãŠã£ã³ããŠã¯èŠªãããã®ãã©ã°ãç¶æ¿ããŸãã ãã ããããã¯å¿ èŠã§ã¯ãªãå ŽåããããŸãïŒããšãã°ãABBYY FineReader Sprintã§ã¯ãããã¯ç»åãšãã£ã¿ãŒãŠã£ã³ããŠã§ã-ç»åã®åºåãç¹ã«ããªãã³ã°ãããŒãžã³ã°ãªã©ã®éžæãã¬ãŒã ããã©ãŒãªã³ã°ããŠãæå³ããããŸããïŒã 2ã€ã®æ¹æ³ããããŸã-äœæçŽåŸã«ãã®ãã©ã°ãã¯ãªã¢ãããã芪ãŠã£ã³ããŠãäœæãããšãã«WS_EX_NOINHERITLAYOUTãã©ã°ã䜿çšããŸãã ã»ãšãã©ã®å Žåãæåã®æ¹æ³ãããåççã§ãã
ãšããã§ãç§ãèšã£ãããã«ããã¹ãŠã®ãŠã£ã³ããŠã芪ããWS_EX_LAYOUTRTLã¹ã¿ã€ã«ãç¶æ¿ããããã§ã¯ãããŸããã å€ãã®äžè¬çãªã³ã³ãããŒã«ã¯ãä»ã®ã³ã³ãããŒã«ã«çœ®ãæããããŸãïŒRTLã®æ¹æ³ã§åäœããããïŒã ããšãã°ãç·šéã®å Žåãéçã¯ãã©ã°WS_EX_RIGHTã®çµã¿åããã«ãªããŸã| WS_EX_RTLREADINGã
ç§ãåºäŒã£ãæãçããééããé¢é£ããŠããã®ã¯ããã§ãã èšèªéžæã³ã³ãããã¯ã¹ã«ã¯ãå ¥åæã«ãã³ãã®æ©èœããããŸãã
ã芧ã®ãšããããã£ã¬ããäœçœ®ã«ããŒã«ãããããããã¢ããããŸãã GetCaretPosã¡ãœããã䜿çšããŠãã£ãªããžäœçœ®ãååŸããŸãããã®ã¡ãœããã¯ãã¯ã©ã€ã¢ã³ã座æšã§ãããè¿ããŸãã 次ã«ãïŒMapWindowPointsã䜿çšããŠïŒãã£ãªããžã®ãŠã£ã³ããŠåº§æšãååŸããããã«ããŒã«ããããé 眮ããŸããRTLã®å Žåãã³ã³ãããã¯ã¹ã®å察åŽã®ç«¯ã«ããŒã«ãããã衚瀺ãããŸãã
ãã®ãšã©ãŒã®çç±ã¯ããã£ãªããžäœçœ®ãååŸããã¯ã©ã€ã¢ã³ã座æšãã³ã³ãããã¯ã¹ã®åº§æšã§ã¯ãªãããã®åã®ç·šéã³ã³ãããŒã«ã ããã§ãã äžèšã§è¿°ã¹ãããã«ãããã¯ïŒã³ã³ãããã¯ã¹ãšã¯ç°ãªãïŒWS_EX_LAYOUTRTLãã©ã°ãç¶æ¿ããŸããã ããããä¿®æ£ã¯æããã§ããMapWindowPointsåŒã³åºãã®ãŠã£ã³ããŠãæ£ãããŠã£ã³ããŠã«å€æŽããã ãã§ãã
æç»ã«ã€ããŠã®è©³çŽ°ã ä»GDI +
MSDNã¯ãRTLç°å¢ã§ã®GDI +ã®äœ¿çšãæšå¥šããŠããŸããã ã€ãŸããGDI +ã¡ãœããã¯ãããããæç»ãããããã€ã¹ã³ã³ããã¹ãã®LAYOUT_RTLããããã£ãèæ ®ããŸããã ããã«ãããããããè©ŠããŠã¿ãããšãã§ããŸã-æç»ãããšãã«åº§æšãèªåã§å€æããã ãã§ãã 次ã®æ¹æ³ãæã䟿å©ã§ãããLAYOUT_RTLããããã£ãèšå®ãããããã€ã¹ã³ã³ããã¹ãïŒHDCïŒã䜿çšããŠãLPToDPã¡ãœãããåŒã³åºããŠåº§æšã転éããŸãã
ãã ãããããã®ç·šéåŸãGDI +ã®æç»ã³ãŒãã¯ããæ··ä¹±ããããšãå€æãããããGDI +ããŸã£ãã䜿çšããã«ãã®è£œåã䜿çšããæ¹æ³ãèŠã€ããŸããã
ããã€ã«ã»ãŽã¡ã·ã«ãã§ã³ã³ã
ããã¹ãèªè補åéšé