source: dev/trunk/ab5.0/abdev/ProjectEditor/StringCount.cpp@ 479

Last change on this file since 479 was 475, checked in by dai_9181, 17 years ago

構成管理を変更中・・・(いったんコミット)

File size: 2.0 KB
Line 
1#include "stdafx.h"
2
3#include "common.h"
4
5#ifdef THETEXT
6
7BOOL CALLBACK DlgStringCount(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
8 if(message==WM_INITDIALOG){
9 SetPosCenter(hwnd);
10
11 int i,WndNum;
12
13 WndNum=GetWndNum(GetWindow(hClient,GW_CHILD));
14
15 char *pBuf;
16 if(lParam){
17 //選択範囲
18 CHARRANGE CharRange;
19 TextEdit_GetSel(WndNum,&CharRange);
20 pBuf=(char *)HeapAlloc(hHeap,0,(CharRange.cpMax-CharRange.cpMin)+1);
21 TextEdit_GetSelText(WndNum,&CharRange,pBuf);
22
23 SetWindowText(hwnd,"選択範囲の文字カウント");
24 }
25 else{
26 //すべての範囲
27 pBuf=(char *)HeapAlloc(hHeap,0,lstrlen(MdiInfo[WndNum].pMdiTextEdit->buffer)+1);
28 lstrcpy(pBuf,MdiInfo[WndNum].pMdiTextEdit->buffer);
29 }
30
31 //総バイト数を取得
32 int iByte;
33 iByte=lstrlen(pBuf);
34
35 //文字数(スペースを含めない)を取得
36 int iOmitSpace=0;
37 for(i=0;i<iByte;i++){
38 if(pBuf[i]==' '||pBuf[i]=='\t') continue;
39 if(pBuf[i]==(char)0x81&&pBuf[i+1]==(char)0x40){
40 i++;
41 continue;
42 }
43 if(pBuf[i]=='\r'&&pBuf[i+1]=='\n'){
44 i++;
45 continue;
46 }
47 iOmitSpace++;
48 if(IsDBCSLeadByte(pBuf[i])){
49 i++;
50 continue;
51 }
52 }
53
54 //文字数(スペースを含む)を取得
55 int iWithSpace=0,iLineNum=0;
56 for(i=0;i<iByte;i++){
57 if(pBuf[i]=='\r'&&pBuf[i+1]=='\n'){
58
59 //行数
60 iLineNum++;
61
62 i++;
63 continue;
64 }
65 iWithSpace++;
66 if(IsDBCSLeadByte(pBuf[i])){
67 i++;
68 continue;
69 }
70 }
71
72 if(iByte) iLineNum++;
73
74 char temporary[255];
75
76 //総バイト数
77 Digit(iByte,temporary);
78 SetDlgItemText(hwnd,IDC_SCOUNT_BYTE,temporary);
79
80 //文字数(スペースを含めない)
81 Digit(iOmitSpace,temporary);
82 SetDlgItemText(hwnd,IDC_SCOUNT_OMIT_SPACE,temporary);
83
84 //文字数(スペースを含む)
85 Digit(iWithSpace,temporary);
86 SetDlgItemText(hwnd,IDC_SCOUNT_WITH_SPACE,temporary);
87
88 //行数
89 Digit(iLineNum,temporary);
90 SetDlgItemText(hwnd,IDC_SCOUNT_LINENUM,temporary);
91
92
93 HeapDefaultFree(pBuf);
94 }
95 if(message==WM_COMMAND&&LOWORD(wParam)==IDCANCEL) EndDialog(hwnd,NULL);
96 return 0;
97}
98
99#endif //THETEXT
100
101
Note: See TracBrowser for help on using the repository browser.