deargui-vpl/ref/virtools/Samples/Virtools Interface SDK/Test/TestEditorDlg.cpp

142 lines
3.3 KiB
C++

// TestEditorDlg.cpp : implementation file
//
#include "stdafx.h"
#include "TestEditor.h"
#include "TestEditorDlg.h"
#include "TestKeyboardShortcuts.h"
#ifdef _MFCDEBUGNEW
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#endif
DllEditorDlg* fCreateEditorDlg(HWND parent)
{
HRESULT r = CreateDllDialog(parent,IDD_EDITOR,&g_Editor);
return (DllEditorDlg*)g_Editor;
}
/////////////////////////////////////////////////////////////////////////////
// TestEditorDlg dialog
TestEditorDlg::TestEditorDlg(CWnd* pParent /*=NULL*/)
: DllEditorDlg(TestEditorDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(TestEditorDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void TestEditorDlg::DoDataExchange(CDataExchange* pDX)
{
DllEditorDlg::DoDataExchange(pDX);
//{{AFX_DATA_MAP(TestEditorDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(TestEditorDlg, DllEditorDlg)
//{{AFX_MSG_MAP(TestEditorDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// TestEditorDlg message handlers
LRESULT TestEditorDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
// TODO: Add your specialized code here and/or call the base class
switch (message)
{
case WM_KEYDOWN:
{
KeyboardShortcutManager* ksm = GetInterface()->GetKeyboardShortcutManager();
int commandID = ksm->TestKS(STR_CATEGORY,wParam);
if (commandID)
OnGlobalKeyboardShortcut(commandID);
}break;
}
return DllEditorDlg::WindowProc(message, wParam, lParam);
}
BOOL TestEditorDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
switch(pMsg->message)
{
case WM_SYSKEYDOWN:
case WM_KEYDOWN:
{
KeyboardShortcutManager* ksm = GetInterface()->GetKeyboardShortcutManager();
int commandID = ksm->TestKS(STR_CATEGORY,pMsg->wParam);
if (commandID)
if (OnLocalKeyboardShortcut(commandID))
return 1;
}break;
}
return DllEditorDlg::PreTranslateMessage(pMsg);
}
BOOL TestEditorDlg::OnInitDialog()
{
DllEditorDlg::OnInitDialog();
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
//this is the almost equivalent of OnInitDialog you should use if you want to
//use the PluginInterface with GetInterface or if you want to be sure the toolbar is present
void TestEditorDlg::OnInterfaceInit()
{
}
//called on WM_DESTROY
void TestEditorDlg::OnInterfaceEnd()
{
}
int TestEditorDlg::OnGlobalKeyboardShortcut(int commandID)
{
return 0; //return 1 if successfull/keyboard shortcut has been processed
}
int TestEditorDlg::OnLocalKeyboardShortcut(int commandID)
{
return 0; //return 1 if successfull/keyboard shortcut has been processed
}
void TestEditorDlg::OnCustomMenu(CMenu* menu,int startingCommandID,int endingCommandID)
{
menu->AppendMenu(0,0 /*base ID*/ + startingCommandID,"Sample Command 1");
menu->AppendMenu(0,1 /*base ID*/ + startingCommandID,"Sample Command 2");
}
void TestEditorDlg::OnCustomMenu(int commandID)
{
switch(commandID) {
case 0:
AfxMessageBox("sample command 1 called");
break;
case 1:
AfxMessageBox("sample command 2 called");
break;
}
}