// Written by Christopher E. Miller
// www.dprogramming.com
// This DFL example is public domain.
// Drop this file in your dfl/ source directory.
// import dfl.mylistview; to use it.
// You must compile this source file along with your other files:
// dmd mystuff.d c:\path\to\dfl\mylistview.d -L/exet:nt/su:windows:4.0
// or
// dfl -gui mystuff.d c:\path\to\dfl\mylistview.d
// Note: the preferred way to do this may be changed and simplified in the future.
module dfl.mylistview;
private import dfl.base, dfl.control, dfl.winapi, dfl.application;
private import dfl.event;
class MyListView: ControlSuperClass
{
// Called in createControl(), just before CreateWindowEx().
// Note: show() calls createControl().
protected override void createParams(inout CreateParams cp)
{
super.createParams(cp);
cp.exStyle |= WS_EX_CLIENTEDGE;
cp.className = MYLISTVIEW_CLASSNAME; // Specify which window class to create. Must be a DFL window class.
}
// Called in ControlSuperClass when the previous window procedure needs to handle a message.
protected override void prevWndProc(inout Message msg)
{
msg.result = CallWindowProcA(mylistviewPrevWndProc, msg.hWnd, msg.msg, msg.wParam, msg.lParam);
}
// Prepare the window class to work with DFL.
// Need to "super class" the window class so that DFL can keep track of it.
static this()
{
mylistviewPrevWndProc = superClass(GetModuleHandleA(null), LISTVIEW_CLASSNAME, MYLISTVIEW_CLASSNAME);
if(!mylistviewPrevWndProc)
throw new DflException(MYLISTVIEW_CLASSNAME ~ " failed.");
}
private:
const char[] LISTVIEW_CLASSNAME = "SysListView32"; // The existing window class to use.
const char[] MYLISTVIEW_CLASSNAME = "MyListView"; // My new unique window class name for DFL.
static WNDPROC mylistviewPrevWndProc; // The previous window callback procedure.
}