ÓÑÇéÌáʾ£ºÈç¹û±¾ÍøÒ³´ò¿ªÌ«Âý»òÏÔʾ²»ÍêÕû£¬Çë³¢ÊÔÊó±êÓÒ¼ü¡°Ë¢Ð¡±±¾ÍøÒ³£¡ÔĶÁ¹ý³Ì·¢ÏÖÈκδíÎóÇë¸æËßÎÒÃÇ£¬Ð»Ð»£¡£¡ ±¨¸æ´íÎó
ÒÀÒÀС˵ ·µ»Ø±¾ÊéĿ¼ ÎÒµÄÊé¼Ü ÎÒµÄÊéÇ© TXTÈ«±¾ÏÂÔØ ½øÈëÊé°É ¼ÓÈëÊéÇ©

windows»·¾³ÏÂ32λ»ã±àÓïÑÔ³ÌÐòÉè¼Æ-µÚ63²¿·Ö

°´¼üÅÌÉÏ·½Ïò¼ü ¡û »ò ¡ú ¿É¿ìËÙÉÏÏ·­Ò³£¬°´¼üÅÌÉ쵀 Enter ¼ü¿É»Øµ½±¾ÊéĿ¼ҳ£¬°´¼üÅÌÉÏ·½Ïò¼ü ¡ü ¿É»Øµ½±¾Ò³¶¥²¿£¡
¡ª¡ª¡ª¡ªÎ´ÔĶÁÍꣿ¼ÓÈëÊéÇ©ÒѱãÏ´μÌÐøÔĶÁ£¡




¡ñ¡¡¡¡¡¡ES_READONLY¡ª¡ªÖ»¶ÁÊôÐÔ¡£

¡ñ¡¡¡¡¡¡ES_CENTER£¬ES_RIGHTºÍES_LEFT¡ª¡ªÎı¾µÄ¶ÔÆ뷽ʽ¡£

¡ñ¡¡¡¡¡¡ES_WANTRETURN¡ª¡ªÔÊÐíÓû§°´»Ø³µ¼ü²åÈëеÄÐС£

µ«ÏÂÁÐEdit¿Ø¼þ·ç¸ñ²»ÄÜÔÚRichedit¿Ø¼þÖÐʹÓãº

¡ñ¡¡¡¡¡¡ES_LOWERCASE»òES_UPPERCASE¡ª¡ª½«¿Ø¼þÖеÄÎÄ×ÖÈ«²¿×ª»»³ÉСд»ò´óд¡£

¡ñ¡¡¡¡¡¡ES_PASSWORD¡ª¡ª½«¿Ø¼þÖеÄÎÄ×ÖÏÔʾΪÃÜÂ뷽ʽ£¨ÏÔʾΪÐǺţ©¡£

ÏÂÃæÁгöµÄÊDz¿·ÖRichedit¿Ø¼þÌØÓеķç¸ñ£º

¡ñ¡¡¡¡¡¡ES_DISABLENOSCROLL¡ª¡ªÖ¸¶¨Õâ¸ö·ç¸ñºó£¬¿Ø¼þÔÚ²»ÐèÒª¹ö¶¯ÌõµÄʱºò£¨ÎÄ×ÖûÓг¬³ö¿Í»§Çø´óС£©ÏÔʾ»Ò»¯×´Ì¬µÄ¹ö¶¯Ìõ£¬¶øĬÈÏÇé¿öÏ£¬µ±²»ÐèÒª¹ö¶¯ÌõµÄʱºò£¬¿Ø¼þ¸ù±¾²»»áÏÔʾËü¡£

¡ñ¡¡¡¡¡¡ES_NOIME¡ª¡ª½ûÖ¹ÊäÈë·¨£¨IME£©²Ù×÷£¬½öÓÃÓÚÑÇÖÞÓïÑÔ°æ±¾¡£

¡ñ¡¡¡¡¡¡ES_SAVESEL¡ª¡ªÔÚʧȥ¼üÅÌÊäÈë½¹µãµÄʱºò±£´æµ±Ç°Ñ¡ÔñÇøÓò£¬Ä¬ÈÏ״̬ϵ±¿Ø¼þÔÚÖØлñµÃ½¹µãµÄʱºò»á½«È«²¿Îı¾Ñ¡ÖС£

´´½¨¿Ø¼þÒÔºó£¬ÐèÒª·¢ËÍEM_EXLIMITTEXTÏûÏ¢ÉèÖÿؼþÖÐÄܹ»ÈÝÄÉ×Ö·ûµÄ×ÜÊý£¬ËäÈ»Richedit¿Ø¼þÖеÄÎÄ×Ö³¤¶È¿ÉÒÔÖ§³Öµ½×î´óµÄÎļþ³ß´ç£¬µ«Ä¬ÈÏÇé¿öÏ£¬¿Ø¼þ»¹Êǽ«×î´ó×Ö·ûÊýÏÞÖÆΪ64¡¡KB£¬ËùÒÔÈç¹û¶ÁÕß·¢ÏÖRichedit¿Ø¼þÒ²Ö»Äܱ༭64¡¡KB×Ö·ûµÄ»°£¬ÄDz¢²»ÊǿؼþµÄ´í£¬¶øÊÇûÓиæËßËü¾ßÌåµÄÒªÇó£¬EM_EXLIMITTEXTÏûÏ¢µÄʹÓ÷½·¨ÊÇ£º

¡¡¡¡¡¡¡¡invoke¡¡¡¡SendMessage£»hWinEdit£»EM_EXLIMITTEXT£»0£»dwTextMax

ÆäÖÐdwTextMaxÖ¸¶¨ÁË×î´ó×Ö·ûÊý¡£

9¡£4¡£2¡¡¡¡Richedit¿Ø¼þµÄ¿ØÖÆÏûÏ¢

1¡£¡¡Ñ¡ÔñÇøÓò

Ñ¡ÔñÇøÓò¾ÍÊÇÓû§ÔڿؼþÖÐͨ¹ýÍ϶¯Êó±êÀ´Ñ¡¶¨µÄ¶à¸öÎÄ×Ö£¬Ñ¡ÔñÁËÒ»¶ÎÎÄ×ÖÒÔºó£¬Óû§ÒÔºóµÄ²Ù×÷¾ÍÊÇÕë¶ÔÕâ¶ÎÎÄ×ֵģ¬Èç°´ÏÂDelete¼ü¿ÉÒÔɾ³ýÕû¶ÎÎÄ×Ö£¬°´Ctrl£«C¼ü½«Õâ¶ÎÎÄ×Ö¿½±´µ½¼ôÌù°åÖУ¬°´Ctrl£«V¼üÓüôÌù°åÖеÄÄÚÈÝÌæ»»Õâ¶ÎÎÄ×ֵȡ£

ÔÚ³ÌÐòÖУ¬Ñ¡ÔñÇøÓò¿ÉÒÔ±»³ÌÐò»ñÈ¡£¬Ò²¿ÉÒÔÓɳÌÐò×ÔÓÉÉèÖ㬴ӱà³Ì½Ç¶ÈÀ´¿´£¬Ñ¡ÔñÇøÓòµÄÓô¦ÓÐÁ½¸ö£º

¡ñ¡¡¡¡¡¡Ñ¡¶¨²Ù×÷Îı¾¡ª¡ªÓëÓû§ÊÖ¹¤Ñ¡¶¨Ò»¶ÎÎı¾ÒÔ±ã½øÐи÷ÖÖ²Ù×÷ÀàËÆ£¬³ÌÐòÔÚ¶ÔÎı¾½øÐвÙ×÷֮ǰҲÐèÒªÔ¤ÏÈÉèÖÃÑ¡ÔñÇøÓò¡£

¡ñ¡¡¡¡¡¡¶¨Î»¹â±ê¡ª¡ª¿Ø¼þÖв¢Ã»ÓÐרÃŵÄÓÃÀ´¶¨Î»¹â±êµÄ¿ØÖÆÏûÏ¢£¬¶¨Î»¹â±êÒ²ÊÇ¿¿ÉèÖÃÑ¡ÔñÇøÓòÍê³ÉµÄ¡£Èç¹û°ÑÑ¡ÔñÇøÓòµÄÆðʼλÖúͽáÊøλÖÃÉèÖÃΪÏàͬµÄ£¬ÄÇô¾ÍÏ൱Óڰѹâ±ê¶¨Î»µ½Õâ¸öλÖöø²»Ñ¡¶¨ÈκÎÎÄ×Ö¡£

ÔÚEdit¿Ø¼þÖУ¬»ñÈ¡Ñ¡ÔñÇøÓò¿ÉÒÔͨ¹ýÏò¿Ø¼þ·¢ËÍEM_GETSELÏûÏ¢£º

¡¡¡¡¡¡¡¡invoke¡¡¡¡SendMessage£»hRichedit£»EM_GETSEL£»lpdwStart£»lpdwEnd

lpdwStartºÍlpdwEndÖ¸ÏòÁ½¸öÓÃÀ´·µ»ØÑ¡¶¨ÇøÓòÆðʼλÖúͽáÊøλÖõÄË«×Ö±äÁ¿£¬Ò²¿ÉÒÔ½«ÕâÁ½¸ö²ÎÊýÈ«²¿ÉèÖÃΪNULL£¬ÒòΪÏûÏ¢µÄ·µ»ØÖµÒ²ÊÇλÖÃÊý¾Ý£¬·µ»ØÖµµÄµÍ16λÊÇÑ¡¶¨ÇøÓòµÄÆðʼλÖ㬸ß16λÊǽáÊøλÖá£

µ«ÊÇEM_GETSELÏûÏ¢½öÊÊÓÃÓڿؼþÖÐÎı¾³¤¶È²»³¬¹ý64¡¡KBµÄÇé¿ö£¬Èç¹ûRicheditÖÐÑ¡ÔñÇøÓòµÄÆðʼλÖûò½áÊøλÖÃÓÐÒ»¸öÂäÔÚÁË64¡¡KBÒÔÍ⣬ÄÇôÏûÏ¢½ö·µ»Ø£¿1£¬¶ø²»ÊÇÕýÈ·µÄÊýÖµ£¬ËùÒÔ×îºÃ»¹ÊÇʹÓÃEM_EXGETSELÏûÏ¢£¬EM_EXGETSELÏûÏ¢ÊÇRicheditµÄÌØÓÐÏûÏ¢£¬²»ÄÜÔÚEdit¿Ø¼þÖÐʹÓãº

invoke¡¡¡¡SendMessage£»hRichedit£»EM_EXGETSEL£»0£»lpchr

lpchr²ÎÊýÖ¸ÏòÒ»¸öCHARRANGE½á¹¹£¬ÓÃÀ´½ÓÊÕÑ¡ÔñÇøÓòµÄÆðʼºÍ½áÊøλÖ㬸ýṹ¶¨ÒåÈçÏ£º

CHARRANGE¡¡STRUCT

¡¡¡¡¡¡¡¡cpMin¡¡¡¡DWORD¡¡¡¡¡¡¡¡¡¡¡¡£¿¡¡¡¡¡¡¡¡¡¡¡¡£»Ñ¡ÔñÇøÓòµÄÆðʼλÖÃ

¡¡¡¡¡¡¡¡cpMax¡¡¡¡DWORD¡¡¡¡¡¡¡¡¡¡¡¡£¿¡¡¡¡¡¡¡¡¡¡¡¡£»Ñ¡ÔñÇøÓòµÄ½áÊøλÖÃ

CHARRANGE¡¡ENDS

Èç¹ûcpMinx×ֶεÈÓÚcpMax×ֶΣ¬±íʾѡÔñÇøÓòµÄ³¤¶ÈΪ0£¬¶ø¹â±êλÓÚÕâ¸öλÖã»Èç¹ûcpMinµÈÓÚ0¶øcpMaxµÈÓÚ£¿1£¬±íʾѡ¶¨µÄÊǿؼþÖеÄËùÓÐÄÚÈÝ¡£

³ÌÐòÒ²¿ÉÒÔͨ¹ý·¢ËͶÔÓ¦µÄÏûÏ¢À´ÉèÖÃÑ¡ÔñÇøÓò£º

invoke¡¡¡¡SendMessage£»hRichedit£»EM_SETSEL£»dwStart£»dwEnd

¡¡¡¡¡¡¡¡invoke¡¡¡¡SendMessage£»hRichedit£»EM_EXSETSEL£»0£»lpchr

EM_SETSELµÄ²ÎÊýÖÐÖ±½ÓÓÃdwStartºÍdwEndÖ¸¶¨Ñ¡ÔñÇøÓòµÄ¿ªÊ¼ºÍ½áÊøλÖ㬵«ÊÇÕâ¸öÏûϢͬÑùÓÐ64¡¡KB³¤¶ÈµÄÏÞÖÆ£»EM_EXSETSELÏûϢûÓÐÕâ¸öÏÞÖÆ£¬lpchr²ÎÊýͬÑùÖ¸ÏòÒ»¸öCHARRANGE½á¹¹£¬½á¹¹Öаüº¬ÁËÐèÒªÉ趨µÄλÖá£Èç¹û½öÊÇÒƶ¯¹â±ê¶ø²»Ñ¡ÔñÈκÎÇøÓò£¬¿ÉÒÔ½«ÆðʼλÖúͽáÊøλÖÃÉèÖÃΪÏàͬµÄÊýÖµ¡£

ÔÚ³ÌÐòÖÐÉèÖÃÁËÑ¡ÔñÇøÓò£¨»ò¸Ä±äÁ˹â±êλÖ㩺󣬿ÉÄÜÕâ¸öÇøÓòºÍÔ­À´µÄÑ¡ÔñÇøÓòλÖÃÏà²îÌ«¶à£¬ÒÔÖÁÓÚÂäÔÚÁË¿Í»§ÇøµÄÍâÃ棬Óû§ÒѾ­¿´²»µ½ËüÁË£¬Èç¹ûÏ£Íû¿Ø¼þÄܹ»¾í¶¯ÎÄ×ÖÒԱ㽫еÄλÖÃÂäÔÚ¿Í»§ÇøÖУ¬¿ÉÒÔ·¢ËÍEM_SCROLLCARETÏûÏ¢£¬Õâ¸öÏûϢûÓÐÈκβÎÊý£º

¡¡¡¡¡¡¡¡invoke¡¡¡¡SendMessage£»hRichedit£»EM_SCROLLCARET£»0£»0

ÔÚÀý×Ó³ÌÐòÖУ¬¸ù¾ÝÊÇ·ñ´æÔÚÑ¡ÔñÇøÓòÀ´¾ö¶¨ÊÇ·ñÔÊÐí¿½±´ºÍ¼ôÇй¦ÄÜ¡£ÒòΪÈç¹û²»´æÔÚÑ¡ÔñÇøÓò£¬¾ÍûÓÐÎı¾¿É¹©¿½±´»ò¼ôÇУ¬ËùÒÔÔÚ_SetStatus×Ó³ÌÐòÖÐʹÓÃÏÂÃæµÄ´úÂëÊ×ÏÈ»ñÈ¡Ñ¡ÔñÇøÓò£¬²¢¸ù¾ÝÇé¿öÔÊÐí»ò½ûÖ¹¿½±´ºÍ¼ôÇв˵¥Ï

invoke¡¡¡¡SendMessage£»hWinEdit£»EM_EXGETSEL£»0£»addr¡¡@stRange

¡¡¡¡¡¡¡¡mov¡¡¡¡¡¡¡¡¡¡eax£»@stRange¡£cpMin

¡¡¡¡¡¡¡¡¡£if¡¡¡¡¡¡¡¡¡¡eax¡¡¡¡¡¡@stRange¡£cpMax¡¡¡¡£»²»´æÔÚÑ¡ÔñÇøÓò

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡invoke¡¡¡¡EnableMenuItem£»hMenu£»IDM_COPY£»MF_GRAYED

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡invoke¡¡¡¡EnableMenuItem£»hMenu£»IDM_CUT£»MF_GRAYED

¡¡¡¡¡¡¡¡¡£else¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡£»´æÔÚÑ¡ÔñÇøÓò

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡invoke¡¡¡¡EnableMenuItem£»hMenu£»IDM_COPY£»MF_ENABLED

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡invoke¡¡¡¡EnableMenuItem£»hMenu£»IDM_CUT£»MF_ENABLED

¡¡¡¡¡¡¡¡¡£endif

ÁíÍ⣬ÔÚ²éÕÒÎı¾µÄ_FindText×Ó³ÌÐòÖУ¬Ò»¿ªÊ¼Ò²Í¨¹ý·¢ËÍEM_EXGETSELÏûÏ¢»ñÈ¡Ñ¡ÔñÇøÓò£¬ÕâÊÇΪÁË»ñµÃ¹â±êλÖÃÒÔ±ãÉèÖòéÕÒµÄÆðʼµã£¬µ±ÕÒµ½Îı¾ÒÔºó£¬Îı¾µÄλÖÃÔÚFINDTEXTEX½á¹¹µÄchrgText×Ö¶ÎÖзµ»Ø£¬chrgText×ֶα¾ÉíÊÇÒ»¸öCHARRANGE½á¹¹£¬ËùÒÔÖ±½ÓÔÚEM_EXSETSELÏûÏ¢ÖÐʹÓÃËü¾Í¿ÉÒÔ½«Ñ¡ÔñÇøÓòÉèÖõ½ÕÒµ½µÄÎÄ×ÖÉÏ£º

invoke¡¡¡¡SendMessage£»hWinEdit£»EM_EXSETSEL£»0£»addr¡¡@stFindText¡£chrgText

¡¡¡¡¡¡¡¡invoke¡¡¡¡SendMessage£»hWinEdit£»EM_SCROLLCARET£»NULL£»NULL

×îºó³ÌÐò·¢ËÍEM_SCROLLCARETÏûÏ¢¾í¶¯ÎÄ×Ö£¬ÒÔ±ãÕÒµ½µÄÎı¾Äܹ»³öÏÖÔÚÓû§µÄÊÓÒ°ÖС£

2¡£¡¡Îı¾¹ÜÀí

Îı¾¹ÜÀíÉæ¼°»ñÈ¡Îı¾£¬ÉèÖÃÎı¾ÒÔ¼°Ò»Ð©¸¨Öú²Ù×÷¡£

Richedit¿Ø¼þ±¾Éí¾ÍÊÇÒ»¸ö´°¿Ú£¬ËùÒÔ¿ÉÒÔͨ¹ý³£¹æµÄº¯Êý¶ÔÆäÖеÄÎı¾½øÐвÙ×÷£¬±ÈÈçÒª»ñÈ¡ºÍÉèÖÃÎı¾£¬¿ÉÒÔµ÷ÓÃGetWindowText»òSetWindowTextº¯Êý£¬Ò²¿ÉÒÔͨ¹ý·¢ËÍWM_GETTEXTºÍWM_SETTEXTÏûÏ¢À´Íê³É£»Èç¹ûÐèÒª»ñÈ¡¿Ø¼þÖеÄÎı¾³¤¶È£¬¿ÉÒÔͨ¹ýGetWindowTextLengthº¯Êý»ò·¢ËÍWM_GETTEXTLENGTHÏûÏ¢£¬²»¹ýËùÓÐÕâЩ²Ù×÷Õë¶ÔµÄ¶¼ÊǿؼþÖеÄÈ«²¿ÎÄ×Ö£¬ÎÞ·¨ÊµÏÖϸ΢µÄ²Ù×÷¡£

Ïò¿Ø¼þ·¢ËÍ¿ØÖÆÏûÏ¢½öÕë¶ÔÑ¡ÔñÇøÓò²Ù×÷ÔòÁé»îµÃ¶à£¬µ±Í¨¹ýEM_EXSETSELÏûÏ¢ÉèÖúÃÑ¡ÔñÇøÓòºó£¬ÔÙͨ¹ýEM_GETSELTEXTÏûÏ¢¾Í¿ÉÒÔ»ñÈ¡µ±Ç°Ñ¡¶¨µÄÎı¾£º



¡¡
À´Ô´£ºµç×Ó¹¤Òµ³ö°æÉç¡¡×÷ÕߣºÂÞÔƱò¡¡ÉÏÒ»Ò³¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡»ØÊéÄ¿¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ÏÂÒ»Ò³¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
ÉÏÒ»Ò³¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡»ØÊéÄ¿¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ÏÂÒ»Ò³¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
¡¡¡¡


µÚ9Õ¡¡Í¨Óÿؼþ


9¡£4¡¡Ê¹ÓÃRichedit¿Ø¼þ£¨7£©

¡¡¡¡¡¡¡¡
invoke¡¡¡¡SendMessage£»hWinEdit£»EM_GETSELTEXT£»0£»lpBuffer

lpBufferÓÃÀ´Ö¸¶¨½ÓÊÕÎı¾µÄ»º³åÇø£¬ÓÉÓÚûÓвÎÊýÖ¸¶¨»º³åÇøµÄ´óС£¬ËùÒÔ³ÌÐò±ØÐëʹÓÃ×ã¹»´óµÄ»º³åÇø£¬²»¹ýÕâ²»ÊÇÎÊÌ⣬ÒòΪͨ¹ý¼ì²éÑ¡ÔñÇøÓò¿ÉÒÔÔ¤ÏȵÃÖª·µ»ØÎı¾µÄ´óС£¬ÏûÏ¢µÄ·µ»ØÖµÊÇ·µ»Øµ½»º³åÇøÖеÄ×Ö·û´®µÄ³¤¶È£¨²»°üÀ¨Ä©Î²µÄ0×Ö·û£©¡£

ͨ¹ý·¢ËÍEM_REPLACESELÏûÏ¢¿ÉÒÔÌ滻ѡÔñÇøÓòÖеÄÎı¾£¬Èç¹ûµ±Ç°µÄÑ¡ÔñÇøÓò³¤¶È²»Îª0µÄ»°£¬Ñ¡ÔñÇøÓòµÄÎı¾±»ÏûÏ¢Ö¸¶¨µÄ×Ö·û´®Ëù´úÌ棬Èç¹ûÑ¡ÔñÇøÓò³¤¶ÈΪ0£¬ÔòÖ¸¶¨µÄ×Ö·û´®±»²åÈëµ½µ±Ç°¹â±êλÖãº

invoke¡¡¡¡SendMessage£»hWinEdit£»EM_REPLACESEL£»fCanUndo£»lpString

ÆäÖÐfCanUndo²ÎÊýÖ¸³ö±¾´ÎÌæ»»²Ù×÷ÊÇ·ñ¿ÉÒÔ³·Ïú£¬Èç¹ûÖ¸¶¨TRUE£¬Ôò¿Ø¼þ±£´æ³·ÏúÐÅÏ¢ÒÔ±ãÓû§¿ÉÒÔ°´Ctrl£«Z¼ü½øÐг·Ïú£¬Ö¸¶¨FALSEµÄ»°²Ù×÷¾Í²»Äܱ»³·Ïú¡£lpString²ÎÊýÖ¸Ïò²åÈë»òÌæ»»ÓõÄ×Ö·û´®£¬×Ö·û´®ÒÔ0½áβ¡£

³ýÁË»ñÈ¡ºÍÉèÖÃÎÄ×Ö£¬»¹ÓÐһϵÁеĿØÖÆÏûÏ¢¿ÉÒÔÓÃÀ´½øÐж¨Î»²Ù×÷£¬±ÈÈçÏëҪѡ¶¨Ò»ÕûÐÐÄÚÈÝ£¬¾Í±ØÐëÖªµÀijһÐеÄÆðʼλÖúͽáÊøλÖã»ÁíÍ⣬ÓÐʱºòÒ²ÐèÒªÔÚ×Ö·ûλÖúÍÐкÅÖ®¼ä½øÐÐת»»¼ÆË㣬¶ÔÓÚÕâЩҪÇ󣬰ÑËùÓÐÎı¾´Ó¿Ø¼þÖжÁ³öÀ´ÔÙ×Ô¼º½øÐд¦ÀíÏÔÈ»ÊǺÜÂé·³µÄ£¬ÐÒºÃRichedit¿Ø¼þÒѾ­ÌṩÁËÕâЩ¹¦ÄÜ¡£

ͨ¹ý·¢ËÍEM_EXLINEFROMCHARÏûÏ¢¿ÉÒÔµÃÖªÖ¸¶¨µÄ×Ö·ûλÓÚÄÄÒ»ÐÐÖУº

invoke¡¡¡¡SendMessage£»hWinEdit£»EM_EXLINEFROMCHAR£»0£»dwCharPos

¡¡¡¡¡¡¡¡mov¡¡¡¡¡¡¡¡¡¡dwLine£»eax

ÆäÖÐdwCharPosÖ¸³ö×Ö·ûµÄλÖã¨ÒÔ0¿ªÊ¼£©£¬ÏûÏ¢½«·µ»Ø×Ö·ûËù´¦µÄÐкš£ÔÚËùÓÐÕâЩÏûÏ¢ÖУ¬×Ö·ûλÖúÍÐкŶ¼ÊÇ´Ó0¿ªÊ¼¼ÆËãµÄ£¬Ò²¾ÍÊÇ˵µÚ1ÐеÄÐкÅÓÃ0±íʾ¡£

EM_LINEINDEXÏûÏ¢ÔòÍê³ÉÄæÔËË㣬Ëü·µ»ØÖ¸¶¨ÐкŵĵÚÒ»¸ö×Ö·ûµÄλÖã¬dwLine²ÎÊýΪÊäÈëµÄÐкţ¬Èç¹ûdwLine²ÎÊýÊäÈ룿1µÄ»°£¬´ú±íµÄÊǵ±Ç°ÐУ¨¹â±êËùÔÚµÄÐУ©£º

invoke¡¡¡¡SendMessage£»hWinEdit£»EM_LINEINDEX£»dwLine£»0

mov¡¡dwCharPos£»eax

¸ÃÏûÏ¢·µ»ØÖ¸¶¨ÐеÄÆðʼ×Ö·ûµÄλÖã¬Èç¹ûÖ¸¶¨µÄÐкų¬¹ýÁ˿ؼþÖÐÎı¾µÄ×ÜÐÐÊý£¬ÄÇôÏûÏ¢½«·µ»Ø£¿1¡£¿Ø¼þÖаüº¬Îı¾µÄ×ÜÐÐÊý¿ÉÒÔͨ¹ýEM_GETLINECOUNTÏûÏ¢»ñÈ¡£º

¡¡¡¡¡¡¡¡invoke¡¡¡¡SendMessage£»hWinEdit£»EM_GETLINECOUNT£»0£»0

¡¡¡¡¡¡¡¡mov¡¡dwTotalLines£»eax

Èç¹ûÏë»ñȡijһÐеij¤¶È£¬Óкü¸ÖÖ·½·¨£¬±ÈÈç¿ÉÒÔÁ½´ÎʹÓÃEM_LINEINDEXÏûÏ¢»ñÈ¡±¾ÐкÍÏÂÒ»ÐÐÎÄ×ÖµÄÆðʼλÖã¬ÔÙÏà¼õ¾ÍµÃ³öÁËÐеij¤¶È£»Ò²¿ÉÒÔÓÃEM_LINELENGTHÖ±½Ó»ñÈ¡£º

invoke¡¡¡¡SendMessage£»hWinEdit£»EM_LINELENGTH£»ich£»0

mov¡¡dwLineLength£»eax

²»¹ýEM_LINELENGTHÏûÏ¢ÖеÄich²ÎÊý²¢²»ÊÇÐкţ¬¶øÊÇÐÐÖÐÈÎÒâÒ»¸ö×Ö·ûµÄλÖã¬ËùÒÔÏëÒÔÐкÅΪ²ÎÊý»ñÈ¡Ðг¤¶ÈµÄ»°£¬»¹ÐèÒªÏÈÓÃEM_LINEINDEXÏûÏ¢½«ÐкÅת»»µ½×Ö·ûλÖúóÔÙʹÓÃEM_LINELENGTHÏûÏ¢¡£Õâ¸öÏûÏ¢»¹ÓиöÌØÊâÓÃ;£¬µ±ich²ÎÊýÖ¸¶¨Îª¡­1µÄʱºò£¬·µ»ØÖµÊÇÑ¡¶¨ÇøÓò¿çÔ½µÄ¶à¸öÐÐÖÐûÓб»Ñ¡¶¨µÄ×Ö·ûµÄ×ÜÊý£¬ÕâÓÐʲôÓô¦ÄØ£¿ÏÔÈ»£¬µ±°´ÏÂÁËDelete¼üɾ³ýÁËÑ¡ÔñÇøÓòʱ£¬Ê£ÏµÄÐеij¤¶È¾ÍÊÇÕâ¸ö·µ»ØÖµ¡£

ÒªÏë»ñȡijһÐеÄÄÚÈÝÒ²ÓжàÖÖ°ì·¨£¬±ÈÈç¿ÉÒÔÏÈÑ¡¶¨Ä³¸öÐУ¬ÔÙÓÃEM_GETSELTEXTÏûÏ¢À´Íê³É£¬µ«×î¼òµ¥µÄ°ì·¨ÊÇʹÓÃEM_GETLINEÏûÏ¢£º

¡¡¡¡¡¡¡¡mov¡¡word¡¡ptr¡¡szBuffer£»sizeof¡¡szBuffer

¡¡¡¡¡¡¡¡invoke¡¡¡¡SendMessage£»hWinEdit£»EM_GETLINE£»dwLine£»addr¡¡szBuffer

ÆäÖÐdwLine²ÎÊýÖ¸¶¨Òª»ñÈ¡µÄÐкţ¬lpBuffer²ÎÊýÖ¸ÏòÓÃÀ´½ÓÊÕ×Ö·û´®µÄ»º³åÇø£¬×¢Ò⣺»º³åÇøµÄµÚÒ»¸ö×Ö£¨²»ÊÇË«×Ö£¡£©±ØÐëÔ¤ÏÈÖ¸¶¨Îª»º´æÇøµÄ³¤¶È£¡ÁíÍ⣬½ÓÊÕµÄ×Ö·û´®²¢²»°üÀ¨½áÊø·û0£¬ËùÒÔÔÚ·¢ËÍÏûϢ֮ǰ×îºÃÏÈ°Ñ»º³åÇøÈ«²¿ÇåÁ㣬·ñÔò»áºÍ»º³åÇøÖÐÔ­ÓеÄÊý¾Ý»ìÔÚÒ»Æð¡£ÏûÏ¢µÄ·µ»ØÖµÊÇ·µ»Øµ½»º³åÇøÖеÄ×Ö·û´®µÄ³¤¶È¡£

3¡£¡¡ÉèÖÃÎı¾¸ñʽ

Richedit¿Ø¼þÖ§³ÖÁ½ÖÖģʽ£º´ø¸ñʽÎı¾RTF£¨Rich¡¡Text¡¡Format£©Ä£Ê½ºÍ²»´ø¸ñʽÎı¾£¨Plain¡¡Text£©Ä£Ê½¡£ÔÚĬÈÏ״̬Ï¿ؼþ´¦ÓÚRTFģʽ£¬ÔÚÕâÖÖģʽÏ£¬³ÌÐò¿ÉÒԶԿؼþÖеIJ»Í¬ÎÄ×Ö·Ö±ðÉèÖò»Í¬µÄ¸ñʽ£¬ÕâЩ¸ñʽ¿ÉÒÔ±»±£´æµ½*¡£rtfÎļþÖС£¶øÔÚPlain¡¡TextģʽÏ£¬Ö»Äܽ«¿Ø¼þÖеÄÈ«²¿ÎÄ×ÖÉèÖÃͳһµÄ¸ñʽ£¬¶øÇÒÕâЩ¸ñʽ½ö±íÏÖÔÚ¡°ÏÔʾ¡±ÉÏ£¬²»»á±»±£´æµ½*¡£txtÎļþÖС£

Ôڿؼþ´°¿Ú±»´´½¨ºó¿ÉÒÔͨ¹ý·¢ËÍEM_SETTEXTMODEÏûÏ¢À´ÉèÖù¤×÷ģʽ£¬ÕâÌõÏûÏ¢½ö¶Ô2¡£0°æ±¾ÒÔÉϵÄRichedit¿Ø¼þÓÐЧ£º

invoke¡¡¡¡SendMessage£»hWinEdit£»EM_SETTEXTMODE£»dwTextMode£»0

µ±dwTextMode²ÎÊýÖ¸¶¨Îª¡¡TM_PLAINTEXT¡¡µÄʱºò£¬¿Ø¼þÇл»µ½²»´ø¸ñʽģʽ£»Ö¸¶¨ÎªTM_RICHTEXTµÄʱºò£¬¿Ø¼þÇл»µ½RTFģʽ¡£Õâ¸öÏûÏ¢Ò²¿ÉÒÔÓÃÀ´ÉèÖÃÖØ×ö/³·ÏúµÄģʽ£¬ÔÚdwTextMode²ÎÊýÖÐͬʱָ¶¨TM_SINGLELEVELUNDO±êÖ¾¿ÉÒÔ½«¿Ø¼þÉèÖÃΪµ¥¼¶ÖØ×ö/³·Ïúģʽ£»Ö¸¶¨TM_MULTILEVELUNDO±êÖ¾ÔòÉèÖÃΪ¶à¼¶ÖØ×ö/³·Ïúģʽ¡£

ÒªÉèÖÃÎı¾¸ñʽ¿ÉÒÔͨ¹ý·¢ËÍEM_SETCHARFORMATÏûÏ¢£¬Õâ¸öÏûÏ¢ÉèÖÿؼþÖÐÒ»¶ÎÑ¡¶¨µÄÎı¾»òÕ
·µ»ØĿ¼ ÉÏÒ»Ò³ ÏÂÒ»Ò³ »Øµ½¶¥²¿ ÔÞ£¨0£© ²È£¨0£©
δÔĶÁÍꣿ¼ÓÈëÊéÇ©ÒѱãÏ´μÌÐøÔĶÁ£¡
ÎÂÜ°Ìáʾ£º ο´Ð¡ËµµÄͬʱ·¢±íÆÀÂÛ£¬Ëµ³ö×Ô¼ºµÄ¿´·¨ºÍÆäËüС»ï°éÃÇ·ÖÏíÒ²²»´íŶ£¡·¢±íÊéÆÀ»¹¿ÉÒÔ»ñµÃ»ý·ÖºÍ¾­Ñé½±Àø£¬ÈÏÕæдԭ´´ÊéÆÀ ±»²ÉÄÉΪ¾«ÆÀ¿ÉÒÔ»ñµÃ´óÁ¿½ð±Ò¡¢»ý·ÖºÍ¾­Ñé½±ÀøŶ£¡