ホーム » 2014 » 7月

月別アーカイブ: 7月 2014

2014年7月
 12345
6789101112
13141516171819
20212223242526
2728293031  

カテゴリー

アーカイブ

ブログ統計情報

  • 79,628 アクセス



CSplitterWnd – 2

SDI で,MDI の「新しいウィンドウを開く」で 4 つのビューを表示した様な動作が欲しかったので,調べてみた.
動的な分割ウィンドウである程度の所まではできそう.


1. MainFrm.h の CMainFrame に以下を追加.
    CSplitterWnd m_wndSplitter;
    virtual BOOL OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext);
2. CMainFrame::OnCreateClient の追加.
    BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
    {
      {
        if (!m_wndSplitter.Create(this,2, 2,CSize(10, 10), pContext,
            WS_CHILD | WS_VISIBLE /* | WS_HSCROLL | WS_VSCROLL */ | SPLS_DYNAMIC_SPLIT))	{
          TRACE0("Failed to create split bar ");
          return FALSE;
          }
        return TRUE;
        }
      }
    スクロールバーを付加したくなかったので,6 つ目のウィンドウスタイルを変更している.
テスト用に分割動作をコマンドとして実装.
    void CMainFrame::OnSplit() 
    {
      if (IsSplit)	{
        if (m_wndSplitter.GetColumnCount() > 1) {	m_wndSplitter.DeleteColumn(1) ;	}
        if (m_wndSplitter.GetRowCount() > 1) {     	m_wndSplitter.DeleteRow   (1) ;	}
        IsSplit = !IsSplit ;
        }
      else {
        CRect	rect ;
        m_wndSplitter.GetClientRect(&rect) ;
        if (m_wndSplitter.GetColumnCount() == 1) {	m_wndSplitter.SplitColumn(rect.Width ()/2) ; }
        if (m_wndSplitter.GetRowCount() == 1) {		m_wndSplitter.SplitRow   (rect.Height()/2) ; }
        IsSplit = !IsSplit ;
        }
      }

2 x 2 の分割ウィンドウのコントロールの ID (Spy++ で確認)
  左上(0,0)  E900  AFX_IDW_PANE_FIRST
  右上(0,1)  E901
  左下(1,0)  E910
  右下(1,1)  E911


ビューの OnDraw を以下の様に書き換えると

  void CSpltWView::OnDraw(CDC* pDC)
  {
    int		row = -1 ;
    int		clm = -1 ;
    CMainFrame*		mw = (CMainFrame*)AfxGetMainWnd() ;
    CSplitterWnd*	sw = &mw->m_wndSplitter ;
    CString			str ;
    if (sw->IsChildPane(this,&row,&clm)) {
      int	id = sw->IdFromRowCol(row,clm) ;
      CString	tmp1 ;	tmp1.Format(_T("row = %d  ,  clm = %d"),row,clm) ;
      CString	tmp2 ;	tmp2.Format(_T("IdFromRowCol = %04X"),	id) ;
      str += tmp1 + _T("\r\n") ;
      str += tmp2 + _T("\r\n") ;
      }
    {
      UINT	nID = GetDlgCtrlID() ;
      CString	tmp ;	tmp.Format(_T("GetDlgCtrlID  = %04X"),nID) ;
      str += tmp + _T("\r\n") ;
      }
    {
      CWnd*	pw = GetParent() ;
      CString	tmp1 ;	tmp1.Format(_T("Splitter = %08x "),sw->GetSafeHwnd()) ;
      CString	tmp2 ;	tmp2.Format(_T("Parent  = %08x "),pw->GetSafeHwnd()) ;
      str += tmp1 + _T("\r\n") ;
      str += tmp2 + _T("\r\n") ;
      }
    CRect	rect ;
    GetClientRect(rect) ;
    rect.top = rect.left = 10 ;
    pDC->DrawText(str,rect,0) ;
    }


MFC の ソースを眺めていると CView::GetParentSplitter があったので,間接的にはそれを使えば良さそう.


ビューでどの位置かを求めるだけなら,
    short	texNo = 0 ;
    {
      UINT	nID = GetDlgCtrlID() ;
      switch	(nID)	{
        case	AFX_IDW_PANE_FIRST + 0x00 :	texNo = 1 ;		break ;
        case	AFX_IDW_PANE_FIRST + 0x01 :	texNo = 2 ;		break ;
        case	AFX_IDW_PANE_FIRST + 0x10 :	texNo = 3 ;		break ;
        case	AFX_IDW_PANE_FIRST + 0x11 :	texNo = 4 ;		break ;
        }
      }
Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

‘THIS_FILE’ がシンタックスエラーを…

今まで通っていたプロジェクトで,
  ComPrj03.cpp
  c:\…\memory(16) : error C2061: 構文エラー : 識別子 ‘THIS_FILE’ がシンタックスエラーを起こしました。
  c:\…\memory(17) : error C2091: 関数は関数を返せません。
  c:\…\memory(17) : error C2809: ‘operator new’ に仮引数リストがありません。
  c:\…\memory(20) : error C2954: テンプレートの定義はネストできません。
  cl.exe の実行エラー
  ComPrj03.obj – エラー 4、警告 0


ソースの先頭付近に #include <memory> を追加.
  #include “StdAfx.h”
  #include “ComPrj00.hpp”
  #include <memory>
 


2019/01/18

--------------------構成: MkZIP2 - Win32 Release--------------------
コンパイル中...
MkZIP2.cpp
リンク中...

MkZIP2.exe - エラー 0、警告 0
--------------------構成: MkZIP2 - Win32 Debug--------------------
コンパイル中...
MkZIP2.cpp
c:\program files\microsoft visual studio\vc98\include\memory(16) : error C2061: 構文エラー : 識別子 'THIS_FILE' がシンタックスエラーを起こしました。
c:\program files\microsoft visual studio\vc98\include\memory(17) : error C2091: 関数は関数を返せません。
c:\program files\microsoft visual studio\vc98\include\memory(17) : error C2809: 'operator new' に仮引数リストがありません。
c:\program files\microsoft visual studio\vc98\include\memory(20) : error C2954: テンプレートの定義はネストできません。
cl.exe の実行エラー

MkZIP2.exe - エラー 4、警告 0

#include “stdafx.h”
#include “MkZIP2.h”
#include <ShlObj.h>
#import <Shell32.dll> // named_guids
//#include <memory>


エラーになるのはデバッグ版のビルド.リリース版では通る.
#include <memory> を有効に.


2023/03/24
error C2061 , C2091 , C2809 , C2556

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

~iDocText でダウン

先日作成した TextureToPath 関係でダウンする様になってしまった.
場所は,iDocText のデストラクタ付近.
呼出し元をたどると,#pragma omp parallel for .


TextureCopy::GetDrawName に #pragma omp critical (TextureCopy_GetDrawName) を追加.

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

LAN-GTJU3H3 追加

LAN-GTJU3H3 を追加.
何が悪いのかわからないが 100 M で接続されているみたい.今の用途では遅さはそれほど気にならない.
付属のマニュアルはちょっと古いみたいで,ここからマニュアルを参照.

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

時刻の同期

6/20 に HDL-Z2WM2C2 を追加した.
ソースファイルの保管のサーバとしての利用で,Win7 USB 2 HDD と比べても遜色ない.
ひとつ気になることが,思っていたよりファンの音がうるさい.


先日,クライアントの PC と WSS で,時間が少しずれていたので time.windows.com で時刻を合わせた.
今日時刻を見てみると 10 秒位の差ができてしまっている.
もう少し精度が欲しかったので検索すると,
インターネット時刻機能のポーリング間隔を調整する方法
Windowsの時計がずれる / 自動で正確に合わせる小技 (Windows 7/8.1編)
これらを参考にさせてもらって,1 日に 1 回程度の設定とした.

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.