ホーム » 2010

年別アーカイブ: 2010

2024年4月
 123456
78910111213
14151617181920
21222324252627
282930  

カテゴリー

アーカイブ

ブログ統計情報

  • 80,395 アクセス



VC 10 Dialog を VC 6 に

VC 10 で作成したダイアログベースのプロジェクトを VC 6 に

  1. プロジェクト作成時の基本クラス CDialogEx → CDialog
  2. 「構成プロパティ」-「全般」の「出力ディレクトリ」と「中間ディレクトリ」を $(Configuration).100\ に
  3. RC ファイルなどが UNICODE だったため,Shift-JIS に
  4. RC ファイル内でエラーになる部分をコメントに
  5. ico ファイル内に2573x1293x16777216 (256x256x32 png) があり,ビルドエラーになったので削除
    C:\…\Project.rc (67): error RC2176 : old DIB in res\Project.ico; pass it through SDKPAINT
  6. StdAfx.h 内の AfxControlBar.h をコメントに
  7. CAboutDlg : CDialogEx となっているので,CDialog に
  8. CShellManager 関係をコメントに
  9. ON_COMMAND(ID_HELP, &CWinApp::OnHelp) をコメントに

ここまででビルド,実行はできたが,なんか変
VC 10 でのダイアログエディタの操作は可能だが,VC 6 では出来ない.
VC 10 で編集したものを,VC 6 でビルド,実行は可能?
ON_BN_CLICKED(IDC_XXX, &CBrwFileDlg::OnClickedXxx) の ‘&’ が邪魔.

* ここの情報は,動作などを保証するものではありません.個人的なメモです.

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

    VC 6 RC ファイル内の DISCARDABLE

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

    いつも場所を忘れるので

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

    LBT-HS121C2 を追加

    取扱説明書には特に記述はないようであるが,…
    Win 7 環境では USB アダプタのドライバをインストールしてはいけない?
    PC とヘッドセットとの接続は可能であったが,PC と X02T との接続がうまくない.

    Web で検索かけると取説の PDF では,Win 7 には必要なしとのこと.
    「プログラムと機能」からドライバ類をアンインストールして再起動.
    PC と X02T との接続が可能になった.

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

    GetLongPathName 存在しないと失敗

    http://msdn.microsoft.com/ja-jp/library/cc429335.aspx

    簡略化するために HelpAPI.hxx に以下を用意.
    inline CString GetLongPathName (LPCTSTR fileName)
    {
     CString longPath ;
     UINT size = _MAX_PATH ;
     DWORD len  = ::GetLongPathName(fileName,longPath.GetBuffer(size),size) ;
     longPath.ReleaseBuffer() ;
     if (len == 0) { return fileName ; }
     return longPath ;
     }

    ファイルが存在しないと関数が失敗する様なので,
     ::CreateEmptyFile(sFile) ;
     CString  lFile = ::GetLongPathName(sFile) ;
     

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

    DImageS の配列で,…

    以下の様な DImageS の配列で,要素の表示が 1 回目しかできなかった.
     CString selFile = DImgAry.GetAt(selIndex).GetFileName() ;
     DImgAry[selIndex].Draw(&m_Image) ;

    配列を直接使用するのではなく,DImageS にファイル名を取得してからでは OK .
     DImageS dImg ;
     dImg.SetFileName(selFile) ;
     dImg.Draw(&m_ImageMBA) ;
     

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

    CEdit::SetSel である位置を選択

    SetSel を UpdateData(FALSE) の呼び出しより後に使用すれば良い.
    UpdateData(TRUE) ;

    // 例えば文字列の最後へ
    int pos = m_SelectStr.GetLength() ;
    m_CtrlSelectStr.SetSel (pos,pos) ;

    // UpdateData(FALSE) ;
    または,UpdateData を使用しないで取得,更新する.
    CEdit::Setsel の使い方

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

    画像付ファイル名のリストボックス

    ヘッダファイルへの追加
     #include “DImgS.hxx” または “DImg.hxx”
     #include “ODrawDcM.hxx”

     ListBoxDocMF m_ListDImage;
     CArray <DImageS,DImageS> DImgAry ; または <DImage,…>

    OnInitDialog など
     m_ListDImage.SubclassDlgItem(IDC_XXXX_FILE_LIST,this) ;
     m_ListDImage.Init() ;
     m_ListDImage.ResetContent() ;

    リストに表示するファイルの設定
     DImgAry.RemoveAll() ;
     for (int dIndex=0 ; dIndex<addFiles.GetSize() ; dIndex++) {
      DImageS dImg ; または DImage
      dImg.SetFileName(addFiles[dIndex]) ;
      DImgAry.Add(dImg) ;
      }
     m_ListDImage.ResetContent() ;
     for (int rIndex=0 ; rIndex<DImgAry.GetSize() ; rIndex++) {
      CString fileName = DImgAry.GetAt(rIndex).GetFileName() ;
      m_ListDImage.AddString(fileName,fileName) ;
       // 以下は登録時に画像を付ける場合
      CString mfName = CacheFile::GetCF_Name(fileName,1000) ;
      if (::FileIsExist(mfName)) {
       m_ListDImage.SetAtDocMF(rIndex,mfName) ;
       }
      else {
       HICON icon = DImageS_GetIcon(fileName) ;
       m_ListDImage.SetAtIcon(rIndex,icon) ;
       }
      }

    DImageS クラスでなく DImage クラスを使用した場合は,ImageDMF クラスをサポートする形になる.
    DImageS クラスでは,対応付けた EMF での動作になる.
    現状の ListBoxDocMF では Shell Extension を利用できないみたい.
    別のクラスを用意するか変更が必要.間にListBoxDocSE などを用意するか?
     

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

    コントロールをサブクラス化した時のエラー

    ダイアログのコントロールをサブクラス化した時の実行時エラーの対応.
    m_ListXxx.SubclassDlgItem(IDC_Xxxx_LIST,this) ;
    —————————
    Microsoft Visual C++ Debug Library
    —————————
    Debug Assertion Failed!
    Program: …\Xxxx\Xxxx\Debug\Xxxx.exe
    File: wincore.cpp
    Line: 321
    For information on how your program can cause an assertion
    failure, see the Visual C++ documentation on asserts.
    (Press Retry to debug the application)
    —————————
    中止(A)   再試行(R)   無視(I)
    —————————
    以前 CListBox として使用していたので,変数として割り付けられていた.
    変数を削除してOK.

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

    リンクエラーの時のソースとの対応

    AlphaBlend MSImg32.lib
    SE_ExtractImage HelpEImg.cxx

     

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

    FaceA::Search の高速化

    データが増えると遅かったので改良
    BOOL FaceA::Search(const long edgeS,const long edgeE,long* left_Face,long* rightFace) const
    {
      if (left_Face == NULL) { return FALSE ; }
      if (rightFace== NULL) { return FALSE ; }
      *left_Face = *rightFace = -1 ;
      BOOL lfFound = FALSE ;
      BOOL rfFound = FALSE ;
       static long LastFace = 0 ;
      int index = 0 ;
       for (index=LastFace ; index<GetCount() ; index++) {
         Face f = Faces[index] ;
         if (!f.Search(edgeS,edgeE,&lfFound,&rfFound)) { continue ; }
         if (*left_Face<0 && lfFound) { *left_Face = index ; }
         if (*rightFace<0 && rfFound) { *rightFace = index ; }
         if (*left_Face >= 0 && *rightFace>=0) {
           LastFace = min(*left_Face,*rightFace) ;
           return TRUE ;
           }
         }
      for (index=0 ; index<GetCount() ; index++) {
        Face f = Faces[index] ;
        if (!f.Search(edgeS,edgeE,&lfFound,&rfFound)) { continue ; }
        if (*left_Face<0 && lfFound) { *left_Face = index ; }
        if (*rightFace<0 && rfFound) { *rightFace = index ; }
        if (*left_Face >= 0 && *rightFace>=0) {
          LastFace = min(*left_Face,*rightFace) ;
          return TRUE ;
          }
        }
      return FALSE ;
      }

    前に検索して一致した所から再検索するコードを追加.

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

    CArray の要素のコピー

    FaceA::FaceA (const FaceA& other)
    {

    // ループによるコピー
      Faces.SetSize(other.Faces.GetSize()) ;
      for (int index=0 ; index<other.Faces.GetSize() ; index++) {
        Faces[index] = other.Faces[index] ;
        }

    // CArray::Copy
      Faces.Copy(other.Faces) ;

      }

    VC 6 リリース版では体感できなかったが,少なくともデバッグ版では Copy の方がはるかに速かった.

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

    VC 2010 $(IncludePath)

    Microsoft.Cpp.Xxxx.user.props の場所
    C:\Users\(UserName)\AppData\Local\Microsoft\MSBuild\v4.0
    http://msdn.microsoft.com/ja-jp/library/ee855621.aspx

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

    CImage::Draw 部分のメモ

    //  AtlImage.h より

    inline BOOL CImage::Draw(
      _In_ HDC hDestDC,
      _In_ int xDest,
      _In_ int yDest,
      …
    {
      …
    #if WINVER >= 0x0500
      if( ((m_iTransparentColor != -1) || (m_clrTransparentColor != (COLORREF)-1)) && IsTransparencySupported() ) {
        bResult = ::TransparentBlt( hDestDC, xDest, yDest, … , GetTransparentRGB() ) ;
        }
      else if( m_bHasAlphaChannel && IsTransparencySupported() ) {
        BLENDFUNCTION bf;
        bf.BlendOp = AC_SRC_OVER;
        bf.BlendFlags = 0;
        bf.SourceConstantAlpha = 0xff;
        bf.AlphaFormat = AC_SRC_ALPHA;
        bResult = ::AlphaBlend( hDestDC, xDest, yDest, … , bf) ;
        }
      else
    #endif // WINVER >= 0x0500
      {
        bResult = ::StretchBlt( hDestDC, xDest, yDest, … , SRCCOPY) ;
        }
      …
      return( bResult );
      }

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

    VC 6 で GlobalMemoryStatusEx

    #if(_MFC_VER >= 0x0700)
      #include	<WinBase.h>
    #else
    
    #include	<Windows.h>
    #include	<TChar.h>
    
    //  WinBase.h より
    typedef struct _MEMORYSTATUSEX {
      DWORD    dwLength;
      DWORD    dwMemoryLoad;
      DWORDLONG  ullTotalPhys;
      DWORDLONG  ullAvailPhys;
      DWORDLONG  ullTotalPageFile;
      DWORDLONG  ullAvailPageFile;
      DWORDLONG  ullTotalVirtual;
      DWORDLONG  ullAvailVirtual;
      DWORDLONG  ullAvailExtendedVirtual;
      } MEMORYSTATUSEX, *LPMEMORYSTATUSEX;
    
    typedef	BOOL	(WINAPI *PFnGlobalMemoryStatusEx)	(LPMEMORYSTATUSEX lpBuffer) ;
    
    ////
    //*******************************************************************************
    //	クラス名:Kernel32.DLL ラッパー
    //	作成日	:’10/09/16
    //*******************************************************************************
    class	WrapKernel32	{
    public:
          WrapKernel32	() ;
      virtual ~WrapKernel32	() ;
    public:
      virtual	BOOL	GlobalMemoryStatusEx(LPMEMORYSTATUSEX lpBuffer) ;
    protected:
      HMODULE   HLibrary ;
      PFnGlobalMemoryStatusEx  FnGlobalMemoryStatusEx ;
      } ;
    
    ////
    //*******************************************************************************
    //	関数名	:コンストラクタ/デストラクタ
    //	作成日	:’10/09/16
    //*******************************************************************************
    inline
    WrapKernel32::WrapKernel32	()
    {
      HLibrary = NULL ;
      FnGlobalMemoryStatusEx = NULL ;
      HLibrary = ::LoadLibrary	(TEXT("Kernel32.DLL")) ;
      if (HLibrary == NULL)	{	return ;	}
      FnGlobalMemoryStatusEx = (PFnGlobalMemoryStatusEx) GetProcAddress(HLibrary,("GlobalMemoryStatusEx")) ;
      }
    
    inline
    WrapKernel32::~WrapKernel32	()
    {
      if (HLibrary != NULL) {
        FreeLibrary(HLibrary) ;
        }
      }
    
    ////
    //*******************************************************************************
    //	関数名	:それぞれの呼び出し
    //	作成日	:’10/09/16
    //*******************************************************************************
    inline
    BOOL	WrapKernel32::GlobalMemoryStatusEx	(LPMEMORYSTATUSEX lpBuffer)
    {
      if (FnGlobalMemoryStatusEx != NULL)	{
        return	FnGlobalMemoryStatusEx	(lpBuffer) ;
        }
      return	FALSE ;
      }
    
    inline
    BOOL	WINAPI	GlobalMemoryStatusEx(LPMEMORYSTATUSEX lpBuffer)
    {
      if (lpBuffer->dwLength != sizeof(MEMORYSTATUSEX)) {
        #ifdef	_DEBUG
          afxDump << _T("GlobalMemoryStatusEx ... dwLength != ") << sizeof(MEMORYSTATUSEX)
                << _T("  ") << lpBuffer->dwLength << _T("\r\n") ;
        #endif
        }
      WrapKernel32	wk32 ;
      return	wk32.GlobalMemoryStatusEx(lpBuffer) ;
      }
    
    #endif	//	(_MFC_VER >= 0x0700)
    

    WrpKrnl3.hxx

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

    EMF への保存

    Displaying a Picture and Storing It in an Enhanced Metafile
    http://msdn.microsoft.com/en-us/library/dd183568.aspx


    2020/12
    E_MF.hxx
    EMF_fnc.hxx

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

    DIB の縮小表示

    サイズの大きな画像を縮小して表示すると汚くなる

    SetStretchBltMode の指定が必要.
    http://msdn.microsoft.com/ja-jp/library/cc428734.aspx

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

    「応答なし」になり難くする

    //*******************************************************************************
    // 関数名 :時間がかかる時に,応答なしにならない様にする
    // 作成日 :’07/10/05
    //*******************************************************************************
    BOOL WaitPeek (void)
    {
      MSG msg ;
      ::PeekMessage(&msg,NULL,0,0,PM_NOREMOVE) ;
      return TRUE ;
      }

    //*******************************************************************************
    // 関数名 :時間がかかる時に他に制御を回す
    // 作成日 :’95/12/05
    //*******************************************************************************
    BOOL Wait (void)
    {
      MSG msg ;
      for (int msgCnt=0 ; msgCnt < 1000 ; msgCnt++) {
        if (::PeekMessage(&msg ,NULL,0,0,PM_REMOVE)) {
          if (msg.message == WM_QUIT) {
            return FALSE ;
            }
          ::TranslateMessage(&msg) ;
          ::DispatchMessage(&msg) ;
          continue ;
          }
        break ;
        }
      return TRUE ;
      }


    2011/11/02 追加
    //*******************************************************************************
    // 関数名 :時間がかかった時に,不要なイベントをスキップする
    // 作成日 :’11/03/31
    //*******************************************************************************
    inline
    BOOL EatMessage (const HWND wnd=NULL,const UINT skipWM=WM_TIMER)
    {
      MSG eatMsg;
      while(::PeekMessage(&eatMsg,wnd,skipWM,skipWM,PM_REMOVE)) ;
      return TRUE ;
      }


    HelpWait.hxx

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

    Win7 srv 2017

    ログの名前: System
    ソース: srv
    日付: 2010/01/08 21:15:09
    イベント ID: 2017
    タスクのカテゴリ: なし
    レベル: エラー
    キーワード: クラシック
    ユーザー: N/A
    コンピューター: T54W7U64
    説明:
    非ページ プール割り当ての制限に達したため、サーバーはシステムの非ページ プールから割り当てることができませんでした。

    検索すると,
    [HKEY_LOCAL_MACHINESYSTEMCurrentControlSetservicesLanmanServerParameters]
    "Size"=dword:00000003
    "MaxMpxCt"=dword:000000ff
    "MaxWorkItems"=dword:00000400
    とある.

    T54W7U64 の現在の設定は,
    [HKEY_LOCAL_MACHINESYSTEMCurrentControlSetservicesLanmanServerParameters]
    "MaxNonPagedMemoryUsage"=dword:ffffffff

    http://cid-535f5973454c1292.office.live.com/self.aspx/.Public/RegFiles/Win7^_SRV^_2017.zip

    Win7_SRV_2017.zip

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

    Win7 エクスプローラ左のツリーの展開

    Windows 7 のエクスプローラで,左側にあるフォルダツリーを自動で展開表示する設定
    エクスプローラ左のツリーの展開

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