NPP サンプル:API (MAPI) をメッセージ ウィンドウを示します

NPP サンプルは、メモ帳に似たシングル ドキュメント インターフェイス (SDI: Single-Document Interface) アプリケーションです。テキストのメッセージを編集し、Windows メッセージ API (MAPI: Messaging API)、つまり MAPI を経由してほかのユーザーやシステムに送信できます。

セキュリティに関するメモセキュリティに関するメモ

このサンプル コードは概念を示すためのものであり、その概念に関連するコードのみを示しています。特定の環境について必ずしもセキュリティ要件を満たしていませんので、そのまま使用しないでください。セキュリティおよびエラー処理コードを追加して、プロジェクトをより安全かつ堅牢にすることをお勧めします。これらのサンプル コードは、現状有姿のままで提供されるものであり、一切保証されていません。

サンプルとそのインストール手順を取得するには

Visual Studio のサンプルにアクセスするには

  • [ヘルプ] メニューの [サンプル] をクリックします。

    既定では、これらのサンプルは drive:\Program Files\Microsoft Visual Studio 10.0\Samples\ にインストールされています。

  • このサンプルの最新版および他のサンプルの一覧については、MSDN Web サイト上で Visual Studio サンプル 」を参照してください。

サンプルのビルドと実行

NPP サンプルをビルドおよび実行するには

  1. ソリューション NPP.sln を開きます。

  2. [ビルド] メニューの [ビルド] をクリックします。

  3. でデバッグ メニューの、[デバッグなしで開始 をクリックします。

ファイル メニュー編集ウィンドウの内容が MAPI メッセージに添付できる 送信 コマンドがあります。 選択送信 ユーザー名と、既にログオンしていない場合、MAPI セッションを開始するのにはパスワードを求められます。

The two important lines of code that enable this feature (aside from adding the menu choice itself to the resource file) are entries in the message map for the CNotepadDocinstance, which the application maintains. これらのエントリは次のとおりです。

ON_COMMAND(ID_FILE_SEND_MAIL, OnFileSendMail)
ON_UPDATE_COMMAND_UI(ID_FILE_SEND_MAIL, OnUpdateFileSendMail)

CDocument::OnFileSendMailCDocument::OnUpdateFileSendMail は MFC に組み込まれています。アプリケーションでこのレベルの MAPI サポートを実現する場合は、これだけで十分です。

Keywords

このサンプルでは、次のキーワードを使用します。

AfxGetMainWnd; AfxMessageBox; CComboBox::Copy; CComboBox::Create; CComboBox::GetDroppedState; CComboBox::Paste; CComboBox::SetEditSel; CComboBox::ShowDropDown; CDC::GetTextExtent; CDC::GetTextMetrics; CDC::SelectObject; CDialog::DoModal; CDialog::OnCancel; CDialog::OnInitDialog; CDocument::OnNewDocument; CEdit::GetLineCount; CEdit::LineFromChar; CEdit::LineIndex; CEdit::LineScroll; CEdit::SetSel; CEditView::GetEditCtrl; CEditView::GetSelectedText; CEditView::OnFindNext; CFrameWnd::Create; CFrameWnd::DockControlBar; CFrameWnd::EnableDocking; CFrameWnd::GetActiveView; CFrameWnd::RecalcLayout; CObject::AssertValid; CObject::Dump; CObject::Serialize; CRect::Height; CStatusBar::CommandToIndex; CStatusBar::SetPaneText; CString::Format; CString::GetLength; CString::LoadString; CToolBar::GetItemRect; CToolBar::SetButtonInfo; CView::GetDocument; CView::OnBeginPrinting; CView::OnDraw; CView::OnEndPrinting; CView::OnPreparePrinting; CWinApp::AddDocTemplate; CWinApp::InitInstance; CWinApp::LoadStdProfileSettings; CWinApp::OnFileNew; CWinApp::OnIdle; CWinApp::OpenDocumentFile; CWnd::Create; CWnd::DoDataExchange; CWnd::FromHandle; CWnd::GetDescendantWindow; CWnd::GetDlgItem; CWnd::GetFocus; CWnd::GetStyle; CWnd::GetWindowRect; CWnd::GetWindowText; CWnd::GetWindowTextLength; CWnd::KillTimer; CWnd::OnClose; CWnd::OnCreate; CWnd::PostMessage; CWnd::PreTranslateMessage; CWnd::ScreenToClient; CWnd::SendMessage; CWnd::SetFocus; CWnd::SetFont; CWnd::SetTimer; CWnd::SetWindowPos; CWnd::SetWindowText; CWnd::ShowWindow; CreateFontIndirect; DragAcceptFiles; EndDialog; EnumFontFamilies; GetDlgItem; GetKeyState; GetLocalTime; GetStockObject; LoadBitmap; MessageBeep; SendMessage; SetWindowText; memcpy

注意

このサンプルを含む一部のサンプルには、Visual C++ のウィザード、ライブラリ、およびコンパイラの変更が反映されていませんが、必要なタスクを実行する方法は示されています。

参照

その他の技術情報

MFC サンプル