From 855a09656a382d4089674712b400391a6e9dd3f9 Mon Sep 17 00:00:00 2001
From: Pietro Gagliardi <pietro10@mac.com>
Date: Fri, 30 May 2014 22:14:55 -0400
Subject: [PATCH] Changed Areas on Windows to store their sysData inside the
 window memory instead of being given it via a closure. Actually having only
 one window class for all Areas comes next.

---
 area_windows.go    | 6 +++++-
 sysdata_windows.go | 1 +
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/area_windows.go b/area_windows.go
index 6708a27..35438e3 100644
--- a/area_windows.go
+++ b/area_windows.go
@@ -604,8 +604,12 @@ var (
 	_setFocus = user32.NewProc("SetFocus")
 )
 
-func areaWndProc(s *sysData) func(hwnd _HWND, uMsg uint32, wParam _WPARAM, lParam _LPARAM) _LRESULT {
+func areaWndProc(unused *sysData) func(hwnd _HWND, uMsg uint32, wParam _WPARAM, lParam _LPARAM) _LRESULT {
 	return func(hwnd _HWND, uMsg uint32, wParam _WPARAM, lParam _LPARAM) _LRESULT {
+		s := getSysData(hwnd)
+		if s == nil {		// not yet saved
+			return storeSysData(hwnd, uMsg, wParam, lParam)
+		}
 		switch uMsg {
 		case _WM_PAINT:
 			paintArea(s)
diff --git a/sysdata_windows.go b/sysdata_windows.go
index 06b2ac8..e6b6484 100644
--- a/sysdata_windows.go
+++ b/sysdata_windows.go
@@ -116,6 +116,7 @@ var classTypes = [nctypes]*classData{
 		register:			registerAreaWndClass,
 		style:			areastyle,
 		xstyle:			areaxstyle,
+		storeSysData:		true,
 		doNotLoadFont:	true,
 	},
 }