Grid Control 6
- ◆プログラム作成ガイド
- ◆プログラムの開始
- ◆初期表示のデザイン
- ◆データの入力方法
- ◆クラスの作り方
- ◆データをメモリーに
- ◆ファイル読み書き
- ◆データの保存方法
- ◆ツリービューマウス右
- ◆画面表示インプリメント
- ◆複数のページ印字
- ◆DLL化する
- ◆エクセル似の入力
サブメニュー
ここに紹介するプログラムは、WIN XP 2003/Windows 7 (32bits) - OS 環境でマイクロソフトのVisual Studio 2010 で作ったものです。
Windows XP/ Windows 7(32bits) での動作は確認済みですが…
矢印キーへの対応
矢印キーの左右・上下を指定した場合、そのセルにハイライトが移動したりする機能を追加することにしましょう。
ClassWinzardでダイアログクラスに次の関数を追加します。
///////////////////////////////////////////////
// 右矢印キー
void CWallDlg::MoveCurRight()
{
CGridControl gc;
long row = m_rc.y;
long col = m_rc.x;
if( col>0 && col<6 ) {
col++; // 着目列を右に1つずらす
m_rc = gc.SetCurrentCel( &m_grid, m_nMaxRow, row,
col );
EditBoxRedraw( &m_grid, &m_rc );
}
}
///////////////////////////////////////////////
// 左矢印キー
void CWallDlg::MoveCurLeft( )
{
CGridControl gc;
long row = m_rc.y;
long col = m_rc.x;
if( col>1 && col<=6 ) {
col--;// 着目列を左に1つずらす
m_rc = gc.SetCurrentCel( &m_grid, m_nMaxRow, row, col );
EditBoxRedraw( &m_grid, &m_rc );
}
}
///////////////////////////////////////////////
// 下矢印キー
void CWallDlg::MoveCurDown()
{
CGridControl gc;
long row = m_rc.y;
long col = m_rc.x;
int nLine = m_nData + 1;
if( row>0 && row<nLine ) { // 0から最大行までの範囲
row++;// 着目列を下に1つずらす
if( row > ( m_nTopRow + m_nInitia_maxrow - 4 )) {
m_nTopRow++;
m_grid.SetTopRow( m_nTopRow );
}
m_rc = gc.SetCurrentCel( &m_grid, m_nMaxRow, row, col );
EditBoxRedraw( &m_grid, &m_rc );
}
}
///////////////////////////////////////////////
// 上矢印キー
void CWallDlg::MoveCurUp()
{
CGridControl gc;
long row = m_rc.y;
long col = m_rc.x;
int nLine = m_nData + 1;
if( row>1 && row <= nLine ) {
row--;// 着目列を上に1つずらす
if( (m_nMaxRow - ( m_nInitia_maxrow - 3 )) > row) {// 変更 2->3
m_nTopRow = m_grid.GetTopRow();
if( m_nTopRow > 1) m_nTopRow--;
m_grid.SetTopRow( m_nTopRow );
}
m_rc = gc.SetCurrentCel( &m_grid, m_nMaxRow, row, col );
EditBoxRedraw( &m_grid, &m_rc );
}
}
ページ先頭に戻る
最終更新日: 2020/02/04