00001
00009 #ifndef INCLUDE_TANUKI_APP_H__
00010 #define INCLUDE_TANUKI_APP_H__
00011
00012
00013 #include <WINDOWS.H>
00014 #include <TCHAR.H>
00015 #include <CRTDBG.H>
00016
00017
00018
00019 #ifdef TANUKI_USED_DLL_EXPORT
00020 #define TANUKI_API __declspec( dllexport )
00021 #else //TANUKI_USED_DLL_EXPORT
00022 #define TANUKI_API
00023 #endif //TANUKI_USED_DLL_EXPORT
00024
00025
00026 namespace tanuki {
00027
00028
00029 #ifndef INCLUDE_TANUKI_EXCEPTION_BASE_CL__
00030 #define INCLUDE_TANUKI_EXCEPTION_BASE_CL__
00031
00037 class TANUKI_API exc_base {
00038
00039
00040
00041 protected:
00043 exc_base(LPCTSTR msg) : m_msg(msg) {}
00045 virtual ~exc_base() {}
00046
00047
00048
00049
00050 public:
00052 LPCTSTR What() const { return m_msg; }
00053
00054
00055
00056
00057 private:
00058
00059 LPCTSTR m_msg;
00060 };
00061
00062 #endif //INCLUDE_TANUKI_EXCEPTION_BASE_CL__
00063
00064
00070 class TANUKI_API exc_application : public exc_base {
00071
00072
00073
00074 public:
00078 exc_application(LPCTSTR msg) : exc_base(msg) {}
00080 virtual ~exc_application() {}
00081 };
00082
00083
00144 class TANUKI_API cl_application {
00145
00146
00147
00148 private:
00149 enum {
00150
00151 MAX_MODELESS_DIALOG = 127,
00152 };
00153
00154
00155
00156
00157 protected:
00159 cl_application()
00160 : M_ReturnValue(0), m_h_instance(NULL),
00161 m_is_use_message_loop(true),
00162 m_is_use_translate_message(true),
00163 m_is_use_translate_accelerator(true),
00164 m_is_use_modeless_dialog(true)
00165 {
00166
00167
00168 m_p_instance = this;
00169 }
00171 virtual ~cl_application() = 0;
00172 private:
00173
00174 cl_application(const cl_application &);
00175 cl_application & operator =(const cl_application &);
00176
00177
00178
00179
00180 public:
00199 virtual void Initialize(HINSTANCE h_instance,
00200 LPCTSTR argv,
00201 int show_flag)
00202 {
00203
00204
00205 m_h_instance = h_instance;
00206 }
00214 virtual void Terminate() {}
00215 protected:
00229 void useMessageLoop(bool is_use = true)
00230 { m_is_use_message_loop = is_use; }
00246 void useTranslateMessage(bool is_use = true)
00247 { m_is_use_translate_message = is_use; }
00263 void useTranslateAccelerator(bool is_use = true)
00264 { m_is_use_translate_accelerator = is_use; }
00278 void useModelessDialog(bool is_use = true)
00279 { m_is_use_modeless_dialog = is_use; }
00280 public:
00293 bool RegisterModelessDialog(HWND h_dlg);
00297 bool RemoveModelessDialog(HWND h_dlg);
00301 bool DispatchModelessDialogMessage(LPMSG p_msg);
00302
00303
00304
00305
00306 public:
00310 HINSTANCE GetInstanceHandle() const { return m_h_instance; }
00318 bool IsUseMessageLoop() const { return m_is_use_message_loop; }
00326 bool IsUseTranslateMessage() const
00327 { return m_is_use_translate_message; }
00335 bool IsUseTranslateAccelerator() const
00336 { return m_is_use_translate_accelerator; }
00344 bool IsUseModelessDialog() const { return m_is_use_modeless_dialog; }
00348 static cl_application * GetApplicationPtr() { return m_p_instance; }
00349
00350
00351
00352
00353 public:
00360 int M_ReturnValue;
00361 private:
00362
00363 HINSTANCE m_h_instance;
00364
00365 bool m_is_use_message_loop;
00366
00367 bool m_is_use_translate_message;
00368
00369 bool m_is_use_translate_accelerator;
00370
00371 bool m_is_use_modeless_dialog;
00372
00373 HWND m_modeless_dialog_table[MAX_MODELESS_DIALOG];
00374
00375
00376 static cl_application * m_p_instance;
00377 };
00378
00379
00380 }
00381
00382
00383 #endif //INCLUDE_TANUKI_APP_H__
00384
00385
00386