2024年4月
 123456
78910111213
14151617181920
21222324252627
282930  

カテゴリー

アーカイブ

ブログ統計情報

  • 80,154 アクセス



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

//*******************************************************************************
// 関数名 :時間がかかる時に,応答なしにならない様にする
// 作成日 :’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.

画像付 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.

ツールバーにドロップダウンボタン

ツール バー コントロールでのドロップダウン ボタンの使い方
http://msdn.microsoft.com/ja-jp/library/1ke6s1fc.aspx
 
上の方法だけでは,MFC のバージョンによりうまく動作しないので…
ToolBar.hxx
BOOL ToolBar::SetStyleDropDown (CToolBar* toolBar,int commandID)
MFC 6 では,CBRS_SIZE_DYNAMIC を無効にして.Create する必要あり.
ツールバーにドロップダウンボタンを追加

ToolBar.hxx

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

ファイルを選択した状態で explorer.exe

explorer.exe /select,c:~exmple.txt
http://support.microsoft.com/kb/314853/ja
https://www.betaarchive.com/wiki/index.php?title=Microsoft_KB_Archive/314853
void CXxxxDoc::OnExecExplorer() 
{
 CString docName = GetPathName() ;
 ShellExec se ;
 se.SetNon2QMark(TRUE) ;
 se.SetFile(_T("explorer.exe")) ;
 se.SetParamaters(_T("/e,/select,")+docName) ;
 se.Execute() ;
 }


ShellExc.hxx , ShellExc.cxx


S_Exec.hxx

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

CChildFrame を最大化して表示

MDI の新規ウィンドウで ChildFrame を最大化して表示

BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)
{
  cs.style = WS_CHILD | WS_VISIBLE | WS_OVERLAPPED | WS_CAPTION 
             | WS_SYSMENU     | FWS_ADDTOTITLE | WS_THICKFRAME 
             | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_MAXIMIZE;
  if( !CMDIChildWnd::PreCreateWindow(cs) ) {
    return FALSE;
    }
  return TRUE;
  }
Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

分割ウィンドウ CSplitterWnd

MDI 分割ウィンドウ
ChildFrm.cpp 内の CChildFrame::OnCreateClient で分割数などを指定している.

SDI は,CMainFrame::OnCreateClient 


静的分割ウィンドウ
OnCreateClient 内のコードを書き換える.
/* // コメント部分はスケルトンで生成されたもの
  return m_wndSplitter.Create( this,
    2, 2,         // TODO: 行と列の数を調整してください。
    CSize( 10, 10 ),  // TODO: 最小の区画サイズを調整してください。
    pContext );
*/

  if (!m_wndSplitter.CreateStatic(this,1,2)) {
    return FALSE ;
    }
  if (!m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CLeft_View), CSize(150, 100), pContext) ||
    !m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CRightView), CSize(100, 100), pContext)) {
    m_wndSplitter.DestroyWindow();     // この部分は,どこに書かれていたか不明
    return FALSE;
    }
  return TRUE ;

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

CString で保存される形式

BOM — U+FEFF

UNICODE  FF FE FF  04  32 00  30 00  31 00  30 00 
MBCS    04 32 30 31 30


//  VC98\MFC\SRC\ArcCore.cpp

// CString serialization code
// String format:
//  UNICODE strings are always prefixed by 0xff, 0xfffe
//  if < 0xff chars: len:BYTE, TCHAR chars
//  if >= 0xff characters: 0xff, len:WORD, TCHAR chars
//  if >= 0xfffe characters: 0xff, 0xffff, len:DWORD, TCHARs

CArchive& AFXAPI operator<<(CArchive& ar, const CString& string)
{
  // special signature to recognize unicode strings
  #ifdef _UNICODE
   ar << (BYTE)0xff;
   ar << (WORD)0xfffe;

  #endif
  if (string.GetData()->nDataLength < 255) {
   ar << (BYTE)string.GetData()->nDataLength;
   }
  else if (string.GetData()->nDataLength < 0xfffe) {
   ar << (BYTE)0xff;
   ar << (WORD)string.GetData()->nDataLength;
   }
  else {
   ar << (BYTE)0xff;
   ar << (WORD)0xffff;
   ar << (DWORD)string.GetData()->nDataLength;
   }
  ar.Write(string.m_pchData, string.GetData()->nDataLength*sizeof(TCHAR));
  return ar;
  }

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

X02T Bluetooth Profile

HSP Headset Profile デバイスとBluetooth 対応ヘッドセットとの通信に使用する。
HFP Hands-Free Profile ハンズフリーデバイスで発呼および着呼する。
SPP Serial Port Protocol 2 台の Bluetooth 対応デバイスを接続する。
A2DP Advanced Audio Distribution Profile ステレオ品質のオーディオをメディア ソースからストリーミングする。
AVRCP Audio/Video Remote Control Profile TVやハイファイ設備、その他のデバイスを制御する(リモコンのような役割)。
HID Human Interface Device キーボードやマウス、ゲームデバイスなどに使用する。
OPP Object Push Profile 携帯電話間、または携帯電話と PC 間での連絡先やスケジュール、名刺データの交換などに使用する。

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.

ビューのそのままを 1 ページに印刷

CXxxxView::OnDraw が以下の様な場合,それを単純にプリンタに送る
{
  CXxxxDoc* pDoc = GetDocument();
  CRect drawRect ;
  GetClientRect(drawRect) ;
  pDoc->Object.Draw(pDC,drawRect,…) ;
  }

CXxxxView::OnPrint を追加.
void CXxxxView::OnPrint(CDC* pDC, CPrintInfo* pInfo) 
{
  CXxxxDoc* pDoc = GetDocument();
  CRect drawRect ;
  drawRect = pInfo->m_rectDraw ;
  pDoc->Object.Draw(pDC,drawRect,…) ;
// CView::OnPrint(pDC, pInfo);
  }

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

ドキュメントのダブルクリックを無効に

ドキュメントのファイルタイプを指定してスケルトンを作成した場合
CXxxxApp::InitInstance 内の以下をコメントに
 // EnableShellOpen();
 // RegisterShellFileTypes(TRUE);

後から,ドキュメントタイプを指定する場合
リソースの StringTable の対応するドキュメント文字列を変更する.

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

MDI , SDI へのドロップの追加

CXxxxApp::InitInstance のメインフレームを作成した後に,以下を追加.
 m_pMainWnd->DragAcceptFiles();

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

起動時に MDI 子ウィンドウを表示しない

起動時に MDIチャイルドウインドウを表示させない
CXxxxApp::InitInstance の ParseCommandLine(cmdInfo); の後に
if (cmdInfo.m_nShellCommand == CCommandLineInfo::FileNew) {
  cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing ;
  }

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.

Shell_NotifyIcon

SDK32: 通知領域にアイコンが登録されないことがある
http://support.microsoft.com/kb/418138/ja

マウスの位置の取得
BOOL ::GetCursorPos(LPPOINT lpPoint) ;

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

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

タスクバーのドキュメント

mk:@MSITStore:X:MSDNShellcc.chm::/platform/Shell/Shell_Int/Taskbar.htm
http://msdn.microsoft.com/ja-jp/library/cc144179(VS.85).aspx

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

hdc が拡張メタファイルのデバイスコンテキスト?

hdc が拡張メタファイルのデバイスコンテキストかどうかを調べるには、GetObjectType 関数
GetDeviceCaps
GetObjectType

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

マルチバイト→UNICODE

「構成プロパティ」-「全般」-「文字セット」を「マルチバイト...」から「UNICODE...」に変更すると,以下のエラーになることがある.
msvcrtd.lib(wcrtexew.obj) : error LNK2019: 未解決の外部シンボル _wWinMain@16 が関数 ___tmainCRTStartup で参照されました。

vcproj をエディタなどで開き,";_MBCS;$(NoInherit)" を削除.

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