|
ダイアログの場合
メインウインドウの場合
|
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch( message ) {
case WM_CREATE:
LvTable = new LboxListview(
hWnd,
LBOX_LISTVIEW_EDITABLE |
LBOX_LISTVIEW_CREATE
);
LvTable->Grid( );
Win = new LboxWin( hWnd );
Win->StatusCreate( ID_STATUS );
Win->ScreenFit( );
break;
case WM_SIZE:
Win->StatusFit( wParam, lParam );
LvTable->ParentFit(
(DWORD)wParam,
0, 0,
Win->GetHeight( Win->hStatus ),
0
);
break;
case WM_DESTROY:
delete LvTable;
delete Win;
PostQuitMessage( 0 );
break;
default:
return DefWindowProc( hWnd, message, wParam, lParam );
}
return 0;
}
| |
|
|
|
|
LboxDlg *Dlg;
LboxListview *Lview;
LRESULT CALLBACK About( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
{
switch( message )
{
case WM_INITDIALOG:
Dlg = new LboxDlg( hDlg );
Lview = new LboxListview( GetDlgItem( hDlg, IDC_LIST1 ) );
Lview->Grid( );
Lview->AddColumn( LVCFMT_LEFT, 70, "コード" );
Lview->AddColumn( LVCFMT_LEFT, 150, "氏名" );
Lview->AddColumn( LVCFMT_LEFT, 150, "フリガナ" );
Lview->AddColumn( LVCFMT_LEFT, 100, "電話番号" );
return TRUE;
case WM_COMMAND:
if( LOWORD(wParam) == IDCANCEL ) {
Dlg->End( LOWORD(wParam) );
delete Lview;
return TRUE;
}
break;
}
return FALSE;
}
| |
|
|
|
|
LboxDlg *Dlg;
LboxListview *Lview;
LRESULT CALLBACK About( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
{
switch( message )
{
case WM_INITDIALOG:
Dlg = new LboxDlg( hDlg );
Lview = new LboxListview( GetDlgItem( hDlg, IDC_LIST1 ) );
Lview->Grid( );
Lview->AddColumn( LVCFMT_LEFT, 70, "コード" );
Lview->AddColumn( LVCFMT_LEFT, 150, "氏名" );
Lview->AddColumn( LVCFMT_LEFT, 150, "フリガナ" );
Lview->AddColumn( LVCFMT_LEFT, 100, "電話番号" );
return TRUE;
case WM_COMMAND:
if( LOWORD(wParam) == IDCANCEL ) {
Dlg->End( LOWORD(wParam) );
delete Lview;
return TRUE;
}
if( LOWORD(wParam) == IDC_BUTTON1 ) {
Lview->AddRow();
Lview->SetColumnText( 0, "0001" );
Lview->SetColumnText( 1, "山田太郎" );
Lview->SetColumnText( 2, "ヤマダタロウ" );
Lview->SetColumnText( 3, "123-456-7890" );
}
break;
}
return FALSE;
}
| |
|
|
|
|
// *********************************************************
// デフォルトコンストラクタ
// *********************************************************
LboxListview::LboxListview()
{
LboxListview::Rowid = 0;
LboxListview::hHeader = NULL;
LboxListview::lpSkipColumn = "";
LboxListview::hhkFlg = false;
LboxListview::dwInitFlag = 0;
this->hWnd = NULL;
LboxListview::hCombo = NULL;
LboxListview::hEdit = NULL;
LboxListview::hMenu = NULL;
LboxListview::hFont = NULL;
LboxListview::ColumnType = NULL;
LboxListview::ColumnSize = NULL;
ListView_SetExtendedListViewStyle(
this->hWnd,
LVS_EX_SUBITEMIMAGES
);
LboxListview::Buffer = new LboxString( );
}
// *********************************************************
// 拡張コンストラクタ
// *********************************************************
LboxListview::LboxListview( HWND hTarget )
{
LboxListview::Rowid = 0;
LboxListview::hHeader = NULL;
LboxListview::lpSkipColumn = "";
LboxListview::hhkFlg = false;
LboxListview::dwInitFlag = 0;
LboxListview::ColumnType = NULL;
LboxListview::ColumnSize = NULL;
this->hWnd = hTarget;
LboxListview::hEdit =
LboxCreateEdit( this->hWnd, 50001 );
if ( LboxListview::hEdit != NULL ) {
HFONT hFont;
hFont = (HFONT)SendMessage( this->hWnd, WM_GETFONT, 0, 0 );
SendMessage( LboxListview::hEdit, WM_SETFONT, (WPARAM)hFont, 0 );
LboxMoveWindowTop( LboxListview::hEdit );
}
LboxListview::hCombo =
LboxCreateDropdownListbox( this->hWnd, 50002 );
if ( LboxListview::hCombo != NULL ) {
HFONT hFont;
hFont = (HFONT)SendMessage( this->hWnd, WM_GETFONT, 0, 0 );
SendMessage( LboxListview::hCombo, WM_SETFONT, (WPARAM)hFont, 0 );
LboxMoveWindowTop( LboxListview::hCombo );
}
LboxListview::hMenu = NULL;
LboxListview::hFont = NULL;
ListView_SetExtendedListViewStyle(
this->hWnd,
LVS_EX_SUBITEMIMAGES
);
LboxListview::Buffer = new LboxString( );
LboxListview::hHeader = ListView_GetHeader( this->hWnd );
}
// *********************************************************
// 拡張コンストラクタ2
// *********************************************************
LboxListview::LboxListview( HWND hTarget, DWORD dwFlag )
{
LboxListview::Rowid = 0;
LboxListview::hHeader = NULL;
LboxListview::lpSkipColumn = "";
LboxListview::hhkFlg = false;
LboxListview::dwInitFlag = dwFlag;
LboxListview::ColumnType = NULL;
LboxListview::ColumnSize = NULL;
if ( dwFlag & 0x00000002 ) {
LboxListview::nID = nBaseId;
nBaseId++;
this->hWnd = CreateWindowEx(
0,
WC_LISTVIEW,
"",
WS_CHILD | WS_VISIBLE | WS_BORDER |
LVS_REPORT | LVS_SHOWSELALWAYS,
0, 0, 0, 0,
hTarget,
(HMENU)(LboxListview::nID),
LboxGetInstance( hTarget ),
NULL
);
}
else {
this->hWnd = hTarget;
}
LboxListview::hCombo =
LboxCreateDropdownListbox( this->hWnd, 50002 );
if ( LboxListview::hCombo != NULL ) {
HFONT hFont;
hFont = (HFONT)SendMessage( this->hWnd, WM_GETFONT, 0, 0 );
SendMessage( LboxListview::hCombo, WM_SETFONT, (WPARAM)hFont, 0 );
LboxMoveWindowTop( LboxListview::hCombo );
}
LboxListview::hEdit =
LboxCreateEdit( this->hWnd, 50001 );
if ( LboxListview::hEdit != NULL ) {
HFONT hFont;
hFont = (HFONT)SendMessage( this->hWnd, WM_GETFONT, 0, 0 );
SendMessage( LboxListview::hEdit, WM_SETFONT, (WPARAM)hFont, 0 );
LboxMoveWindowTop( LboxListview::hEdit );
}
if ( dwFlag & 0x00000001 ) {
if ( hhk == NULL ) {
LboxListview::hhkFlg = true;
hhk = SetWindowsHookEx(
WH_CALLWNDPROCRET,
CallWndRetProc,
NULL,
GetCurrentThreadId()
);
hhkPost = SetWindowsHookEx(
WH_GETMESSAGE,
GetMsgProc,
NULL,
GetCurrentThreadId()
);
}
}
LboxListview::hMenu = NULL;
LboxListview::hFont = NULL;
ListView_SetExtendedListViewStyle(
this->hWnd,
LVS_EX_SUBITEMIMAGES
);
LboxListview::Buffer = new LboxString( );
LboxListview::hHeader = ListView_GetHeader( this->hWnd );
}
// *********************************************************
// デストラクタ
// *********************************************************
LboxListview::~LboxListview()
{
if ( LboxListview::hEdit != NULL ) {
DestroyWindow( LboxListview::hEdit );
LboxListview::hEdit = NULL;
}
if ( LboxListview::hCombo != NULL ) {
DestroyWindow( LboxListview::hCombo );
LboxListview::hCombo = NULL;
}
if ( LboxListview::hhkFlg ) {
if ( hhk != NULL ) {
UnhookWindowsHookEx( hhk );
hhk = NULL;
}
if ( hhkPost != NULL ) {
UnhookWindowsHookEx( hhkPost );
hhkPost = NULL;
}
}
if ( LboxListview::hMenu != NULL ) {
DestroyMenu( LboxListview::hMenu );
LboxListview::hMenu = NULL;
}
if ( LboxListview::hFont != NULL ) {
DeleteObject( LboxListview::hFont );
LboxListview::hFont = NULL;
}
if ( LboxListview::dwInitFlag & 0x00000002 ) {
if ( this->hWnd != NULL ) {
DestroyWindow( this->hWnd );
this->hWnd = NULL;
}
}
if ( LboxListview::ColumnType != NULL ) {
delete LboxListview::ColumnType;
}
if ( LboxListview::ColumnSize != NULL ) {
delete LboxListview::ColumnSize;
}
delete LboxListview::Buffer;
}
| |
|
|
|
|
// *********************************************************
// リストビューに列挿入
// 戻り値 : 無し
// nFmt 用定数
// LVCFMT_CENTER : 中央
// LVCFMT_LEFT : 左寄せ
// LVCFMT_RIGHT : 右寄せ
// *********************************************************
void LboxListview::InsertColumn(
int nCol, int nFmt, int nWidth, LboxString *LString
)
{
LboxListview::InsertColumn(
nCol,
nFmt,
nWidth,
LString->szLboxString
);
}
void LboxListview::InsertColumn(
int nCol, int nFmt, int nWidth, LPTSTR szTitle
)
{
LV_COLUMN col;
ZeroMemory( &col, sizeof( LV_COLUMN ) );
col.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT;
col.fmt = nFmt;
col.cx = nWidth;
col.pszText = szTitle;
ListView_InsertColumn(hWnd, nCol, &col);
}
| |
|
|
|
|
// *********************************************************
// リストビューのカラムデータをエディットコントロールにセット
// 戻り値 : 無し
// *********************************************************
void LboxListview::LoadColumnText( int nRow, int nCol )
{
if ( nRow == -1 ) {
return;
}
char *szBuffer = new char[512];
Buffer->Printf( "%d", nCol );
if ( Buffer->Case( LboxListview::lpSkipColumn ) ) {
delete [] szBuffer;
return;
}
ListView_GetItemText(
this->hWnd,
nRow,
nCol,
szBuffer,
512
);
SetWindowText( LboxListview::hEdit, szBuffer );
RECT rt;
ListView_GetSubItemRect(
this->hWnd,
nRow,
nCol,
LVIR_LABEL,
&rt
);
LboxMoveWindow(
LboxListview::hEdit,
rt.left,
rt.top-2
);
LboxChangeWindowSize(
LboxListview::hEdit,
rt.right - rt.left,
rt.bottom - rt.top + 3
);
ShowWindow( LboxListview::hEdit, SW_SHOW );
::SetFocus( LboxListview::hEdit );
nEditRow = nRow;
nEditCol = nCol;
LboxEditNumberonly( LboxListview::hEdit, false );
LboxEditLimitText( LboxListview::hEdit, 0 );
int nType,nSize;
nType = 0;
nSize = 0;
LboxToken *Token;
Token = new LboxToken();
LboxString *LString;
LString = new LboxString();
if ( LboxListview::ColumnType != NULL ) {
Token->CreateToken( LboxListview::ColumnType->szLboxString, "," );
if ( Token->nCount >= nCol ) {
LString->operator = ( Token->Token[nCol] );
nType = LString->Atoi();
}
}
if ( LboxListview::ColumnSize != NULL ) {
Token->CreateToken( LboxListview::ColumnSize->szLboxString, "," );
if ( Token->nCount >= nCol ) {
LString->operator = ( Token->Token[nCol] );
nSize = LString->Atoi();
}
}
delete LString;
delete Token;
if ( nType == 1 ) {
LboxEditNumberonly( LboxListview::hEdit, true );
}
LboxEditLimitText( LboxListview::hEdit, nSize );
delete [] szBuffer;
}
void LboxListview::LoadColumnText( int nRow, int nCol, int nType, int nSize )
{
LboxListview::LoadColumnText( nRow, nCol );
if ( nType == 1 ) {
LboxEditNumberonly( LboxListview::hEdit, true );
}
LboxEditLimitText( LboxListview::hEdit, nSize );
}
| |
|
|
|
|
// *********************************************************
// WM_NOTIFYメッセージ用ポスト関数
// 戻り値 : 無し
// *********************************************************
void LboxListviewNotifyPost(
UINT message, HWND hTarget, HWND hLview, int nRow, int nCol )
{
switch( message ) {
case NM_RCLICK:
PostMessage(
hTarget,
LBOX_LV_RCLICK,
(WPARAM)hLview,
(LPARAM)(MAKELPARAM(nRow,nCol))
);
break;
case NM_DBLCLK:
PostMessage(
hTarget,
LBOX_LV_DBLCLK,
(WPARAM)hLview,
(LPARAM)(MAKELPARAM(nRow,nCol))
);
break;
case NM_RDBLCLK:
PostMessage(
hTarget,
LBOX_LV_RDBLCLK,
(WPARAM)hLview,
(LPARAM)(MAKELPARAM(nRow,nCol))
);
break;
case NM_CLICK:
PostMessage(
hTarget,
LBOX_LV_CLICK,
(WPARAM)hLview,
(LPARAM)(MAKELPARAM(nRow,nCol))
);
break;
case NM_RETURN:
PostMessage(
hTarget,
LBOX_LV_RETURN,
(WPARAM)hLview,
(LPARAM)(MAKELPARAM(nRow,nCol))
);
break;
case NM_SETFOCUS:
PostMessage(
hTarget,
LBOX_LV_SETFOCUS,
(WPARAM)hLview,
0
);
break;
case NM_KILLFOCUS:
PostMessage(
hTarget,
LBOX_LV_KILLFOCUS,
(WPARAM)hLview,
0
);
break;
}
}
// *********************************************************
// WM_NOTIFYメッセージを取得してユーザメッセージを送る
// 戻り値 : メッセージ( 0 の時は対象外 )
// *********************************************************
UINT LboxListview::Notify( HWND hTarget, LPARAM lParam )
{
HWND hLv;
LPNMLISTVIEW lpNmlv;
int nRow;
lpNmlv = (LPNMLISTVIEW)lParam;
hLv = lpNmlv->hdr.hwndFrom;
// メッセ−ジがこのオブジェクトである場合
if ( hLv == this->hWnd ) {
LboxListview::Action = lpNmlv->hdr.code;
LboxListview::hCurrent = lpNmlv->hdr.hwndFrom;
LboxListview::nCurrentId = lpNmlv->hdr.idFrom;
if ( LboxListview::Action == NM_RCLICK ) {
LboxListview::nCurrentCol = lpNmlv->iSubItem;
LboxListview::nCurrentRow = lpNmlv->iItem;
LboxListviewNotifyPost(
LboxListview::Action,
hTarget,
hLv,
LboxListview::nCurrentRow,
LboxListview::nCurrentCol
);
if ( LboxListview::hMenu != NULL ) {
HMENU hPopup;
hPopup = GetSubMenu(
LboxListview::hMenu,
LboxListview::nCurrentPopup
);
LboxWintool::ClientToScreen(
&lpNmlv->ptAction
);
TrackPopupMenu(
hPopup,
TPM_LEFTALIGN | TPM_TOPALIGN,
lpNmlv->ptAction.x,
lpNmlv->ptAction.y,
0,
hTarget,
NULL
);
}
return lpNmlv->hdr.code;
}
switch( LboxListview::Action ) {
case NM_DBLCLK:
case NM_RDBLCLK:
case NM_CLICK:
LboxListview::nCurrentCol = lpNmlv->iSubItem;
LboxListview::nCurrentRow = lpNmlv->iItem;
break;
case NM_RETURN:
LboxListview::nCurrentCol = 0;
nRow = -1;
LboxListview::FindNextSelectedRow( &nRow );
break;
}
LboxListviewNotifyPost(
LboxListview::Action,
hTarget,
hLv,
LboxListview::nCurrentRow,
LboxListview::nCurrentCol
);
return lpNmlv->hdr.code;
}
return 0;
}
| |
|
使用例
|
|
|
char *szTag1 = "<TABLE >";
char *szTag2 = "<TR>";
char *szTag3 = "</TR>";
char *szTag4 = "<TD>";
char *szTag5 = "</TD>";
char *szTag6 = "</TABLE>";
char *szTag7 = "<TH>";
char *szTag8 = "</TH>";
// *********************************************************
// クリップボードにコピー
// 行の終わりには、改行コードを付加
// bSelect が true の場合は 選択した行のみコピーする
// bTitle が true の場合は、タイトルもコピーする
// nType
// 0 : タブ
// 1 : カンマ(CSV)
// 3 : \
// 4 : HTML テーブルタグ
// 戻り値 : true 成功, false 失敗
// *********************************************************
BOOL LboxListview::CopyClipboard( BOOL bSelect, BOOL bTitle, int nType )
{
DWORD nRows,nCols;
DWORD nSize;
DWORD i;
char *szBuffer = new char[MAX_PATH];
if ( nType < 0 || nType > 3 ) {
return false;
}
char delim[3][4];
lstrcpy( delim[0], "\t" );
lstrcpy( delim[1], "," );
lstrcpy( delim[2], "\\" );
nRows = LboxListview::Count();
nCols = LboxListview::ColumnCount();
nSize = 0;
if ( bTitle ) {
for( i = 0; i < nCols; i++ ) {
LboxListview::GetColumnTitle(
i,
szBuffer,
MAX_PATH
);
nSize += lstrlen( szBuffer );
nSize++;
if ( nType == 3 ) {
nSize += lstrlen( szTag7 );
nSize += lstrlen( szTag8 );
}
}
nSize++;
if ( nType == 3 ) {
nSize += lstrlen( szTag2 );
nSize += lstrlen( szTag3 );
}
}
int nRow;
nRow = -1;
while( LboxListview::FindNextRow( &nRow ) ) {
if ( bSelect ) {
if ( false == LboxListview::IsState(
nRow,
LVIS_SELECTED
) ) {
continue;
}
}
for( i = 0; i < nCols; i++ ) {
LboxListview::GetColumnText(
i,
szBuffer,
MAX_PATH
);
nSize += lstrlen( szBuffer );
nSize++;
if ( nType == 3 ) {
nSize += lstrlen( szTag4 );
nSize += lstrlen( szTag5 );
}
}
nSize++;
if ( nType == 3 ) {
nSize += lstrlen( szTag2 );
nSize += lstrlen( szTag3 );
}
}
if ( nType == 3 ) {
nSize += lstrlen( szTag1 );
nSize += lstrlen( szTag6 );
}
HGLOBAL hGlobal;
LPTSTR pMem;
hGlobal = GlobalAlloc(GHND, nSize + 128 );
if ( hGlobal == NULL ) {
return false;
}
pMem = (LPTSTR)GlobalLock( hGlobal );
if ( pMem == NULL ) {
GlobalFree( hGlobal );
return false;
}
*pMem = 0x00;
if ( nType == 3 ) {
lstrcat( pMem, szTag1 );
}
if ( bTitle ) {
if ( nType == 3 ) {
lstrcat( pMem, szTag2 );
}
for( i = 0; i < nCols; i++ ) {
if ( nType == 3 ) {
lstrcat( pMem, szTag7 );
}
else {
if ( i != 0 ) {
lstrcat( pMem, delim[nType] );
}
}
LboxListview::GetColumnTitle(
i,
szBuffer,
MAX_PATH
);
lstrcat( pMem, szBuffer );
if ( nType == 3 ) {
lstrcat( pMem, szTag8 );
}
}
if ( nType == 3 ) {
lstrcat( pMem, szTag3 );
}
lstrcat( pMem, "\n" );
pMem += lstrlen( pMem );;
}
nRow = -1;
while( LboxListview::FindNextRow( &nRow ) ) {
if ( bSelect ) {
if ( false == LboxListview::IsState(
nRow,
LVIS_SELECTED
) ) {
continue;
}
}
if ( nType == 3 ) {
lstrcat( pMem, szTag2 );
}
for( i = 0; i < nCols; i++ ) {
if ( nType == 3 ) {
lstrcat( pMem, szTag4 );
}
else {
if ( i != 0 ) {
lstrcat( pMem, delim[nType] );
}
}
LboxListview::GetColumnText(
i,
szBuffer,
MAX_PATH
);
lstrcat( pMem, szBuffer );
if ( nType == 3 ) {
lstrcat( pMem, szTag5 );
}
}
if ( nType == 3 ) {
lstrcat( pMem, szTag3 );
}
lstrcat( pMem, "\n" );
pMem += lstrlen( pMem );;
}
if ( nType == 3 ) {
lstrcat( pMem, szTag6 );
}
GlobalUnlock( hGlobal );
OpenClipboard( NULL );
EmptyClipboard();
SetClipboardData(CF_TEXT, hGlobal);
CloseClipboard();
delete [] szBuffer;
return true;
}
| |
|
|
|
|
// *********************************************************
// フォントのセット
// 戻り値 : true 成功, false 失敗
// *********************************************************
BOOL LboxListview::SetFont( int nType, int nSize, BOOL bBold )
{
if ( LboxListview::hFont != NULL ) {
DeleteObject( LboxListview::hFont );
}
LboxListview::hFont = LboxCreateFont(
nType,
nSize,
bBold
);
if ( LboxListview::hFont == NULL ) {
return false;
}
SendMessage(
this->hWnd,
WM_SETFONT,
(WPARAM)(LboxListview::hFont),
MAKELPARAM(true, 0)
);
if ( LboxListview::hEdit != NULL ) {
SendMessage( LboxListview::hEdit,
WM_SETFONT,
(WPARAM)(LboxListview::hFont),
0
);
}
if ( LboxListview::hCombo != NULL ) {
SendMessage( LboxListview::hCombo,
WM_SETFONT,
(WPARAM)(LboxListview::hFont),
0
);
}
return true;
}
| |
|
|
|
|
// *********************************************************
// リストビューのカラムデータをコンボボックスにセット
// 戻り値 : 無し
// *********************************************************
void LboxListview::LoadColumnTextCombo( int nRow, int nCol )
{
if ( nRow == -1 ) {
return;
}
char *szBuffer = new char[512];
Buffer->Printf( "%d", nCol );
ListView_GetItemText(
this->hWnd,
nRow,
nCol,
szBuffer,
512
);
int nComboRow;
nComboRow = LboxComboFindString( LboxListview::hCombo, szBuffer );
LboxComboSelect( LboxListview::hCombo, nComboRow );
RECT rt,rtCombo;
ListView_GetSubItemRect(
this->hWnd,
nRow,
nCol,
LVIR_LABEL,
&rt
);
LboxMoveWindow(
LboxListview::hCombo,
rt.left,
rt.top-3
);
GetWindowRect(
LboxListview::hCombo,
&rtCombo
);
LboxChangeWindowSize(
LboxListview::hCombo,
rt.right - rt.left,
rtCombo.bottom - rtCombo.top
);
LboxComboSetHeight(
LboxListview::hCombo,
(LPARAM)(rt.bottom - rt.top)
);
ShowWindow( LboxListview::hCombo, SW_SHOW );
::SetFocus( LboxListview::hCombo );
nEditRow = nRow;
nEditCol = nCol;
delete [] szBuffer;
}
| |
|
|
|
|
// *********************************************************
// リストビューのカラムデータを次のエディットコントロールにセット
// 戻り値 : 無し
// *********************************************************
void LboxListview::LoadColumnTextNext( void )
{
int nRowCount,nColCount;
int nRow,nCol;
BOOL bBreak;
int nType,nSize;
LboxListview::HideEdit( );
nRowCount = LboxListview::Count();
nColCount = LboxListview::ColumnCount();
nRow = LboxListview::nEditRow;
nCol = LboxListview::nEditCol + 1;
bBreak = false;
while( 1 ) {
if ( bBreak ) {
break;
}
if ( nRow + 1 > nRowCount ) {
nRow = 0;
continue;
}
while( 1 ) {
if ( nCol + 1 > nColCount ) {
nCol = 0;
break;
}
Buffer->Printf( "%d", nCol );
if ( Buffer->Case( LboxListview::lpSkipColumn ) ) {
nCol++;
continue;
}
nType = 0;
nSize = 0;
LboxToken *Token;
Token = new LboxToken();
LboxString *LString;
LString = new LboxString();
if ( LboxListview::ColumnType != NULL ) {
Token->CreateToken(
LboxListview::ColumnType->szLboxString, "," );
if ( Token->nCount >= nCol ) {
LString->operator = ( Token->Token[nCol] );
nType = LString->Atoi();
}
}
if ( LboxListview::ColumnSize != NULL ) {
Token->CreateToken(
LboxListview::ColumnSize->szLboxString, "," );
if ( Token->nCount >= nCol ) {
LString->operator = ( Token->Token[nCol] );
nSize = LString->Atoi();
}
}
delete LString;
delete Token;
LboxListview::LoadColumnText( nRow, nCol, nType, nSize );
bBreak = true;
break;
}
nRow++;
}
}
| |
|
|
|
|
// *********************************************************
// リストビューのカラムデータを次のエディットコントロールにセット
// 戻り値 : 無し
// *********************************************************
void LboxListview::GetColumnTextNext(
int *pRow, int *pCol, int *pType, int *pSize )
{
int nRowCount,nColCount;
int nRow,nCol;
BOOL bBreak;
int nType,nSize;
LboxListview::HideEdit( );
nRowCount = LboxListview::Count();
nColCount = LboxListview::ColumnCount();
nRow = LboxListview::nEditRow;
nCol = LboxListview::nEditCol + 1;
bBreak = false;
while( 1 ) {
if ( bBreak ) {
break;
}
if ( nRow + 1 > nRowCount ) {
nRow = 0;
continue;
}
while( 1 ) {
if ( nCol + 1 > nColCount ) {
nCol = 0;
break;
}
Buffer->Printf( "%d", nCol );
if ( Buffer->Case( LboxListview::lpSkipColumn ) ) {
nCol++;
continue;
}
nType = 0;
nSize = 0;
LboxToken *Token;
Token = new LboxToken();
LboxString *LString;
LString = new LboxString();
if ( LboxListview::ColumnType != NULL ) {
Token->CreateToken(
LboxListview::ColumnType->szLboxString, "," );
if ( Token->nCount >= nCol ) {
LString->operator = ( Token->Token[nCol] );
nType = LString->Atoi();
}
}
if ( LboxListview::ColumnSize != NULL ) {
Token->CreateToken(
LboxListview::ColumnSize->szLboxString, "," );
if ( Token->nCount >= nCol ) {
LString->operator = ( Token->Token[nCol] );
nSize = LString->Atoi();
}
}
delete LString;
delete Token;
*pRow = nRow;
*pCol = nCol;
*pType = nType;
*pSize = nSize;
bBreak = true;
break;
}
nRow++;
}
}
| |
|
|
|
|
// *********************************************************
// 文字列オブジェクトにコピー
// 行の終わりには、改行コードを付加
// bSelect が true の場合は 選択した行のみコピーする
// bTitle が true の場合は、タイトルもコピーする
// nType
// 0 : タブ
// 1 : カンマ(CSV)
// 2 : \
// 3 : HTML テーブルタグ
// 100 : タブ区切りタイトルのみ
// 101 : カンマ区切りタイトルのみ
// 102 : 改行区切りタイトルのみ
// 戻り値 : true 成功, false 失敗
// *********************************************************
BOOL LboxListview::CopyString(
BOOL bSelect, BOOL bTitle, int nType, LboxString *LString )
{
DWORD nRows,nCols;
DWORD i;
int nSaveType;
nSaveType = nType;
// 通常文字列としてクリア
LString->SetChar( 0, 0 );
// ワーク用文字列オブジェクト
LboxString *LstrWork;
LstrWork = new LboxString();
// デリミタ
char delim[5][4];
lstrcpy( delim[0], "\t" );
lstrcpy( delim[1], "," );
lstrcpy( delim[2], "\\" );
lstrcpy( delim[4], "\n" );
nRows = LboxListview::Count();
nCols = LboxListview::ColumnCount();
// タイトル部分の作成
if ( nType == 3 ) {
// <TABLE>
LString->operator += ( szTag1 );
}
if ( bTitle ) {
if ( nType == 3 ) {
// <TR>
LString->operator += ( szTag2 );
}
switch( nSaveType ) {
case 100:
nType = 0;
break;
case 101:
nType = 1;
break;
case 102:
nType = 4;
break;
}
for( i = 0; i < nCols; i++ ) {
if ( nType == 3 ) {
// <TH>
LString->operator += ( szTag7 );
}
else {
if ( i != 0 ) {
LString->operator += ( delim[nType] );
}
}
LboxListview::GetColumnTitle(
i,
LstrWork
);
LString->operator += ( LstrWork );
if ( nType == 3 ) {
// </TH>
LString->operator += ( szTag8 );
}
}
if ( nType == 3 ) {
// </TR>
LString->operator += ( szTag3 );
}
if ( nSaveType >= 100 ) {
delete LstrWork;
return true;
}
LString->operator += ( "\n" );
}
// データ部分の作成
int nRow;
nRow = -1;
while( LboxListview::FindNextRow( &nRow ) ) {
// 選択行のみ
if ( bSelect ) {
if ( false == LboxListview::IsState(
nRow,
LVIS_SELECTED
) ) {
continue;
}
}
if ( nType == 3 ) {
// <TR>
LString->operator += ( szTag2 );
}
for( i = 0; i < nCols; i++ ) {
if ( nType == 3 ) {
// <TD>
LString->operator += ( szTag4 );
}
else {
if ( i != 0 ) {
LString->operator += ( delim[nType] );
}
}
LboxListview::GetColumnText(
i,
LstrWork
);
LString->operator += ( LstrWork );
if ( nType == 3 ) {
// </TD>
LString->operator += ( szTag5 );
}
}
if ( nType == 3 ) {
// </TR>
LString->operator += ( szTag3 );
}
LString->operator += ( "\n" );
}
if ( nType == 3 ) {
// </TABLE>
LString->operator += ( szTag6 );
LString->operator += ( "\n" );
}
delete LstrWork;
return true;
}
| |
|
|
|