Listing 8
// Quickstart - part of the samples coming with win32gui
// sample_dlg.h
#include <win32gui/window.hpp>
struct sample_dlg : win32::gui::wnd_extend<win32::gui::dialog,sample_dlg> {
static int dialog_id();
};
// sample_dlg.cpp
#include "resource.h"
#include "sample_dlg.h"
#include <win32gui/event_handler.hpp>
#include <win32gui/frame.hpp>
#include <win32gui/dialog.hpp>
using namespace win32::gui;
struct sample_dlg_handler
: event_handler<sample_dlg_handler,dialog,sample_dlg> {
handle_event on_new_view() {
wnd<> view = create_dlg<sample_dlg>( top_parent());
top_parent<sdi_frame>()->activate( view);
return command<ID_new_view>().HANDLED_BY(&me::on_new_view);
}
};
int sample_dlg::dialog_id() { return IDD_SAMPLE; }
// main.cpp
#include <win32gui/frame.hpp>
#include <win32gui/dialog.hpp>
#include "sample_dlg.h"
#include "resource.h"
using namespace win32::gui;
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int) {
wnd<> top = create_wnd<sdi_frame>( null_wnd, create_info().menu(IDR_my_app));
create_dlg<sample_dlg>(top);
top->wait();
}