summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2015-01-07 12:43:58 -0500
committerPietro Gagliardi <[email protected]>2015-01-07 12:43:58 -0500
commitff4212913a391abb9019f034f93c2f009fa55f66 (patch)
tree663df789da0795812d45cb2074b7445eb346be2c
parent095c6dc79cfa0a81a18422a4e0b3657a2691861d (diff)
Split the actual test code from the main Table code.
-rw-r--r--wintable/main.h (renamed from wintable/main.c)51
-rw-r--r--wintable/test.c52
2 files changed, 53 insertions, 50 deletions
diff --git a/wintable/main.c b/wintable/main.h
index 2674d66..7199676 100644
--- a/wintable/main.c
+++ b/wintable/main.h
@@ -1,7 +1,4 @@
-// 19 october 2014
-#include "../wininclude_windows.h"
-
-// #qo LIBS: user32 kernel32 gdi32 comctl32 uxtheme ole32 oleaut32 oleacc uuid
+// 7 january 2015
// TODO
// - should tablePanic be CALLBACK or some other equivalent macro? and definitely export initTable somehow, but which alias macro to use?
@@ -173,49 +170,3 @@ void initTable(void (*panicfunc)(const char *msg, DWORD lastError), BOOL (*WINAP
if (RegisterClassW(&wc) == 0)
panic("error registering Table window class");
}
-
-int main(int argc, char *argv[])
-{
- HWND mainwin;
- MSG msg;
- INITCOMMONCONTROLSEX icc;
-
- ZeroMemory(&icc, sizeof (INITCOMMONCONTROLSEX));
- icc.dwSize = sizeof (INITCOMMONCONTROLSEX);
- icc.dwICC = ICC_LISTVIEW_CLASSES;
- if (InitCommonControlsEx(&icc) == 0)
- panic("(test program) error initializing comctl32.dll");
- initTable(NULL, _TrackMouseEvent);
- mainwin = CreateWindowExW(0,
- tableWindowClass, L"Main Window",
- WS_OVERLAPPEDWINDOW | WS_HSCROLL | WS_VSCROLL,
- CW_USEDEFAULT, CW_USEDEFAULT,
- 400, 400,
- NULL, NULL, GetModuleHandle(NULL), NULL);
- if (mainwin == NULL)
- panic("(test program) error creating Table");
- SendMessageW(mainwin, tableAddColumn, tableColumnText, (LPARAM) L"Column");
- SendMessageW(mainwin, tableAddColumn, tableColumnImage, (LPARAM) L"Column 2");
- SendMessageW(mainwin, tableAddColumn, tableColumnCheckbox, (LPARAM) L"Column 3");
- if (argc > 1) {
- NONCLIENTMETRICSW ncm;
- HFONT font;
-
- ZeroMemory(&ncm, sizeof (NONCLIENTMETRICSW));
- ncm.cbSize = sizeof (NONCLIENTMETRICSW);
- if (SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, sizeof (NONCLIENTMETRICSW), &ncm, sizeof (NONCLIENTMETRICSW)) == 0)
- panic("(test program) error getting non-client metrics");
- font = CreateFontIndirectW(&ncm.lfMessageFont);
- if (font == NULL)
- panic("(test program) error creating lfMessageFont HFONT");
- SendMessageW(mainwin, WM_SETFONT, (WPARAM) font, TRUE);
- }
- ShowWindow(mainwin, SW_SHOWDEFAULT);
- if (UpdateWindow(mainwin) == 0)
- panic("(test program) error updating window");
- while (GetMessageW(&msg, NULL, 0, 0) > 0) {
- TranslateMessage(&msg);
- DispatchMessageW(&msg);
- }
- return 0;
-}
diff --git a/wintable/test.c b/wintable/test.c
new file mode 100644
index 0000000..a9832df
--- /dev/null
+++ b/wintable/test.c
@@ -0,0 +1,52 @@
+// 19 october 2014
+#include "../wininclude_windows.h"
+
+// #qo LIBS: user32 kernel32 gdi32 comctl32 uxtheme ole32 oleaut32 oleacc uuid
+
+#include "main.h"
+
+int main(int argc, char *argv[])
+{
+ HWND mainwin;
+ MSG msg;
+ INITCOMMONCONTROLSEX icc;
+
+ ZeroMemory(&icc, sizeof (INITCOMMONCONTROLSEX));
+ icc.dwSize = sizeof (INITCOMMONCONTROLSEX);
+ icc.dwICC = ICC_LISTVIEW_CLASSES;
+ if (InitCommonControlsEx(&icc) == 0)
+ panic("(test program) error initializing comctl32.dll");
+ initTable(NULL, _TrackMouseEvent);
+ mainwin = CreateWindowExW(0,
+ tableWindowClass, L"Main Window",
+ WS_OVERLAPPEDWINDOW | WS_HSCROLL | WS_VSCROLL,
+ CW_USEDEFAULT, CW_USEDEFAULT,
+ 400, 400,
+ NULL, NULL, GetModuleHandle(NULL), NULL);
+ if (mainwin == NULL)
+ panic("(test program) error creating Table");
+ SendMessageW(mainwin, tableAddColumn, tableColumnText, (LPARAM) L"Column");
+ SendMessageW(mainwin, tableAddColumn, tableColumnImage, (LPARAM) L"Column 2");
+ SendMessageW(mainwin, tableAddColumn, tableColumnCheckbox, (LPARAM) L"Column 3");
+ if (argc > 1) {
+ NONCLIENTMETRICSW ncm;
+ HFONT font;
+
+ ZeroMemory(&ncm, sizeof (NONCLIENTMETRICSW));
+ ncm.cbSize = sizeof (NONCLIENTMETRICSW);
+ if (SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, sizeof (NONCLIENTMETRICSW), &ncm, sizeof (NONCLIENTMETRICSW)) == 0)
+ panic("(test program) error getting non-client metrics");
+ font = CreateFontIndirectW(&ncm.lfMessageFont);
+ if (font == NULL)
+ panic("(test program) error creating lfMessageFont HFONT");
+ SendMessageW(mainwin, WM_SETFONT, (WPARAM) font, TRUE);
+ }
+ ShowWindow(mainwin, SW_SHOWDEFAULT);
+ if (UpdateWindow(mainwin) == 0)
+ panic("(test program) error updating window");
+ while (GetMessageW(&msg, NULL, 0, 0) > 0) {
+ TranslateMessage(&msg);
+ DispatchMessageW(&msg);
+ }
+ return 0;
+}