/*
* CommonDialog.h
* Copyright (c) 2011 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED.
*/
// SOL++2000
// 2000.02.18
#pragma once
#include <sol\View.h>
#include <commdlg.h>
typedef UINT (CALLBACK* HOOKFUN)(HWND, UINT, WPARAM, LPARAM);
namespace SOL {
class CommonDialog :public View {
private:
void* calldata;
protected:
CommonDialog():View() {
calldata = NULL;
}
public:
CommonDialog(View* parent, void* data)
:View(parent)
{
calldata = data;
}
public:
virtual Boolean create(View* parent, void* data)
{
Boolean rc = True;
View::setParent(parent);
calldata = data;
return rc;
}
public:
long defaultProc(Event& event)
{
return FALSE;
}
public:
virtual void popup(Action& action)
{
// Realize a modal/modeless common dialog.
}
public:
~CommonDialog() {
setWindow(NULL);
}
void* getCallData() {
return calldata;
}
public:
static long CALLBACK hookProc(HWND hwnd, UINT message,
WPARAM wParam, LPARAM lParam)
{
CommonDialog* dlg = NULL;
if (message == WM_INITDIALOG) {
dlg = (CommonDialog*)lParam;
Application::add(hwnd, dlg);
} else {
dlg = (CommonDialog*)Application::lookup(hwnd);
}
if(message == WM_DESTROY) {
Application::remove(hwnd);
return 0L;
}
Event event(message, wParam, lParam);
if(dlg) {
return (UINT)dlg -> dispatch(event);
} else{
return 0L;
}
}
};
}
|