Go to the documentation of this file.00001 #include "../../Library/SDK_Manila_Sense.h"
00002
00003
00004 EventHandler::EventHandler(HINSTANCE hInstance,wstring windowName,bool topmost,HMENU menu)
00005 {
00006
00007 if(!GlobalInformations::alreadyInitialized())
00008 GlobalInformations::setName(windowName);
00009
00010 HWND myAppHwnd = FindWindow(windowName.c_str(), NULL);
00011 if(myAppHwnd!=NULL){
00012
00013 SetForegroundWindow((HWND)(((ULONG) myAppHwnd) | 0x01));
00014 ShowWindow(myAppHwnd, SW_SHOW);
00015 UpdateWindow(myAppHwnd);
00016 SetFocus(myAppHwnd);
00017
00018
00019 exit(0);
00020 }
00021
00022 this->gInstance=hInstance;
00023 new DirectDrawWarp(this->gInstance,windowName.c_str(),topmost,menu);
00024 Element::setGestEvent(this);
00025
00026
00027
00028 }
00029 DWORD WINAPI EventHandler::launchApp( LPVOID lpParameter ){
00030 return 0;
00031 };
00032
00033
00034 EventHandler::~EventHandler(void)
00035 {
00036
00037 GlobalInformations* gi=GlobalInformations::getInstance();
00038 delete gi->window;
00039 }
00040
00041 void EventHandler::messageProc(void* src,WPARAM type){
00042 PostThreadMessage(NULL,WM_USER,type,(LPARAM)src);
00043 }
00044
00045
00046
00047 void EventHandler::msgExecute(MSG msg){
00048 GlobalInformations* gi=GlobalInformations::getInstance();
00049 switch(msg.message)
00050 {
00051 case WM_QUIT:
00052 return;
00053 case WM_USER:
00054 {
00055 switch (msg.wParam)
00056 {
00057 case 0:
00058 {
00059 gi->isActiv=false;
00060 Element::getGestEvent()->initApplication();
00061 gi->rcUpdateRegion=gi->rs;
00062 gi->rcUpdateRegion.top=gi->rcVisibleDesktopTOP.top;
00063 gi->rcUpdateRegion.bottom=GetSystemMetrics(SM_CYSCREEN);
00064 gi->mustRedraw=true;
00065 gi->window->initWindow();
00066 gi->isActiv=true;
00067 }
00068 break;
00069 case EVENT_CLICK:
00070 case EVENT_VALUE_CHANGED:
00071 case EVENT_RIGHT_CLICK:
00072 Element::getGestEvent()->messageTreatment((Element*)msg.lParam,msg.wParam);
00073 break;
00074 case MESSAGE_REP:
00075 SetEvent(gi->waitForMSG);
00076 break;
00077 default:
00078 Element::getGestEvent()->messageTreatment(NULL,msg.wParam,(void*)msg.lParam);
00079 }
00080 }
00081 break;
00082 default:
00083 TranslateMessage(&msg);
00084 DispatchMessage(&msg);
00085 }
00086 }
00087 void EventHandler::runApp(){
00088
00089 GlobalInformations* gi=GlobalInformations::getInstance();
00090 MSG msg;
00091
00092 bool retour;
00093 while( 1 )
00094 {
00095 if(GetMessage( &msg, NULL, 0, 0)==-1){
00096 LocalisedString::explainFail( L"Main function fail...",L"GetMessage");
00097 break;
00098 }
00099 if (msg.message == WM_QUIT||msg.message==WM_CLOSE)
00100 {
00101 if(gi->cantBeClosed)
00102 PostMessage(gi->m_hWnd,WM_ACTIVATE,(WPARAM)WA_INACTIVE,(LPARAM)NULL);
00103 else
00104 break;
00105 }else{
00106 if(msg.hwnd==NULL)
00107 {
00108 msgExecute(msg);
00109 }else{
00110 if(MyEditControl::input==msg.hwnd)
00111 {
00112 if(msg.message==WM_EXITMENULOOP){
00113 if (MyEditControl::pEditCtrl!=NULL)
00114 MyEditControl::pEditCtrl->showSIP();
00115 }
00116 }
00117 TranslateMessage(&msg);
00118 DispatchMessage(&msg);
00119 }
00120 }
00121 }
00122 DestroyWindow(gi->m_hWnd);
00123
00124 int i=0;
00125 i++;
00126 }
00127
00128 void EventHandler::showWindow(bool isVisible){
00129 GlobalInformations* gi=GlobalInformations::getInstance();
00130 if(isVisible){
00131 SetForegroundWindow((HWND)(((ULONG) gi->m_hWnd) | 0x01));
00132 ShowWindow(gi->m_hWnd, SW_SHOW);
00133 UpdateWindow(gi->m_hWnd);
00134 SetFocus(gi->m_hWnd);
00135 }else{
00136 ShowWindow(gi->m_hWnd, SW_HIDE);
00137 }
00138 }