// Enable or disable the OK button void PromptDialog::OnChange() { SetTimer(TIMER_ID_CHECK_OK, 10, NULL); }
INT_PTR CALLBACK DlgProcUrlSend(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { struct UrlSendData* dat = (struct UrlSendData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); Window_SetIcon_IcoLib(hwndDlg, SKINICON_EVENT_URL); Button_SetIcon_IcoLib(hwndDlg, IDC_ADD, SKINICON_OTHER_ADDCONTACT, LPGEN("Add contact permanently to list")); Button_SetIcon_IcoLib(hwndDlg, IDC_DETAILS, SKINICON_OTHER_USERDETAILS, LPGEN("View user's details")); Button_SetIcon_IcoLib(hwndDlg, IDC_HISTORY, SKINICON_OTHER_HISTORY, LPGEN("View user's history")); Button_SetIcon_IcoLib(hwndDlg, IDC_USERMENU, SKINICON_OTHER_DOWNARROW, LPGEN("User menu")); SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_LIMITTEXT, 450, 0); dat = (struct UrlSendData*)mir_alloc(sizeof(struct UrlSendData)); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat); dat->hContact = (HANDLE)lParam; dat->hAckEvent = NULL; dat->hSendId = NULL; dat->sendBuffer = NULL; WindowList_Add(hUrlWindowList, hwndDlg, dat->hContact); { TCHAR *str = pcli->pfnGetContactDisplayName(dat->hContact, 0); SetDlgItemText(hwndDlg, IDC_NAME, str); } GetOpenBrowserUrls(hwndDlg, GetDlgItem(hwndDlg, IDC_URLS)); SendDlgItemMessage(hwndDlg, IDC_URLS, CB_SETCURSEL, 0, 0); if (SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETCOUNT, 0, 0))SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_URLS, CBN_SELCHANGE), 0); EnableWindow(GetDlgItem(hwndDlg, IDOK), (SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETCURSEL, 0, 0) == CB_ERR)?FALSE:TRUE); Utils_RestoreWindowPositionNoSize(hwndDlg, NULL, "SRUrl", "send"); mir_subclassWindow( GetDlgItem(hwndDlg, IDC_MESSAGE), SendEditSubclassProc); mir_subclassWindow( GetWindow(GetDlgItem(hwndDlg, IDC_URLS), GW_CHILD), SendEditSubclassProc); // From message dlg if ( !db_get_b(dat->hContact, "CList", "NotOnList", 0)) ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), SW_HIDE); SendMessage(hwndDlg, DM_UPDATETITLE, 0, 0); // From message dlg end return TRUE; case WM_DDE_DATA: case WM_DDE_ACK: return DdeMessage(hwndDlg, msg, wParam, lParam); case WM_TIMER: if (wParam == 0) { //ICQ sendurl timed out KillTimer(hwndDlg, 0); MessageBox(hwndDlg, TranslateT("Send timed out"), _T(""), MB_OK); EnableWindow(GetDlgItem(hwndDlg, IDOK), TRUE); EnableWindow(GetDlgItem(hwndDlg, IDC_URLS), TRUE); SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_SETREADONLY, FALSE, 0); } break; case WM_MEASUREITEM: return CallService(MS_CLIST_MENUMEASUREITEM, wParam, lParam); case WM_DRAWITEM: { LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT)lParam; if (dis->hwndItem == GetDlgItem(hwndDlg, IDC_PROTOCOL)) { char *szProto = GetContactProto(dat->hContact); if (szProto) { HICON hIcon = (HICON)CallProtoService(szProto, PS_LOADICON, PLI_PROTOCOL|PLIF_SMALL, 0); if (hIcon) { DrawIconEx(dis->hDC, dis->rcItem.left, dis->rcItem.top, hIcon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, NULL, DI_NORMAL); DestroyIcon(hIcon); } } } } return CallService(MS_CLIST_MENUDRAWITEM, wParam, lParam); case DM_UPDATETITLE: sttUpdateTitle(hwndDlg, dat->hContact); break; case WM_COMMAND: if (CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam), MPCF_CONTACTMENU), (LPARAM)dat->hContact)) break; switch (LOWORD(wParam)) { case IDOK: { char *body, *url; int bodySize, urlSize; urlSize = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_URLS))+1; url = (char*)mir_alloc(urlSize); GetDlgItemTextA(hwndDlg, IDC_URLS, url, urlSize); if (url[0] == 0) { mir_free(url); break; } bodySize = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_MESSAGE))+1; body = (char*)mir_alloc(bodySize); GetDlgItemTextA(hwndDlg, IDC_MESSAGE, body, bodySize); dat->sendBuffer = (char*)mir_realloc(dat->sendBuffer, lstrlenA(url)+lstrlenA(body)+2); lstrcpyA(dat->sendBuffer, url); lstrcpyA(dat->sendBuffer+lstrlenA(url)+1, body); dat->hAckEvent = HookEventMessage(ME_PROTO_ACK, hwndDlg, HM_EVENTSENT); dat->hSendId = (HANDLE)CallContactService(dat->hContact, PSS_URL, 0, (LPARAM)dat->sendBuffer); mir_free(url); mir_free(body); //create a timeout timer SetTimer(hwndDlg, 0, TIMEOUT_URLSEND, NULL); EnableWindow(GetDlgItem(hwndDlg, IDOK), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_URLS), FALSE); SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_SETREADONLY, TRUE, 0); return TRUE; } case IDCANCEL: DestroyWindow(hwndDlg); return TRUE; case IDC_URLS: if (HIWORD(wParam) == CBN_SELCHANGE) { int i, urlSize; char *title; i = SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETCURSEL, 0, 0); title = (char*)SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETITEMDATA, (WPARAM)i, 0); SetDlgItemTextA(hwndDlg, IDC_MESSAGE, title); urlSize = SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETLBTEXTLEN, (WPARAM)i, 0); EnableWindow(GetDlgItem(hwndDlg, IDOK), (urlSize>0)); } else if (HIWORD(wParam) == CBN_EDITCHANGE) { int urlSize = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_URLS)); EnableWindow(GetDlgItem(hwndDlg, IDOK), (urlSize>0)); } break; case IDC_USERMENU: { RECT rc; HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)dat->hContact, 0); GetWindowRect(GetDlgItem(hwndDlg, IDC_USERMENU), &rc); TrackPopupMenu(hMenu, 0, rc.left, rc.bottom, 0, hwndDlg, NULL); DestroyMenu(hMenu); } break; case IDC_HISTORY: CallService(MS_HISTORY_SHOWCONTACTHISTORY, (WPARAM)dat->hContact, 0); break; case IDC_DETAILS: CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)dat->hContact, 0); break; case IDC_ADD: ADDCONTACTSTRUCT acs = {0}; acs.handle = dat->hContact; acs.handleType = HANDLE_CONTACT; acs.szProto = 0; CallService(MS_ADDCONTACT_SHOW, (WPARAM)hwndDlg, (LPARAM)&acs); if ( !db_get_b(dat->hContact, "CList", "NotOnList", 0)) ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), FALSE); } break; case HM_EVENTSENT: { ACKDATA *ack = (ACKDATA*)lParam; if (ack->hProcess != dat->hSendId) break; if (ack->hContact != dat->hContact) break; if (ack->type != ACKTYPE_URL || ack->result != ACKRESULT_SUCCESS) break; DBEVENTINFO dbei = { sizeof(dbei) }; dbei.eventType = EVENTTYPE_URL; dbei.flags = DBEF_SENT; dbei.szModule = GetContactProto(dat->hContact); dbei.timestamp = time(NULL); dbei.cbBlob = (DWORD)(strlen(dat->sendBuffer)+strlen(dat->sendBuffer+strlen(dat->sendBuffer)+1)+2); dbei.pBlob = (PBYTE)dat->sendBuffer; db_event_add(dat->hContact, &dbei); KillTimer(hwndDlg, 0); DestroyWindow(hwndDlg); } break; case WM_DESTROY: Window_FreeIcon_IcoLib(hwndDlg); Button_FreeIcon_IcoLib(hwndDlg, IDC_ADD); Button_FreeIcon_IcoLib(hwndDlg, IDC_DETAILS); Button_FreeIcon_IcoLib(hwndDlg, IDC_HISTORY); Button_FreeIcon_IcoLib(hwndDlg, IDC_USERMENU); WindowList_Remove(hUrlWindowList, hwndDlg); if (dat->hAckEvent) UnhookEvent(dat->hAckEvent); if (dat->sendBuffer != NULL) mir_free(dat->sendBuffer); mir_free(dat); Utils_SaveWindowPosition(hwndDlg, NULL, "SRUrl", "send"); for (int i = SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETCOUNT, 0, 0)-1;i>=0;i--) mir_free((char*)SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETITEMDATA, i, 0)); break; } return FALSE; }
/* Property page dialog callback */ INT_PTR CALLBACK DateTimePageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { SYSTEMTIME st; GetLocalTime(&st); switch (uMsg) { case WM_INITDIALOG: FillMonthsComboBox(GetDlgItem(hwndDlg, IDC_MONTHCB)); SetTimer(hwndDlg, ID_TIMER, 1000, NULL); /* Set range and current year */ SendMessageW(GetDlgItem(hwndDlg, IDC_YEAR), UDM_SETRANGE, 0, MAKELONG ((short) 9999, (short) 1900)); SendMessageW(GetDlgItem(hwndDlg, IDC_YEAR), UDM_SETPOS, 0, MAKELONG( (short) st.wYear, 0)); pOldWndProc = (WNDPROC) SetWindowLongPtrW(GetDlgItem(hwndDlg, IDC_TIMEPICKER), GWL_WNDPROC, (INT_PTR) DTPProc); break; case WM_TIMER: SendMessageW(GetDlgItem(hwndDlg, IDC_TIMEPICKER), DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM) &st); break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_MONTHCB: if (HIWORD(wParam) == CBN_SELCHANGE) { ChangeMonthCalDate(GetDlgItem(hwndDlg, IDC_MONTHCALENDAR), (WORD) -1, GetCBSelectedMonth((HWND)lParam), (WORD) -1); } break; } break; case WM_CTLCOLORSTATIC: if ((HWND)lParam == GetDlgItem(hwndDlg, IDC_YEARTEXT)) return (INT_PTR)GetSysColorBrush(COLOR_WINDOW); break; case WM_NOTIFY: { LPNMHDR lpnm = (LPNMHDR)lParam; switch (lpnm->idFrom) { case IDC_YEAR: switch (lpnm->code) { case UDN_DELTAPOS: { SHORT wYear; LPNMUPDOWN updown = (LPNMUPDOWN)lpnm; wYear = (SHORT)SendMessageW(GetDlgItem(hwndDlg, IDC_YEAR), UDM_GETPOS, 0, 0); /* Enable the 'Apply' button */ PropSheet_Changed(GetParent(hwndDlg), hwndDlg); ChangeMonthCalDate(GetDlgItem(hwndDlg, IDC_MONTHCALENDAR), (WORD) -1, (WORD) -1, (WORD) (wYear + updown->iDelta)); } break; } break; case IDC_TIMEPICKER: switch (lpnm->code) { case DTN_DATETIMECHANGE: /* Stop the timer */ KillTimer(hwndDlg, ID_TIMER); /* Tell the clock to stop ticking */ SendDlgItemMessageW(hwndDlg, IDC_CLOCKWND, CLM_STOPCLOCK, 0, 0); /* Enable the 'Apply' button */ PropSheet_Changed(GetParent(hwndDlg), hwndDlg); break; } break; case IDC_MONTHCALENDAR: switch (lpnm->code) { case MCCN_SELCHANGE: /* Enable the 'Apply' button */ PropSheet_Changed(GetParent(hwndDlg), hwndDlg); break; case MCCN_AUTOUPDATE: AutoUpdateMonthCal(hwndDlg, (PNMMCCAUTOUPDATE)lpnm); break; } break; default: switch (lpnm->code) { case PSN_SETACTIVE: SetTimeZoneName(hwndDlg); break; case PSN_APPLY: SetLocalSystemTime(hwndDlg); SetTimer(hwndDlg, ID_TIMER, 1000, NULL); /* Tell the clock to start ticking */ SendDlgItemMessageW(hwndDlg, IDC_CLOCKWND, CLM_STARTCLOCK, 0, 0); return TRUE; } break; } } break; case WM_TIMECHANGE: /* FIXME: We don't get this message as we're not a top-level window... */ SendMessageW(GetDlgItem(hwndDlg, IDC_MONTHCALENDAR), MCCM_RESET, 0, 0); break; case WM_DESTROY: KillTimer(hwndDlg, ID_TIMER); break; } return FALSE; }
bool Extract(std::list<CString> &ParamList,CConfigManager &ConfigManager,DLL_ID ForceDLL,LPCTSTR lpSpecificOutputDir,const CMDLINEINFO* lpCmdLineInfo) { TRACE(_T("Function ::Extract() started.\n")); CConfigGeneral ConfGeneral; CConfigExtract ConfExtract; ConfGeneral.load(ConfigManager); ConfExtract.load(ConfigManager); //設定上書き if(lpCmdLineInfo){ if(-1!=lpCmdLineInfo->OutputToOverride){ ConfExtract.OutputDirType=lpCmdLineInfo->OutputToOverride; } if(-1!=lpCmdLineInfo->CreateDirOverride){ ConfExtract.CreateDir=lpCmdLineInfo->CreateDirOverride; } if(-1!=lpCmdLineInfo->DeleteAfterProcess){ ConfExtract.DeleteArchiveAfterExtract=lpCmdLineInfo->DeleteAfterProcess; } } //セマフォによる排他処理 CSemaphoreLocker SemaphoreLock; if(ConfExtract.LimitExtractFileCount){ SemaphoreLock.Lock(LHAFORGE_EXTRACT_SEMAPHORE_NAME,ConfExtract.MaxExtractFileCount); } UINT uFiles=ParamList.size(); //引数にあるファイルの数 //プログレスバー CProgressDialog dlg; //メッセージループを回すためのタイマー int timer=NULL; if(uFiles>=2){ //ファイルが複数ある時に限定 dlg.Create(NULL); dlg.SetTotalFileCount(uFiles); dlg.ShowWindow(SW_SHOW); timer=SetTimer(NULL,NULL,1000,UtilMessageLoopTimerProc); } //指定の出力先 CPath pathSpecificOutputDir(lpSpecificOutputDir ? lpSpecificOutputDir : _T("")); std::vector<ARCLOG> LogArray; //処理結果を保持 bool bAllOK=true; //すべて問題なく解凍されればtrue //解凍処理 for(std::list<CString>::iterator ite_param=ParamList.begin();ite_param!=ParamList.end();++ite_param){ //プログレスバーを進める if(dlg.IsWindow())dlg.SetNextState(*ite_param); ARCLOG arcLog; //メッセージループ while(UtilDoMessageLoop())continue; //アーカイバハンドラ取得 //ここでUNICODE非対応DLLにユニコードファイル名を渡そうとした場合は弾かれる。そして、ここでは失敗の原因を解明できない CArchiverDLL *lpArchiver=CArchiverDLLManager::GetInstance().GetArchiver(*ite_param,ConfExtract.DenyExt,ForceDLL); if(!lpArchiver){ //対応するハンドラがなかった arcLog.Result=EXTRACT_NOTARCHIVE; arcLog.strMsg.Format(IDS_ERROR_ILLEGAL_HANDLER,(LPCTSTR)*ite_param); arcLog.strFile=*ite_param; bAllOK=false; LogArray.push_back(arcLog); continue; } CPath pathOpenDir; //ファイラが開くべきフォルダ //解凍実行 bool bRet=ExtractOneArchive(ConfigManager,ConfGeneral,ConfExtract,lpArchiver,*ite_param,pathSpecificOutputDir,arcLog,pathOpenDir); //ログ保存 LogArray.push_back(arcLog); if(!bRet){ bAllOK=false; }else{ //出力先フォルダを開く if(ConfExtract.OpenDir){ if(ConfGeneral.Filer.UseFiler){ //パラメータ展開に必要な情報 std::map<stdString,CString> envInfo; MakeExpandInformationEx(envInfo,pathOpenDir,NULL); //コマンド・パラメータ展開 CString strCmd,strParam; UtilExpandTemplateString(strCmd,ConfGeneral.Filer.FilerPath,envInfo); //コマンド UtilExpandTemplateString(strParam,ConfGeneral.Filer.Param,envInfo); //パラメータ ShellExecute(NULL, _T("open"), strCmd,strParam, NULL, SW_SHOWNORMAL); }else{ //Explorerで開く UtilNavigateDirectory(pathOpenDir); } } //正常に解凍できた圧縮ファイルを削除orごみ箱に移動 if(bRet && ConfExtract.DeleteArchiveAfterExtract){ if(!ConfExtract.ForceDelete && lpArchiver->IsWeakErrorCheck()){ //エラーチェック機構が貧弱なため、解凍失敗時にも正常と判断してしまうような //DLLを使ったときには明示的に指定しない限り削除させない MessageBox(NULL,CString(MAKEINTRESOURCE(IDS_MESSAGE_EXTRACT_DELETE_SKIPPED)),UtilGetMessageCaption(),MB_OK|MB_ICONINFORMATION); }else{ //削除 DeleteOriginalArchives(ConfExtract,*ite_param); } } } } //プログレスバーを閉じる if(dlg.IsWindow())dlg.DestroyWindow(); //タイマーを閉じる if(timer)KillTimer(NULL,timer); //---ログ表示 switch(ConfGeneral.LogViewEvent){ case LOGVIEW_ON_ERROR: if(!bAllOK){ if(1==uFiles){ //ファイル一つだけの時はダイアログボックスで if(EXTRACT_CANCELED!=LogArray[0].Result){ ErrorMessage(LogArray[0].strMsg); } }else{ //ログに表示 CLogListDialog LogDlg(CString(MAKEINTRESOURCE(IDS_LOGINFO_OPERATION_EXTRACT))); LogDlg.SetLogArray(LogArray); LogDlg.DoModal(::GetDesktopWindow()); } } break; case LOGVIEW_ALWAYS: //ログに表示 CLogListDialog LogDlg(CString(MAKEINTRESOURCE(IDS_LOGINFO_OPERATION_EXTRACT))); LogDlg.SetLogArray(LogArray); LogDlg.DoModal(::GetDesktopWindow()); break; } TRACE(_T("Exit Extract()\n")); return bAllOK; }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- BOOL CTextureBrowser::OnInitDialog() { CDialog::OnInitDialog(); m_cSizeList.SubclassDlgItem(IDC_TEXTURESIZE, this); m_cFilter.SubclassDlgItem(IDC_FILTER, this); m_cKeywords.SubclassDlgItem(IDC_KEYWORDS, this); m_cCurName.SubclassDlgItem(IDC_CURNAME, this); m_cCurDescription.SubclassDlgItem(IDC_CURDESCRIPTION, this); m_cUsed.SubclassDlgItem(IDC_USED, this); m_FilterOpaque.SubclassDlgItem(IDC_FILTER_OPAQUE, this); m_FilterTranslucent.SubclassDlgItem(IDC_FILTER_TRANSLUCENT, this); m_FilterSelfIllum.SubclassDlgItem(IDC_FILTER_SELFILLUM, this); m_FilterEnvMask.SubclassDlgItem(IDC_FILTER_ENVMASK, this); m_ShowErrors.SubclassDlgItem(IDC_SHOW_ERROR, this); m_FilterOpaque.SetCheck( true ); m_FilterTranslucent.SetCheck( true ); m_FilterSelfIllum.SetCheck( true ); m_FilterEnvMask.SetCheck( true ); m_ShowErrors.SetCheck( true ); // // Create CTextureWindow that takes up area of dummy control. // RECT r; GetDlgItem(IDC_BROWSERDUMMY)->GetClientRect(&r); m_cTextureWindow.Create(this, r); // Show everything initially m_cTextureWindow.SetTypeFilter( ~0, true ); // // Add latest history to the filter combo. // for (int i = 0; i < m_nFilterHistory; i++) { m_cFilter.AddString(m_FilterHistory[i]); } // // Set the name filter unless one was explicitly specified. // if (m_szNameFilter[0] == '\0') { // // No name filter specified. Use whatever is on top of the history. // if (m_cFilter.GetCount() > 0) { m_cFilter.GetLBText(0, m_szNameFilter); m_cFilter.SetCurSel(0); } } m_cFilter.SetWindowText(m_szNameFilter); m_cTextureWindow.SetNameFilter(m_szNameFilter); // // Done with the name filter; clear it for next time. // m_szNameFilter[0] = '\0'; // // Add the global list of keywords to the keywords combo. // POSITION pos = g_Textures.KeywordsGetHeadPosition(); while (pos != NULL) { char *pszKeyword = g_Textures.KeywordsGetNext(pos); m_cKeywords.AddString(pszKeyword); } // // Set the keyword filter. // m_cKeywords.SetWindowText(m_szLastKeywords); m_cTextureWindow.SetKeywords(m_szLastKeywords); m_cUsed.SetCheck(m_bUsed); CWinApp *pApp = AfxGetApp(); CString str = pApp->GetProfileString(pszIniSection, "Position"); if (!str.IsEmpty()) { CRect r; sscanf(str, "%d %d %d %d", &r.left, &r.top, &r.right, &r.bottom); if (r.left < 0) { ShowWindow(SW_SHOWMAXIMIZED); } else { MoveWindow(r.left, r.top, r.right-r.left, r.bottom-r.top, FALSE); } } int iSize = pApp->GetProfileInt(pszIniSection, "ShowSize", 0); m_cSizeList.SetCurSel(iSize); OnSelendokTexturesize(); if (szInitialTexture[0]) { m_cTextureWindow.SelectTexture(szInitialTexture); } m_cTextureWindow.ShowWindow(SW_SHOW); SetTimer(1, 500, NULL); m_cFilter.SetFocus(); return(FALSE); }
LRESULT CALLBACK DisplayProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_ACTIVATE: break; case WM_SETFOCUS: break; case WM_SIZE: break; case WM_ERASEBKGND: return DefWindowProc(hWnd, message, wParam, lParam); // Poor man's touch - mouse input. We send the data both as an input_state pointer, // and as asynchronous touch events for minimal latency. case WM_LBUTTONDOWN: // Hack: Take the opportunity to show the cursor. mouseButtonDown = true; { lock_guard guard(input_state.lock); input_state.mouse_valid = true; input_state.pointer_down[0] = true; int factor = g_Config.iWindowZoom == 1 ? 2 : 1; input_state.pointer_x[0] = GET_X_LPARAM(lParam) * factor; input_state.pointer_y[0] = GET_Y_LPARAM(lParam) * factor; TouchInput touch; touch.id = 0; touch.flags = TOUCH_DOWN; touch.x = GET_X_LPARAM(lParam); touch.y = GET_Y_LPARAM(lParam); NativeTouch(touch); } break; case WM_MOUSEMOVE: { // Hack: Take the opportunity to show the cursor. mouseButtonDown = (wParam & MK_LBUTTON) != 0; int cursorX = GET_X_LPARAM(lParam); int cursorY = GET_Y_LPARAM(lParam); if (abs(cursorX - prevCursorX) > 1 || abs(cursorY - prevCursorY) > 1) { hideCursor = false; SetTimer(hwndMain, TIMER_CURSORMOVEUPDATE, CURSORUPDATE_MOVE_TIMESPAN_MS, 0); } prevCursorX = cursorX; prevCursorY = cursorY; lock_guard guard(input_state.lock); int factor = g_Config.iWindowZoom == 1 ? 2 : 1; input_state.pointer_x[0] = GET_X_LPARAM(lParam) * factor; input_state.pointer_y[0] = GET_Y_LPARAM(lParam) * factor; if (wParam & MK_LBUTTON) { TouchInput touch; touch.id = 0; touch.flags = TOUCH_MOVE; touch.x = GET_X_LPARAM(lParam); touch.y = GET_Y_LPARAM(lParam); NativeTouch(touch); } } break; case WM_LBUTTONUP: // Hack: Take the opportunity to hide the cursor. mouseButtonDown = false; { lock_guard guard(input_state.lock); input_state.pointer_down[0] = false; int factor = g_Config.iWindowZoom == 1 ? 2 : 1; input_state.pointer_x[0] = GET_X_LPARAM(lParam) * factor; input_state.pointer_y[0] = GET_Y_LPARAM(lParam) * factor; TouchInput touch; touch.id = 0; touch.flags = TOUCH_UP; touch.x = GET_X_LPARAM(lParam); touch.y = GET_Y_LPARAM(lParam); NativeTouch(touch); } break; // Actual touch! Unfinished case WM_TOUCH: { // TODO: Enabling this section will probably break things on Windows XP. // We probably need to manually fetch pointers to GetTouchInputInfo and CloseTouchInputHandle. #if ENABLE_TOUCH UINT inputCount = LOWORD(wParam); TOUCHINPUT *inputs = new TOUCHINPUT[inputCount]; if (GetTouchInputInfo((HTOUCHINPUT)lParam, inputCount, inputs, sizeof(TOUCHINPUT))) { for (int i = 0; i < inputCount; i++) { // TODO: process inputs here! } if (!CloseTouchInputHandle((HTOUCHINPUT)lParam)) { // error handling } } else { // GetLastError() and error handling } delete [] inputs; return DefWindowProc(hWnd, message, wParam, lParam); #endif } case WM_PAINT: return DefWindowProc(hWnd, message, wParam, lParam); default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }
LRESULT CALLBACK SplashWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_LOADED: #ifdef _DEBUG logMessage(_T("WM_LOADED"), _T("called")); #endif if (!options.showtime) SetTimer(hwnd, 7, 2000, 0); break; case WM_LBUTTONDOWN: PostMessage(hwnd, WM_CLOSE, 0, 0); break; case WM_TIMER: #ifdef _DEBUG TCHAR b[40]; mir_sntprintf(b, _T("%d"), wParam); logMessage(_T("Timer ID"), b); mir_sntprintf(b, _T("%d"), options.showtime); logMessage(_T("ShowTime value"), b); #endif if (options.showtime > 0) { // TimeToShow enabled if (wParam == 6) { PostMessage(hwnd, WM_CLOSE, 0, 0); #ifdef _DEBUG logMessage(_T("Showtime timer"), _T("triggered")); #endif } } else { PostMessage(hwnd, WM_CLOSE, 0, 0); if (wParam == 7) { #ifdef _DEBUG logMessage(_T("On Modules Loaded timer"), _T("triggered")); #endif } } break; case WM_RBUTTONDOWN: ShowWindow(hwndSplash, SW_HIDE); DestroyWindow(hwndSplash); bpreviewruns = false; // preview is stopped. break; case WM_CLOSE: { RECT rc; GetWindowRect(hwndSplash, &rc); POINT ptDst = { rc.left, rc.top }; POINT ptSrc = { 0, 0 }; SIZE sz = { rc.right - rc.left, rc.bottom - rc.top }; BLENDFUNCTION blend; blend.BlendOp = AC_SRC_OVER; blend.BlendFlags = 0; blend.SourceConstantAlpha = 255; blend.AlphaFormat = AC_SRC_ALPHA; // Fade Out if (options.fadeout) { int i; for (i = 255; i >= 0; i -= options.fosteps) { blend.SourceConstantAlpha = i; UpdateLayeredWindow(hwndSplash, NULL, &ptDst, &sz, SplashBmp->getDC(), &ptSrc, 0xffffffff, &blend, LWA_ALPHA); Sleep(1); } } } if (bserviceinvoked) bserviceinvoked = false; if (bpreviewruns) bpreviewruns = false; DestroyWindow(hwndSplash); break; case WM_MOUSEMOVE: if (bserviceinvoked) PostMessage(hwnd, WM_CLOSE, 0, 0); break; case WM_DESTROY: #ifdef _DEBUG logMessage(_T("WM_DESTROY"), _T("called")); #endif ShowWindow(hwndSplash, SW_HIDE); DestroyWindow(hwndSplash); PostQuitMessage(0); break; } return DefWindowProc(hwnd, message, wParam, lParam); }
int CGLWindow::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CWnd::OnCreate(lpCreateStruct) == -1) return -1; // Get the device context m_hDC = ::GetDC(this->m_hWnd); // Set the Pixel Format SetPixelFormat(m_hDC, m_nPixelFormat, NULL); // Create the rendering context and make it current m_hRC = wglCreateContext(m_hDC); if(m_hRC != NULL) wglMakeCurrent(m_hDC, m_hRC); // Setup the context if(m_hRC != NULL) { glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glGenTextures(6, m_Sides); glEnable(GL_TEXTURE_2D); glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); glFrontFace(GL_CCW); BYTE *pBytes; int nWidth, nHeight; glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE, GL_REPLACE); // Load the texture objects pBytes = gltResourceBMPBits(IDB_BITMAP1, &nWidth, &nHeight); glBindTexture(GL_TEXTURE_2D, m_Sides[0]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexImage2D(GL_TEXTURE_2D,0,GL_RGB8,nWidth, nHeight, 0, GL_BGR_EXT, GL_UNSIGNED_BYTE, pBytes); pBytes = gltResourceBMPBits(IDB_BITMAP2, &nWidth, &nHeight); glBindTexture(GL_TEXTURE_2D, m_Sides[1]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexImage2D(GL_TEXTURE_2D,0,GL_RGB8,nWidth, nHeight, 0, GL_BGR_EXT, GL_UNSIGNED_BYTE, pBytes); pBytes = gltResourceBMPBits(IDB_BITMAP3, &nWidth, &nHeight); glBindTexture(GL_TEXTURE_2D, m_Sides[2]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexImage2D(GL_TEXTURE_2D,0,GL_RGB8,nWidth, nHeight, 0, GL_BGR_EXT, GL_UNSIGNED_BYTE, pBytes); pBytes = gltResourceBMPBits(IDB_BITMAP4, &nWidth, &nHeight); glBindTexture(GL_TEXTURE_2D, m_Sides[3]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexImage2D(GL_TEXTURE_2D,0,GL_RGB8,nWidth, nHeight, 0, GL_BGR_EXT, GL_UNSIGNED_BYTE, pBytes); pBytes = gltResourceBMPBits(IDB_BITMAP5, &nWidth, &nHeight); glBindTexture(GL_TEXTURE_2D, m_Sides[4]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexImage2D(GL_TEXTURE_2D,0,GL_RGB8,nWidth, nHeight, 0, GL_BGR_EXT, GL_UNSIGNED_BYTE, pBytes); pBytes = gltResourceBMPBits(IDB_BITMAP6, &nWidth, &nHeight); glBindTexture(GL_TEXTURE_2D, m_Sides[5]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexImage2D(GL_TEXTURE_2D,0,GL_RGB8,nWidth, nHeight, 0, GL_BGR_EXT, GL_UNSIGNED_BYTE, pBytes); } SetTimer(101, 30, NULL); return 0; }
//游戏场景 bool CGameClientDlg::OnGameSceneMessage(BYTE cbGameStation, bool bLookonOther, const void * pBuffer, WORD wDataSize) { if(IsLookonMode())m_GameClientView.m_bLookOnUser=true; switch (cbGameStation) { case GS_FREE: //空闲状态 { //效验数据 if (wDataSize!=sizeof(CMD_S_StatusFree)) return false; CMD_S_StatusFree * pStatusFree=(CMD_S_StatusFree *)pBuffer; //设置控件 if (IsLookonMode()==false) { SetGameTimer(GetMeChairID(),IDI_START_GAME,TIME_USER_START_GAME); m_GameClientView.m_btStart.ShowWindow(SW_SHOW); m_GameClientView.m_btStart.SetFocus(); } return true; } case GS_TK_CALL: // 叫庄状态 { //效验数据 if (wDataSize!=sizeof(CMD_S_StatusCall)) return false; CMD_S_StatusCall * pStatusCall=(CMD_S_StatusCall *)pBuffer; //用户信息 for (WORD i=0;i<GAME_PLAYER;i++) { //视图位置 m_wViewChairID[i]=SwitchViewChairID(i); //获取用户 const tagUserData * pUserData=GetUserData(i); if (pUserData==NULL) continue; //游戏信息 m_cbPlayStatus[i]=TRUE; //用户名字 lstrcpyn(m_szAccounts[i],pUserData->szName,CountArray(m_szAccounts[i])); } //始叫用户 if(!IsLookonMode() && pStatusCall->wCallBanker==GetMeChairID()) { //控件显示 //ActiveGameFrame(); m_GameClientView.m_btBanker.ShowWindow(SW_SHOW); m_GameClientView.m_btIdler.ShowWindow(SW_SHOW); } //等待标志 WORD wViewID=m_wViewChairID[pStatusCall->wCallBanker]; m_GameClientView.SetWaitCall((BYTE)wViewID); //实际定时器 if(pStatusCall->wCallBanker==GetMeChairID()) { SetGameTimer(pStatusCall->wCallBanker,IDI_CALL_BANKER,TIME_USER_CALL_BANKER); } else SetGameTimer(pStatusCall->wCallBanker,IDI_NULLITY,TIME_USER_CALL_BANKER); return true; } case GS_TK_SCORE: //下注状态 { //效验数据 if (wDataSize!=sizeof(CMD_S_StatusScore)) return false; CMD_S_StatusScore * pStatusScore=(CMD_S_StatusScore *)pBuffer; //设置变量 m_lTurnMaxScore=pStatusScore->lTurnMaxScore; m_wBankerUser=pStatusScore->wBankerUser; CopyMemory(m_lTableScore,pStatusScore->lTableScore,sizeof(m_lTableScore)); for (WORD i=0;i<GAME_PLAYER;i++) { //视图位置 m_wViewChairID[i]=SwitchViewChairID(i); //桌面筹码 if(m_lTableScore[i]>0L)m_GameClientView.SetUserTableScore(m_wViewChairID[i],m_lTableScore[i]); //获取用户 const tagUserData * pUserData=GetUserData(i); if (pUserData==NULL) continue; //游戏信息 m_cbPlayStatus[i]=TRUE; //用户名字 lstrcpyn(m_szAccounts[i],pUserData->szName,CountArray(m_szAccounts[i])); } //设置筹码 if (!IsLookonMode() && pStatusScore->lTurnMaxScore>0L && m_lTableScore[GetMeChairID()]==0L) { LONGLONG lUserMaxScore[GAME_PLAYER]; ZeroMemory(lUserMaxScore,sizeof(lUserMaxScore)); LONGLONG lTemp=m_lTurnMaxScore; for (WORD i=0;i<GAME_PLAYER;i++) { if(i>0)lTemp/=2; lUserMaxScore[i]=__max(lTemp,1L); } //更新控件 UpdateScoreControl(lUserMaxScore,SW_SHOW); //实际定时器 SetTimer(IDI_TIME_USER_ADD_SCORE,(TIME_USER_ADD_SCORE)*1000,NULL); } //庄家标志 WORD wID=m_wViewChairID[m_wBankerUser]; m_GameClientView.SetBankerUser(wID); //等待标志 m_GameClientView.SetWaitInvest(true); //辅助显示中心时钟 SetGameTimer(GetMeChairID(),IDI_NULLITY,TIME_USER_ADD_SCORE); return true; } case GS_TK_PLAYING: //游戏状态 { //效验数据 if (wDataSize!=sizeof(CMD_S_StatusPlay)) return false; CMD_S_StatusPlay * pStatusPlay=(CMD_S_StatusPlay *)pBuffer; //设置变量 m_lTurnMaxScore=pStatusPlay->lTurnMaxScore; m_wBankerUser=pStatusPlay->wBankerUser; CopyMemory(m_lTableScore,pStatusPlay->lTableScore,sizeof(m_lTableScore)); CopyMemory(m_bUserOxCard,pStatusPlay->bOxCard,sizeof(m_bUserOxCard)); for (WORD i=0;i<GAME_PLAYER;i++) { //视图位置 m_wViewChairID[i]=SwitchViewChairID(i); //桌面筹码 if(m_lTableScore[i]>0L)m_GameClientView.SetUserTableScore(m_wViewChairID[i],m_lTableScore[i]); //获取用户 const tagUserData * pUserData=GetUserData(i); if (pUserData==NULL) continue; //游戏信息 m_cbPlayStatus[i]=TRUE; //扑克数据 CopyMemory(m_cbHandCardData[i],pStatusPlay->cbHandCardData[i],MAX_COUNT); //用户名字 lstrcpyn(m_szAccounts[i],pUserData->szName,CountArray(m_szAccounts[i])); } //庄家标志 WORD wID=m_wViewChairID[m_wBankerUser]; m_GameClientView.SetBankerUser(wID); //左上信息 //m_GameClientView.SetScoreInfo(m_lTurnMaxScore,0); //设置界面 LONGLONG lTableScore=0L; for (WORD i=0;i<GAME_PLAYER;i++) { //设置位置 WORD wViewChairID=m_wViewChairID[i]; //设置扑克 if (m_cbPlayStatus[i]==TRUE) { m_GameClientView.m_CardControl[wViewChairID].SetCardData(pStatusPlay->cbHandCardData[i],MAX_COUNT); } } WORD wMeChiarID=GetMeChairID(); WORD wViewChairID=m_wViewChairID[wMeChiarID]; if(!IsLookonMode())m_GameClientView.m_CardControl[wViewChairID].SetPositively(true); if(IsAllowLookon() || !IsLookonMode()) { m_GameClientView.m_CardControl[wViewChairID].SetDisplayFlag(true); } //摊牌标志 for (WORD i=0;i<GAME_PLAYER;i++) { if(m_bUserOxCard[i]!=0xff) { m_GameClientView.ShowOpenCard(m_wViewChairID[i]); } } //控件处理 if(!IsLookonMode()) { //显示控件 if(m_bUserOxCard[wMeChiarID]==0xff) { OnSendCardFinish(0,0); } else { m_GameClientView.m_CardControl[wViewChairID].SetPositively(false); if(m_bUserOxCard[wMeChiarID]==TRUE)//牛牌分类 { //设置变量 BYTE bTemp[MAX_COUNT]; CopyMemory(bTemp,m_cbHandCardData[wMeChiarID],sizeof(bTemp)); //获取牛牌 m_GameLogic.GetOxCard(bTemp,MAX_COUNT); BYTE bCardValue=m_GameLogic.GetCardType(bTemp,MAX_COUNT); ASSERT(bCardValue>0); if(bCardValue<OX_THREE_SAME) { //设置控件 m_GameClientView.m_CardControl[wViewChairID].SetCardData(bTemp,3); m_GameClientView.m_CardControlOx[wViewChairID].SetCardData(&bTemp[3],2); } //显示点数 m_GameClientView.SetUserOxValue(wViewChairID,bCardValue); } else { //无牛 m_GameClientView.SetUserOxValue(wViewChairID,0); } } } return true; } } return false; }
void StartTimedRedraw(UINT millis) { SetTimer(g_hWnd, REFRESH_TIMER, millis, NULL); }
static INT_PTR CALLBACK FtMgrDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { struct TFtMgrData *dat = (struct TFtMgrData *)GetWindowLongPtr(hwnd, GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: { TCITEM tci = {0}; HWND hwndTab = GetDlgItem(hwnd, IDC_TABS); TranslateDialogDefault(hwnd); Window_SetIcon_IcoLib(hwnd, SKINICON_EVENT_FILE); dat = (struct TFtMgrData *)mir_calloc(sizeof(struct TFtMgrData)); SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)dat); dat->hhkPreshutdown = HookEventMessage(ME_SYSTEM_PRESHUTDOWN, hwnd, M_PRESHUTDOWN); dat->hwndIncoming = CreateDialog(hMirandaInst, MAKEINTRESOURCE(IDD_FTPAGE), hwnd, FtMgrPageDlgProc); dat->hwndOutgoing = CreateDialog(hMirandaInst, MAKEINTRESOURCE(IDD_FTPAGE), hwnd, FtMgrPageDlgProc); ShowWindow(dat->hwndIncoming, SW_SHOW); tci.mask = TCIF_PARAM|TCIF_TEXT; tci.pszText = TranslateT("Incoming"); tci.lParam = (LPARAM)dat->hwndIncoming; TabCtrl_InsertItem(hwndTab, 0, &tci); tci.pszText = TranslateT("Outgoing"); tci.lParam = (LPARAM)dat->hwndOutgoing; TabCtrl_InsertItem(hwndTab, 1, &tci); // Utils_RestoreWindowPosition(hwnd, NULL, "SRFile", "FtMgrDlg_"); SAVEWINDOWPOS swp; swp.hwnd=hwnd; swp.hContact=NULL; swp.szModule="SRFile"; swp.szNamePrefix="FtMgrDlg_"; CallService(MS_UTILS_RESTOREWINDOWPOSITION, RWPF_NOACTIVATE, (LPARAM)&swp); // Fall through to setup initial placement } case WM_SIZE: { RECT rc, rcButton; HDWP hdwp; HWND hwndTab = GetDlgItem(hwnd, IDC_TABS); GetWindowRect(GetDlgItem(hwnd, IDCANCEL), &rcButton); OffsetRect(&rcButton, -rcButton.left, -rcButton.top); GetClientRect(hwnd, &rc); InflateRect(&rc, -6, -6); hdwp = BeginDeferWindowPos(3); hdwp = DeferWindowPos(hdwp, GetDlgItem(hwnd, IDC_CLEAR), NULL, rc.left, rc.bottom-rcButton.bottom, 0, 0, SWP_NOZORDER|SWP_NOSIZE); hdwp = DeferWindowPos(hdwp, GetDlgItem(hwnd, IDCANCEL), NULL, rc.right-rcButton.right, rc.bottom-rcButton.bottom, 0, 0, SWP_NOZORDER|SWP_NOSIZE); rc.bottom -= rcButton.bottom + 5; hdwp = DeferWindowPos(hdwp, hwndTab, NULL, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, SWP_NOZORDER); EndDeferWindowPos(hdwp); GetWindowRect(hwndTab, &rc); MapWindowPoints(NULL, hwnd, (LPPOINT)&rc, 2); TabCtrl_AdjustRect(hwndTab, FALSE, &rc); InflateRect(&rc, -5, -5); hdwp = BeginDeferWindowPos(2); hdwp = DeferWindowPos(hdwp, dat->hwndIncoming, HWND_TOP, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, 0); hdwp = DeferWindowPos(hdwp, dat->hwndOutgoing, HWND_TOP, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, 0); EndDeferWindowPos(hdwp); break; } case WM_MOUSEWHEEL: { if (IsWindowVisible(dat->hwndIncoming)) SendMessage(dat->hwndIncoming, msg, wParam, lParam); if (IsWindowVisible(dat->hwndOutgoing)) SendMessage(dat->hwndOutgoing, msg, wParam, lParam); break; } case WM_FT_SELECTPAGE: { TCITEM tci = {0}; HWND hwndTab = GetDlgItem(hwnd, IDC_TABS); if (TabCtrl_GetCurSel(hwndTab) == (int)wParam) break; tci.mask = TCIF_PARAM; TabCtrl_GetItem(hwndTab, TabCtrl_GetCurSel(hwndTab), &tci); ShowWindow((HWND)tci.lParam, SW_HIDE); TabCtrl_SetCurSel(hwndTab, wParam); TabCtrl_GetItem(hwndTab, TabCtrl_GetCurSel(hwndTab), &tci); ShowWindow((HWND)tci.lParam, SW_SHOW); break; } case WM_GETMINMAXINFO: { LPMINMAXINFO lpmmi = (LPMINMAXINFO)lParam; lpmmi->ptMinTrackSize.x = 300; lpmmi->ptMinTrackSize.y = 400; return 0; } case WM_COMMAND: switch (LOWORD(wParam)) { case IDCANCEL: PostMessage(hwnd, WM_CLOSE , 0, 0); break; case IDC_CLEAR: PostMessage(dat->hwndIncoming, WM_FT_CLEANUP, 0, 0); PostMessage(dat->hwndOutgoing, WM_FT_CLEANUP, 0, 0); break; } break; case WM_NOTIFY: { switch (((LPNMHDR)lParam)->idFrom) { case IDC_TABS: { HWND hwndTab = GetDlgItem(hwnd, IDC_TABS); switch (((LPNMHDR)lParam)->code) { case TCN_SELCHANGING: { TCITEM tci = {0}; tci.mask = TCIF_PARAM; TabCtrl_GetItem(hwndTab, TabCtrl_GetCurSel(hwndTab), &tci); ShowWindow((HWND)tci.lParam, SW_HIDE); break; } case TCN_SELCHANGE: { TCITEM tci = {0}; tci.mask = TCIF_PARAM; TabCtrl_GetItem(hwndTab, TabCtrl_GetCurSel(hwndTab), &tci); ShowWindow((HWND)tci.lParam, SW_SHOW); break; } } break; } } break; } case M_PRESHUTDOWN: SendMessage(dat->hwndIncoming, M_PRESHUTDOWN, 0, 0); SendMessage(dat->hwndOutgoing, M_PRESHUTDOWN, 0, 0); DestroyWindow(hwnd); break; case WM_CLOSE: ShowWindow(hwnd, SW_HIDE); if (DBGetContactSettingByte(NULL, "SRFile", "AutoClear", 1)) { PostMessage(dat->hwndIncoming, WM_FT_CLEANUP, 0, 0); PostMessage(dat->hwndOutgoing, WM_FT_CLEANUP, 0, 0); } return TRUE; /* Disable default IDCANCEL notification */ case WM_DESTROY: UnhookEvent(dat->hhkPreshutdown); Window_FreeIcon_IcoLib(hwnd); DestroyWindow(dat->hwndIncoming); DestroyWindow(dat->hwndOutgoing); mir_free(dat); SetWindowLongPtr(hwnd, GWLP_USERDATA, 0); Utils_SaveWindowPosition(hwnd, NULL, "SRFile", "FtMgrDlg_"); break; case WM_ACTIVATE: { dat->errorState = TBPF_NOPROGRESS; wParam = 1; } break; case WM_SHOWWINDOW: { if (!wParam) // hiding { KillTimer(hwnd, 1); break; } lParam = 0; } case WM_TIMER: { if (pTaskbarInterface) { SetTimer(hwnd, 1, 400, NULL); if ((lParam == ACKRESULT_FAILED) || (lParam == ACKRESULT_DENIED)) dat->errorState = TBPF_ERROR; TFtProgressData prg = {0}; SendMessage(dat->hwndIncoming, M_CALCPROGRESS, (WPARAM)&prg, 0); SendMessage(dat->hwndOutgoing, M_CALCPROGRESS, (WPARAM)&prg, 0); if (dat->errorState) { pTaskbarInterface->SetProgressState(hwnd, dat->errorState); if (!prg.run) pTaskbarInterface->SetProgressValue(hwnd, 1, 1); } else if (prg.run) { pTaskbarInterface->SetProgressState(hwnd, TBPF_NORMAL); } else if (prg.init || prg.scan) { pTaskbarInterface->SetProgressState(hwnd, TBPF_INDETERMINATE); } else { pTaskbarInterface->SetProgressState(hwnd, TBPF_NOPROGRESS); KillTimer(hwnd, 1); } if (prg.run) { pTaskbarInterface->SetProgressValue(hwnd, prg.totalProgress, prg.totalBytes); } } } break; } return FALSE; }
void CMainFrame::StartTimer() { // Start timer that checks for continued existence of attached HWND SetTimer(HWND_CHECK_TIMER, 200, 0); }
LRESULT CALLBACK SplashWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { UINT_PTR iRes = 0; // for SetTimer ret val switch (message) { case WM_CREATE: TRACE( _T("SplashWndProc> WM_CREATE\n") ); iRes = SetTimer( hWnd, 1, g_dwSplashScreenTimeToLive, NULL ); // InvalidateRect( hWnd, NULL, FALSE ); // OnSplashWndPaint(hWnd); CenterWindow( hWnd ); MakeWindowTransparent( hWnd, transparentFactor, crTransparent ); SetCursor( LoadCursor( NULL, MAKEINTRESOURCE(IDC_ARROW) ) ); break; case WM_PAINT: // TRACE( _T("SplashWndProc> WM_PAINT\n") ); OnSplashWndPaint(hWnd); break; case WM_LBUTTONUP: if( g_bDragSplash ) { g_bDragSplash = FALSE; ReleaseCapture(); } break; case WM_MOUSEMOVE: if( g_bDragSplash ) { POINT p1 = g_ptMouseDragBegin; RECT r = g_rWindowDragBegin; POINT p2; GetCursorPos( &p2 ); int dx = p2.x - p1.x; int dy = p2.y - p1.y; MoveWindow( hWnd, r.left + dx, r.top + dy, r.right - r.left, r.bottom - r.top, TRUE ); } break; case WM_LBUTTONDOWN: #ifdef EXIT_ON_MOUSE_CLICK ::DestroyWindow(hWnd); #else SetCapture(hWnd); GetCursorPos( &g_ptMouseDragBegin ); GetWindowRect( hWnd, &g_rWindowDragBegin ); g_bDragSplash = TRUE; // Set flag to check for key down in mouse move // message. #endif break; case WM_MBUTTONDOWN: case WM_RBUTTONDOWN: // TRACE( _T("SplashWndProc> Mouse click\n") ); #ifdef EXIT_ON_MOUSE_CLICK ::DestroyWindow(hWnd); #else #ifdef TOGGLE_SPLASH g_bStopSplashOnTimer = !g_bStopSplashOnTimer; #endif #endif break; case WM_KEYDOWN: // TRACE( _T("SplashWndProc> WM_KEYDOWN: VK = %X\n"), wParam ); if( wParam == VK_ESCAPE ) { ::DestroyWindow(hWnd); } else { #ifdef EXIT_ON_KBD_HIT ::DestroyWindow(hWnd); #else #ifdef TOGGLE_SPLASH g_bStopSplashOnTimer = !g_bStopSplashOnTimer; #endif #endif } //return DefWindowProc(hWnd, message, wParam, lParam); break; case WM_TIMER: TRACE( _T("SplashWndProc> WM_TIMER\n") ); if( g_bStopSplashOnTimer ) { ::DestroyWindow(hWnd); } break; case WM_DESTROY: TRACE( _T("SplashWndProc> WM_DESTROY\n") ); #ifdef EXIT_AFTER_SPLASH PostQuitMessage( 0 ); #endif break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }
void CControlBar::FilterToolTipMsg(UINT message, CPoint point) { EnterCriticalSection(_afxCriticalSection); if (message == WM_LBUTTONDOWN || message == WM_LBUTTONUP || message == WM_NCLBUTTONDOWN || message == WM_NCLBUTTONUP || (message >= WM_KEYFIRST && message <= WM_KEYLAST) || (message >= WM_SYSKEYFIRST && message <= WM_SYSKEYLAST)) { // clicking or typing causes the tooltip to go away DestroyToolTip(TRUE, TRUE); ScreenToClient(&point); m_nHitLast = OnCmdHitTest(point, NULL); m_pBarLast = (m_nHitLast == (UINT)-1 ? NULL : this); // set a timer to detect moving out of the window and don't // bother with a long timer before showing next tip ClientToScreen(&point); int nHitType = HitTestToolTip(point, NULL); if (nHitType >= -1 || nHitType == HITTYPE_DISABLED || nHitType == HITTYPE_TRACKING) { VERIFY(SetTimer(ID_TIMER, 200, NULL) != 0); m_bDelayDone = TRUE; } } else if (message == WM_MOUSEMOVE || message == WM_NCMOUSEMOVE || message == WM_TIMER) { // moving the mouse changes the state of the timer/tooltip // timer is used to detect when to display tooltips and to detect // when mouse has left the window. In Win32, can't capture the // mouse across apps when the mouse button is not down, so have // to use the timer UINT nHit; int nHitType = HitTestToolTip(point, &nHit); if (nHitType >= 0) { if (!m_bDelayDone) { if (point != m_pointLastMove) { // first delay timer not done yet, so reset DestroyToolTip(FALSE, TRUE); VERIFY(SetTimer(ID_TIMER, 600, NULL) != 0); } } else if (message != WM_TIMER || point != m_pointLastMove) { if (m_nHitLast != nHit) { DestroyToolTip(FALSE, TRUE); m_bDelayDone = TRUE; KillTimer(ID_TIMER); VERIFY(SetTimer(ID_TIMER, 50, NULL) != 0); } } else { // second delay already done so show tooltip for item hit KillTimer(ID_TIMER); VERIFY(SetTimer(ID_TIMER, 200, NULL) != 0); ShowToolTip(point, nHit); } } else { // different levels of tooltip removal is necessary switch (nHitType) { case HITTYPE_NOTHING: DestroyToolTip(TRUE, !m_bDelayDone); m_nHitLast = (UINT)-1; m_pBarLast = NULL; break; case HITTYPE_FOCUS: case HITTYPE_OUTSIDE: case HITTYPE_INACTIVE: DestroyToolTip(TRUE, TRUE); m_nHitLast = (UINT)-1; m_pBarLast = NULL; break; case HITTYPE_TRACKING: case HITTYPE_DISABLED: DestroyToolTip(FALSE, FALSE); ScreenToClient(&point); m_nHitLast = OnCmdHitTest(point, NULL); if (m_nHitLast == (UINT)-1) m_pBarLast = NULL; ClientToScreen(&point); break; } } } m_pointLastMove = point; LeaveCriticalSection(_afxCriticalSection); }
void FirstTimeCheck() { hFirstCheckTimer = SetTimer(NULL, 0, 5 * 1000, OnFirstCheckTimer); }
INT_PTR CALLBACK DlgProcAlarm(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { WindowData *wd = (WindowData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); Utils_RestoreWindowPositionNoSize(hwndDlg, 0, MODULENAME, "Notify"); SetFocus(GetDlgItem(hwndDlg, IDC_SNOOZE)); wd = new WindowData; wd->moving = false; wd->alarm = nullptr; wd->win_num = win_num++; if (wd->win_num > 0) { RECT r; GetWindowRect(hwndDlg, &r); r.top += 20; r.left += 20; SetWindowPos(hwndDlg, nullptr, r.left, r.top, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE); Utils_SaveWindowPosition(hwndDlg, 0, MODULENAME, "Notify"); } SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)wd); // options SendMessage(hwndDlg, WMU_SETOPT, 0, 0); // fonts SendMessage(hwndDlg, WMU_SETFONTS, 0, 0); return FALSE; case WMU_REFRESH: InvalidateRect(hwndDlg, nullptr, TRUE); return TRUE; case WM_CTLCOLORSTATIC: { HDC hdc = (HDC)wParam; HWND hwndCtrl = (HWND)lParam; if (hBackgroundBrush) { if (hTitleFont && GetDlgItem(hwndDlg, IDC_TITLE) == hwndCtrl) SetTextColor(hdc, title_font_colour); else if (hWindowFont) SetTextColor(hdc, window_font_colour); SetBkMode(hdc, TRANSPARENT); return (INT_PTR)hBackgroundBrush; } } break; case WM_CTLCOLORDLG: if (hBackgroundBrush) return (INT_PTR)hBackgroundBrush; break; case WMU_SETFONTS: // fonts if (hWindowFont) SendMessage(hwndDlg, WM_SETFONT, (WPARAM)hWindowFont, TRUE); if (hTitleFont) SendDlgItemMessage(hwndDlg, IDC_TITLE, WM_SETFONT, (WPARAM)hTitleFont, TRUE); if (hBackgroundBrush) { SetClassLongPtr(hwndDlg, GCLP_HBRBACKGROUND, (LONG_PTR)hBackgroundBrush); InvalidateRect(hwndDlg, nullptr, TRUE); } return TRUE; case WMU_SETOPT: Options *opt; if (lParam) opt = (Options*)lParam; else opt = &options; // round corners if (opt->aw_roundcorners) { HRGN hRgn1; RECT r; int w = 10; GetWindowRect(hwndDlg, &r); int h = (r.right - r.left) > (w * 2) ? w : (r.right - r.left); int v = (r.bottom - r.top) > (w * 2) ? w : (r.bottom - r.top); h = (h < v) ? h : v; hRgn1 = CreateRoundRectRgn(0, 0, (r.right - r.left + 1), (r.bottom - r.top + 1), h, h); SetWindowRgn(hwndDlg, hRgn1, 1); } else { HRGN hRgn1; RECT r; int w = 10; GetWindowRect(hwndDlg, &r); int h = (r.right - r.left) > (w * 2) ? w : (r.right - r.left); int v = (r.bottom - r.top) > (w * 2) ? w : (r.bottom - r.top); h = (h < v) ? h : v; hRgn1 = CreateRectRgn(0, 0, (r.right - r.left + 1), (r.bottom - r.top + 1)); SetWindowRgn(hwndDlg, hRgn1, 1); } // transparency #ifdef WS_EX_LAYERED SetWindowLongPtr(hwndDlg, GWL_EXSTYLE, GetWindowLongPtr(hwndDlg, GWL_EXSTYLE) | WS_EX_LAYERED); #endif #ifdef LWA_ALPHA SetLayeredWindowAttributes(hwndDlg, RGB(0, 0, 0), (int)((100 - opt->aw_trans) / 100.0 * 255), LWA_ALPHA); #endif return TRUE; case WMU_SETALARM: { ALARM *data = (ALARM *)lParam; SetWindowText(hwndDlg, data->szTitle); SetWindowText(GetDlgItem(hwndDlg, IDC_TITLE), data->szTitle); SetDlgItemText(hwndDlg, IDC_ED_DESC, data->szDesc); wd->alarm = data; if (data->action & AAF_SOUND && options.loop_sound) { if (data->sound_num <= 3) SetTimer(hwndDlg, ID_TIMER_SOUND, SOUND_REPEAT_PERIOD, nullptr); else if (data->sound_num == 4) SetTimer(hwndDlg, ID_TIMER_SOUND, SPEACH_REPEAT_PERIOD, nullptr); } HWND hw = GetDlgItem(hwndDlg, IDC_SNOOZE); EnableWindow(hw, !(data->flags & ALF_NOSNOOZE)); ShowWindow(hw, (data->flags & ALF_NOSNOOZE) ? SW_HIDE : SW_SHOWNA); } return TRUE; case WMU_FAKEALARM: SetWindowText(hwndDlg, TranslateT("Example alarm")); SetDlgItemText(hwndDlg, IDC_TITLE, TranslateT("Example alarm")); SetDlgItemText(hwndDlg, IDC_ED_DESC, TranslateT("Some example text. Example, example, example.")); return TRUE; case WM_TIMER: if (wParam == ID_TIMER_SOUND && wd) { ALARM *data = wd->alarm; if (data && data->action & AAF_SOUND) { if (data->sound_num <= 3) { char buff[128]; mir_snprintf(buff, "Triggered%d", data->sound_num); Skin_PlaySound(buff); } else if (data->sound_num == 4) { if (data->szTitle != nullptr && data->szTitle[0] != '\0') { if (ServiceExists("Speak/Say")) { CallService("Speak/Say", 0, (LPARAM)data->szTitle); } } } } } return TRUE; case WM_MOVE: Utils_SaveWindowPosition(hwndDlg, 0, MODULENAME, "Notify"); break; case WMU_ADDSNOOZER: if (wd) { ALARM *data = wd->alarm; if (data) { // add snooze minutes to current time FILETIME ft; GetLocalTime(&data->time); SystemTimeToFileTime(&data->time, &ft); ULARGE_INTEGER uli; uli.LowPart = ft.dwLowDateTime; uli.HighPart = ft.dwHighDateTime; // there are 10000000 100-nanosecond blocks in a second... uli.QuadPart += mult.QuadPart * (int)(wParam); ft.dwHighDateTime = uli.HighPart; ft.dwLowDateTime = uli.LowPart; FileTimeToSystemTime(&ft, &data->time); data->occurrence = OC_ONCE; data->snoozer = true; data->flags = data->flags & ~ALF_NOSTARTUP; data->id = next_alarm_id++; append_to_list(data); } } return TRUE; case WM_COMMAND: if (HIWORD(wParam) == BN_CLICKED) { switch (LOWORD(wParam)) { case IDCANCEL: // no button - esc pressed case IDOK: // space? case IDC_SNOOZE: SendMessage(hwndDlg, WMU_ADDSNOOZER, (WPARAM)options.snooze_minutes, 0); //drop through case IDC_DISMISS: KillTimer(hwndDlg, ID_TIMER_SOUND); if (wd) { if (wd->alarm) { free_alarm_data(wd->alarm); delete wd->alarm; } delete wd; } SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0); win_num--; WindowList_Remove(hAlarmWindowList, hwndDlg); DestroyWindow(hwndDlg); break; case IDC_SNOOZELIST: POINT pt, pt_rel; GetCursorPos(&pt); pt_rel = pt; ScreenToClient(hwndDlg, &pt_rel); HMENU hMenu = CreatePopupMenu(); MENUITEMINFO mii = { 0 }; mii.cbSize = sizeof(mii); mii.fMask = MIIM_ID | MIIM_STRING; #define AddItem(x) \ mii.wID++; \ mii.dwTypeData = TranslateW(x); \ mii.cch = ( UINT )mir_wstrlen(mii.dwTypeData); \ InsertMenuItem(hMenu, mii.wID, FALSE, &mii); AddItem(LPGENW("5 mins")); AddItem(LPGENW("15 mins")); AddItem(LPGENW("30 mins")); AddItem(LPGENW("1 hour")); AddItem(LPGENW("1 day")); AddItem(LPGENW("1 week")); TPMPARAMS tpmp = { 0 }; tpmp.cbSize = sizeof(tpmp); LRESULT ret = (LRESULT)TrackPopupMenuEx(hMenu, TPM_RETURNCMD, pt.x, pt.y, hwndDlg, &tpmp); switch (ret) { case 0: DestroyMenu(hMenu); return 0; // dismis menu case 1: SendMessage(hwndDlg, WMU_ADDSNOOZER, (WPARAM)5, 0); break; case 2: SendMessage(hwndDlg, WMU_ADDSNOOZER, (WPARAM)15, 0); break; case 3: SendMessage(hwndDlg, WMU_ADDSNOOZER, (WPARAM)30, 0); break; case 4: SendMessage(hwndDlg, WMU_ADDSNOOZER, (WPARAM)60, 0); break; case 5: SendMessage(hwndDlg, WMU_ADDSNOOZER, (WPARAM)(60 * 24), 0); break; case 6: SendMessage(hwndDlg, WMU_ADDSNOOZER, (WPARAM)(60 * 24 * 7), 0); break; } DestroyMenu(hMenu); SendMessage(hwndDlg, WM_COMMAND, IDC_DISMISS, 0); break; } } return TRUE; case WM_MOUSEMOVE: if (wParam & MK_LBUTTON) { SetCapture(hwndDlg); POINT newp; newp.x = (short)LOWORD(lParam); newp.y = (short)HIWORD(lParam); ClientToScreen(hwndDlg, &newp); if (!wd->moving) wd->moving = true; else { RECT r; GetWindowRect(hwndDlg, &r); SetWindowPos(hwndDlg, nullptr, r.left + (newp.x - wd->p.x), r.top + (newp.y - wd->p.y), 0, 0, SWP_NOSIZE | SWP_NOZORDER); } wd->p.x = newp.x; wd->p.y = newp.y; } else { ReleaseCapture(); wd->moving = false; } return TRUE; } return FALSE; }
// Message handler for control box. LRESULT CALLBACK Controls(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_INITDIALOG: W32Util::CenterWindow(hDlg); { // IDC_EDIT_xxx is need continuous value to IDC_EDIT_KEY_ANALOG_RIGHT from IDC_EDIT_KEY_MENU. // it is total 16. // it is need the same order as the dinput_ctrl_map(and xinput/keyboard). if (CONTROLS_BUTTONS_COUNT != 16) { char mes[100]; snprintf(mes, 100, "CONTROLS_BUTTONS_COUNT(%d) is need 16.", CONTROLS_BUTTONS_COUNT); MessageBoxA(hDlg, mes, "Controls dialog init error.", MB_OK); } pCtrlDlgState = new ControlsDlgState(); ZeroMemory(pCtrlDlgState, sizeof(ControlsDlgState)); pCtrlDlgState->pCtrlMap = ControlMapping::CreateInstance(CONTROLS_BUTTONS_COUNT); if (!pCtrlDlgState->pCtrlMap) { MessageBoxA(hDlg, "Cannot Created ControlMapping instance.", "Controls dialog init error.", MB_OK); } pCtrlDlgState->pCtrlMap->SetTargetDevice(CONTROLS_KEYBOARD_INDEX); pCtrlDlgState->hCtrlTab = GetDlgItem(hDlg, IDC_TAB_INPUT_DEVICE); TCITEM tcItem; ZeroMemory(&tcItem, sizeof(tcItem)); tcItem.mask = TCIF_TEXT; tcItem.dwState = 0; tcItem.pszText = "Keyboard"; tcItem.cchTextMax = (int)strlen(tcItem.pszText)+1; tcItem.iImage = 0; TabCtrl_InsertItem(pCtrlDlgState->hCtrlTab, TabCtrl_GetItemCount(pCtrlDlgState->hCtrlTab),&tcItem); tcItem.pszText = "DirectInput"; tcItem.cchTextMax = (int)strlen(tcItem.pszText)+1; TabCtrl_InsertItem(pCtrlDlgState->hCtrlTab, TabCtrl_GetItemCount(pCtrlDlgState->hCtrlTab),&tcItem); tcItem.pszText = "XInput"; tcItem.cchTextMax = (int)strlen(tcItem.pszText)+1; TabCtrl_InsertItem(pCtrlDlgState->hCtrlTab, TabCtrl_GetItemCount(pCtrlDlgState->hCtrlTab),&tcItem); int tp_w = 0, tp_h = 0; // TODO: connect to keyboard device instead { HBITMAP hResBM = LoadImageFromResource(hInst, MAKEINTRESOURCE(IDB_IMAGE_PSP), "IMAGE"); pCtrlDlgState->hStaticPspImage = GetDlgItem(hDlg,IDC_STATIC_IMAGE_PSP); RECT clientRect, tabPageRect, imgRect; GetClientRect(hDlg, &clientRect); memcpy(&tabPageRect, &clientRect, sizeof(RECT)); TabCtrl_AdjustRect(pCtrlDlgState->hCtrlTab, FALSE, &tabPageRect); tp_w = tabPageRect.right - tabPageRect.left; tp_h = tabPageRect.bottom - tabPageRect.top; MoveWindow(pCtrlDlgState->hStaticPspImage, tabPageRect.left, tabPageRect.top, tp_w, tp_h, FALSE); HDC hDC = GetDC(pCtrlDlgState->hStaticPspImage); HBITMAP hMemBM = CreateCompatibleBitmap(hDC, tp_w, tp_h); HDC hResDC = CreateCompatibleDC(hDC); HDC hMemDC = CreateCompatibleDC(hDC); SelectObject(hResDC, hResBM); SelectObject(hMemDC, hMemBM); BITMAP bm; GetObject(hResBM, sizeof(BITMAP), &bm); SetStretchBltMode(hMemDC, HALFTONE); float scaleX = (float)bm.bmWidth / clientRect.right; float scaleY = (float)bm.bmHeight / clientRect.bottom; imgRect.left = (int)(tabPageRect.left * scaleX); imgRect.top = (int)(tabPageRect.top * scaleY); imgRect.right= (int)(bm.bmWidth - ((clientRect.right - tabPageRect.right) * scaleX)); imgRect.bottom = (int)(bm.bmHeight - ((clientRect.bottom - tabPageRect.bottom) * scaleY)); StretchBlt(hMemDC, 0, 0, tp_w, tp_h, hResDC, imgRect.left, imgRect.top, imgRect.right - imgRect.left, imgRect.bottom - imgRect.top, SRCCOPY); if (pCtrlDlgState->hbmPspImage) DeleteObject(pCtrlDlgState->hbmPspImage); pCtrlDlgState->hbmPspImage = hMemBM; DeleteDC(hMemDC); DeleteDC(hResDC); ReleaseDC(pCtrlDlgState->hStaticPspImage, hDC); DeleteObject(hResBM); } pCtrlDlgState->orgEditProc = (WNDPROC)GetWindowLongPtr( GetDlgItem(hDlg, CONTROLS_IDC_EDIT_BEGIN), GWLP_WNDPROC); for (int i = 0; i <= CONTROLS_IDC_EDIT_END - CONTROLS_IDC_EDIT_BEGIN; i++) { HWND hEdit = GetDlgItem(hDlg, CONTROLS_IDC_EDIT_BEGIN + i); if (i < CONTROLS_BUTTONS_COUNT) { u32 keyCode = pCtrlDlgState->pCtrlMap->GetBindCode(CONTROLS_KEYBOARD_INDEX, i); SetWindowTextForButton(hEdit, keyCode, getVirtualKeyName(keyCode)); } else { u32 analogCode = pCtrlDlgState->pCtrlMap->GetBindCode( CONTROLS_KEYBOARD_ANALOG_INDEX, i - CONTROLS_BUTTONS_COUNT); SetWindowTextForButton(hEdit, analogCode, getVirtualKeyName(analogCode)); } if (pCtrlDlgState->orgEditProc != (WNDPROC)GetWindowLongPtr(hEdit, GWLP_WNDPROC)) { MessageBoxA(hDlg, "Can not hook to the inherited Edit control. need wndproc of original edit control.", "Controls dialog init error.", MB_OK); break; } SetWindowLongPtr(hEdit, GWLP_WNDPROC, (LONG_PTR)ButtonsEditProc); } ComboBox_AddString(GetDlgItem(hDlg, IDC_FORCE_INPUT_DEVICE), "None"); ComboBox_AddString(GetDlgItem(hDlg, IDC_FORCE_INPUT_DEVICE), "XInput"); ComboBox_AddString(GetDlgItem(hDlg, IDC_FORCE_INPUT_DEVICE), "DirectInput"); if ((g_Config.iForceInputDevice < 0) || (g_Config.iForceInputDevice > 1)) { ComboBox_SetCurSel(GetDlgItem(hDlg, IDC_FORCE_INPUT_DEVICE), 0); } else { ComboBox_SetCurSel(GetDlgItem(hDlg, IDC_FORCE_INPUT_DEVICE), (g_Config.iForceInputDevice + 1)); } pCtrlDlgState->orgPSPImageProc = (WNDPROC)GetWindowLongPtr(pCtrlDlgState->hStaticPspImage, GWLP_WNDPROC); SetWindowLongPtr(pCtrlDlgState->hStaticPspImage, GWLP_WNDPROC, (LONG_PTR)PSPImageProc); DWORD dwThreadID = GetWindowThreadProcessId(hDlg, NULL); pCtrlDlgState->pKeydownHook = SetWindowsHookEx(WH_KEYBOARD, KeyboardProc, NULL, dwThreadID); pCtrlDlgState->timerId = SetTimer(hDlg, TIMER_CONTROLS_BINDUPDATE, BINDUPDATE_INTERVAL_MS, 0); } return TRUE; case WM_TIMER: { if (wParam == TIMER_CONTROLS_BINDUPDATE && pCtrlDlgState->pCtrlMap->GetTargetDevice() != CONTROLS_KEYBOARD_INDEX) { HWND hEdit = GetFocus(); UINT nCtrlID = GetDlgCtrlID(hEdit); if (nCtrlID < CONTROLS_IDC_EDIT_BEGIN || nCtrlID > IDC_EDIT_KEYRIGHT) { break; } // device polling and update. int prevButton = pCtrlDlgState->pCtrlMap->GetBindCode(); pCtrlDlgState->pCtrlMap->UpdateState(); char str[CONTROLS_BUTTONNAME_MAX]; ZeroMemory(str, CONTROLS_BUTTONNAME_MAX * sizeof(char)); int buttonCode = pCtrlDlgState->pCtrlMap->GetBindCode(); if (buttonCode == -1 || prevButton == buttonCode) break; switch(pCtrlDlgState->pCtrlMap->GetTargetDevice()) { case CONTROLS_KEYBOARD_INDEX: { ; // leave it to KeyboardProc. } break; case CONTROLS_DIRECT_INPUT_INDEX: { if (buttonCode > 0xFF) { int n = 1; for (int i = buttonCode >> 8; i > 1; i >>= 1) { n++; } snprintf(str, CONTROLS_BUTTONNAME_MAX, "%s", controllist[(IDC_EDIT_KEYUP - CONTROLS_IDC_EDIT_BEGIN - 1) + n]); } else { snprintf(str, CONTROLS_BUTTONNAME_MAX, "%d", buttonCode + 1); } SetWindowTextA(hEdit, str); RECT rc = getRedrawRect(hEdit); InvalidateRect(hDlg, &rc, FALSE); } break; case CONTROLS_XINPUT_INDEX: { SetWindowTextA(hEdit, getXinputButtonName(buttonCode)); RECT rc = getRedrawRect(hEdit); InvalidateRect(hDlg, &rc, FALSE); } break; } }
/********************************************** * [関数名] * WindowProc * * [説明] * ウィンドウコールバック * **********************************************/ LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { /********************************************** * 変数宣言 **********************************************/ static HWND hClickButton; static int iFlgClickStart = FALSE; static int iClickCnt = 0; static UINT_PTR uTimerID; static long lStartClock, lCurrentClock; /********************************************** * メッセージ処理 **********************************************/ switch (uMsg) { case WM_CREATE: { /********************************************** * メニュー表示 **********************************************/ g_MyWnd.SetWndMenu(hWnd, (MY_LIB_WND_MENU*)MY_MENU, MENU_NUM); POINT point = {SPEED_CLICK_BUTTON_POS_X, SPEED_CLICK_BUTTON_POS_Y}; SIZE sz = {SPEED_CLICK_BUTTON_WIDTH, SPEED_CLICK_BUTTON_HEIGHT}; g_MyWnd.AddBasicButton(&hClickButton, hWnd, TEXT("クリック"), point, sz, ID_BUTTON_CLICK); } break; case WM_PAINT: { HDC hdc; PAINTSTRUCT ps; TCHAR strTextTime[100] = TEXT("TIME: "); TCHAR strTextClick[100] = TEXT("クリック回数: "); TCHAR strTextTmp[100]; /********************************************** * クリック回数表示文字列生成 **********************************************/ wsprintf(strTextTmp, TEXT("%d"), iClickCnt); wcscat_s(strTextClick, 100, strTextTmp); /********************************************** * タイマ文字列生成 **********************************************/ if (iFlgClickStart == TRUE) { lCurrentClock = lStartClock - clock(); if (lCurrentClock <= 0) { lCurrentClock = 0; iFlgClickStart = FALSE; wsprintf(strTextTmp, TEXT("記録は %d 回でした."), iClickCnt); MessageBox(hWnd, strTextTmp, TEXT("終了!"), MB_OK); } } else { lCurrentClock = 0; } wsprintf(strTextTmp, TEXT("%03d'%02d.%03d"), lCurrentClock/60000, (lCurrentClock%60000)/1000, (lCurrentClock%60000)%1000); wcscat_s(strTextTime, 100, strTextTmp); hdc = BeginPaint(hWnd, &ps); SetBkColor(hdc, RGB(255, 255, 255)); FillRect(hdc, &ps.rcPaint, (HBRUSH) (COLOR_WINDOW+1)); TextOut(hdc, SPEED_CLICK_TEXT_TIME_POS_X, SPEED_CLICK_TEXT_TIME_POS_Y, strTextTime, _tcslen(strTextTime)); TextOut(hdc, SPEED_CLICK_TEXT_CLICK_POS_X, SPEED_CLICK_TEXT_CLICK_POS_Y, strTextClick, _tcslen(strTextClick)); EndPaint(hWnd, &ps); } break; case WM_COMMAND: switch (LOWORD(wParam)) { case ID_MENU_GAME_EXIT: SendMessage(hWnd, WM_CLOSE, 0, 0); break; case ID_MENU_MODE: { SIZE size = {SPEED_CLICK_DLG_MODE_WIDTH, SPEED_CLICK_DLG_MODE_HEIGHT}; g_MyWnd.ModalDialog(hWnd, TEXT("モード選択"), ModeDlgProc, size, &etMode); } break; case ID_MENU_ABOUT: MessageBox(hWnd, TEXT("SpeedClick Version.0.0.1"), TEXT("バージョン情報"), MB_OK); break; case ID_BUTTON_CLICK: if (iFlgClickStart == FALSE) { uTimerID = SetTimer(hWnd, WM_TIMER, 1, NULL); switch (etMode) { case SPEED_CLICK_MODE_1s: lStartClock = clock() + 1*1000; break; case SPEED_CLICK_MODE_5s: lStartClock = clock() + 5*1000; break; case SPEED_CLICK_MODE_10s: lStartClock = clock() + 10*1000; break; case SPEED_CLICK_MODE_30s: lStartClock = clock() + 30*1000; break; default: lStartClock = clock() + 5*1000; break; } iClickCnt = 0; iFlgClickStart = TRUE; } iClickCnt ++; { RECT stUpdateRect = {SPEED_CLICK_TEXT_CLICK_POS_X, SPEED_CLICK_TEXT_CLICK_POS_Y, SPEED_CLICK_TEXT_CLICK_POS_X + SPEED_CLICK_WINDOW_WIDTH, SPEED_CLICK_TEXT_CLICK_POS_Y + 20}; InvalidateRect(hWnd, &stUpdateRect, TRUE); UpdateWindow(hWnd); } break; default: break; } break; case WM_TIMER: { RECT stUpdateRect = {SPEED_CLICK_TEXT_TIME_POS_X, SPEED_CLICK_TEXT_TIME_POS_Y, SPEED_CLICK_TEXT_TIME_POS_X + SPEED_CLICK_WINDOW_WIDTH, SPEED_CLICK_TEXT_TIME_POS_Y + 20}; InvalidateRect(hWnd, &stUpdateRect, TRUE); UpdateWindow(hWnd); } break; case WM_CLOSE: if (MessageBox(hWnd, TEXT("終了しますか?"), TEXT("確認"), MB_OKCANCEL) == IDOK) { g_MyWnd.DestroyMyWindow(hWnd); } break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, uMsg, wParam, lParam); } /********************************************** * リターン **********************************************/ return 0; }
void __cdecl SplashThread(void *arg) { IGraphBuilder *pGraph = NULL; IMediaControl *pControl = NULL; if (options.playsnd) { // Initialize the COM library. CoInitialize(NULL); // Create the filter graph manager and query for interfaces. CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **)&pGraph); // Get MediaControl Interface pGraph->QueryInterface(IID_IMediaControl, (void **)&pControl); // Build the graph. IMPORTANT: Change this string to a file on your system. pGraph->RenderFile(szSoundFile, NULL); // Run the graph. pControl->Run(); } WNDCLASSEX wcl; wcl.cbSize = sizeof(wcl); wcl.lpfnWndProc = SplashWindowProc; wcl.style = 0; wcl.cbClsExtra = 0; wcl.cbWndExtra = 0; wcl.hInstance = hInst; wcl.hIcon = NULL; wcl.hCursor = LoadCursor(NULL, IDC_ARROW); wcl.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH); wcl.lpszMenuName = NULL; wcl.lpszClassName = _T(SPLASH_CLASS); wcl.hIconSm = NULL; RegisterClassEx(&wcl); RECT DesktopRect; int w = GetSystemMetrics(SM_CXSCREEN); int h = GetSystemMetrics(SM_CYSCREEN); DesktopRect.left = 0; DesktopRect.top = 0; DesktopRect.right = w; DesktopRect.bottom = h; RECT WindowRect; WindowRect.left = (DesktopRect.left + DesktopRect.right - SplashBmp->getWidth()) / 2; WindowRect.top = (DesktopRect.top + DesktopRect.bottom - SplashBmp->getHeight()) / 2; WindowRect.right = WindowRect.left + SplashBmp->getWidth(); WindowRect.bottom = WindowRect.top + SplashBmp->getHeight(); hwndSplash = CreateWindowEx( WS_EX_TOOLWINDOW | WS_EX_TOPMOST,//dwStyleEx _T(SPLASH_CLASS), //Class name NULL, //Title DS_SETFONT | DS_FIXEDSYS | WS_POPUP, //dwStyle WindowRect.left, // x WindowRect.top, // y SplashBmp->getWidth(), // Width SplashBmp->getHeight(), // Height HWND_DESKTOP, //Parent NULL, //menu handle hInst, //Instance NULL); RECT rc; GetWindowRect(hwndSplash, &rc); POINT ptDst = { rc.left, rc.top }; POINT ptSrc = { 0, 0 }; SIZE sz = { rc.right - rc.left, rc.bottom - rc.top }; bool splashWithMarkers = false; BLENDFUNCTION blend; blend.BlendOp = AC_SRC_OVER; blend.BlendFlags = 0; blend.SourceConstantAlpha = 0; blend.AlphaFormat = AC_SRC_ALPHA; if (options.showversion) { // locate text markers: int i, x = -1, y = -1; int splashWidth = SplashBmp->getWidth(); for (i = 0; i < splashWidth; ++i) if (SplashBmp->getRow(0)[i] & 0xFF000000) { if (x < 0) { x = i - 1; // 1 pixel for marker line splashWithMarkers = true; } else { x = -1; splashWithMarkers = false; break; } } int splashHeight = SplashBmp->getHeight(); for (i = 0; splashWithMarkers && (i < splashHeight); ++i) if (SplashBmp->getRow(i)[0] & 0xFF000000) { if (y < 0) { y = i - 1; // 1 pixel for marker line splashWithMarkers = true; } else { y = -1; splashWithMarkers = false; break; } } TCHAR verString[256] = { 0 }; TCHAR *mirandaVerString = mir_a2t(szVersion); mir_sntprintf(verString, _T("%s%s"), szPrefix, mirandaVerString); mir_free(mirandaVerString); LOGFONT lf = { 0 }; lf.lfHeight = 14; mir_tstrcpy(lf.lfFaceName, _T("Verdana")); SelectObject(SplashBmp->getDC(), CreateFontIndirect(&lf)); if (!splashWithMarkers) { SIZE v_sz = { 0, 0 }; GetTextExtentPoint32(SplashBmp->getDC(), verString, (int)mir_tstrlen(verString), &v_sz); x = SplashBmp->getWidth() / 2 - (v_sz.cx / 2); y = SplashBmp->getHeight() - (SplashBmp->getHeight()*(100 - 90) / 100); } SetTextColor(SplashBmp->getDC(), (0xFFFFFFFFUL - SplashBmp->getRow(y)[x]) & 0x00FFFFFFUL); SetBkMode(SplashBmp->getDC(), TRANSPARENT); SplashBmp->DrawText(verString, x, y); } SetWindowLongPtr(hwndSplash, GWL_EXSTYLE, GetWindowLongPtr(hwndSplash, GWL_EXSTYLE) | WS_EX_LAYERED); UpdateLayeredWindow(hwndSplash, NULL, &ptDst, &sz, SplashBmp->getDC(), &ptSrc, 0xffffffff, &blend, LWA_ALPHA); ShowWindow(hwndSplash, SW_SHOWNORMAL); if (options.fadein) { // Fade in for (int i = 0; i < 255; i += options.fisteps) { blend.SourceConstantAlpha = i; UpdateLayeredWindow(hwndSplash, NULL, &ptDst, &sz, SplashBmp->getDC(), &ptSrc, 0xffffffff, &blend, LWA_ALPHA); Sleep(1); } } blend.SourceConstantAlpha = 255; UpdateLayeredWindow(hwndSplash, NULL, &ptDst, &sz, SplashBmp->getDC(), &ptSrc, 0xffffffff, &blend, LWA_ALPHA); if (DWORD_PTR(arg) > 0) { if (SetTimer(hwndSplash, 6, DWORD_PTR(arg), 0)) { #ifdef _DEBUG logMessage(_T("Timer TimeToShow"), _T("set")); #endif } } else if (bmodulesloaded) { if (SetTimer(hwndSplash, 8, 2000, 0)) { #ifdef _DEBUG logMessage(_T("Timer Modules loaded"), _T("set")); #endif } } // The Message Pump MSG msg; while (GetMessage(&msg, NULL, 0, 0) == TRUE) //NULL means every window in the thread; == TRUE means a safe pump. { TranslateMessage(&msg); DispatchMessage(&msg); } if (options.playsnd) { pControl->Release(); pGraph->Release(); CoUninitialize(); } }
void CBlendingAnimationsView::OnAnimationStart() { SetTimer(1, 1, 0); KillTimer(2); KillTimer(3); }
BOOL CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { DWORD ws; struct ParentWindowData *dat; dat = (struct ParentWindowData *) GetWindowLong(hwndDlg, GWL_USERDATA); if (!dat && msg!=WM_INITDIALOG) return FALSE; switch (msg) { case WM_INITDIALOG: { struct NewMessageWindowLParam *newData = (struct NewMessageWindowLParam *) lParam; dat = (struct ParentWindowData *) malloc(sizeof(struct ParentWindowData)); dat->hContact = newData->hContact; dat->nFlash = 0; dat->nFlashMax = DBGetContactSettingByte(NULL, SRMMMOD, SRMSGSET_FLASHCOUNT, SRMSGDEFSET_FLASHCOUNT); dat->childrenCount = 0; dat->children = NULL; dat->hwnd = hwndDlg; dat->flags = g_dat->flags;// | SMF_SHOWTITLEBAR; dat->mouseLBDown = 0; dat->windowWasCascaded = 0; dat->hwndStatus = CreateWindowEx(0, STATUSCLASSNAME, NULL, WS_CHILD | WS_VISIBLE | SBARS_SIZEGRIP, 0, 0, 0, 0, hwndDlg, NULL, g_hInst, NULL); { int statwidths[4]; RECT rc; SendMessage(dat->hwndStatus, SB_SETMINHEIGHT, GetSystemMetrics(SM_CYSMICON), 0); GetWindowRect(dat->hwndStatus, &rc); /* statwidths[0] = rc.right - rc.left - SB_CHAR_WIDTH - SB_TYPING_WIDTH - SB_SENDING_WIDTH; statwidths[1] = rc.right - rc.left - SB_TYPING_WIDTH - SB_SENDING_WIDTH; //rc.right - rc.left - SB_CHAR_WIDTH; statwidths[2] = rc.right - rc.left - SB_TYPING_WIDTH; //rc.right - rc.left - SB_CHAR_WIDTH; statwidths[3] = -1; SendMessage(dat->hwndStatus, SB_SETPARTS, 4, (LPARAM) statwidths); */ statwidths[0] = rc.right - rc.left - SB_CHAR_WIDTH - SB_TYPING_WIDTH; statwidths[1] = rc.right - rc.left - SB_TYPING_WIDTH; statwidths[2] = -1; SendMessage(dat->hwndStatus, SB_SETPARTS, 3, (LPARAM) statwidths); } dat->hwndTabs = GetDlgItem(hwndDlg, IDC_TABS); dat->hwndActive = NULL; SetWindowLong(hwndDlg, GWL_USERDATA, (LONG) dat); if (g_dat->hIconList != NULL) { TabCtrl_SetImageList(dat->hwndTabs, g_dat->hIconList); } WindowList_Add(g_dat->hParentWindowList, hwndDlg, 0); dat->tabCtrlDat = (struct TabCtrlData *) malloc(sizeof(struct TabCtrlData)); dat->tabCtrlDat->bDragging = FALSE; SetWindowLong(dat->hwndTabs, GWL_USERDATA, (LONG) dat->tabCtrlDat); OldTabCtrlProc = (WNDPROC) SetWindowLong(dat->hwndTabs, GWL_WNDPROC, (LONG) TabCtrlProc); ws = GetWindowLong(dat->hwndTabs, GWL_STYLE) & ~(TCS_BOTTOM); if (dat->flags & SMF_TABSATBOTTOM) { ws |= TCS_BOTTOM; } SetWindowLong(dat->hwndTabs, GWL_STYLE, ws); ws = GetWindowLong(hwndDlg, GWL_STYLE) & ~(WS_CAPTION); if (dat->flags & SMF_SHOWTITLEBAR) { ws |= WS_CAPTION; SetWindowLong(hwndDlg, GWL_STYLE, ws); } else { RECT rc; SetWindowLong(hwndDlg, GWL_STYLE, ws); GetWindowRect(hwndDlg, &rc); SetWindowPos(hwndDlg, 0, 0, 0, rc.right - rc.left, rc.bottom - rc.top, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOSENDCHANGING); } ws = GetWindowLong(hwndDlg, GWL_EXSTYLE) & ~WS_EX_LAYERED; ws |= dat->flags & SMF_USETRANSPARENCY ? WS_EX_LAYERED : 0; SetWindowLong(hwndDlg , GWL_EXSTYLE , ws); if (dat->flags & SMF_USETRANSPARENCY) { pSetLayeredWindowAttributes(hwndDlg, RGB(255,255,255), (BYTE)(255-g_dat->inactiveAlpha), LWA_ALPHA); // RedrawWindow(hwndDlg, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN); } //SetWindowPos(dat->hwndTabs, 0, 0, -10, 0, 0, SWP_NOSIZE | SWP_NOZORDER); if (!(dat->flags & SMF_SHOWSTATUSBAR)) { ShowWindow(dat->hwndStatus, SW_HIDE); } if (dat->flags & SMF_USETABS) { if (ScriverRestoreWindowPosition(hwndDlg, NULL, SRMMMOD, "", 0, SW_HIDE)) { SetWindowPos(hwndDlg, 0, 0, 0, 450, 300, SWP_NOZORDER | SWP_NOMOVE | SWP_HIDEWINDOW); } } else { int savePerContact = DBGetContactSettingByte(NULL, SRMMMOD, SRMSGSET_SAVEPERCONTACT, SRMSGDEFSET_SAVEPERCONTACT); if (ScriverRestoreWindowPosition(hwndDlg, savePerContact ? dat->hContact : NULL, SRMMMOD, "", 0, SW_HIDE)) { //if (Utils_RestoreWindowPosition(GetParent(hwndDlg), savePerContact ? dat->hContact : NULL, SRMMMOD, "")) { if (savePerContact) { if (ScriverRestoreWindowPosition(hwndDlg, NULL, SRMMMOD, "", RWPF_NOSIZE, SW_HIDE)) // if (Utils_RestoreWindowPositionNoMove(GetParent(hwndDlg), NULL, SRMMMOD, "")) SetWindowPos(GetParent(hwndDlg), 0, 0, 0, 450, 300, SWP_NOZORDER | SWP_NOMOVE); } else SetWindowPos(hwndDlg, 0, 0, 0, 450, 300, SWP_NOZORDER | SWP_NOMOVE); } if (!savePerContact && DBGetContactSettingByte(NULL, SRMMMOD, SRMSGSET_CASCADE, SRMSGDEFSET_CASCADE)) WindowList_Broadcast(g_dat->hParentWindowList, DM_CASCADENEWWINDOW, (WPARAM) hwndDlg, (LPARAM) & dat->windowWasCascaded); } } return TRUE; case WM_GETMINMAXINFO: { MINMAXINFO *mmi = (MINMAXINFO *) lParam; SIZE size; GetMinimunWindowSize(dat, &size); mmi->ptMinTrackSize.x = size.cx; mmi->ptMinTrackSize.y = size.cy; return FALSE; } case WM_SIZE: if (wParam == SIZE_MINIMIZED) { dat->bMinimized = 1; } else if (!IsIconic(hwndDlg)) { int i; RECT rc, rcStatus, rcChild, rcWindow; SIZE size; dat->bMinimized = 0; GetClientRect(hwndDlg, &rc); rcStatus.top = rcStatus.bottom = 0; if (dat->flags & SMF_SHOWSTATUSBAR) { int statwidths[4]; GetWindowRect(dat->hwndStatus, &rcStatus); statwidths[0] = rc.right - rc.left - SB_CHAR_WIDTH - SB_TYPING_WIDTH; statwidths[1] = rc.right - rc.left - SB_TYPING_WIDTH; statwidths[2] = -1; SendMessage(dat->hwndStatus, SB_SETPARTS, 3, (LPARAM) statwidths); SendMessage(dat->hwndStatus, WM_SIZE, 0, 0); } MoveWindow(dat->hwndTabs, 0, 2, (rc.right - rc.left), (rc.bottom - rc.top) - (rcStatus.bottom - rcStatus.top) - 2, FALSE); RedrawWindow(dat->hwndTabs, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE); GetMinimunWindowSize(dat, &size); GetWindowRect(hwndDlg, &rcWindow); if ((rcWindow.bottom-rcWindow.top) < size.cy || (rcWindow.right-rcWindow.left) < size.cx) { if ((rcWindow.bottom-rcWindow.top) < size.cy) { rcWindow.bottom = rcWindow.top + size.cy; } if ((rcWindow.right-rcWindow.left) < size.cx) { rcWindow.right = rcWindow.left + size.cx; } MoveWindow(hwndDlg, rcWindow.left, rcWindow.top, rcWindow.right - rcWindow.left, rcWindow.bottom - rcWindow.top, TRUE); } GetChildWindowRect(dat, &rcChild); for (i=0;i<dat->childrenCount;i++) { if (dat->children[i] == dat->hwndActive) { MoveWindow(dat->children[i], rcChild.left, rcChild.top, rcChild.right-rcChild.left, rcChild.bottom - rcChild.top, TRUE); RedrawWindow(GetDlgItem(dat->children[i], IDC_LOG), NULL, NULL, RDW_INVALIDATE); } } if (dat->flags & SMF_SHOWSTATUSBAR) { RedrawWindow(dat->hwndStatus, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE); } } return FALSE; case WM_SETFOCUS: SetFocus(dat->hwndActive); return TRUE; case WM_CLOSE: DestroyWindow(hwndDlg); return TRUE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDCANCEL: //DestroyWindow(hwndDlg); return TRUE; } case WM_NOTIFY: { NMHDR* pNMHDR = (NMHDR*) lParam; if (pNMHDR->hwndFrom == dat->hwndTabs) { switch (pNMHDR->code) { case TCN_SELCHANGE: { TCITEM tci = {0}; int iSel = TabCtrl_GetCurSel(dat->hwndTabs); tci.mask = TCIF_PARAM; if (TabCtrl_GetItem(dat->hwndTabs, iSel, &tci)) { struct MessageWindowData * mdat = (struct MessageWindowData *) tci.lParam; ActivateChild(dat, mdat->hwnd); } } break; case NM_RCLICK: { TCHITTESTINFO thinfo; int tabId, x, y; GetCursorPos(&thinfo.pt); x = thinfo.pt.x; y = thinfo.pt.y; ScreenToClient(dat->hwndTabs, &thinfo.pt); tabId = TabCtrl_HitTest(dat->hwndTabs, &thinfo); if (tabId != -1) { struct MessageWindowData * mwd = GetChildFromTab(dat->hwndTabs, tabId); //CallService(MS_USERINFO_SHOWDIALOG, (WPARAM) mwd->hContact, 0); HMENU hMenu = (HMENU) CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM) mwd->hContact, 0); TrackPopupMenu(hMenu, 0, x, y, 0, mwd->hwnd, NULL); DestroyMenu(hMenu); } } break; } } else if (pNMHDR->hwndFrom == dat->hwndStatus) { switch (pNMHDR->code) { case NM_CLICK: { NMMOUSE *nm=(NMMOUSE*)lParam; RECT rc; SendMessage(dat->hwndStatus, SB_GETRECT, SendMessage(dat->hwndStatus, SB_GETPARTS, 0, 0) - 1, (LPARAM)&rc); if (nm->pt.x >= rc.left) SendMessage(dat->hwndActive, DM_SWITCHUNICODE, 0, 0); } } break; } } break; case WM_DROPFILES: SendMessage(dat->hwndActive, WM_DROPFILES, wParam, lParam); break; case WM_TIMER: if (wParam == TIMERID_FLASHWND) { if ((dat->nFlash > dat->nFlashMax)) {// || ((GetActiveWindow() == hwndDlg) && (GetForegroundWindow() == hwndDlg))) { KillTimer(hwndDlg, TIMERID_FLASHWND); FlashWindow(hwndDlg, FALSE); } else if (dat->nFlash < dat->nFlashMax) { FlashWindow(hwndDlg, TRUE); dat->nFlash++; } } break; case WM_CONTEXTMENU: { if (dat->hwndStatus && dat->hwndStatus == (HWND) wParam) { RECT rc; POINT pt, pt2; GetCursorPos(&pt); pt2.x = pt.x; pt2.y = pt.y; ScreenToClient(dat->hwndStatus, &pt); SendMessage(dat->hwndStatus, SB_GETRECT, SendMessage(dat->hwndStatus, SB_GETPARTS, 0, 0) - 1, (LPARAM)&rc); if (pt.x >= rc.left && dat->hwndActive != NULL) { int codePage = (int) SendMessage(dat->hwndActive, DM_GETCODEPAGE, 0, 0); int i, iSel; for(i = 0; i < GetMenuItemCount(g_dat->hMenuANSIEncoding); i++) { CheckMenuItem (g_dat->hMenuANSIEncoding, i, MF_BYPOSITION | MF_UNCHECKED); } if(codePage == CP_ACP) { CheckMenuItem(g_dat->hMenuANSIEncoding, 0, MF_BYPOSITION | MF_CHECKED); } else { CheckMenuItem(g_dat->hMenuANSIEncoding, codePage, MF_BYCOMMAND | MF_CHECKED); } iSel = TrackPopupMenu(g_dat->hMenuANSIEncoding, TPM_RETURNCMD, pt2.x, pt2.y, 0, hwndDlg, NULL); if (iSel >= 500) { if (iSel == 500) iSel = CP_ACP; SendMessage(dat->hwndActive, DM_SETCODEPAGE, 0, iSel); } } else SendMessage(dat->hwndActive, WM_CONTEXTMENU, (WPARAM)hwndDlg, 0); } break; } case WM_ACTIVATE: if (LOWORD(wParam) == WA_INACTIVE) { ws = GetWindowLong(hwndDlg, GWL_EXSTYLE) & ~WS_EX_LAYERED; ws |= dat->flags & SMF_USETRANSPARENCY ? WS_EX_LAYERED : 0; SetWindowLong(hwndDlg , GWL_EXSTYLE , ws); if (dat->flags & SMF_USETRANSPARENCY) { pSetLayeredWindowAttributes(hwndDlg, RGB(255,255,255), (BYTE)(255-g_dat->inactiveAlpha), LWA_ALPHA); // RedrawWindow(hwndDlg, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN); } } if (LOWORD(wParam) != WA_ACTIVE) break; case WM_MOUSEACTIVATE: if (KillTimer(hwndDlg, TIMERID_FLASHWND)) { FlashWindow(hwndDlg, FALSE); dat->nFlash = 0; } ws = GetWindowLong(hwndDlg, GWL_EXSTYLE) & ~WS_EX_LAYERED; ws |= dat->flags & SMF_USETRANSPARENCY ? WS_EX_LAYERED : 0; SetWindowLong(hwndDlg , GWL_EXSTYLE , ws); if (dat->flags & SMF_USETRANSPARENCY) { pSetLayeredWindowAttributes(hwndDlg, RGB(255,255,255), (BYTE)(255-g_dat->activeAlpha), LWA_ALPHA); // RedrawWindow(hwndDlg, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN); } SendMessage(dat->hwndActive, WM_ACTIVATE, WA_ACTIVE, 0); break; case WM_LBUTTONDOWN: dat->mouseLBDown = 1; GetCursorPos(&dat->mouseLBDownPos); SetCapture(hwndDlg); break; case WM_LBUTTONUP: dat->mouseLBDown = 0; ReleaseCapture(); break; case WM_MOUSEMOVE: if (dat->mouseLBDown) { POINT pt; RECT rc; GetCursorPos(&pt); GetWindowRect(hwndDlg, &rc); SetWindowPos(hwndDlg, 0, rc.left - (dat->mouseLBDownPos.x - pt.x), rc.top - (dat->mouseLBDownPos.y - pt.y), 0, 0, SWP_NOZORDER | SWP_NOSIZE); dat->mouseLBDownPos = pt; } break; case WM_DESTROY: { g_dat->hParent = NULL; SetWindowLong(hwndDlg, GWL_USERDATA, 0); WindowList_Remove(g_dat->hParentWindowList, hwndDlg); if (dat->children!=NULL) free (dat->children); free(dat->tabCtrlDat); free(dat); if (dat->flags & SMF_USETABS) { WINDOWPLACEMENT wp = { 0 }; wp.length = sizeof(wp); GetWindowPlacement(hwndDlg, &wp); DBWriteContactSettingDword(NULL, SRMMMOD, "x", wp.rcNormalPosition.left); DBWriteContactSettingDword(NULL, SRMMMOD, "y", wp.rcNormalPosition.top); DBWriteContactSettingDword(NULL, SRMMMOD, "width", wp.rcNormalPosition.right - wp.rcNormalPosition.left); DBWriteContactSettingDword(NULL, SRMMMOD, "height", wp.rcNormalPosition.bottom - wp.rcNormalPosition.top); } else { WINDOWPLACEMENT wp = { 0 }; HANDLE hContact; if (DBGetContactSettingByte(NULL, SRMMMOD, SRMSGSET_SAVEPERCONTACT, SRMSGDEFSET_SAVEPERCONTACT)) hContact = dat->hContact; else hContact = NULL; wp.length = sizeof(wp); GetWindowPlacement(hwndDlg, &wp); if (!dat->windowWasCascaded) { DBWriteContactSettingDword(hContact, SRMMMOD, "x", wp.rcNormalPosition.left); DBWriteContactSettingDword(hContact, SRMMMOD, "y", wp.rcNormalPosition.top); } DBWriteContactSettingDword(hContact, SRMMMOD, "width", wp.rcNormalPosition.right - wp.rcNormalPosition.left); DBWriteContactSettingDword(hContact, SRMMMOD, "height", wp.rcNormalPosition.bottom - wp.rcNormalPosition.top); } } break; case DM_ERRORDECIDED: break; case DM_STARTFLASHING: if (GetActiveWindow() != hwndDlg || GetForegroundWindow() != hwndDlg) { dat->nFlash = 0; SetTimer(hwndDlg, TIMERID_FLASHWND, TIMEOUT_FLASHWND, NULL); } break; case DM_REMOVECHILD: { RemoveChild(dat, (HWND) lParam); if (dat->childrenCount == 0) { DestroyWindow(hwndDlg); } else { } } return TRUE; case DM_ADDCHILD: { struct MessageWindowData * mdat = (struct MessageWindowData *) lParam; AddChild(dat, mdat); } return TRUE; case DM_ACTIVATECHILD: if((HWND) lParam != dat->hwndActive) { ActivateChild(dat, (HWND) lParam); } return TRUE; case DM_ACTIVATEPREV: ActivatePrevChild(dat, (HWND) lParam); return TRUE; case DM_ACTIVATENEXT: ActivateNextChild(dat, (HWND) lParam); return TRUE; case DM_SENDMESSAGE: { int i; for (i=0;i<dat->childrenCount;i++) { SendMessage(dat->children[i], DM_SENDMESSAGE, wParam, lParam); } } break; case DM_OPTIONSAPPLIED: { RECT rc; dat->flags = g_dat->flags; if (!(dat->flags & SMF_SHOWSTATUSBAR)) { ShowWindow(dat->hwndStatus, SW_HIDE); } else { ShowWindow(dat->hwndStatus, SW_SHOW); } ws = GetWindowLong(hwndDlg, GWL_STYLE) & ~(WS_CAPTION); if (dat->flags & SMF_SHOWTITLEBAR) { ws |= WS_CAPTION; } SetWindowLong(hwndDlg, GWL_STYLE, ws); ws = GetWindowLong(hwndDlg, GWL_EXSTYLE)& ~WS_EX_LAYERED; ws |= dat->flags & SMF_USETRANSPARENCY ? WS_EX_LAYERED : 0; SetWindowLong(hwndDlg , GWL_EXSTYLE , ws); if (dat->flags & SMF_USETRANSPARENCY) { pSetLayeredWindowAttributes(hwndDlg, RGB(255,255,255), (BYTE)(255-g_dat->inactiveAlpha), LWA_ALPHA); // RedrawWindow(hwndDlg, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN); } ws = GetWindowLong(dat->hwndTabs, GWL_STYLE) & ~(TCS_BOTTOM); if (dat->flags & SMF_TABSATBOTTOM) { ws |= TCS_BOTTOM; } SetWindowLong(dat->hwndTabs, GWL_STYLE, ws); RedrawWindow(dat->hwndTabs, NULL, NULL, RDW_INVALIDATE); GetWindowRect(hwndDlg, &rc); SetWindowPos(hwndDlg, 0, 0, 0, rc.right - rc.left, rc.bottom - rc.top, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOSENDCHANGING); SendMessage(hwndDlg, WM_SIZE, 0, 0); //RedrawWindow(hwndDlg, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN); break; } case DM_UPDATETITLE: { struct MessageWindowData * mdat = (struct MessageWindowData *) lParam; TCITEM tci; int tabId; char newtitle[256], oldtitle[256]; char *szStatus, *contactName, *pszNewTitleEnd; TCHAR *tContactName; if (mdat && mdat->hwnd == dat->hwndActive) { pszNewTitleEnd = "Message Session"; if (mdat->hContact) { if (mdat->szProto) { CONTACTINFO ci; char buf[128]; int statusIcon = DBGetContactSettingByte(NULL, SRMMMOD, SRMSGSET_STATUSICON, SRMSGDEFSET_STATUSICON); buf[0] = 0; mdat->wStatus = DBGetContactSettingWord(mdat->hContact, mdat->szProto, "Status", ID_STATUS_OFFLINE); contactName = (char *) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM) mdat->hContact, 0); ZeroMemory(&ci, sizeof(ci)); ci.cbSize = sizeof(ci); ci.hContact = mdat->hContact; ci.szProto = mdat->szProto; ci.dwFlag = CNF_UNIQUEID; if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM) & ci)) { switch (ci.type) { case CNFT_ASCIIZ: mir_snprintf(buf, sizeof(buf), "%s", ci.pszVal); miranda_sys_free(ci.pszVal); break; case CNFT_DWORD: mir_snprintf(buf, sizeof(buf), "%u", ci.dVal); break; } } szStatus = (char *) CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, mdat->szProto == NULL ? ID_STATUS_OFFLINE : DBGetContactSettingWord(mdat->hContact, mdat->szProto, "Status", ID_STATUS_OFFLINE), 0); if (statusIcon) mir_snprintf(newtitle, sizeof(newtitle), "%s - %s", contactName, Translate(pszNewTitleEnd)); else mir_snprintf(newtitle, sizeof(newtitle), "%s (%s): %s", contactName, szStatus, Translate(pszNewTitleEnd)); } } else lstrcpynA(newtitle, pszNewTitleEnd, sizeof(newtitle)); GetWindowTextA(hwndDlg, oldtitle, sizeof(oldtitle)); if (lstrcmpA(newtitle, oldtitle)) { //swt() flickers even if the title hasn't actually changed SetWindowTextA(hwndDlg, newtitle); //SendMessage(hwndDlg, WM_SIZE, 0, 0); } } tabId = GetTabFromHWND(dat, mdat->hwnd); tContactName = GetTabName(mdat->hContact); tci.mask = TCIF_TEXT; tci.pszText = tContactName; TabCtrl_SetItem(dat->hwndTabs, tabId, &tci); free(tContactName); break; } case DM_UPDATEWINICON: { struct MessageWindowData * mdat = (struct MessageWindowData *) lParam; if (mdat) { if (mdat->szProto) { int i, icoIdx = 0; WORD wStatus; wStatus = DBGetContactSettingWord(mdat->hContact, mdat->szProto, "Status", ID_STATUS_OFFLINE); if (mdat->hwnd == dat->hwndActive) { if (DBGetContactSettingByte(NULL, SRMMMOD, SRMSGSET_STATUSICON, SRMSGDEFSET_STATUSICON)) { if (mdat->showTyping && (dat->flags&SMF_SHOWTYPINGWIN)) { SendMessage(hwndDlg, WM_SETICON, (WPARAM) ICON_BIG, (LPARAM) g_dat->hIcons[SMF_ICON_TYPING]); } else if (mdat->showUnread && (GetActiveWindow() != hwndDlg || GetForegroundWindow() != hwndDlg)) { SendMessage(hwndDlg, WM_SETICON, (WPARAM) ICON_BIG, (LPARAM) LoadSkinnedIcon(SKINICON_EVENT_MESSAGE)); } else { SendMessage(hwndDlg, WM_SETICON, (WPARAM) ICON_BIG, (LPARAM) LoadSkinnedProtoIcon(mdat->szProto, wStatus)); } } else { SendMessage(hwndDlg, WM_SETICON, (WPARAM) ICON_BIG, (LPARAM) LoadSkinnedIcon(SKINICON_EVENT_MESSAGE)); } } icoIdx = 0; for (i = 0; i < g_dat->protoNum; i++) { if (!strcmp(g_dat->protoNames[i], mdat->szProto)) { icoIdx = wStatus - ID_STATUS_OFFLINE + (ID_STATUS_OUTTOLUNCH - ID_STATUS_OFFLINE + 1) * (i +1) + 2; break; } } if (mdat->hwnd != dat->hwndActive) { if (mdat->showTyping) { icoIdx = 1; } else if (mdat->showUnread & 1) { icoIdx = 0; } } i = GetTabFromHWND(dat, mdat->hwnd); if (i>=0) { TCITEM tci; tci.mask = TCIF_IMAGE; tci.iImage = icoIdx; TabCtrl_SetItem(dat->hwndTabs, i, &tci); } } } break; } case DM_UPDATESTATUSBAR: break; case DM_SWITCHSTATUSBAR: dat->flags ^= SMF_SHOWSTATUSBAR; if (!(dat->flags & SMF_SHOWSTATUSBAR)) { ShowWindow(dat->hwndStatus, SW_HIDE); } else { ShowWindow(dat->hwndStatus, SW_SHOW); } SendMessage(hwndDlg, WM_SIZE, 0, 0); break; case DM_SWITCHTOOLBAR: { int i; dat->flags ^= SMF_SHOWBTNS; for (i=0;i<dat->childrenCount;i++) { SendMessage(dat->children[i], DM_SWITCHTOOLBAR, 0, 0); } SendMessage(hwndDlg, WM_SIZE, 0, 0); } break; case DM_SWITCHTITLEBAR: { RECT rc; dat->flags ^= SMF_SHOWTITLEBAR; ws = GetWindowLong(hwndDlg, GWL_STYLE) & ~(WS_CAPTION); if (dat->flags & SMF_SHOWTITLEBAR) { ws |= WS_CAPTION; } SetWindowLong(hwndDlg, GWL_STYLE, ws); GetWindowRect(hwndDlg, &rc); SetWindowPos(hwndDlg, 0, 0, 0, rc.right - rc.left, rc.bottom - rc.top, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOSENDCHANGING); // SendMessage(hwndDlg, WM_SIZE, 0, 0); RedrawWindow(hwndDlg, NULL, NULL, RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN); } break; case DM_CASCADENEWWINDOW: if ((HWND) wParam == hwndDlg) break; { RECT rcThis, rcNew; GetWindowRect(hwndDlg, &rcThis); GetWindowRect((HWND) wParam, &rcNew); if (abs(rcThis.left - rcNew.left) < 3 && abs(rcThis.top - rcNew.top) < 3) { int offset = GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYFRAME); SetWindowPos((HWND) wParam, 0, rcNew.left + offset, rcNew.top + offset, 0, 0, SWP_NOZORDER | SWP_NOSIZE); *(int *) lParam = 1; } } break; //case DM_MESSAGESENDING: // dat->messagesInProgress += wParam ? -1 : 1; // if (dat->messagesInProgress < 0) dat->messagesInProgress = 0; // break; } return FALSE; }
void CBlendingAnimationsView::OnAnimationStartwalk() { SetTimer(2, 1, 0); KillTimer(1); KillTimer(3); }
LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam) { HDC hdc; PAINTSTRUCT ps; RECT rect; HBRUSH hBrush; int i; static POINT pts[4]={120,150,170,150,170,200,120,200}; HWND hwndChild; static POINT center,rectangleCenter; static int timerOn,figure,color; //figure =1 -square, =2 triangle, =3 circle; similar to color switch(message) { case WM_CREATE: center.x=320; center.y=200; for (i=0; i<4; i++) { rectangleCenter.x+=pts[i].x; rectangleCenter.y+=pts[i].y; } rectangleCenter.x/=4; rectangleCenter.y/=4; distance=computeDistance(rectangleCenter,center); timerOn=0; figure=0; color=0; CreateWindow(TEXT("button"), TEXT("Rotate"), WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, 10, 10, 100, 40, hwnd, (HMENU)0, ((LPCREATESTRUCT)lParam)->hInstance, NULL); CreateWindow(TEXT("button"), TEXT("Stop"), WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, 10, 60, 100, 40, hwnd, (HMENU)1, ((LPCREATESTRUCT)lParam)->hInstance, NULL); CreateWindow(TEXT("button"), TEXT("Sqare"), WS_CHILD|WS_VISIBLE|BS_RADIOBUTTON, 10, 110, 100, 40, hwnd, (HMENU)2, ((LPCREATESTRUCT)lParam)->hInstance, NULL); CreateWindow(TEXT("button"), TEXT("Triangle"), WS_CHILD|WS_VISIBLE|BS_RADIOBUTTON, 10, 150, 100, 40, hwnd, (HMENU)3, ((LPCREATESTRUCT)lParam)->hInstance, NULL); CreateWindow(TEXT("button"), TEXT("Circle"), WS_CHILD|WS_VISIBLE|BS_RADIOBUTTON, 10, 190, 100, 40, hwnd, (HMENU)4, ((LPCREATESTRUCT)lParam)->hInstance, NULL); CreateWindow(TEXT("button"), TEXT("Red"), WS_CHILD|WS_VISIBLE|BS_CHECKBOX|BS_AUTOCHECKBOX, 10, 250, 100, 40, hwnd, (HMENU)5, ((LPCREATESTRUCT)lParam)->hInstance, NULL); CreateWindow(TEXT("button"), TEXT("Green"), WS_CHILD|WS_VISIBLE|BS_CHECKBOX|BS_AUTOCHECKBOX, 10, 290, 100, 40, hwnd, (HMENU)6, ((LPCREATESTRUCT)lParam)->hInstance, NULL); CreateWindow(TEXT("button"), TEXT("Blue"), WS_CHILD|WS_VISIBLE|BS_CHECKBOX|BS_AUTOCHECKBOX, 10, 330, 100, 40, hwnd, (HMENU)7, ((LPCREATESTRUCT)lParam)->hInstance, NULL); return 0; case WM_COMMAND: switch(LOWORD(wParam)) { case 0: //Rotate timerOn=1; SetTimer(hwnd,1,100,NULL); //MessageBox(hwnd,TEXT("0"),NULL,NULL); break; case 1: //Stop if (timerOn) KillTimer(hwnd,1); timerOn=0; //MessageBox(hwnd,TEXT("1"),NULL,NULL); break; case 2: //Sqare figure=1; hwndChild=GetDlgItem(hwnd,3); SendMessage(hwndChild,BM_SETCHECK,0,0); hwndChild=GetDlgItem(hwnd,4); SendMessage(hwndChild,BM_SETCHECK,0,0); SendMessage((HWND)lParam,BM_SETCHECK,1,0); break; case 3: //Triangle figure=2; hwndChild=GetDlgItem(hwnd,2); SendMessage(hwndChild,BM_SETCHECK,0,0); hwndChild=GetDlgItem(hwnd,4); SendMessage(hwndChild,BM_SETCHECK,0,0); SendMessage((HWND)lParam,BM_SETCHECK,1,0); break; case 4://Circle figure=3; hwndChild=GetDlgItem(hwnd,3); SendMessage(hwndChild,BM_SETCHECK,0,0); hwndChild=GetDlgItem(hwnd,2); SendMessage(hwndChild,BM_SETCHECK,0,0); SendMessage((HWND)lParam,BM_SETCHECK,1,0); break; case 5://Red if (SendMessage((HWND)lParam,BM_GETCHECK,0,0)) { color=1; hwndChild=GetDlgItem(hwnd,6); EnableWindow(hwndChild,FALSE); hwndChild=GetDlgItem(hwnd,7); EnableWindow(hwndChild,FALSE); } else { color=0; hwndChild=GetDlgItem(hwnd,6); EnableWindow(hwndChild,TRUE); hwndChild=GetDlgItem(hwnd,7); EnableWindow(hwndChild,TRUE); } break; case 6://Green if (SendMessage((HWND)lParam,BM_GETCHECK,0,0)) { color=2; hwndChild=GetDlgItem(hwnd,5); EnableWindow(hwndChild,FALSE); hwndChild=GetDlgItem(hwnd,7); EnableWindow(hwndChild,FALSE); } else { color=0; hwndChild=GetDlgItem(hwnd,5); EnableWindow(hwndChild,TRUE); hwndChild=GetDlgItem(hwnd,7); EnableWindow(hwndChild,TRUE); } break; case 7://blue if (SendMessage((HWND)lParam,BM_GETCHECK,0,0)) { color=3; hwndChild=GetDlgItem(hwnd,6); EnableWindow(hwndChild,FALSE); hwndChild=GetDlgItem(hwnd,5); EnableWindow(hwndChild,FALSE); } else { color=0; hwndChild=GetDlgItem(hwnd,6); EnableWindow(hwndChild,TRUE); hwndChild=GetDlgItem(hwnd,5); EnableWindow(hwndChild,TRUE); } break; } SetRect(&rect,120,0,520,400); InvalidateRect(hwnd,&rect,TRUE); return 0; case WM_TIMER: rotatePoint(&rectangleCenter,0.15,center); pts[0].x=rectangleCenter.x-25; pts[0].y=rectangleCenter.y-25; pts[1].x=rectangleCenter.x+25; pts[1].y=pts[0].y; pts[2].x=pts[1].x; pts[2].y=rectangleCenter.y+25; pts[3].x=pts[0].x; pts[3].y=pts[2].y; SetRect(&rect,120,0,520,400); InvalidateRect(hwnd,&rect,TRUE); return 0; case WM_PAINT: hdc=BeginPaint(hwnd,&ps); hBrush=NULL; if (color==1) { hBrush=CreateSolidBrush(RGB(255,0,0)); } else if (color==2) { hBrush=CreateSolidBrush(RGB(0,255,0)); } else if (color==3) { hBrush=CreateSolidBrush(RGB(0,0,255)); } if (figure==1) { SelectObject(hdc,hBrush); Polygon(hdc,pts,4); } else if (figure==2) { POINT pts1[3]; pts1[0].x=(pts[0].x+pts[1].x)/2; pts1[0].y=pts[0].y; pts1[1]=pts[2]; pts1[2]=pts[3]; SelectObject(hdc,hBrush); Polygon(hdc,pts1,3); } else if(figure==3) { SelectObject(hdc,hBrush); Ellipse(hdc,pts[0].x,pts[0].y,pts[2].x,pts[2].y); } if (color!=0) DeleteObject(hBrush); EndPaint(hwnd,&ps); return 0; case WM_DESTROY: PostQuitMessage(0); return 0; } return DefWindowProc(hwnd,message,wParam,lParam); }
void CBlendingAnimationsView::OnAnimationStartslump() { SetTimer(3, 1, 0); KillTimer(2); KillTimer(1); }
LRESULT CMainDlg::OnSend(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { HWND hWndEmail = GetDlgItem(IDC_EMAIL); HWND hWndDesc = GetDlgItem(IDC_DESCRIPTION); int nEmailLen = ::GetWindowTextLength(hWndEmail); int nDescLen = ::GetWindowTextLength(hWndDesc); LPTSTR lpStr = m_sEmailFrom.GetBufferSetLength(nEmailLen+1); ::GetWindowText(hWndEmail, lpStr, nEmailLen+1); m_sEmailFrom.ReleaseBuffer(); lpStr = m_sDescription.GetBufferSetLength(nDescLen+1); ::GetWindowText(hWndDesc, lpStr, nDescLen+1); m_sDescription.ReleaseBuffer(); // // If an email address was entered, verify that // it [1] contains a @ and [2] the last . comes // after the @. // if (m_sEmailFrom.GetLength() && (m_sEmailFrom.Find(_T('@')) < 0 || m_sEmailFrom.ReverseFind(_T('.')) < m_sEmailFrom.Find(_T('@')))) { DWORD dwFlags = 0; CString sRTL = Utility::GetINIString(_T("Settings"), _T("RTLReading")); if(sRTL.CompareNoCase(_T("1"))==0) dwFlags = MB_RTLREADING; // alert user MessageBox( Utility::GetINIString(_T("MainDlg"), _T("InvalidEmailText")), Utility::GetINIString(_T("MainDlg"), _T("InvalidEmailCaption")), MB_OK|dwFlags); // select email ::SetFocus(hWndEmail); return 0; } // Write user email and problem description to XML AddUserInfoToCrashDescriptorXML(m_sEmailFrom, m_sDescription); m_ctx.m_sAppName = m_sAppName; m_ctx.m_sAppVersion = m_sAppVersion; m_ctx.m_sZipName = m_sZipName; m_ctx.m_sEmailTo = m_sEmailTo; m_ctx.m_sEmailFrom = m_sEmailFrom; m_ctx.m_sEmailSubject = m_sEmailSubject; m_ctx.m_sEmailText = m_sDescription; m_ctx.m_sUrl = m_sUrl; memcpy(&m_ctx.m_uPriorities, &m_uPriorities, 3*sizeof(UINT)); DWORD dwThreadId = 0; m_hSenderThread = CreateThread(NULL, 0, SenderThread, (LPVOID)&m_ctx, NULL, &dwThreadId); ShowWindow(SW_HIDE); CreateTrayIcon(true, m_hWnd); m_dlgProgress.m_pctx = &m_ctx; m_dlgProgress.Start(); SetTimer(0, 500); return 0; }
static void CALLBACK sttMainThreadCallback(PVOID) { if (timerId == 0xffffffff) timerId = SetTimer(NULL, 0, 10000, (TIMERPROC)timerProc); }
//--------------------------------------------------------------------------------------- // WinMain is like main() in C programs, just for Windows apps. //--------------------------------------------------------------------------------------- int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASSEX clas; MSG msg; int style; RECT rect; //Here we create the Class we named above clas.cbSize = sizeof(WNDCLASSEX); clas.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; clas.lpfnWndProc = WindowProc;//<- tell it where the WindowProc is clas.cbClsExtra = 0; clas.cbWndExtra = 0; clas.hInstance = hInstance; clas.hIcon = NULL; clas.hCursor = NULL; clas.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);//<- background colour of window clas.lpszMenuName = NULL; clas.lpszClassName = game_class;//<- the class name clas.hIconSm = 0; //do it! RegisterClassEx(&clas); //style of the window - what boxes do we need (close minimised etc) style = WS_CAPTION|WS_SYSMENU|WS_MAXIMIZEBOX|WS_MINIMIZEBOX; //create the window game_window = CreateWindowEx(0, game_class, "DirectInput", style, CW_USEDEFAULT, CW_USEDEFAULT, 1,1, NULL, NULL, hInstance, 0); //adjust the window size so that a SCREEN_X x SCREEN_Y window will fit inside its frame rect.left = rect.top = 0; rect.right = SCREEN_X; rect.bottom = SCREEN_Y; AdjustWindowRectEx(&rect, style , FALSE, 0); SetWindowPos(game_window, NULL, 0,0, rect.right - rect.left, rect.bottom - rect.top, SWP_NOMOVE|SWP_NOZORDER); //show the window on the desktop ShowWindow(game_window, nCmdShow); if (init_dinput(hInstance) == 0) { MessageBox(NULL, "A problem occurred creating DirectInput.\nCheck your DirectX version.\n" "This demo requires DirectX9.0 or better.", "DirectX Initialisation Error", MB_ICONWARNING|MB_OK); shutdown_dinput(); return 0; } // Create a timer to refresh the window SetTimer(game_window, 1, 1000/30, NULL); //message processing loop //all Windows programs have one of these. It receives the messages Windows sends to the program and //passes them to the WindowProc in the Class we registered for the window. quit = 0; do { //Are there any messages waiting? while (GetMessage(&msg, game_window, 0,0) > 0 && !quit) { //pass the message to WindowProc TranslateMessage(&msg); DispatchMessage(&msg); } } while (!quit); // Close everything down KillTimer(game_window, 1); shutdown_dinput(); return 0; }
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { node *current = NULL; node *nodes; unsigned short tag; switch (msg) { case WM_CREATE: if (experimental_mouse) { SetTimer(hwnd, TIMER_UPDATE_MOUSE, 500, NULL); // Poll for mouse position } break; case WM_CLOSE: { ClipCursor(0); // Release Cursor Lock DeregisterShellHookWindow(hwnd); UnregisterHotkeys(hwnd); if (experimental_mouse) { KillTimer(hwnd, TIMER_UPDATE_MOUSE); // Mouse Poll Timer } for (tag=0; tag<TAGS; tag++) { nodes = tags[tag].nodes; for (current = nodes; current;) { node *next = current->next; RestoreWindow(current->hwnd); RemoveNode(current->hwnd, tag); current = next; } DestroyWindow(hwnd); } } break; case WM_DESTROY: PostQuitMessage(WM_QUIT); break; case WM_HOTKEY: if (wParam >= KEY_TOGGLE_T1 && wParam < (KEY_TOGGLE_T1 + TAGS)) { ToggleTag(wParam - KEY_TOGGLE_T1); break; } else if (wParam >= KEY_SWITCH_T1 && wParam < (KEY_SWITCH_T1 + TAGS)) { MinimizeTag(current_tag); current_tag = wParam - KEY_SWITCH_T1; ArrangeWindows(); break; } current = tags[current_tag].current_window; switch (wParam) { case KEY_SELECT_UP: if (current) { tags[current_tag].current_window = GetNextNode(); FocusCurrent(); } break; case KEY_SELECT_DOWN: if (current) { tags[current_tag].current_window = GetPreviousNode(); FocusCurrent(); } break; case KEY_MOVE_MAIN: SwapWindowWithNode(tags[current_tag].nodes); ArrangeWindows(); break; case KEY_EXIT: PostMessage(hwnd, WM_CLOSE, 0, 0); break; case KEY_MARGIN_LEFT: margin -= 20; ArrangeWindows(); break; case KEY_MARGIN_RIGHT: margin += 20; ArrangeWindows(); break; case KEY_IGNORE: if (!disableNext) { disableNext = 1; } else { disableNext = 0; } break; case KEY_MOUSE_LOCK: if (lockMouse) { lockMouse = 0; ClipCursor(0); } else { lockMouse = 1; FocusCurrent(); } break; case KEY_TILING_MODE: tags[current_tag].tilingMode = (tags[current_tag].tilingMode + 1) % 3; ArrangeWindows(); break; case KEY_MOVE_UP: if (current) { SwapWindowWithNode(GetNextNode()); ArrangeWindows(); } break; case KEY_MOVE_DOWN: if (current) { SwapWindowWithNode(GetPreviousNode()); ArrangeWindows(); } break; case KEY_DISP_CLASS: { LPSTR temp = (LPSTR)malloc(sizeof(TCHAR) * 128); GetClassName(GetForegroundWindow(), temp, 128); MessageBox(NULL, temp, "Window Class", MB_OK); free(temp); } break; case KEY_TILE: if (IsGoodWindow(GetForegroundWindow())) { AddNode(GetForegroundWindow(), current_tag); ArrangeWindows(); } break; case KEY_UNTILE: FullRemoveNode(GetForegroundWindow()); ArrangeWindows(); break; case KEY_INC_AREA: tags[current_tag].masterarea_count++; ArrangeWindows(); break; case KEY_DEC_AREA: tags[current_tag].masterarea_count--; ArrangeWindows(); break; case KEY_CLOSE_WIN: PostMessage(GetForegroundWindow(), WM_CLOSE, 0, 0); break; } break; case WM_TIMER: switch (wParam) { case TIMER_UPDATE_MOUSE: UpdateMousePos(hwnd); break; } break; default: if (msg == shellhookid) { // Handle the Shell Hook message switch (wParam) { case HSHELL_WINDOWCREATED: if (IsGoodWindow((HWND)lParam)) { AddNode((HWND)lParam, current_tag); ArrangeWindows(); FocusCurrent(); } break; case HSHELL_WINDOWDESTROYED: FullRemoveNode((HWND)lParam); ArrangeWindows(); FocusCurrent(); break; case HSHELL_WINDOWACTIVATED: { node *found = FindNode((HWND)lParam, current_tag); if (found) { tags[current_tag].current_window = current = found; FocusCurrent(); } } break; } } else { return DefWindowProc(hwnd, msg, wParam, lParam); } } return 0; }
void CBeautifulCanlendarYearCombox::BeginRollBack() { m_isDec = 1; SetTimer(201,1,NULL); }
// static LRESULT CALLBACK IGraphicsWin::WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { if (msg == WM_CREATE) { LPCREATESTRUCT lpcs = (LPCREATESTRUCT) lParam; SetWindowLongPtr(hWnd, GWLP_USERDATA, (LPARAM) (lpcs->lpCreateParams)); int mSec = int(1000.0 / sFPS); SetTimer(hWnd, IPLUG_TIMER_ID, mSec, NULL); SetFocus(hWnd); // gets scroll wheel working straight away return 0; } IGraphicsWin* pGraphics = (IGraphicsWin*) GetWindowLongPtr(hWnd, GWLP_USERDATA); char txt[MAX_PARAM_LEN]; double v; if (!pGraphics || hWnd != pGraphics->mPlugWnd) { return DefWindowProc(hWnd, msg, wParam, lParam); } if (pGraphics->mParamEditWnd && pGraphics->mParamEditMsg == kEditing) { if (msg == WM_RBUTTONDOWN || (msg == WM_LBUTTONDOWN)) { pGraphics->mParamEditMsg = kCancel; return 0; } return DefWindowProc(hWnd, msg, wParam, lParam); } switch (msg) { case WM_TIMER: { if (wParam == IPLUG_TIMER_ID) { if (pGraphics->mParamEditWnd && pGraphics->mParamEditMsg != kNone) { switch (pGraphics->mParamEditMsg) { //case kUpdate: { //pGraphics->mEdParam->GetDisplayForHost(txt); //SendMessage(pGraphics->mParamEditWnd, WM_GETTEXT, 0, (LPARAM) txt); //char currentText[MAX_PARAM_LEN]; //SendMessage(pGraphics->mParamEditWnd, WM_GETTEXT, MAX_PARAM_LEN, (LPARAM) currentText); //if (strcmp(txt, currentText)) //{ // if (pGraphics->mEdParam->GetNDisplayTexts()) // SendMessage(pGraphics->mParamEditWnd, CB_SELECTSTRING, -1, (LPARAM) txt); // else // SendMessage(pGraphics->mParamEditWnd, WM_SETTEXT, 0, (LPARAM) txt); //} // break; //} case kCommit: { SendMessage(pGraphics->mParamEditWnd, WM_GETTEXT, MAX_PARAM_LEN, (LPARAM) txt); if(pGraphics->mEdParam){ IParam::EParamType type = pGraphics->mEdParam->Type(); if ( type == IParam::kTypeEnum || type == IParam::kTypeBool){ int vi = 0; pGraphics->mEdParam->MapDisplayText(txt, &vi); v = (double) vi; } else { v = atof(txt); if (pGraphics->mEdParam->DisplayIsNegated()) { v = -v; } } pGraphics->mEdControl->SetValueFromUserInput(pGraphics->mEdParam->GetNormalized(v)); } else { pGraphics->mEdControl->TextFromTextEntry(txt); } // Fall through. } case kCancel: { SetWindowLongPtr(pGraphics->mParamEditWnd, GWLP_WNDPROC, (LPARAM) pGraphics->mDefEditProc); DestroyWindow(pGraphics->mParamEditWnd); pGraphics->mParamEditWnd = 0; pGraphics->mEdParam = 0; pGraphics->mEdControl = 0; pGraphics->mDefEditProc = 0; } break; } pGraphics->mParamEditMsg = kNone; return 0; // TODO: check this! } IRECT dirtyR; if (pGraphics->IsDirty(&dirtyR)) { RECT r = { dirtyR.L, dirtyR.T, dirtyR.R, dirtyR.B }; InvalidateRect(hWnd, &r, FALSE); if (pGraphics->mParamEditWnd) { IRECT* notDirtyR = pGraphics->mEdControl->GetRECT(); RECT r2 = { notDirtyR->L, notDirtyR->T, notDirtyR->R, notDirtyR->B }; ValidateRect(hWnd, &r2); // make sure we dont redraw the edit box area UpdateWindow(hWnd); pGraphics->mParamEditMsg = kUpdate; } else UpdateWindow(hWnd); } } return 0; } case WM_RBUTTONDOWN: case WM_LBUTTONDOWN: case WM_MBUTTONDOWN: if (pGraphics->mParamEditWnd) { SetWindowLongPtr(pGraphics->mParamEditWnd, GWLP_WNDPROC, (LPARAM) pGraphics->mDefEditProc); DestroyWindow(pGraphics->mParamEditWnd); pGraphics->mParamEditWnd = 0; pGraphics->mEdParam = 0; pGraphics->mEdControl = 0; pGraphics->mDefEditProc = 0; pGraphics->mParamEditMsg = kNone; //force full redraw when closing text entry RECT r = { 0, 0, pGraphics->Width(), pGraphics->Height() }; InvalidateRect(hWnd, &r, FALSE); UpdateWindow(hWnd); } SetFocus(hWnd); // Added to get keyboard focus again when user clicks in window SetCapture(hWnd); #ifdef RTAS_API // pass ctrl-start-alt-click or ctrl-start-click to host window (Pro Tools) if ((IsControlKeyDown() && IsOptionKeyDown() && IsCommandKeyDown() ) || (IsControlKeyDown() && IsCommandKeyDown())) { HWND rootHWnd = GetAncestor( hWnd, GA_ROOT); union point{ long lp; struct { short x; short y; }s; } mousePoint; // Get global coordinates of local window RECT childRect; GetWindowRect(hWnd, &childRect); // Convert global coords to parent window coords POINT p; p.x = childRect.left; p.y = childRect.top; ScreenToClient(rootHWnd, &p); // offset the local click-event coordinates to the parent window's values mousePoint.lp = lParam; mousePoint.s.x += p.x; mousePoint.s.y += p.y; if( pGraphics->GetParamIdxForPTAutomation(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)) > -1) { // Send converted coords to parent window's event handler for regular processing LRESULT result = SendMessage(rootHWnd, msg, wParam, mousePoint.lp); } return 0; } #endif pGraphics->OnMouseDown(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), &GetMouseMod(wParam)); return 0; case WM_MOUSEMOVE: { if (!(wParam & (MK_LBUTTON | MK_RBUTTON))) { if (pGraphics->OnMouseOver(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), &GetMouseMod(wParam))) { TRACKMOUSEEVENT eventTrack = { sizeof(TRACKMOUSEEVENT), TME_LEAVE, hWnd, HOVER_DEFAULT }; TrackMouseEvent(&eventTrack); } } else if (GetCapture() == hWnd && !pGraphics->mParamEditWnd) { pGraphics->OnMouseDrag(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), &GetMouseMod(wParam)); } return 0; } case WM_MOUSELEAVE: { pGraphics->OnMouseOut(); return 0; } case WM_LBUTTONUP: case WM_RBUTTONUP: { ReleaseCapture(); pGraphics->OnMouseUp(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), &GetMouseMod(wParam)); return 0; } case WM_LBUTTONDBLCLK: { if (pGraphics->OnMouseDblClick(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), &GetMouseMod(wParam))) { SetCapture(hWnd); } return 0; } case WM_MOUSEWHEEL: { if (pGraphics->mParamEditWnd) { pGraphics->mParamEditMsg = kCancel; return 0; } else { int d = GET_WHEEL_DELTA_WPARAM(wParam) / WHEEL_DELTA; int x = GET_X_LPARAM(lParam), y = GET_Y_LPARAM(lParam); RECT r; GetWindowRect(hWnd, &r); pGraphics->OnMouseWheel(x - r.left, y - r.top, &GetMouseMod(wParam), d); return 0; } } case WM_KEYDOWN: { bool handle = true; int key; if (wParam == VK_SPACE) key = KEY_SPACE; else if (wParam == VK_UP) key = KEY_UPARROW; else if (wParam == VK_DOWN) key = KEY_DOWNARROW; else if (wParam == VK_LEFT) key = KEY_LEFTARROW; else if (wParam == VK_RIGHT) key = KEY_RIGHTARROW; else if (wParam >= '0' && wParam <= '9') key = KEY_DIGIT_0+wParam-'0'; else if (wParam >= 'A' && wParam <= 'Z') key = KEY_ALPHA_A+wParam-'A'; else if (wParam >= 'a' && wParam <= 'z') key = KEY_ALPHA_A+wParam-'a'; else handle = false; if (handle) { POINT p; GetCursorPos(&p); ScreenToClient(hWnd, &p); handle = pGraphics->OnKeyDown(p.x, p.y, key); } if (!handle) { #ifdef RTAS_API HWND rootHWnd = GetAncestor( hWnd, GA_ROOT); SendMessage(rootHWnd, WM_KEYDOWN, wParam, lParam); #endif return DefWindowProc(hWnd, msg, wParam, lParam); } else return 0; } case WM_PAINT: { RECT r; if (GetUpdateRect(hWnd, &r, FALSE)) { IRECT ir(r.left, r.top, r.right, r.bottom); pGraphics->Draw(&ir); } return 0; } /* case WM_CTLCOLOREDIT: { // An edit control just opened. HDC dc = (HDC) wParam; SetBkColor (dc, RGB(0, 0, 0)); SetTextColor(dc, RGB(255, 255, 255)); SetBkMode(dc,OPAQUE); //SetDCBrushColor(dc, RGB(255, 0, 0)); return (BOOL)GetStockObject(DC_BRUSH); //return 0; } */ case WM_CLOSE: { pGraphics->CloseWindow(); return 0; } #ifdef RTAS_API case WM_MEASUREITEM : { HWND rootHWnd = GetAncestor( hWnd, GA_ROOT ); LRESULT result = SendMessage(rootHWnd, msg, wParam, lParam); return result; } case WM_DRAWITEM : { HWND rootHWnd = GetAncestor( hWnd, GA_ROOT ); LRESULT result = SendMessage(rootHWnd, msg, wParam, lParam); return result; } #endif case WM_SETFOCUS: { return 0; } case WM_KILLFOCUS: { return 0; } } return DefWindowProc(hWnd, msg, wParam, lParam); }