หน้าแรก
 การบ้าน
  C/C++ new
  Java new
  Windows Phone
  แจ้งเรื่องที่ต้องการ
 บทความ
  .NET
  Android
  Blackberry
  C++Builder
  Delphi
  Java
  Mobile
  Open Source
  Pocket PC
  Visual Basic
  Web
  Windows Phone
  Others
 แบบเรียนฟรี
  ASP
  ASP.NET Webmatrix
  C++
  eVB
  J2ME
  Java
  PHP
 ซอร์สโค้ด
  Android
  ASP
  C++
  VC++
  CGI-Perl
  Delphi
  Java
  jQuery
  PHP
  Visual Basic
  .NET
 บริการจากเรา
  เปิดท้าย... ขายโค้ด
  Freeware
  อัตราค่าโฆษณา
  รายชื่อลูกค้า
  สถิติผู้เข้าเว็บ
 ดาว์นโหลด
 ค้นหาข้อมูล
 กระดานสนทนา
  .NET
  C/C++
  Delphi
  Java
  Palm/PocketPC
  Visual Basic
  Web
  อื่นๆ
 กระดานงาน
 ลิงค์เว็บ
 เกี่ยวกับผม
 อัตราค่าโฆษณา
Social Network

Facebook  Twitter  YouTube
 New Article
 Webboard
 Freelanceboard
Freeware
โปรแกรมเบอร์ดี (BerDee)
โปรแกรมเบอร์ดี (Android)
เกมส์เป่ายิ้งฉุบ
เกมส์เป่ายิ้งฉุบ(Android)
WebcamMonitor
WebcamMonitor(Windows)
scSendMail
scSendMail(Windows)
MSN Caption
MSN Caption(Windows)
  Freelance comment
  ติดต่อสอบถามมาได้ตลอดนะ...
2015-07-29 13:35:58
  ถ้าผมต้องการเว็บที่พัฒน...
2015-01-18 15:33:54
  ถ้าผมต้องการเว็บที่พัฒน...
2015-01-18 15:32:51
  ติดต่อสอบถามเข้ามาได้นะ...
2014-01-06 12:47:38
  ถ้ายังหาคนสอนไม่ได้ ก็ลอ...
2013-07-06 01:04:37
  สนใจส่งขอบเขตมาคุยราคาก...
2013-03-24 18:54:20
  ถ้ายังไม่มีคนรับงานติดต...
2012-12-16 19:18:14
  สนใจคะ ติดต่อ 0905076277...
2012-11-12 11:07:46
  รับทำโปรเจ็คนักศึกษาหรื...
2012-10-29 03:10:46
  sukit_te34@hotmail.com...
2012-10-29 03:09:36
  Webboard comment
  เขียนโปรแกรมภาษาจาวา
1.โ...

2023-09-12 11:40:28
  ต้องลอง debug ดูเองครับ
ไล่...

2023-06-08 18:03:06
  ร้านค้าแห่งหนึ่ง จะต้องน...
2021-09-21 08:47:08
  จงเขียนโปรแกรมดำเนินการ...
2021-05-07 15:06:11
  จงเขียนโปรแกรมสำหรับคำน...
2021-03-09 14:21:45
  ขอดู...
2021-01-04 23:56:45
  ขอโค้ดเพื่อทำการเรียนกา...
2020-12-09 23:02:09
  แล้ว ?...
2020-12-09 10:56:34
  จ้า...
2020-10-18 16:53:21
  พอดีผมเหลื่อแค่ตัดสต๊อก...
2020-05-31 21:49:43
  Homework comment
  เขียนโปรแกรมเพื่อรับค่า...
2022-02-24 10:45:17
  จากโค้ดนี้อะครับ พอดีลอง...
2021-03-22 01:22:39
  จากโค้ดนี้อะครับ พอดีลอง...
2021-03-22 01:22:39
  โจทย์การบ้าน c++ เขียนรูปแ...
2020-04-06 11:01:33
  แบบนี้ขอเป็น ภาษา php หน่อย...
2019-09-18 14:36:34
  ผมไม่อยากให้คุณได้คะแนน...
2019-04-27 01:29:07
  อาจารย์เขาบอกแนวข้อสอบม...
2019-04-27 00:44:29
  ขอสอบถามการเขียน c++ ครับ เ...
2018-04-02 12:19:21
  โค้ดตัวอย่างศึกษาให้เข้...
2017-11-26 14:50:05
  คำนวณค่าน้ำโดยรับค่ามิเ...
2017-11-20 23:15:26
  Article comment
  เท่าที่อ่าน error คือพื้นที่...
2022-03-23 13:56:48
  เรียน สอบถามปัญหา กับ อ.คร...
2022-01-24 17:39:49
  ต้องการ ให้เขียน โปรแกรม ...
2019-12-09 11:39:58
  รับเขียน arx จาก vc++ 2017 ล็อคโปร...
2019-09-19 09:48:09
  ทำการ register ไฟล์ที่ชื่อ mswinsck.oc...
2019-09-17 14:05:56
  ใน vb 6 ไม่มี component winsock เลยค่ะ ส...
2019-09-03 10:31:02
  รบกวนขอสอบถามหน่อยนะครั...
2019-03-04 05:31:04
  สามารถนำตัวหนังสือจากภา...
2018-12-25 08:54:32
  มีcode ของ VB ไหมค่ะ ถ้ามีรบกว...
2017-09-28 16:50:02
  น่าจะได้ครับ ไม่เคยลอง
...

2017-07-11 09:59:35
  9Mcode comment

Link Exchange

อัตราค่าโฆษณา
 
 Webboard

- - - - - - - - - - - - - - ผู้ให้การสนับสนุน- - - - - - - - - - - - - -

กระทู้ #3069 [C] (จาก IP: 14.207.141.147)

ภาษาไทยในเกม

คือว่าตอนนี้ผมแก้ไขให้พิมไทยได้หมดแล้ว เหลือเวลาสร้างชื่อตัวละคร พิมภาษาไทยไม่ได้ รบกวนพวกพี่ๆ แนะนำหรือช่วยแก้ไขทีครับ หรือทิ้งเมลไว้ก็ได้ครับ

---------------------------------------
โค๊ด
---------------------------------------

#include "stdafx.h"
#include "cIMEex.h"
#include "./interface/cFont.h"
#include "./interface/cEditbox.h"

// 070202 LYW --- Include header file.
#include "../[CC]Header/GameResourceManager.h"

cIMEex::cIMEex()
{
m_wFontIdx = 0;

m_pStrBuf = NULL;
m_InsertPos.nLine = 0;
m_InsertPos.nIndex = 0;

m_nCurTotalLen = 0;
m_nCurTotalLine = 1;

m_nMaxTotalLen = 128;
m_nMaxTotalLine = 1;

m_bCompositing = FALSE;
m_bMultiLine = FALSE;

m_bEnterAllow = TRUE;

const DISPLAY_INFO& dispInfo = GAMERESRCMNGR->GetResolution();
m_nLimitWidth = dispInfo.dwWidth ;
// 070202 LYW --- End.

m_pParentEdit = NULL;

SetValidCheckMethod( VCM_DEFAULT );

// 091126 ShinJS --- CheckMethod 贸府肺 牢窍咯 扁夯巩磊甫 汲沥茄促.
ZeroMemory( m_CheckMethodBaseStr, MAX_LINE );
m_CheckMethodBaseStr[0] = '0';
}


cIMEex::~cIMEex()
{

}


void cIMEex::Init( int nMaxBufSize, int nPixelWidth, BOOL bMultiLine, int nMaxLine )
{
m_nMaxTotalLen = nMaxBufSize;

m_nLimitWidth = nPixelWidth;
m_bMultiLine = bMultiLine;

if( m_bMultiLine )
{
m_nMaxTotalLine = nMaxLine;
}
else
{
m_nMaxTotalLine = 1;
}


m_bChanged = FALSE;

m_pStrBuf = new char[nMaxBufSize+1];
ZeroMemory( m_pStrBuf, nMaxBufSize+1 );
ZeroMemory(
m_pLineDesc,
sizeof(m_pLineDesc));

SetValidCheckMethod( VCM_DEFAULT );
}


void cIMEex::Release()
{
if( m_pStrBuf )
{
delete[] m_pStrBuf;
m_pStrBuf = NULL;
}
}


BOOL cIMEex::Paste( char* str )
{
if( *str == 0 ) return FALSE;

char buf[3];

while( *str )
{
if( str[0] == 13 && str[1] == 10 )
{
if( Enter() == FALSE ) return FALSE;
str += 2;
}
else if( IsDBCSLeadByte(*str) )
{
buf[0] = str[0];
buf[1] = str[1];
buf[2] = 0;
str += 2;

if( IsValidChar( (unsigned char*)buf ) )
if( Insert( buf ) == FALSE )
return FALSE;
}
else
{
buf[0] = str[0];
buf[1] = 0;
++str;

if( IsValidChar( (unsigned char*)buf ) )
if( Insert( buf ) == FALSE )
return FALSE;
}
}

return TRUE;
}


BOOL cIMEex::Insert( char* str ) //坷流 茄臂磊(1~2byte)
{
m_bChanged = TRUE;

if( m_bCompositing )
DeleteBefore();

int nLen = strlen( str );
if( nLen == 0 ) return FALSE;

if( nLen > 2 ) //Paste肺父 啊瓷
{
str[2] = 0;
nLen = 2;
}

if( m_nCurTotalLen + nLen > m_nMaxTotalLen )
return FALSE;

int nInsertIndex = GetInsertIndex();
char* p = GetInsertBufPtr();

memmove( p + nLen, p, m_nCurTotalLen - nInsertIndex );
m_nCurTotalLen += nLen;
memcpy( p, str, nLen );

m_InsertPos.nIndex += nLen;
m_pLineDesc[m_InsertPos.nLine].nLen += nLen;

for( int i = m_InsertPos.nLine + 1 ; i < m_nCurTotalLine ; ++ i )
{
m_pLineDesc[i].nStartIndex += nLen;
}

if( !Wrap( m_InsertPos.nLine ) )
{
DeleteBefore();
return FALSE;
}

return TRUE;
}


BOOL cIMEex::Wrap( int nStartLine )
{
if( m_bMultiLine == FALSE ) return TRUE;

LONG lExtent = CFONT_OBJ->GetTextExtentEx( m_wFontIdx,
m_pStrBuf + m_pLineDesc[nStartLine].nStartIndex,
m_pLineDesc[nStartLine].nLen );

int nWrapNum = 0;
int nStartIndex = m_pLineDesc[nStartLine].nStartIndex;
int nWrapIndex = m_pLineDesc[nStartLine].nLen;

char* p;
int nMoveNum;

////////////////////////

if( lExtent > m_nLimitWidth )
{
// if( m_bMultiLine == FALSE || m_nCurTotalLine >= m_nMaxTotalLine )
if( m_bMultiLine == FALSE || m_nCurTotalLine >= m_nMaxTotalLine )
return FALSE; //路隆脟脦 脟脪录枚 戮酶麓脵.

while( lExtent > m_nLimitWidth )
{
p = m_pStrBuf + nStartIndex + nWrapIndex;
// nMoveNum = IsDBCSLeadByte( *(p-1) ) ? 2 : 1;
nMoveNum = IsDBCSLeadByte( *CharPrev( m_pStrBuf, p ) ) ? 2 : 1;

nWrapNum += nMoveNum;
nWrapIndex -= nMoveNum;

if( m_InsertPos.nIndex > nWrapIndex )
{
m_InsertPos.nIndex = nWrapNum;
++m_InsertPos.nLine;
}

lExtent = CFONT_OBJ->GetTextExtentEx( m_wFontIdx,
m_pStrBuf + m_pLineDesc[nStartLine].nStartIndex,
nWrapIndex );
}

if( m_pLineDesc[nStartLine].nEndKind != EK_WRAP )
{

for( int i = m_nCurTotalLine ; i > nStartLine ; --i )
{
m_pLineDesc[i] = m_pLineDesc[i-1];
}

m_pLineDesc[nStartLine].nLen -= nWrapNum;
m_pLineDesc[nStartLine].nEndKind = EK_WRAP;

m_pLineDesc[nStartLine+1].nStartIndex = nStartIndex + nWrapIndex ;
m_pLineDesc[nStartLine+1].nLen = nWrapNum;

m_nCurTotalLine++;

return TRUE;
}
else
{
m_pLineDesc[nStartLine].nLen -= nWrapNum;

m_pLineDesc[nStartLine+1].nStartIndex -= nWrapNum;
m_pLineDesc[nStartLine+1].nLen += nWrapNum;

return Wrap( nStartLine + 1 );

}
}

////////////////////////

else
{
if( m_pLineDesc[nStartLine].nEndKind != EK_WRAP )
return TRUE; //路隆脟脦脟脪 脟脢驴盲戮酶麓脵

while( 1 )
{
if( m_pLineDesc[nStartLine+1].nLen <= -nWrapNum )
break;

p = m_pStrBuf + nStartIndex + nWrapIndex;
nMoveNum = IsDBCSLeadByte( *p ) ? 2 : 1;

nWrapNum -= nMoveNum;
nWrapIndex += nMoveNum;

lExtent = CFONT_OBJ->GetTextExtentEx( m_wFontIdx,
m_pStrBuf + m_pLineDesc[nStartLine].nStartIndex,
nWrapIndex );

if( lExtent > m_nLimitWidth )
{
nWrapNum += nMoveNum;
nWrapIndex -= nMoveNum;
break;
}
}

if( nWrapNum == 0 ) return TRUE;

m_pLineDesc[nStartLine].nLen -= nWrapNum;

m_pLineDesc[nStartLine+1].nStartIndex -= nWrapNum;
m_pLineDesc[nStartLine+1].nLen += nWrapNum;

if( m_pLineDesc[nStartLine+1].nLen <=0 )
{
--m_nCurTotalLine;

m_pLineDesc[nStartLine].nEndKind = m_pLineDesc[nStartLine+1].nEndKind;

for( int i = nStartLine+1 ; i < m_nCurTotalLine ; ++i )
{
m_pLineDesc[i] = m_pLineDesc[i+1];
}

return TRUE;
}

return Wrap( nStartLine + 1 );
}
}



BOOL cIMEex::Enter()
{
if( m_bEnterAllow == FALSE ) return FALSE;

m_bChanged = TRUE;

if( m_bMultiLine == FALSE || m_nMaxTotalLine <= m_nCurTotalLine ) return FALSE;

int nBreakLen = m_pLineDesc[m_InsertPos.nLine].nLen - m_InsertPos.nIndex;
int nStartIndex = m_pLineDesc[m_InsertPos.nLine].nStartIndex + m_InsertPos.nIndex;

m_pLineDesc[m_InsertPos.nLine].nLen = m_InsertPos.nIndex;
m_pLineDesc[m_InsertPos.nLine].nEndKind = EK_ENTER;

m_InsertPos.nIndex = 0;
++m_InsertPos.nLine;

for( int i = m_nCurTotalLine ; i >= m_InsertPos.nLine ; --i )
{
m_pLineDesc[i] = m_pLineDesc[i-1];
}

m_pLineDesc[m_InsertPos.nLine].nLen = nBreakLen;
m_pLineDesc[m_InsertPos.nLine].nStartIndex = nStartIndex;

++m_nCurTotalLine;

return TRUE;
}


BOOL cIMEex::CaretMoveLeft()
{
m_bChanged = TRUE;
int nInsertIndex = GetInsertIndex();
if( nInsertIndex <= 0 ) return FALSE;

if( m_InsertPos.nIndex <= 0 )
{
--m_InsertPos.nLine;
m_InsertPos.nIndex = m_pLineDesc[m_InsertPos.nLine].nLen;
if( m_pLineDesc[m_InsertPos.nLine].nEndKind == EK_WRAP )
CaretMoveLeft();
}
else
{
char* p = GetInsertBufPtr();
// int nMoveNum = IsDBCSLeadByte( *(p-1) ) ? 2 : 1;
int nMoveNum = IsDBCSLeadByte( *CharPrev( m_pStrBuf, p ) ) ? 2 : 1;
m_InsertPos.nIndex -= nMoveNum;
}

return TRUE;
}


BOOL cIMEex::CaretMoveRight()
{
m_bChanged = TRUE;
int nInsertIndex = GetInsertIndex();
if( nInsertIndex >= m_nCurTotalLen ) return FALSE;

if( m_InsertPos.nIndex >= m_pLineDesc[m_InsertPos.nLine].nLen )
{
++m_InsertPos.nLine;
m_InsertPos.nIndex = 0;
if( m_pLineDesc[m_InsertPos.nLine].nEndKind == EK_WRAP )
CaretMoveRight();
}
else
{
char* p = GetInsertBufPtr();
int nMoveNum = IsDBCSLeadByte( *p ) ? 2 : 1;
m_InsertPos.nIndex += nMoveNum;
}

return TRUE;
}



BOOL cIMEex::CaretMoveUp()
{
m_bChanged = TRUE;
if( m_InsertPos.nLine <= 0 ) return FALSE;

--m_InsertPos.nLine;

if( m_InsertPos.nIndex >= m_pLineDesc[m_InsertPos.nLine].nLen )
{
m_InsertPos.nIndex = m_pLineDesc[m_InsertPos.nLine].nLen;
}
else if( m_InsertPos.nIndex != 0 )
{
char* p = GetInsertBufPtr();
// if( IsDBCSLeadByte( *p ) && IsDBCSLeadByte( *(p-1) ) ) //脟脩卤脹脕脽掳拢
if( p != CharNext( CharPrev( m_pStrBuf, p ) ) )
{
--m_InsertPos.nIndex;
}
}

return TRUE;
}


BOOL cIMEex::CaretMoveDown()
{
m_bChanged = TRUE;
if( m_InsertPos.nLine >= m_nCurTotalLine - 1 ) return FALSE;

++m_InsertPos.nLine;

if( m_InsertPos.nIndex >= m_pLineDesc[m_InsertPos.nLine].nLen )
{
m_InsertPos.nIndex = m_pLineDesc[m_InsertPos.nLine].nLen;
}
else if( m_InsertPos.nIndex != 0 )
{
char* p = GetInsertBufPtr();
// if( IsDBCSLeadByte( *p ) && IsDBCSLeadByte( *(p-1) ) ) //脟脩卤脹脕脽掳拢
if( p != CharNext( CharPrev( m_pStrBuf, p ) ) )
{
--m_InsertPos.nIndex;
}
}

return TRUE;
}


BOOL cIMEex::CaretMoveHome()
{
m_bChanged = TRUE;
m_InsertPos.nIndex = 0;
return TRUE;
}


BOOL cIMEex::CaretMoveEnd()
{
m_bChanged = TRUE;
m_InsertPos.nIndex = m_pLineDesc[m_InsertPos.nLine].nLen;
return TRUE;
}

BOOL cIMEex::CaretMoveFirst()
{
m_bChanged = TRUE; //for scroll and so on
m_InsertPos.nIndex = 0;
m_InsertPos.nLine = 0;
return TRUE;
}


BOOL cIMEex::DeleteAfter()
{
m_bChanged = TRUE;
int nInsertIndex = GetInsertIndex();
if( m_InsertPos.nLine >= m_nCurTotalLine - 1 && nInsertIndex >= m_nCurTotalLen ) return FALSE;

char* p = GetInsertBufPtr();
int nDeleteNum = IsDBCSLeadByte( *p ) ? 2 : 1;

if( m_InsertPos.nIndex >= m_pLineDesc[m_InsertPos.nLine].nLen )
{

if( m_pLineDesc[m_InsertPos.nLine+1].nLen == 0 )
{
--m_nCurTotalLine;
for( int i = m_InsertPos.nLine+1 ; i < m_nCurTotalLine ; ++i )
{
m_pLineDesc[i] = m_pLineDesc[i+1];
}

m_pLineDesc[m_InsertPos.nLine].nEndKind = m_pLineDesc[m_InsertPos.nLine+1].nEndKind;
}
else
{
if( m_pLineDesc[m_InsertPos.nLine].nEndKind == EK_WRAP )
{

m_InsertPos.nIndex = 0;
++m_InsertPos.nLine;
return DeleteAfter();
}

m_pLineDesc[m_InsertPos.nLine].nEndKind = EK_WRAP;
}
}
else
{
memmove( p, p + nDeleteNum, m_nCurTotalLen - nInsertIndex - nDeleteNum );
m_nCurTotalLen -= nDeleteNum;
ZeroMemory( m_pStrBuf + m_nCurTotalLen, nDeleteNum );

m_pLineDesc[m_InsertPos.nLine].nLen -= nDeleteNum;
for( int i = m_InsertPos.nLine + 1 ; i < m_nCurTotalLine ; ++i )
{
m_pLineDesc[i].nStartIndex -= nDeleteNum;
}

if( m_InsertPos.nLine > 0 && m_pLineDesc[m_InsertPos.nLine].nLen == 0 )
{
if( m_pLineDesc[m_InsertPos.nLine-1].nEndKind == EK_WRAP )
{
m_pLineDesc[m_InsertPos.nLine-1].nEndKind = m_pLineDesc[m_InsertPos.nLine].nEndKind;

--m_nCurTotalLine;
--m_InsertPos.nLine;
m_InsertPos.nIndex = m_pLineDesc[m_InsertPos.nLine].nLen;

for( int i = m_InsertPos.nLine + 1 ; i < m_nCurTotalLine ; ++i )
{
m_pLineDesc[i] = m_pLineDesc[i+1];
}
}
}
}

return Wrap( m_InsertPos.nLine );
}


BOOL cIMEex::DeleteBefore()
{
m_bChanged = TRUE;
int nInsertIndex = GetInsertIndex();
if( nInsertIndex <= 0 ) return FALSE;

char* p = GetInsertBufPtr();
// int nDeleteNum = IsDBCSLeadByte( *(p-1) ) ? 2 : 1;

int nDeleteNum = IsDBCSLeadByte( *CharPrev( m_pStrBuf, p ) ) ? 2 : 1;

if( m_InsertPos.nIndex <= 0 )
{
--m_InsertPos.nLine;
m_InsertPos.nIndex = m_pLineDesc[m_InsertPos.nLine].nLen;

if( m_pLineDesc[m_InsertPos.nLine+1].nLen == 0 )
{
--m_nCurTotalLine;
for( int i = m_InsertPos.nLine+1 ; i < m_nCurTotalLine ; ++i )
{
m_pLineDesc[i] = m_pLineDesc[i+1];
}

m_pLineDesc[m_InsertPos.nLine].nEndKind = m_pLineDesc[m_InsertPos.nLine+1].nEndKind;

}
else
{
if( m_pLineDesc[m_InsertPos.nLine].nEndKind == EK_WRAP )
{
return DeleteBefore();
}

m_pLineDesc[m_InsertPos.nLine].nEndKind = EK_WRAP;
}
}
else
{
memmove( p - nDeleteNum, p, m_nCurTotalLen - nInsertIndex );

m_nCurTotalLen -= nDeleteNum;
ZeroMemory( m_pStrBuf + m_nCurTotalLen, nDeleteNum );

m_InsertPos.nIndex -= nDeleteNum;
m_pLineDesc[m_InsertPos.nLine].nLen -= nDeleteNum;

for( int i = m_InsertPos.nLine + 1 ; i < m_nCurTotalLine ; ++i )
{
m_pLineDesc[i].nStartIndex -= nDeleteNum;
}

if( m_InsertPos.nLine > 0 && m_pLineDesc[m_InsertPos.nLine].nLen == 0 )
{
if( m_pLineDesc[m_InsertPos.nLine-1].nEndKind == EK_WRAP )
{
m_pLineDesc[m_InsertPos.nLine-1].nEndKind = m_pLineDesc[m_InsertPos.nLine].nEndKind;

--m_nCurTotalLine;
--m_InsertPos.nLine;
m_InsertPos.nIndex = m_pLineDesc[m_InsertPos.nLine].nLen;

for( int i = m_InsertPos.nLine + 1 ; i < m_nCurTotalLine ; ++i )
{
m_pLineDesc[i] = m_pLineDesc[i+1];
}
}
}
}

return Wrap( m_InsertPos.nLine );
}


BOOL cIMEex::DeleteAllText()
{
ZeroMemory( m_pStrBuf, m_nCurTotalLen );
ZeroMemory( m_pLineDesc, m_nCurTotalLine * sizeof(sLineDesc) );

m_InsertPos.nIndex = 0;
m_InsertPos.nLine = 0;

m_nCurTotalLine = 1;
m_nCurTotalLen = 0;

m_bCompositing = FALSE;

return TRUE;
}


BOOL cIMEex::GetLineText( int nLine, char* strText, int* pStrLen )
{
if( nLine >= m_nCurTotalLine ) return FALSE;

strncpy( strText, m_pStrBuf + m_pLineDesc[nLine].nStartIndex, m_pLineDesc[nLine].nLen );
strText[m_pLineDesc[nLine].nLen] = 0;

if( pStrLen )
*pStrLen = m_pLineDesc[nLine].nLen;

return TRUE;
}




void cIMEex::SetScriptText( const char* str )
{
DeleteAllText();

char strInsert[3];

while( *str )
{
switch( *str )
{
case TEXT_DELIMITER:
{
++str;
switch( *str )
{
case TEXT_NEWLINECHAR:
{
Enter();
}
break;
}
}
break;

default:
{
if( IsDBCSLeadByte(*str) )
{
strInsert[0] = *str;
strInsert[1] = *(++str);
strInsert[2] = 0;
}
else
{
strInsert[0] = *str;
strInsert[1] = 0;
}

Insert( strInsert );
}
break;
}

++str;
}


}


void cIMEex::GetScriptText( char* str )
{
*str = 0; //戮虏路鹿卤芒掳陋 脕陇赂庐
for( int i = 0 ; i < m_nCurTotalLine ; ++i )
{
strncat( str, m_pStrBuf + m_pLineDesc[i].nStartIndex, m_pLineDesc[i].nLen );
if( m_pLineDesc[i].nEndKind == EK_ENTER )
strcat( str, "^n" );
}
}


void cIMEex::SetValidCheckMethod( int nMethodNum )
{
m_nValidCheckMethod = nMethodNum;
}



BOOL cIMEex::IsValidChar( unsigned char* str )
{
if( *str == 0 ) return TRUE;

BOOL bValid = FALSE;

switch( m_nValidCheckMethod )
{

case VCM_SPACE:
{
if( *str == ' ' )
break;
}
case VCM_DBPARAM:
case VCM_ID:
case VCM_PASSWORD:
{
if( *str == '\'' )
break;
}
///
case VCM_DEFAULT:
{
if( (*str >= 32 && *str < 255) || IsDBCSLeadByte(*str) ) //驴碌鹿庐, 脟脩卤脹..脟脩?脷 脝炉录枚鹿庐?脷
{
bValid = TRUE;
break;
}

}
case VCM_CHARNAME:
{
#ifdef _TW_LOCAL_
///////////
if( IsDBCSLeadByte(*str) )
{
bValid = TRUE;
break;
}
///////////
#else
if( str[0] >= 0xa1 && str[0] <= 0xac && str[1] >= 0x80 && str[1] <= 0xfe )
{
if( str[0] == 0xa4 || ( str[1] > 0x80 && str[1] < 0xa1 ) )
{
bValid = TRUE;
break;
}
// if( str[0] == 0xa4 )
// {
// bValid = TRUE;
// break;
// }
break;
}

if( str[0] >= 0xb0 && str[0] <=0xc8 && str[1] >= 0xa1 && str[1] <= 0xfe )//0xB0A1~0xC8FE
{
bValid = TRUE;
break;
}
if( str[0] >= 0x81 && str[0] <= 0xc6 && str[1] >= 0x41 && str[1] <= 0xfe )
{
bValid = TRUE;
break;
}
#endif
}

// case VCM_ID:
// case VCM_PASSWORD:
{

if( ( *str >= 'A' && *str <= 'Z' ) || ( *str >= 'a' && *str <= 'z' ) )
{
bValid = TRUE;
break;
}

#ifdef _TL_LOCAL_
if( *str >= 0xa1 && *str <= 0xd9 )
{
bValid = TRUE;
break;
}
else if( *str >= 0xE0 && *str <= 0xEC )
{
bValid = TRUE;
break;
}
#endif
}

// 080403 LYW --- cIMEex : Add a enum type to use number without comma.
case VCM_NORMAL_NUMBER :
case VCM_NUMBER:
{
if( *str >= '0' && *str <= '9' )
{
bValid = TRUE;
break;
}
}
}

return bValid;
}

BOOL cIMEex::SetLimitLine( int nMaxLine )
{
if( nMaxLine < m_nCurTotalLine )
return FALSE;

m_nMaxTotalLine = nMaxLine;
return TRUE;
}

void cIMEex::CheckAfterChange()
{
if( m_nValidCheckMethod == VCM_NUMBER )
{
// 100607 ONS 荐樊涝仿矫 FOCUS啊 积扁搁 货肺 涝仿阑 罐绰促.
char buf[64] = {0};
if( m_bIsFirstInput )
{
const char* const pBuf = RemoveComma(m_pStrBuf);
int nLen = strlen(pBuf);
buf[0] = pBuf[max(0, nLen - 1)];
m_bIsFirstInput = FALSE;
}
else
{
strcpy( buf, RemoveComma(m_pStrBuf) );
}

int len = strlen(buf);

if( len == 0 )
{
strcpy( buf, m_CheckMethodBaseStr );
}
else
{
if( len > 1 && *buf == '0' )
{
memmove( buf, buf+1, strlen(buf) );
}

AddComma( buf );
}

SetScriptText( buf );
}
// 080403 LYW --- cIMEex : Add a enum type to use number without comma.
else if( m_nValidCheckMethod == VCM_NORMAL_NUMBER )
{
char buf[64] = {0};

if( m_bIsFirstInput )
{
int nLen = strlen(m_pStrBuf);
buf[0] = m_pStrBuf[max(0, nLen - 1)];
m_bIsFirstInput = FALSE;
}
else
{
strcpy( buf, m_pStrBuf );
}

int len = strlen(buf);

if( len == 0 )
{
strcpy( buf, m_CheckMethodBaseStr );
}
else
{
if( len > 1 && *buf == '0' )
{
memmove( buf, buf+1, strlen(buf) );
}
}

SetScriptText( buf );
}
}

---------------------------------------------------------
จากคุณ : smitt / soon_ten@hotmail.com [2011-05-01 21:23:27]  
ตอบกระทู้
  • ห้ามการโฆษณา หากต้องการติดต่อหาลูกค้า ติดต่อโฆษณาโดยตรงได้ที่ webmaster@sourcecode.in.th
  • ห้ามใช้คำหยาบและคำพูดที่ไม่เหมาะสม
  • ขอสงวนสิทธิหากตรวจพบ ข้อความที่ไม่เหมาะสม ข้อความนั้นจะถูกลบทันที
ชื่อ
อีเมล์
รายละเอียด

- - - - - - - - - - - - - - ผู้ให้การสนับสนุน- - - - - - - - - - - - - -

 
 
คลิปสอนเขียนโปรแกรม
เรียนเขียนโปรแกรมดอทเน็ต
เรียนเขียนโปรแกรมแอนดรอยด์
เรียนเขียนโปรแกรมเบล็คเบอร์รี่
เรียนเขียนโปรแกรมซี ซีพลัสพลัส
เรียนเขียนโปรแกรมจาวา
เรียนการใช้งานลินุกส์
เรียนการเขียนโปรแกรมวินโดว์โฟน
เรียนการเขียนโปรแกรมพีเฮชพี มายเอสคิวเอล
อัตราค่าโฆษณา
 
Tutorial
eVB Tutorial
ASP.NET Webmatrix Tutorial
J2ME Tutorial
C++  Tutorial
Java  Tutorial
PHP Tutorial
ASP Tutorial
 
แบบสำรวจ

Home - Article - Tutorial - Sourcecode - Dev Handbook - Search - WebBoard - Links - About Us

สงวนลิขสิทธิ์ ห้ามคัดลอก ทำซ้ำ แก้ไข ดัดแปลง ไม่ว่าในรูปแบบใด โดยไม่ได้รับอนุญาตเป็นลายลักษณ์อักษร
เลขทะเบียนพาณิชย์อิเล็กทรอนิกส์จากกระทรวงพาณิชย์: 7100503002000
Copyright 2001 SourceCode.in.th