00048 {
00049 WNDCLASS wndclass;
00050 hWinDlgInstance = hInstance;
00051 nWinDlgCmdShow = nCmdShow;
00052
00053 if (NULL == hPrevInstance)
00054 {
00055 wndclass.style = CS_HREDRAW | CS_VREDRAW;
00056 wndclass.lpfnWndProc = main_window_proc;
00057 wndclass.cbClsExtra = 0;
00058
00059
00060
00061
00062 wndclass.cbWndExtra = 0;
00063 wndclass.hInstance = hInstance;
00064 wndclass.hIcon = NULL;
00065 wndclass.hCursor = LoadCursor (NULL, IDC_ARROW);
00066 wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
00067 wndclass.lpszMenuName = NULL;
00068 wndclass.lpszClassName = "TITLE_WINDOW";
00069
00070 if (!RegisterClass (&wndclass))
00071 {
00072 MessageBox (NULL, "Can't Registor TITLE_WINDOW Class.", "ERROR",
00073 MB_OK);
00074 return (0);
00075 }
00076 }
00077 title_window =
00078 CreateWindow ("TITLE_WINDOW", "The Title", WS_CAPTION | WS_SYSMENU, 0,
00079 0,
00080 0,
00081 0,
00082 NULL,
00083 NULL,
00084 hInstance, 0);
00085 if (title_window == NULL)
00086 {
00087 MessageBox (NULL, "Can't Create TITLE_WINDOW.", "ERROR", MB_OK);
00088 return 0;
00089 }
00090 ShowWindow (title_window, nCmdShow);
00091 dlg_proc_instance = MakeProcInstance (main_window_dialog_proc, hInstance);
00092 if (NULL == dlg_proc_instance)
00093 {
00094 MessageBox (NULL, "Can't MakeProcInstance for dialog_proc.", "ERROR",
00095 MB_OK);
00096 return NULL;
00097 }
00098 dlg_resource_str = MAKEINTRESOURCE (MAIN_WINDOW_DIALOG);
00099 if (dlg_resource_str == NULL)
00100 {
00101 MessageBox (NULL, "Can't MAKEINTRESOURCE for MAIN_WINDOW_DIALOG",
00102 "ERROR", MB_OK);
00103 return 0;
00104 }
00105 #if 0
00106 dlg_resource_handle = FindResource (hInstance, dlg_resource_str, RT_DIALOG);
00107 if (NULL == dlg_resource_handle)
00108 {
00109 MessageBox (NULL, "Can't FindResource MAIN_WINDOW_DIALOG", "ERROR",
00110 MB_OK);
00111 FreeProcInstance (dlg_proc_instance);
00112 dlg_proc_instance = NULL;
00113 return NULL;
00114 }
00115 dlg_resource = LoadResource (hInstance, dlg_resource_handle);
00116 if (NULL == dlg_resource)
00117 {
00118 MessageBox (NULL, "Can't LoadResource MAIN_WINDOW_DIALOG", "ERROR",
00119 MB_OK);
00120 FreeProcInstance (dlg_proc_instance);
00121 dlg_proc_instance = NULL;
00122 return NULL;
00123 }
00124 dlg_resource_ptr = LockResource (dlg_resource);
00125 if (dlg_resource_ptr == NULL)
00126 {
00127 MessageBox (NULL, "Can't LockResource MAIN_WINDOW_DIALOG", "ERROR",
00128 MB_OK);
00129 return 0;
00130 }
00131 #endif
00132 hDlg = CreateDialog (hInstance,
00133 dlg_resource_str, title_window, dlg_proc_instance);
00134 if (NULL == hDlg)
00135 {
00136 MessageBox (NULL, "Can't CreateDialog.", "ERROR", MB_OK);
00137 FreeProcInstance (dlg_proc_instance);
00138 dlg_proc_instance = NULL;
00139 FreeResource (dlg_resource);
00140 dlg_resource = NULL;
00141 return NULL;
00142 }
00143 while (GetMessage (&main_loop_message, NULL, 0, 0))
00144 {
00145 if (IsDialogMessage (hDlg, &main_loop_message))
00146 {
00147 continue;
00148 }
00149 TranslateMessage (&main_loop_message);
00150 DispatchMessage (&main_loop_message);
00151 }
00152 return main_loop_message.wParam;
00153 }