00001 #ifndef WINDOW_CLASSIST_CLASS
00002 #define WINDOW_CLASSIST_CLASS
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00019
00053 #include <basis/convert_utf.h>
00054
00055 #ifndef __WIN32__
00056
00057
00058 window_handle create_simplistic_window(const istring &formal(window_title),
00059 const istring &formal(class_name)) { return NIL; }
00060 void whack_simplistic_window(window_handle formal(f_window)) {}
00061
00062 #else
00063
00065
00066 LRESULT CALLBACK window_procedure(HWND hWnd, UINT message,
00067 WPARAM wParam, LPARAM lParam)
00068 {
00069
00070 switch (message) {
00071 case WM_COMMAND: {
00072 int identifier, event;
00073 identifier = LOWORD(wParam);
00074 event = HIWORD(wParam);
00075 return DefWindowProc(hWnd, message, wParam, lParam);
00076 break;
00077 }
00078 case WM_PAINT: {
00079 HDC hdc;
00080 PAINTSTRUCT ps;
00081 hdc = BeginPaint(hWnd, &ps);
00082
00083 EndPaint(hWnd, &ps);
00084 break;
00085 }
00086 case WM_DESTROY: {
00087 PostQuitMessage(0);
00088 break;
00089 }
00090 default: {
00091 return DefWindowProc(hWnd, message, wParam, lParam);
00092 }
00093 }
00094 return 0;
00095 }
00096
00098
00099 ATOM register_class(const istring &name)
00100 {
00101 WNDCLASSEX wcex;
00102 wcex.cbSize = sizeof(WNDCLASSEX);
00103
00104 wcex.style = CS_HREDRAW | CS_VREDRAW;
00105 wcex.lpfnWndProc = (WNDPROC)window_procedure;
00106 wcex.cbClsExtra = 0;
00107 wcex.cbWndExtra = 0;
00108 wcex.hInstance = GET_INSTANCE_HANDLE();
00109 wcex.hIcon = 0;
00110 wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
00111 wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
00112 wcex.lpszMenuName = 0;
00113 to_unicode_persist(temp_class, name);
00114 wcex.lpszClassName = temp_class;
00115 wcex.hIconSm = 0;
00116
00117 return RegisterClassEx(&wcex);
00118 }
00119
00120 window_handle create_simplistic_window(const istring &window_title,
00121 const istring &class_name)
00122 {
00123 register_class(class_name);
00124 window_handle f_window = CreateWindow(to_unicode_temp(class_name),
00125 to_unicode_temp(window_title), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,
00126 0, CW_USEDEFAULT, 0, NIL, NIL, GET_INSTANCE_HANDLE(), NIL);
00127 ShowWindow(f_window, SW_HIDE);
00128 UpdateWindow(f_window);
00129 return f_window;
00130 }
00131
00132 void whack_simplistic_window(window_handle f_window)
00133 {
00134 SendMessage(f_window, WM_CLOSE, NIL, NIL);
00135
00136 }
00137
00138 #endif // win32
00139
00140 #endif // outer guard
00141