ホーム » メモ (ページ 25)

メモ」カテゴリーアーカイブ

2024年4月
 123456
78910111213
14151617181920
21222324252627
282930  

カテゴリー

アーカイブ

ブログ統計情報

  • 80,254 アクセス



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.

    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.

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

    ヘッダファイルへの追加
     #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.

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

    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.

    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.

    画像付 RecentFile の追加

    RecentFileMF クラスを利用して,画像でのメニュー表示を可能にする

    1. ODMenu を利用可能な様に追加する.
      アプリケーションクラスのヘッダなどで MetaFile.hxx をインクルードして,ODMMetaFile を利用可能に.
    2. ID_RECENT_FILE_00 ~ の必要数分のリソースを作成する.
    3. アプリケーションクラスのヘッダに,include と変数を追加する.
      #include "RecentFM.hxx"
      RecentFileMF RcntFM ;
    4. アプリケーションクラスのコンストラクタに RecnetFileMF の初期化を追加する.
      : RcntFM(_T("RecentFileMF"),30)
    5. InitInstance で,RcntFM のデータを読込む処理を追加する.
      {
       RcntFM.Read() ;
       RcntFM.SetStartID(ID_RECENT_FILE_00) ;
       }
    6. アプリケーションクラスに,範囲でコマンドハンドラを追加する.
      ON_COMMAND_RANGE  (ID_RECENT_FILE_00,ID_RECENT_FILE_29,OnRecentFile)
      void CXxxxApp::OnRecentFile(UINT nID)
      {
       CString selFile = RcntFM.GetSelectFile(nID) ;
       AfxGetApp()->OpenDocumentFile(selFile) ;
       }
    7. ドキュメントクラスのファイルの読み書きの時に,次の様にドキュメントと対応する画像を指定する.
      {
       CXxxxApp* app = (CXxxxApp*)AfxGetApp() ;
       app->RcntFM.Add(fileName,emfName) ;
       }
    8. さらに,ドキュメントに対するファイル名をステータスバーなどに表示するために,CMainFrame に追加する.
      // ツールチップの表示データの更新
      BOOL CMainFrame::OnToolTipText(UINT id, NMHDR *pNMHDR, LRESULT *pResult)
      {
       BOOL ret = CFrameWnd:: OnToolTipText(id,pNMHDR,pResult) ;
                  Prompt:: OnToolTipText(id,pNMHDR,pResult) ;
       return ret ;
       }
      // ステータスバーの表示データの更新
      void CMainFrame::GetMessageString(UINT nID, CString &rMessage) const
      {
       CFrameWnd:: GetMessageString(nID,rMessage) ;
       Prompt:: GetMessageString(nID,rMessage) ;
       }


    2012/06/12 追記
    VC6 でドロップタウンが有効にならない場合,CBRS_SIZE_DYNAMIC を外す.
      if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | …
            … | CBRS_FLYBY/* | CBRS_SIZE_DYNAMIC*/) ||
           !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
    ODMenu が有効にならない場合,
      #include “ODMenu.hxx”
      #include “WinMFC.cxx”
    Prompt が有効にならない場合,
      #include “Prompt.hxx”
      #include “RecentFM.cxx”
    ODMenu は有効ではあるが,何も表示されない
      手動で追加していたため,メッセージマップの修正漏れ
        ON_WM_MEASUREITEM()
        ON_WM_DRAWITEM()


    2019/09/20
    OnMeasureItem , OnDrawItem が呼ばれない.
      内部的には ODMenu::ModifyMenu が呼ばれていない.
      WinMFC.cxx を読み込む前に ODMenu.hxx が必要.
      App.h 内の include の最後辺りに ODMenu.hxx の追加で対応可能.

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

    PSAPI

    他のプロセスのメモリの使用状況などを求める.
    EnumProcesses
    EnumProcessModules
    GetModuleFileNameEx

    http://cid-535f5973454c1292.office.live.com/self.aspx/.Public/MFC/PStatus.hxx.txt

    プロセスID から,HWND を求める.
     DWORD pid =  processID ;
     EnumWin ew ;
     INT_PTR wCount = ew.GetCount() ;
     for (INT_PTR wIndex=0 ; wIndex<wCount ; wIndex++) {
      HWND hwnd = ew.GetWinHandle(wIndex) ;
      DWORD wpid = 0 ;
      GetWindowThreadProcessId(hwnd,&wpid) ;
      if (pid == wpid) {
       …
       break ;
       }
      }

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

    MX/36 メモリ増設

    メモリカバーを外す事が容易でなかった.

    1. ネジを緩める所まではマニュアル通り.
    2. 「カバーをはずす②」が,思ったほど簡単ではない.
    3. ネジの近くと,その右の部分を上に上げる感じ.
    4. ネジの付近以外?にツメがあった.
    Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

    コンボボックスの高さ指定

    //*******************************************************************************
    //	関数名	:コンボボックスの高さを,親ウィンドウの下に合わせる
    //	作成日	:’09/07/01
    //*******************************************************************************
    #ifndef CBM_FIRST       // C:Program Files (x86)Microsoft SDKsWindowsv7.0AIncludeCommCtrl.h
    #define CBM_FIRST               0x1700       // Combobox control messages
    #define CB_SETMINVISIBLE        (CBM_FIRST + 1)
    #define CB_GETMINVISIBLE        (CBM_FIRST + 2)
    #define CB_SETCUEBANNER         (CBM_FIRST + 3)
    #define CB_GETCUEBANNER         (CBM_FIRST + 4)
    #endif
    
    BOOL	FitDropHeight	(CComboBox* ctrl,CWnd* parent)
    {
      if (ctrl == NULL)              			{	return	FALSE ;	}
      if (ctrl->m_hWnd == NULL) {	return	FALSE ;	}
      CRect	tRect ;
      ctrl->GetWindowRect (&tRect) ;
      parent->ScreenToClient(&tRect) ;
      CRect	pRect ;
      parent->GetClientRect(&pRect) ;
      tRect.bottom= pRect.bottom ;
      ctrl->MoveWindow(&tRect) ;
      	 // ここから上は,Visual Style が無効な exe の時に動作する
      {	 // ここから下は,Visual Style が有効な場合に必要	MoveWindow では変更されない?
        int	minV = tRect.Height()/ctrl->GetItemHeight(0) ;
        if (minV >= 3)	{	minV-= 2 ;	}
        if (minV <= 0)	{	minV = 1 ;	}
        ctrl->SendMessage(CB_SETMINVISIBLE,minV) ;
        }
      return	TRUE ;
      }

    CB_SETCUEBANNER
    CComboBox::SetCueBanner

    Windows Vista コントロールの拡張


    Windows Vista コモン コントロールの作成要件


    サポートされなくなった ANSI API

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

    Microsoft Touch Pack

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

    Outlook で配信不能 配布先リスト

    「配布先リスト」の「名前」の所にメールアドレスでなく「連絡先」の「表示名」のみの場合?に配信不能になる.
    修正後,「配信不能」にならなかったことは確認済み.
    詳細は未確認.

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