void Display::showFlash() { //flash for 3 times FlashWindow(TRUE); Sleep(200); FlashWindow(TRUE); }
// This is a WINDOWS dedicated function // LATER: This function doesn't work as expected, it won't "blink" on and off, and I cann't find a solution yet void EngineApp::FlashWhileMinimized( void ) { #if !defined( _WINDOWS ) && !defined( WINDOWS ) return; #endif if( !m_pWindow ) { return; } HWND hwnd = GetHwnd(); ENG_ASSERT( hwnd ); // If the window is minized if( GetWindowState() & SDL_WINDOW_MINIMIZED ) { GetGlobalTimer()->GetElapsedTime(); float totalTime = 0.f; SDL_Event event; FlashWindow( hwnd, true ); while( true ) { SDL_PumpEvents(); if( SDL_PeepEvents( &event, 1, SDL_PEEKEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT ) > 0 ) { // wait for processing if close or other window event is called if( event.type != SDL_WINDOWEVENT || event.type != SDL_QUIT ) { MsgProc(); } // Not minimized anymore, flash for once and break if( !( GetWindowState() & SDL_WINDOW_MINIMIZED ) ) { FlashWindow( GetHwnd(), false ); break; } } else // The window has no upcoming message, keep flashing { totalTime += GetGlobalTimer()->GetElapsedTime(); if( totalTime > 1.0f ) { totalTime -= 1.0f; FlashWindow( GetHwnd(), true ); } } } } }
static void gwbeep (GUIWIN *gw) { GUI_WINDOW *gwp = (GUI_WINDOW *)gw; if (o_flash && gw != (GUIWIN *)1) { FlashWindow(gwp->frameHWnd, TRUE); Sleep(100); FlashWindow(gwp->frameHWnd, FALSE); } else MessageBeep (MB_OK); }
unsigned __stdcall CDialogPackage::PackagerThreadProc(void* pParam) { CDialogPackage* dialog = (CDialogPackage*)pParam; if (dialog->CreatePackage()) { // Stop the progress bar HWND item = GetDlgItem(dialog->m_TabOptions.GetWindow(), IDC_INSTALLTAB_CREATING_BAR); SendMessage(item, PBM_SETMARQUEE, (WPARAM)FALSE, 0); FlashWindow(dialog->m_Window, TRUE); std::wstring message = L"The skin package has been successfully created."; message += L"\n\nClick OK to close Packager."; MessageBox(c_Dialog->GetWindow(), message.c_str(), L"Rainmeter Skin Packager", MB_OK | MB_ICONINFORMATION); } else { DeleteFile(dialog->m_TargetFile.c_str()); } EndDialog(dialog->m_Window, 0); return 0; }
/** Creates a tray baloon popup with the message, and flashes the main window * * accepts: char *title, title length, char *msg, msg length; * returns void; */ void notify(char *title, uint16_t title_length, const char *msg, uint16_t msg_length, void *UNUSED(object), bool UNUSED(is_group)) { if (have_focus || self.status == 2) { return; } FlashWindow(main_window.window, true); flashing = true; NOTIFYICONDATAW nid = { .cbSize = sizeof(nid), .hWnd = main_window.window, .uFlags = NIF_ICON | NIF_INFO, .hIcon = unread_messages_icon, .uTimeout = 5000, .dwInfoFlags = 0, }; uint16_t title_len = safe_shrink(title, title_length, MAX_TITLE_LENGTH); utf8tonative(title, nid.szInfoTitle, title_len); uint16_t msg_len = safe_shrink(msg, msg_length, MAX_MSG_LENGTH); utf8tonative(msg, nid.szInfo, msg_len); Shell_NotifyIconW(NIM_MODIFY, &nid); } static void redraw_notify(UTOX_WINDOW *win) { LOG_TRACE("Notify", "redraw start"); native_window_set_target(win); panel_draw(win->_.panel, 0, 0, win->_.w, win->_.h); SelectObject(win->draw_DC, win->draw_BM); BitBlt(win->window_DC, win->_.x, win->_.y, win->_.w, win->_.h, win->draw_DC, win->_.x, win->_.y, SRCCOPY); LOG_TRACE("Notify", "redraw end"); }
JNIEXPORT void JNICALL Java_org_jivesoftware_spark_plugin_flashing_FlashWindow_flash(JNIEnv * env, jobject obj, jstring windowTitle, jboolean flash) { const wchar_t * utf16 = (wchar_t *)env->GetStringChars(windowTitle, NULL); HWND hwnd = FindWindowW(NULL, utf16); env->ReleaseStringChars(windowTitle, (jchar*)utf16); FlashWindow(hwnd, flash); }
// // FlashButton() // // used to temporarily flash a button's border // void CBidDialogSmall::FlashButton(int nBid) { // CWnd *pWnd1 = NULL, *pWnd2 = NULL; // if (ISBID(nBid)) { int nLevel = BID_LEVEL(nBid); int nSuit = BID_SUIT(nBid); pWnd1 = GetDlgItem(IDC_BID_LEVEL_1 + nLevel - 1); pWnd2 = GetDlgItem(IDC_SUIT_CLUBS + nSuit); } else if (nBid == BID_PASS) pWnd1 = GetDlgItem(IDC_BID_PASS); else if (nBid == BID_DOUBLE) pWnd1 = GetDlgItem(IDC_BID_DOUBLE); else if (nBid == BID_REDOUBLE) pWnd1 = GetDlgItem(IDC_BID_REDOUBLE); // if (pWnd1 == NULL) return; // FlashWindow(pWnd1, pWnd2); }
static LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_COMMAND: if (HIWORD(wParam) == STN_CLICKED) { SESSION_INFO *si = (SESSION_INFO*)PUGetPluginData(hWnd); CallFunctionAsync(ShowRoomFromPopup, si); PUDeletePopup(hWnd); return TRUE; } break; case WM_CONTEXTMENU: SESSION_INFO *si = (SESSION_INFO*)PUGetPluginData(hWnd); if (si->hContact) if (CallService(MS_CLIST_GETEVENT, (WPARAM)si->hContact, 0)) CallService(MS_CLIST_REMOVEEVENT, (WPARAM)si->hContact, (LPARAM)GC_FAKE_EVENT); if (si->hWnd && KillTimer(si->hWnd, TIMERID_FLASHWND)) FlashWindow(si->hWnd, FALSE); PUDeletePopup(hWnd); break; } return DefWindowProc(hWnd, message, wParam, lParam); }
LRESULT CErrorReportDlg::OnCompleteCollectCrashInfo(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { // This method is called when the worker thread has finished with collection // of crash report data. Now we display the "Error Report" dialog // and offer user to send error report. CErrorReportSender* pSender = CErrorReportSender::GetInstance(); if(pSender->GetCrashInfo()->m_bSendErrorReport) // If we should send error report now { // Get the total size of the report. LONG64 lTotalSize = pSender->GetCrashInfo()->GetReport(0)->GetTotalSize(); CString sTotalSize = Utility::FileSizeToStr(lTotalSize); // Format the text for dialog subheader. CString sSubHeader; sSubHeader.Format(pSender->GetLangStr(_T("MainDlg"), _T("SubHeaderText")), sTotalSize); // Update the subheader text m_statSubHeader.SetWindowText(sSubHeader); // Show "Error Report" dialog ShowWindow(SW_SHOW); SetWindowPos(HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_SHOWWINDOW); // Make it flash FlashWindow(TRUE); } else // If we shouldn't send error report now. { // Exit the app. SendMessage(WM_CLOSE); } return 0; }
/* * Arguments: window_handle (number) * Returns: boolean */ static int plsql_FlashWindow (lua_State *L) { const HWND hwnd = (HWND) luaL_checkinteger(L, 1); lua_pushboolean(L, FlashWindow(hwnd, 1)); return 1; }
void WFlashWindow(HWND fWinHandle) { #ifdef BUILD_WIN98 // flash our window FLASHWINFO finf; finf.cbSize = sizeof(finf); finf.hwnd = fWinHandle; finf.dwFlags = FLASHW_ALL; finf.uCount = 3; finf.dwTimeout = 400; FlashWindowEx(&finf); #elif (WINVER < 0x0500) FlashWindow(fWinHandle,true); #else FlashWindow(fWinHandle,FLASHW_ALL); #endif // BUILD_WIN98 }
void SRenderDocPluginAboutWindow::Construct(const FArguments& InArgs) { FString Message = FString( "Hello and thank you for trying out the RenderDoc plugin!\n\n" \ "To capture a frame, press the green capture button on the top\n" \ "right of any viewport. If you cannot see the button, you might\n" \ "have to adjust your viewport width until all buttons fit the screen.\n" \ "You can also use the assigned hotkey (default is Alt+F12).\n\n" \ "For best performance I recommend using the experimental\n" \ "AutoCompileShaders branch in the repository and downloading\n" \ "my fork of the engine so you are able to include shader meta\n" \ "data in your compiled shaders.This will make it easier to step\n" \ "through your shader code in the UI as you will be able to see \n" \ "your variable names etc.\n\n" \ "If you have any questions or suggestions I'll try to answer them \n" \ "as best I can at:\ntemaran(at) gmail(dot) com.\n\n" \ "You can find my fork and updates to the plugins at these github repos:\n" \ "https://github.com/Temaran/UE4RenderDocPlugin\n" \ "https://github.com/Temaran/UnrealEngine (RenderDocPluginChanges)"); SWindow::Construct(SWindow::FArguments() .SupportsMaximize(false) .SupportsMinimize(false) .IsPopupWindow(false) .CreateTitleBar(false) .SizingRule(ESizingRule::FixedSize) .SupportsTransparency(EWindowTransparency::None) .InitialOpacity(1.0f) .FocusWhenFirstShown(true) .bDragAnywhere(false) .ActivateWhenFirstShown(true) .ClientSize(FVector2D(400, 400)) .ScreenPosition(FVector2D((float)(GEditor->GetActiveViewport()->GetSizeXY().X) / 2.0, (float)(GEditor->GetActiveViewport()->GetSizeXY().Y) / 2.0)) [ SNew(SVerticalBox) + SVerticalBox::Slot() .FillHeight(0.9f) .Padding(5) [ SNew(STextBlock) .Text(FText::FromString(Message)) ] + SVerticalBox::Slot() .FillHeight(0.1f) [ SNew(SButton) .VAlign(VAlign_Center) .OnClicked(this, &SRenderDocPluginAboutWindow::Close) .Text(LOCTEXT("OkButton", "Ok")) ] ]); bIsTopmostWindow = true; FlashWindow(); }
static void hugsprim_FlashWindow_27(HugsStackPtr hugs_root) { HsPtr arg1; HsBool arg2; HsBool res1; arg1 = hugs->getPtr(); arg2 = hugs->getBool(); res1 = FlashWindow(arg1, arg2); hugs->putBool(res1); hugs->returnIO(hugs_root,1); }
static void TSAPI Chat_DismissPopup(const SESSION_INFO *si, HWND hwndPopup) { if (si->hContact) if (CallService(MS_CLIST_GETEVENT, (WPARAM)si->hContact, 0)) CallService(MS_CLIST_REMOVEEVENT, (WPARAM)si->hContact, (LPARAM)GC_FAKE_EVENT); if (si->hWnd && KillTimer(si->hWnd, TIMERID_FLASHWND)) FlashWindow(si->hWnd, FALSE); PUDeletePopup(hwndPopup); }
static int lua_flash_window(lua_State *L) { extern HWND ghmainframe; int result=0; int count=lua_gettop(L); if(count>=1){ unsigned int i,count; count=lua_tounsigned(L,1); if(count>5) count=5; for(i=0;i<count;i++){ FlashWindow(ghmainframe,1); Sleep(500); FlashWindow(ghmainframe,0); Sleep(500); } result=1; } lua_pushinteger(L,result); return 1; }
/** * Notifies the user that maybe he should have a look. */ void flashWindow() { #ifdef _WIN32 SDL_SysWMinfo wminfo; SDL_VERSION(&wminfo.version) if (SDL_GetWMInfo(&wminfo)) { HWND hwnd = wminfo.window; FlashWindow(hwnd, true); } #endif }
void BufferTimeList::FlashCaption(vector<TCHAR *> messages) { // save TCHAR title[1024]; GetWindowText(_hwnd, title, 1024); for (int idx = 0; idx < messages.size(); idx++) { int count = 10; while (--count >= 0) { SetWindowText(_hwnd, messages[idx]); FlashWindow(_hwnd, TRUE); Sleep(500); } delete [] messages[idx]; } // restore SetWindowText(_hwnd, title); FlashWindow(_hwnd, FALSE); }
void CProgressDlg::Start() { // center the dialog on the screen CenterWindow(); ShowWindow(SW_SHOW); SetWindowPos(HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE); FlashWindow(FALSE); SetTimer(1, 3000); SetTimer(0, 200); m_bFinished = FALSE; }
void VID_NotifyActivity(void) { #ifdef _WIN32 SDL_SysWMinfo info; SDL_VERSION(&info.version); if (ActiveApp || !vid_flashonactivity.value) return; if (SDL_GetWindowWMInfo(sdl_window, &info) == SDL_TRUE) { if (info.subsystem == SDL_SYSWM_WINDOWS) FlashWindow(info.info.win.window, TRUE); } else Com_DPrintf("Sys_NotifyActivity: SDL_GetWindowWMInfo failed: %s\n", SDL_GetError()); #endif }
/// 接收文本消息 void CChatRoomServerDlg::ReceiveText( CHATROOMMESSAGEINFO CRMInfo, char *pData, DWORD dwTextLength ) { pData[ dwTextLength ] = 0; for( int nIndex = 1; nIndex < m_arrFriendsInChat.GetSize(); nIndex++ ) { USER userSrc = m_arrFriendsInChat.GetAt( nIndex ); if( 0 == strcmp( userSrc.strIP, CRMInfo.szSrcIP ) ) { CString strText; strText.Format( "%s(%s) %s\r\n %s\r\n\r\n", userSrc.strName, userSrc.strIP, CRMInfo.szTime, pData ); CString strReceiveText; m_editReceived.GetWindowText( strReceiveText ); m_editReceived.SetWindowText( strReceiveText + strText ); m_editReceived.LineScroll( m_editReceived.GetLineCount() ); FlashWindow( TRUE ); CString strSend( pData ); /// 向所有客户端发送消息 for( int nIndex1 = 1; nIndex1 < m_arrFriendsInChat.GetSize(); nIndex1++ ) { USER userSend = m_arrFriendsInChat.GetAt( nIndex1 ); if( 0 == strcmp( userSrc.strIP, userSend.strIP ) ) { continue; } SendTextToIP( userSend.strIP, CHATROOM_CLIENT_PORT, strSend, userSrc.strIP ); } break; } } }
void SendRestartMessage (char *WindowClass, char *Title) { HWND hPrevWnd = FindWindow(WindowClass, Title); if (!hPrevWnd) return; // Command line argument를 hPrevWnd 윈도우로 전송한다. char *cmd = GetCommandLine(); int n_cmd = strlen(cmd)+1; char *buff = (char *)::HeapAlloc(::GetProcessHeap(), HEAP_ZERO_MEMORY, n_cmd); strcpy (buff, cmd); COPYDATASTRUCT tip; tip.dwData = 0; tip.cbData = n_cmd; tip.lpData = buff; SendMessage (hPrevWnd, WM_COPYDATA, (WPARAM)NULL, (LPARAM)&tip); ::HeapFree(::GetProcessHeap(), 0, buff); PostMessage (hPrevWnd, WM_RESTART, 0, 0); FlashWindow (hPrevWnd, TRUE); }
INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { FileDlgData *dat = (FileDlgData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); { TCHAR szPath[450]; CLISTEVENT* cle = (CLISTEVENT*)lParam; dat = (FileDlgData*)mir_calloc(sizeof(FileDlgData)); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat); dat->hContact = cle->hContact; dat->hDbEvent = cle->hDbEvent; dat->hNotifyEvent = HookEventMessage(ME_PROTO_ACK, hwndDlg, HM_RECVEVENT); dat->hPreshutdownEvent = HookEventMessage(ME_SYSTEM_PRESHUTDOWN, hwndDlg, M_PRESHUTDOWN); dat->dwTicks = GetTickCount(); EnumChildWindows(hwndDlg, ClipSiblingsChildEnumProc, 0); Window_SetSkinIcon_IcoLib(hwndDlg, SKINICON_EVENT_FILE); 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")); TCHAR *contactName = pcli->pfnGetContactDisplayName(dat->hContact, 0); SetDlgItemText(hwndDlg, IDC_FROM, contactName); GetContactReceivedFilesDir(dat->hContact, szPath, _countof(szPath), TRUE); SetDlgItemText(hwndDlg, IDC_FILEDIR, szPath); SHAutoComplete(GetWindow(GetDlgItem(hwndDlg, IDC_FILEDIR), GW_CHILD), 1); for (int i = 0; i < MAX_MRU_DIRS; i++) { char idstr[32]; mir_snprintf(idstr, "MruDir%d", i); DBVARIANT dbv; if (db_get_ts(NULL, "SRFile", idstr, &dbv)) break; SendDlgItemMessage(hwndDlg, IDC_FILEDIR, CB_ADDSTRING, 0, (LPARAM)dbv.ptszVal); db_free(&dbv); } db_event_markRead(dat->hContact, dat->hDbEvent); DBEVENTINFO dbei = { sizeof(dbei) }; dbei.cbBlob = db_event_getBlobSize(dat->hDbEvent); if (dbei.cbBlob > 4 && dbei.cbBlob <= 8196) { dbei.pBlob = (PBYTE)alloca(dbei.cbBlob + 1); db_event_get(dat->hDbEvent, &dbei); dbei.pBlob[dbei.cbBlob] = 0; dat->fs = cle->lParam ? (HANDLE)cle->lParam : (HANDLE)*(PDWORD)dbei.pBlob; char *str = (char*)dbei.pBlob + 4; ptrT ptszFileName(DbGetEventStringT(&dbei, str)); SetDlgItemText(hwndDlg, IDC_FILENAMES, ptszFileName); unsigned len = (unsigned)mir_strlen(str) + 1; if (len + 4 < dbei.cbBlob) { str += len; ptrT ptszDescription(DbGetEventStringT(&dbei, str)); SetDlgItemText(hwndDlg, IDC_MSG, ptszDescription); } } else DestroyWindow(hwndDlg); TCHAR datetimestr[64]; TimeZone_PrintTimeStamp(NULL, dbei.timestamp, _T("t d"), datetimestr, _countof(datetimestr), 0); SetDlgItemText(hwndDlg, IDC_DATE, datetimestr); ptrT info(Contact_GetInfo(CNF_UNIQUEID, dat->hContact)); SetDlgItemText(hwndDlg, IDC_NAME, (info) ? info : contactName); if (db_get_b(dat->hContact, "CList", "NotOnList", 0)) { RECT rcBtn1, rcBtn2, rcDateCtrl; GetWindowRect(GetDlgItem(hwndDlg, IDC_ADD), &rcBtn1); GetWindowRect(GetDlgItem(hwndDlg, IDC_USERMENU), &rcBtn2); GetWindowRect(GetDlgItem(hwndDlg, IDC_DATE), &rcDateCtrl); SetWindowPos(GetDlgItem(hwndDlg, IDC_DATE), 0, 0, 0, rcDateCtrl.right - rcDateCtrl.left - (rcBtn2.left - rcBtn1.left), rcDateCtrl.bottom - rcDateCtrl.top, SWP_NOZORDER | SWP_NOMOVE); } else if (db_get_b(NULL, "SRFile", "AutoAccept", 0)) { //don't check auto-min here to fix BUG#647620 PostMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDOK, BN_CLICKED), (LPARAM)GetDlgItem(hwndDlg, IDOK)); } if (!db_get_b(dat->hContact, "CList", "NotOnList", 0)) ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), SW_HIDE); } return TRUE; case WM_MEASUREITEM: return Menu_MeasureItem((LPMEASUREITEMSTRUCT)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 Menu_DrawItem((LPDRAWITEMSTRUCT)lParam); case WM_COMMAND: if (CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam), MPCF_CONTACTMENU), (LPARAM)dat->hContact)) break; switch (LOWORD(wParam)) { case IDC_FILEDIRBROWSE: { TCHAR szDirName[MAX_PATH], szExistingDirName[MAX_PATH]; GetDlgItemText(hwndDlg, IDC_FILEDIR, szDirName, _countof(szDirName)); GetLowestExistingDirName(szDirName, szExistingDirName, _countof(szExistingDirName)); if (BrowseForFolder(hwndDlg, szExistingDirName)) SetDlgItemText(hwndDlg, IDC_FILEDIR, szExistingDirName); } break; case IDOK: { //most recently used directories TCHAR szRecvDir[MAX_PATH], szDefaultRecvDir[MAX_PATH]; GetDlgItemText(hwndDlg, IDC_FILEDIR, szRecvDir, _countof(szRecvDir)); RemoveInvalidPathChars(szRecvDir); GetContactReceivedFilesDir(NULL, szDefaultRecvDir, _countof(szDefaultRecvDir), TRUE); if (_tcsnicmp(szRecvDir, szDefaultRecvDir, mir_tstrlen(szDefaultRecvDir))) { char idstr[32]; int i; DBVARIANT dbv; for (i = MAX_MRU_DIRS-2;i>=0;i--) { mir_snprintf(idstr, "MruDir%d", i); if (db_get_ts(NULL, "SRFile", idstr, &dbv)) continue; mir_snprintf(idstr, "MruDir%d", i+1); db_set_ts(NULL, "SRFile", idstr, dbv.ptszVal); db_free(&dbv); } db_set_ts(NULL, "SRFile", idstr, szRecvDir); } } EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAMES), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_MSG), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_FILEDIR), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_FILEDIRBROWSE), FALSE); GetDlgItemText(hwndDlg, IDC_FILEDIR, dat->szSavePath, _countof(dat->szSavePath)); GetDlgItemText(hwndDlg, IDC_FILE, dat->szFilenames, _countof(dat->szFilenames)); GetDlgItemText(hwndDlg, IDC_MSG, dat->szMsg, _countof(dat->szMsg)); dat->hwndTransfer = FtMgr_AddTransfer(dat); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0); //check for auto-minimize here to fix BUG#647620 if (db_get_b(NULL, "SRFile", "AutoAccept", 0) && db_get_b(NULL, "SRFile", "AutoMin", 0)) { ShowWindow(hwndDlg, SW_HIDE); ShowWindow(hwndDlg, SW_SHOWMINNOACTIVE); } DestroyWindow(hwndDlg); break; case IDCANCEL: if (dat->fs) CallContactService(dat->hContact, PSS_FILEDENY, (WPARAM)dat->fs, (LPARAM)TranslateT("Canceled")); dat->fs = NULL; /* the protocol will free the handle */ DestroyWindow(hwndDlg); break; case IDC_ADD: { ADDCONTACTSTRUCT acs = { 0 }; acs.hContact = dat->hContact; acs.handleType = HANDLE_CONTACT; acs.szProto = ""; CallService(MS_ADDCONTACT_SHOW, (WPARAM)hwndDlg, (LPARAM)&acs); if (!db_get_b(dat->hContact, "CList", "NotOnList", 0)) ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), SW_HIDE); } break; case IDC_USERMENU: { RECT rc; GetWindowRect((HWND)lParam, &rc); HMENU hMenu = Menu_BuildContactMenu(dat->hContact); TrackPopupMenu(hMenu, 0, rc.left, rc.bottom, 0, hwndDlg, NULL); DestroyMenu(hMenu); } break; case IDC_DETAILS: CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)dat->hContact, 0); break; case IDC_HISTORY: CallService(MS_HISTORY_SHOWCONTACTHISTORY, (WPARAM)dat->hContact, 0); break; } break; case HM_RECVEVENT: { ACKDATA *ack = (ACKDATA*)lParam; if ((ack == NULL) || (ack->hProcess != dat->fs) || (ack->type != ACKTYPE_FILE) || (ack->hContact != dat->hContact)) break; if (ack->result == ACKRESULT_DENIED || ack->result == ACKRESULT_FAILED) { EnableWindow(GetDlgItem(hwndDlg, IDOK), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_FILEDIR), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_FILEDIRBROWSE), FALSE); SetDlgItemText(hwndDlg, IDC_MSG, TranslateT("This file transfer has been canceled by the other side")); SkinPlaySound("FileDenied"); FlashWindow(hwndDlg, TRUE); } else if (ack->result != ACKRESULT_FILERESUME) { SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDCANCEL, 0), (LPARAM)GetDlgItem(hwndDlg, IDCANCEL)); } } 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); FreeFileDlgData(dat); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0); break; } return FALSE; }
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: { HMENU hMenu; HANDLE hSContact; int savePerContact = DBGetContactSettingByte(NULL, SRMMMOD, SRMSGSET_SAVEPERCONTACT, SRMSGDEFSET_SAVEPERCONTACT); struct NewMessageWindowLParam *newData = (struct NewMessageWindowLParam *) lParam; dat = (struct ParentWindowData *) malloc(sizeof(struct ParentWindowData)); dat->foregroundWindow = GetForegroundWindow(); 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->bMinimized = 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); } if (!(dat->flags & SMF_SHOWSTATUSBAR)) { ShowWindow(dat->hwndStatus, SW_HIDE); } hSContact = !(dat->flags & SMF_USETABS) && savePerContact ? dat->hContact : NULL; dat->bTopmost = DBGetContactSettingByte(hSContact, SRMMMOD, SRMSGSET_TOPMOST, SRMSGDEFSET_TOPMOST); if (ScriverRestoreWindowPosition(hwndDlg, hSContact, SRMMMOD, "", 0, SW_HIDE)) { if (ScriverRestoreWindowPosition(hwndDlg, hSContact, SRMMMOD, "", RWPF_NOSIZE, SW_HIDE)) { SetWindowPos(GetParent(hwndDlg), 0, 0, 0, 450, 300, SWP_NOZORDER | SWP_HIDEWINDOW); } else { SetWindowPos(hwndDlg, 0, 0, 0, 450, 300, SWP_NOZORDER | SWP_NOMOVE | SWP_HIDEWINDOW); } } if (!(dat->flags & SMF_USETABS)) { if (!savePerContact && DBGetContactSettingByte(NULL, SRMMMOD, SRMSGSET_CASCADE, SRMSGDEFSET_CASCADE)) WindowList_Broadcast(g_dat->hParentWindowList, DM_CASCADENEWWINDOW, (WPARAM) hwndDlg, (LPARAM) & dat->windowWasCascaded); } hMenu = GetSystemMenu( hwndDlg, FALSE ); AppendMenu( hMenu, MF_SEPARATOR, 0, NULL ); if (dat->bTopmost) { AppendMenu( hMenu, MF_ENABLED | MF_CHECKED | MF_STRING, IDM_TOPMOST, TranslateT("Always On Top")); SetWindowPos(hwndDlg, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); } else { AppendMenu( hMenu, MF_ENABLED | MF_UNCHECKED | MF_STRING, IDM_TOPMOST, TranslateT("Always On Top")); } } return TRUE; case WM_GETMINMAXINFO: { MINMAXINFO *mmi = (MINMAXINFO *) lParam; SIZE size; if (GetKeyState(VK_CONTROL) & 0x8000) { WINDOWPLACEMENT wp; RECT rcDesktop; wp.length = sizeof(wp); GetWindowPlacement(hwndDlg, &wp); SystemParametersInfo(SPI_GETWORKAREA, 0, &rcDesktop, 0); mmi->ptMaxSize.x = wp.rcNormalPosition.right - wp.rcNormalPosition.left; mmi->ptMaxSize.y = rcDesktop.bottom - rcDesktop.top; mmi->ptMaxPosition.x = wp.rcNormalPosition.left; if(IsIconic(hwndDlg)) { mmi->ptMaxPosition.y = rcDesktop.top; } else { mmi->ptMaxPosition.y = 0; } } 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; } if (IsIconic(hwndDlg)) { MoveWindow(dat->hwndActive, dat->childRect.left, dat->childRect.top, dat->childRect.right-dat->childRect.left, dat->childRect.bottom - dat->childRect.top, TRUE); } else { // } // if (!IsIconic(hwndDlg)) { int i; RECT rc, rcStatus, rcChild, rcWindow; SIZE size; dat->bMinimized = 0; GetClientRect(hwndDlg, &rc); GetWindowRect(hwndDlg, &rcWindow); 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); 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); memcpy(&dat->childRect, &rcChild, sizeof(RECT)); 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: if (dat->hwndActive != NULL) { 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); SetFocus(dat->hwndActive); } } 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; if (dat->hwndActive == NULL) { // do not set foreground window at all (always stay in the background !) // SendMessage(hwndDlg, DM_DEACTIVATE, 0, 0); } else { PostMessage(hwndDlg, WM_SETFOCUS, 0, 0); } 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); } break; case WM_LBUTTONDOWN: if (!IsZoomed(hwndDlg)) { POINT pt; GetCursorPos(&pt); // dat->mouseLBDown = 1; // GetCursorPos(&dat->mouseLBDownPos); return SendMessage(hwndDlg, WM_SYSCOMMAND, SC_MOVE | HTCAPTION, MAKELPARAM(pt.x, pt.y)); // SetCapture(hwndDlg); } break; case WM_LBUTTONUP: //if (dat->mouseLBDown) { // 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_MOVING: { int snapPixels = 10; RECT rcDesktop; RECT *pRect = (RECT *)lParam; POINT pt; SIZE szSize = {pRect->right-pRect->left,pRect->bottom-pRect->top}; GetCursorPos(&pt); SystemParametersInfo(SPI_GETWORKAREA, 0, &rcDesktop, 0); pRect->left = pt.x-dat->mouseLBDownPos.x; pRect->top = pt.y-dat->mouseLBDownPos.y; pRect->right = pRect->left+szSize.cx; pRect->bottom = pRect->top+szSize.cy; if (!(GetAsyncKeyState(VK_CONTROL) & 0x8000)) { if(pRect->top < snapPixels && pRect->top > -snapPixels) { pRect->top = 0; pRect->bottom = szSize.cy; } if(pRect->left < snapPixels && pRect->left > -snapPixels) { pRect->left = 0; pRect->right = szSize.cx; } if(pRect->right < rcDesktop.right+snapPixels && pRect->right > rcDesktop.right-snapPixels) { pRect->right = rcDesktop.right; pRect->left = rcDesktop.right-szSize.cx; } if(pRect->bottom < rcDesktop.bottom+snapPixels && pRect->bottom > rcDesktop.bottom-snapPixels) { pRect->bottom = rcDesktop.bottom; pRect->top = rcDesktop.bottom-szSize.cy; } } } break; case WM_SYSCOMMAND: if ((wParam & 0xFFF0) == SC_MOVE) { RECT rc; GetWindowRect(hwndDlg, &rc); dat->mouseLBDownPos.x = LOWORD(lParam) - rc.left; dat->mouseLBDownPos.y = HIWORD(lParam) - rc.top; } else if (wParam == IDM_TOPMOST) { HMENU hMenu = GetSystemMenu(hwndDlg, FALSE); if (dat->bTopmost) { CheckMenuItem(hMenu, IDM_TOPMOST, MF_BYCOMMAND | MF_UNCHECKED); SetWindowPos(hwndDlg, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); dat->bTopmost = FALSE; } else { CheckMenuItem(hMenu, IDM_TOPMOST, MF_BYCOMMAND | MF_CHECKED); SetWindowPos(hwndDlg, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); dat->bTopmost = TRUE; } } break; case WM_DESTROY: { WINDOWPLACEMENT wp = { 0 }; HANDLE hContact; 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) && 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); DBWriteContactSettingByte(hContact, SRMMMOD, SRMSGSET_TOPMOST, (BYTE)dat->bTopmost); } break; case DM_DEACTIVATE: SetForegroundWindow(dat->foregroundWindow); 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) { SetFocus(dat->hwndActive); } else { DestroyWindow(hwndDlg); } } 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); SetFocus(dat->hwndActive); return TRUE; case DM_ACTIVATENEXT: ActivateNextChild(dat, (HWND) lParam); SetFocus(dat->hwndActive); 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; TCHAR *tContactName; if (mdat && mdat->hwnd == dat->hwndActive) { TCHAR *newtitle, oldtitle[256]; #if defined ( _UNICODE ) newtitle = GetWindowTitle(mdat->hContact, mdat->szProto); #else newtitle = GetWindowTitle(mdat->hContact, mdat->szProto); #endif GetWindowText(hwndDlg, oldtitle, sizeof(oldtitle)); if (lstrcmp(newtitle, oldtitle)) { //swt() flickers even if the title hasn't actually changed SetWindowText(hwndDlg, newtitle); //SendMessage(hwndDlg, WM_SIZE, 0, 0); } free(newtitle); } 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; char *szProto = mdat->szProto; HANDLE hContact = mdat->hContact; if (strcmp(mdat->szProto, "MetaContacts") == 0 && DBGetContactSettingByte(NULL,"CLC","Meta",0) == 0) { hContact = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT,(UINT)mdat->hContact, 0); if (hContact != NULL) { szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(UINT)hContact,0); } else { hContact = mdat->hContact; } } wStatus = DBGetContactSettingWord(hContact, szProto, "Status", ID_STATUS_OFFLINE); mdat->wStatus = wStatus; if (mdat->hwnd == dat->hwndActive) { if (DBGetContactSettingByte(NULL, SRMMMOD, SRMSGSET_STATUSICON, SRMSGDEFSET_STATUSICON)) { if (mdat->showTyping && (g_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(szProto, wStatus)); } } else { SendMessage(hwndDlg, WM_SETICON, (WPARAM) ICON_BIG, (LPARAM) LoadSkinnedIcon(SKINICON_EVENT_MESSAGE)); } } SendDlgItemMessage(mdat->hwnd, IDC_USERMENU, BM_SETIMAGE, IMAGE_ICON, (LPARAM) LoadSkinnedProtoIcon(szProto, wStatus)); icoIdx = 0; for (i = 0; i < g_dat->protoNum; i++) { if (!strcmp(g_dat->protoNames[i], 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; }
BOOL CALLBACK ContainerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { ChatContainer *container; container = (ChatContainer *) GetWindowLong(hwndDlg, GWL_USERDATA); if (container==NULL && msg!=WM_INITDIALOG) return FALSE; switch (msg) { case WM_INITDIALOG: SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM) muccIcon[MUCC_IDI_CHAT]); container = (ChatContainer *) lParam; container->setHWND(hwndDlg); TabCtrl_SetImageList(GetDlgItem(hwndDlg, IDC_TABS), hImageList); SetWindowLong(hwndDlg, GWL_USERDATA, (LONG) container); ShowWindow(hwndDlg, SW_SHOW); SetEvent(container->getEvent()); return TRUE; case WM_GETMINMAXINFO: MINMAXINFO *mmi; RECT rcChild, rcWindow; mmi = (MINMAXINFO *) lParam; GetWindowRect(hwndDlg, &rcWindow); container->getChildWindowRect(&rcChild); mmi->ptMinTrackSize.x = 380; mmi->ptMinTrackSize.y = 130 + (rcWindow.bottom - rcWindow.top) - (rcChild.bottom - rcChild.top); return FALSE; case WM_SIZE: if (IsIconic(hwndDlg) || wParam == SIZE_MINIMIZED) break; { RECT rc, rcChild, rcWindow; GetClientRect(hwndDlg, &rc); HWND hwndTabs = GetDlgItem(hwndDlg, IDC_TABS); MoveWindow(hwndTabs, 0, 0, (rc.right - rc.left), (rc.bottom - rc.top) - 0, FALSE); RedrawWindow(hwndTabs, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE); container->getChildWindowRect(&rcChild); if ((rcChild.bottom-rcChild.top) < 130 || (rcChild.right-rcChild.left) < 380) { GetWindowRect(hwndDlg, &rcWindow); if ((rcChild.bottom-rcChild.top) < 130) { rcWindow.bottom = rcWindow.top + 130 + (rcWindow.bottom - rcWindow.top) - (rcChild.bottom - rcChild.top); } if ((rcChild.right-rcChild.left) < 380) { rcWindow.right = rcWindow.left + 380; } MoveWindow(hwndDlg, rcWindow.left, rcWindow.top, rcWindow.right - rcWindow.left, rcWindow.bottom - rcWindow.top, TRUE); container->getChildWindowRect(&rcChild); } if (container->getActive()!=NULL) { MoveWindow(container->getActive()->getHWND(), rcChild.left, rcChild.top, rcChild.right-rcChild.left, rcChild.bottom - rcChild.top, TRUE); } } return TRUE; case DM_CREATECHILD: SetWindowLong(hwndDlg, DWL_MSGRESULT, (LONG)CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_GROUPCHAT_LOG), hwndDlg, (DLGPROC) wParam, (LPARAM) lParam)); return TRUE; case DM_ADDCHILD: container->addChild((ChatWindow *) lParam); return TRUE; case DM_REMOVECHILD: container->removeChild((ChatWindow *) lParam); return TRUE; case DM_CHANGECHILDDATA: container->removeChild((ChatWindow *) lParam); return TRUE; case DM_SETUNREAD: container->setUnread((ChatWindow *) lParam, (int)wParam); return TRUE; case DM_FLASHWINDOW: if (GetActiveWindow() != hwndDlg && GetForegroundWindow() != hwndDlg) { container->setFlash(0); SetTimer(hwndDlg, TIMERID_FLASHWND, container->getFlashTimeout(), NULL); } return TRUE; case WM_NOTIFY: { NMHDR* pNMHDR = (NMHDR*) lParam; switch (pNMHDR->code) { case TCN_SELCHANGE: { TCITEM tci = {0}; HWND hwndTabs = GetDlgItem(hwndDlg, IDC_TABS); int iSel = TabCtrl_GetCurSel(hwndTabs); tci.mask = TCIF_PARAM; if (TabCtrl_GetItem(hwndTabs, iSel, &tci)) { ChatWindow * chatWindow = (ChatWindow *) tci.lParam; container->activateChild(chatWindow); } } break; case NM_CLICK: { FILETIME ft; TCHITTESTINFO thinfo; int tabId; HWND hwndTabs = GetDlgItem(hwndDlg, IDC_TABS); GetSystemTimeAsFileTime(&ft); GetCursorPos(&thinfo.pt); ScreenToClient(hwndTabs, &thinfo.pt); tabId = TabCtrl_HitTest(hwndTabs, &thinfo); if (tabId != -1 && tabId == container->lastClickTab && (ft.dwLowDateTime - container->lastClickTime) < (GetDoubleClickTime() * 10000)) { SendMessage(container->getChildFromTab(tabId)->getHWND(), WM_CLOSE, 0, 0); container->lastClickTab = -1; } else { container->lastClickTab = tabId; } container->lastClickTime = ft.dwLowDateTime; } break; } } break; case WM_ACTIVATE: if (LOWORD(wParam) != WA_ACTIVE) break; case WM_MOUSEACTIVATE: if (KillTimer(hwndDlg, TIMERID_FLASHWND)) { FlashWindow(hwndDlg, FALSE); } /* if (container->getActive()!=NULL) { container->setUnread(container->getActive(), 0); SendMessage(container->getActive()->getHWND(), WM_ACTIVATE, WA_ACTIVE, 0); }*/ break; case WM_CLOSE: EndDialog(hwndDlg, 0); return FALSE; case WM_TIMER: if (wParam == TIMERID_FLASHWND) { if ((container->getFlash() > container->getFlashMax()) || (GetActiveWindow() == hwndDlg) || (GetForegroundWindow() == hwndDlg)) { KillTimer(hwndDlg, TIMERID_FLASHWND); FlashWindow(hwndDlg, FALSE); } else if (container->getFlash() < container->getFlashMax()) { FlashWindow(hwndDlg, TRUE); container->setFlash(container->getFlash()+1); } } break; case WM_DESTROY: SetWindowLong(hwndDlg, GWL_USERDATA, 0); delete container; return TRUE; } return FALSE; }
struct Box_s *GameInvitation_Create(struct Box_s *roster, char *fromjid, struct gamesearchinfo_s *info, int replace, int cascade) { struct gameinvitationdata_s *data = malloc(sizeof(*data)); struct Box_s *dialog, *pbox, *vertsize; char titlebartxt[512]; memset(data, 0, sizeof(*data)); dialog = Box_Create(0, 0, 440, 270, BOX_VISIBLE); dialog->boxtypeid = BOXTYPE_GAMEINVITATION; dialog->bgcol = DefaultBG; dialog->boxdata = data; data->jid = strdup(fromjid); data->info = Info_DupeGameSearchInfo(info); if (replace) { i18n_stringsub(titlebartxt, 512, _("Game Renegotiation From %1"), Model_GetFriendNick(fromjid)); } else { i18n_stringsub(titlebartxt, 512, _("Game Invitation From %1"), Model_GetFriendNick(fromjid)); } dialog->titlebar = TitleBarOnly_Add(dialog, titlebartxt); dialog->OnActive = TitleBarRoot_OnActive; dialog->OnInactive = TitleBarRoot_OnInactive; vertsize = AutoSize_Create(10, 43, 0, 0, 0, 0, AUTOSIZE_VERT); Box_AddChild(dialog, vertsize); data->sizeablecontent = vertsize; { struct Box_s *horizsize; struct Box_s *vertsize2; pbox = Text_Create(10, 2, 280, 60, BOX_TRANSPARENT, TX_WRAP); /*pbox->OnSizeWidth = Text_OnSizeWidth_Stretch; pbox->OnSizeHeight = Box_OnSizeHeight_Stretch; */ pbox->fgcol = RGB(222, 222, 222); Box_AddChild(vertsize, pbox); data->messagebox = pbox; vertsize2 = AutoSize_Create(0, 0, 0, 0, 0, 0, AUTOSIZE_VERT); vertsize2->OnSizeWidth = Box_OnSizeWidth_Stretch; data->infobox = vertsize2; Box_AddChild(vertsize, vertsize2); { struct Box_s *vertsize = AutoSize_Create(10, 0, 0, 0, 0, 0, AUTOSIZE_VERT); Box_AddChild(vertsize2, vertsize); { struct Box_s *horizsize = AutoSize_Create(0, 0, 0, 0, 0, 0, AUTOSIZE_HORIZ | AUTOSIZE_EVENSPACING); Box_AddChild(vertsize, horizsize); { struct Box_s *horizsize2 = AutoSize_Create(0, 0, 0, 0, 0, 0, AUTOSIZE_HORIZ); Box_AddChild(horizsize, horizsize2); { pbox = Text_Create(0, 0, 95, 20, BOX_VISIBLE | BOX_TRANSPARENT, TX_STRETCHHORIZ | TX_RIGHT); pbox->fgcol = UserInfoFG2; Text_SetText(pbox, _("Side")); Box_AddChild(horizsize2, pbox); AutoSize_AddSpacer(horizsize2, 10); pbox = Text_Create(10 /*115*/, 0, 90, 20, BOX_VISIBLE | BOX_TRANSPARENT, TX_STRETCHHORIZ); pbox->fgcol = RGB(222, 222, 222); if (info->colorpreference == 1) { Text_SetText(pbox, _("Black")); } else if (info->colorpreference == 2) { Text_SetText(pbox, _("White")); } else { Text_SetText(pbox, _("No Preference")); } Box_AddChild(horizsize2, pbox); } horizsize2 = AutoSize_Create(0, 0, 0, 0, 0, 0, AUTOSIZE_HORIZ); Box_AddChild(horizsize, horizsize2); { pbox = Text_Create(10 /*215*/, 0, 60, 20, BOX_VISIBLE | BOX_TRANSPARENT, TX_STRETCHHORIZ | TX_RIGHT); pbox->fgcol = UserInfoFG2; Text_SetText(pbox, _("Rated Game")); Box_AddChild(horizsize2, pbox); AutoSize_AddSpacer(horizsize2, 10); pbox = Text_Create(10, /*280*/ 0, 90, 20, BOX_VISIBLE | BOX_TRANSPARENT, TX_STRETCHHORIZ); pbox->fgcol = RGB(222, 222, 222); Text_SetText(pbox, info->rated ? _("Yes") : _("No")); Box_AddChild(horizsize2, pbox); } } AutoSize_AddSpacer(vertsize, 2); horizsize = AutoSize_Create(0, 0, 0, 0, 0, 0, AUTOSIZE_HORIZ | AUTOSIZE_EVENSPACING); Box_AddChild(vertsize, horizsize); { struct Box_s *horizsize2 = AutoSize_Create(0, 0, 0, 0, 0, 0, AUTOSIZE_HORIZ); Box_AddChild(horizsize, horizsize2); { pbox = Text_Create(0, 0, 95, 20, BOX_VISIBLE | BOX_TRANSPARENT, TX_STRETCHHORIZ | TX_RIGHT); pbox->fgcol = UserInfoFG2; Text_SetText(pbox, _("Game Variant")); Box_AddChild(horizsize2, pbox); AutoSize_AddSpacer(horizsize2, 10); pbox = Text_Create(10 /*115*/, 0, 90, 20, BOX_VISIBLE | BOX_TRANSPARENT, TX_STRETCHHORIZ); pbox->fgcol = RGB(222, 222, 222); Text_SetText(pbox, Util_Capitalize(info->variant)); Box_AddChild(horizsize2, pbox); } if (info->takebacks) { horizsize2 = AutoSize_Create(0, 0, 0, 0, 0, 0, AUTOSIZE_HORIZ); Box_AddChild(horizsize, horizsize2); { pbox = Text_Create(10 /*215*/, 0, 60, 20, BOX_VISIBLE | BOX_TRANSPARENT, TX_STRETCHHORIZ | TX_RIGHT); pbox->fgcol = UserInfoFG2; Text_SetText(pbox, _("Takebacks")); Box_AddChild(horizsize2, pbox); AutoSize_AddSpacer(horizsize2, 10); pbox = Text_Create(10, /*280*/ 0, 90, 20, BOX_VISIBLE | BOX_TRANSPARENT, TX_STRETCHHORIZ); pbox->fgcol = RGB(222, 222, 222); Text_SetText(pbox, Util_Capitalize(info->takebacks)); Box_AddChild(horizsize2, pbox); } } } AutoSize_AddSpacer(vertsize, 2); horizsize = AutoSize_Create(0, 0, 0, 0, 0, 0, AUTOSIZE_HORIZ); Box_AddChild(vertsize, horizsize); { char buffer[1024]; pbox = Text_Create(10, 0, 95, 20, BOX_VISIBLE | BOX_TRANSPARENT, TX_STRETCHHORIZ | TX_RIGHT); pbox->fgcol = UserInfoFG2; Text_SetText(pbox, _("Time Settings")); Box_AddChild(horizsize, pbox); AutoSize_AddSpacer(horizsize, 10); pbox = Text_Create(10, 0, 265, 20, BOX_VISIBLE | BOX_TRANSPARENT, TX_STRETCHVERT); pbox->fgcol = RGB(222, 222, 222); Text_SetLinkColor(pbox, CR_LtOrange); Text_SetText(pbox, Info_TimeControlsToMultilineText(info->timecontrol, info->blacktimecontrol, buffer, 1024)); Box_AddChild(horizsize, pbox); } AutoSize_AddSpacer(vertsize, 2); horizsize = AutoSize_Create(0, 0, 0, 0, 0, 0, AUTOSIZE_HORIZ); Box_AddChild(vertsize, horizsize); { pbox = Text_Create(10, 0, 95, 20, BOX_VISIBLE | BOX_TRANSPARENT, TX_STRETCHHORIZ | TX_RIGHT); pbox->fgcol = UserInfoFG2; Text_SetText(pbox, _("Comment")); Box_AddChild(horizsize, pbox); AutoSize_AddSpacer(horizsize, 10); pbox = Text_Create(5, 0, 255, 40, BOX_VISIBLE | BOX_TRANSPARENT, TX_WRAP | TX_STRETCHVERT); pbox->fgcol = RGB(222, 222, 222); Text_SetText(pbox, info->comment); Box_AddChild(horizsize, pbox); } } AutoSize_AddSpacer(vertsize2, 2); pbox = Box_Create(0, 0, vertsize2->w, 1, BOX_VISIBLE); pbox->bgcol = RGB(77, 77, 77); pbox->OnSizeWidth = Box_OnSizeWidth_Stretch; Box_AddChild(vertsize2, pbox); pbox = Box_Create(0, 0, vertsize2->w, 1, BOX_VISIBLE); pbox->bgcol = RGB(102, 102, 102); pbox->OnSizeWidth = Box_OnSizeWidth_Stretch; Box_AddChild(vertsize2, pbox); AutoSize_AddSpacer(vertsize2, 13); horizsize = AutoSize_Create(0, 0, 0, 0, 0, 0, AUTOSIZE_HORIZ); horizsize->OnSizeWidth = Box_OnSizeWidth_Stretch; Box_AddChild(vertsize2, horizsize); { AutoSize_AddSpacer(horizsize, 40); pbox = Text_Create(0, 5, 50, 20, BOX_VISIBLE | BOX_TRANSPARENT, TX_STRETCHHORIZ | TX_RIGHT); pbox->fgcol = UserInfoFG2; Text_SetText(pbox, _("Opponent")); Box_AddChild(horizsize, pbox); AutoSize_AddSpacer(horizsize, 20); pbox = MiniProfile_Create(0, 0, 225, 50, fromjid); pbox->OnSizeWidth = Box_OnSizeWidth_Stretch; data->opponentbox = pbox; Box_AddChild(horizsize, pbox); AutoSize_AddSpacer(horizsize, 40); } } AutoSize_AddSpacer(vertsize, 37); horizsize = AutoSize_Create(0, 0, 0, 0, 0, 0, AUTOSIZE_HORIZ); horizsize->OnSizeWidth = Box_OnSizeWidth_Stretch; Box_AddChild(vertsize, horizsize); { struct Box_s *horizsize2 = AutoSizeSpace_Create(0, 0, 0, 0, 0, 0, 10, AUTOSIZE_HORIZ); Box_AddChild(horizsize, horizsize2); { pbox = StdButton_Create(0, 0, 90, _("Change Game Terms"), 0); Button2_SetOnButtonHit(pbox, GameInvitation_OnChange); Box_AddChild(horizsize2, pbox); data->changebutton = pbox; pbox = StdButton_Create(0, 0, 90, _("Open Chat"), 0); Button2_SetOnButtonHit(pbox, GameInvitation_OnChat); Box_AddChild(horizsize2, pbox); data->openchatbutton = pbox; AutoSize_AddSpacer(horizsize2, 0); } horizsize2 = AutoSizeSpace_Create(0, 0, 0, 0, 0, 0, 10, AUTOSIZE_HORIZ); horizsize2->OnSizeWidth = Box_OnSizeWidth_StickRight; Box_AddChild(horizsize, horizsize2); { pbox = StdButton_Create(0, 0, 90, _("Accept Game"), 0); Button2_SetOnButtonHit(pbox, GameInvitation_OnAccept); Box_AddChild(horizsize2, pbox); data->acceptbutton = pbox; pbox = StdButton_Create(0, 0, 90, _("Decline Game"), 0); Button2_SetOnButtonHit(pbox, GameInvitation_OnDecline); Box_AddChild(horizsize2, pbox); data->cancelbutton = pbox; } } } AutoSize_Fit(data->sizeablecontent); AutoSize_Fill(data->sizeablecontent); Box_OnSizeWidth_Stretch(dialog, data->sizeablecontent->w + 20 - dialog->w); Box_OnSizeHeight_Stretch(dialog, data->sizeablecontent->h + 50 - dialog->h); { RECT windowrect; HMONITOR hm; MONITORINFO mi; int remainw, remainh; windowrect.left = roster->x; windowrect.right = windowrect.left + roster->w - 1; windowrect.top = roster->y; windowrect.bottom = windowrect.top + roster->h - 1; hm = MonitorFromRect(&windowrect, MONITOR_DEFAULTTONEAREST); mi.cbSize = sizeof(mi); GetMonitorInfo(hm, &mi); remainw = mi.rcWork.right - mi.rcWork.left - dialog->w; remainh = mi.rcWork.bottom - mi.rcWork.top - dialog->h; dialog->x = remainw / 2; dialog->y = remainh / 2; dialog->x += 20 * cascade; dialog->x %= remainw; dialog->y += 20 * cascade; dialog->y %= remainh; dialog->x += mi.rcWork.left; dialog->y += mi.rcWork.top; } #if 0 pbox = Text_Create(20, 40, dialog->w - 40, dialog->h - 80, BOX_TRANSPARENT, TX_WRAP); pbox->fgcol = RGB(222, 222, 222); Box_AddChild(dialog, pbox); data->messagebox = pbox; pbox = Box_Create(0, 0, dialog->w, dialog->h, BOX_VISIBLE | BOX_TRANSPARENT); data->infobox = pbox; Box_AddChild(dialog, pbox); pbox = Box_Create(20, 45, 95, 20, BOX_VISIBLE | BOX_TRANSPARENT | BOX_RIGHTTEXT); pbox->fgcol = UserInfoFG2; Box_SetText(pbox, _("Side")); Box_AddChild(data->infobox, pbox); pbox = Box_Create(125, 45, 90, 20, BOX_VISIBLE | BOX_TRANSPARENT); pbox->fgcol = RGB(222, 222, 222); /* Reversed here since it is the opponent's color preference */ if (info->colorpreference == 1) { Box_SetText(pbox, _("Black")); } else if (info->colorpreference == 2) { Box_SetText(pbox, _("White")); } else { Box_SetText(pbox, _("No Preference")); } Box_AddChild(data->infobox, pbox); pbox = Box_Create(265, 45, 95, 20, BOX_VISIBLE | BOX_TRANSPARENT); pbox->fgcol = UserInfoFG2; Box_SetText(pbox, _("Rated Game")); Box_AddChild(data->infobox, pbox); pbox = Box_Create(330, 45, 90, 20, BOX_VISIBLE | BOX_TRANSPARENT); pbox->fgcol = RGB(222, 222, 222); if (info->rated) { Box_SetText(pbox, _("Yes")); } else { Box_SetText(pbox, _("No")); } Box_AddChild(data->infobox, pbox); pbox = Box_Create(20, 65, 95, 20, BOX_VISIBLE | BOX_TRANSPARENT | BOX_RIGHTTEXT); pbox->fgcol = UserInfoFG2; Box_SetText(pbox, _("Game Variant")); Box_AddChild(data->infobox, pbox); pbox = Box_Create(125, 65, 90, 20, BOX_VISIBLE | BOX_TRANSPARENT); pbox->fgcol = RGB(222, 222, 222); Box_SetText(pbox, Util_Capitalize(info->variant)); Box_AddChild(data->infobox, pbox); pbox = Box_Create(20, 85, 95, 20, BOX_VISIBLE | BOX_TRANSPARENT | BOX_RIGHTTEXT); pbox->fgcol = UserInfoFG2; Box_SetText(pbox, _("Time Settings")); Box_AddChild(data->infobox, pbox); pbox = Text_Create(125, 85, 315, 20, BOX_VISIBLE | BOX_TRANSPARENT, 0); pbox->fgcol = RGB(222, 222, 222); Text_SetText(pbox, Info_TimeControlToLongText(info->timecontrol)); Box_AddChild(data->infobox, pbox); pbox = Box_Create(20, 105, 95, 20, BOX_VISIBLE | BOX_TRANSPARENT | BOX_RIGHTTEXT); pbox->fgcol = UserInfoFG2; Box_SetText(pbox, _("Comment")); Box_AddChild(data->infobox, pbox); pbox = Text_Create(125, 105, 290, 40, BOX_VISIBLE | BOX_TRANSPARENT, TX_WRAP); pbox->fgcol = RGB(222, 222, 222); Text_SetText(pbox, info->comment); Box_AddChild(data->infobox, pbox); pbox = Box_Create(10, 139, 420, 1, BOX_VISIBLE); pbox->bgcol = RGB(77, 77, 77); pbox->OnSizeWidth = Box_OnSizeWidth_Stretch; Box_AddChild(data->infobox, pbox); pbox = Box_Create(10, 140, 420, 1, BOX_VISIBLE); pbox->bgcol = RGB(102, 102, 102); pbox->OnSizeWidth = Box_OnSizeWidth_Stretch; Box_AddChild(data->infobox, pbox); pbox = Box_Create(65, 165, 90, 20, BOX_VISIBLE | BOX_TRANSPARENT); pbox->fgcol = UserInfoFG2; Box_SetText(pbox, _("Opponent")); Box_AddChild(data->infobox, pbox); pbox = Box_Create(120, 155, 265, 50, BOX_VISIBLE | BOX_BORDER); pbox->brcol = RGB(90, 97, 108); pbox->bgcol = DrawerBG; data->opponentbox = pbox; Box_AddChild(data->infobox, pbox); pbox = StdButton_Create(10, 270 - 30, 130, _("Change Game Terms"), 0); Button2_SetOnButtonHit(pbox, GameInvitation_OnChange); Box_AddChild(dialog, pbox); data->changebutton = pbox; pbox = StdButton_Create(10 + 135, 270 - 30, 80, _("Open Chat"), 0); Button2_SetOnButtonHit(pbox, GameInvitation_OnChat); Box_AddChild(dialog, pbox); pbox = StdButton_Create(440 - 100 - 95, 270 - 30, 90, _("Accept Game"), 0); Button2_SetOnButtonHit(pbox, GameInvitation_OnAccept); Box_AddChild(dialog, pbox); data->acceptbutton = pbox; pbox = StdButton_Create(440 - 100, 270 - 30, 90, _("Decline Game"), 0); Button2_SetOnButtonHit(pbox, GameInvitation_OnDecline); Box_AddChild(dialog, pbox); data->cancelbutton = pbox; #endif Box_CreateWndCustom(dialog, titlebartxt, roster->hwnd); MiniProfile_SetProfile(data->opponentbox, data->jid, NULL); Model_SubscribeProfile(data->jid, GameInvitation_SetProfile, dialog); dialog->OnDestroy = GameInvitation_OnDestroy; if (!Model_GetOption(OPTION_NOGAMENOTIFY)) { FlashWindow(dialog->hwnd, 1); } return dialog; }
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; } if (IsIconic(hwndDlg)) { MoveWindow(dat->hwndActive, dat->childRect.left, dat->childRect.top, dat->childRect.right-dat->childRect.left, dat->childRect.bottom - dat->childRect.top, TRUE); } else { // } // if (!IsIconic(hwndDlg)) { int i; RECT rc, rcStatus, rcChild, rcWindow; SIZE size; dat->bMinimized = 0; GetClientRect(hwndDlg, &rc); GetWindowRect(hwndDlg, &rcWindow); 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); 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); memcpy(&dat->childRect, &rcChild, sizeof(RECT)); 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; }
BOOL CALLBACK vncAcceptDialog::vncAcceptDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { // This is a static method, so we don't know which instantiation we're // dealing with. But we can get a pseudo-this from the parameter to // WM_INITDIALOG, which we therafter store with the window and retrieve // as follows: vncAcceptDialog *_this = helper::SafeGetWindowUserData<vncAcceptDialog>(hwnd); switch (uMsg) { // Dialog has just been created case WM_INITDIALOG: { // Save the lParam into our user data so that subsequent calls have // access to the parent C++ object helper::SafeSetWindowUserData(hwnd, lParam); vncAcceptDialog *_this = (vncAcceptDialog *) lParam; // Set the IP-address string SetDlgItemText(hwnd, IDC_ACCEPT_IP, _this->m_ipAddress); if (SetTimer(hwnd, 1, 1000, NULL) == 0) { if (_this->m_acceptOnTimeout) EndDialog(hwnd, IDACCEPT); else EndDialog(hwnd, IDREJECT); } _this->m_timeoutCount = _this->m_timeoutSecs; char temp[256]; if (_this->m_acceptOnTimeout) sprintf(temp, "AutoAccept:%u", (_this->m_timeoutCount)); else sprintf(temp, "AutoReject:%u", (_this->m_timeoutCount)); SetDlgItemText(hwnd, IDC_ACCEPT_TIMEOUT, temp); // Attempt to mimic Win98/2000 dialog behaviour if ((vncService::IsWinNT() && (vncService::VersionMajor() <= 4)) || (vncService::IsWin95() && (vncService::VersionMinor() == 0))) { // Perform special hack to display the dialog safely if (GetWindowThreadProcessId(GetForegroundWindow(), NULL) != GetCurrentProcessId()) { // We can't set our dialog as foreground if the foreground window // doesn't belong to us - it's unsafe! SetActiveWindow(hwnd); _this->m_foreground_hack = TRUE; _this->m_flash_state = FALSE; } } if (!_this->m_foreground_hack) { SetForegroundWindow(hwnd); } // Beep MessageBeep(MB_ICONEXCLAMATION); // Return success! return TRUE; } // Timer event case WM_TIMER: if ((_this->m_timeoutCount) == 0) { if ( _this->m_acceptOnTimeout ) { EndDialog(hwnd, IDACCEPT); } else { EndDialog(hwnd, IDREJECT); } } _this->m_timeoutCount--; // Flash if necessary if (_this->m_foreground_hack) { if (GetWindowThreadProcessId(GetForegroundWindow(), NULL) != GetCurrentProcessId()) { _this->m_flash_state = !_this->m_flash_state; FlashWindow(hwnd, _this->m_flash_state); } else { _this->m_foreground_hack = FALSE; } } // Update the displayed count char temp[256]; if ( _this->m_acceptOnTimeout ) sprintf(temp, "AutoAccept: %u", (_this->m_timeoutCount)); else sprintf(temp, "AutoReject: %u", (_this->m_timeoutCount)); SetDlgItemText(hwnd, IDC_ACCEPT_TIMEOUT, temp); break; // Dialog has just received a command case WM_COMMAND: switch (LOWORD(wParam)) { // User clicked Accept or pressed return case IDACCEPT: case IDOK: EndDialog(hwnd, IDACCEPT); return TRUE; case IDREJECT: case IDCANCEL: EndDialog(hwnd, IDREJECT); return TRUE; }; break; // Window is being destroyed! (Should never happen) case WM_DESTROY: EndDialog(hwnd, IDREJECT); return TRUE; } return 0; }
/* Window flasher */ static gboolean flash_window_cb(gpointer data) { FlashWindow((HWND)data, TRUE); return TRUE; }
void MainWindow::flashWindow() { #if defined(Q_WS_WIN) FlashWindow(winId(), true); #endif }
BOOL CALLBACK vncAcceptDialog::vncAcceptDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { // This is a static method, so we don't know which instantiation we're // dealing with. But we can get a pseudo-this from the parameter to // WM_INITDIALOG, which we therafter store with the window and retrieve // as follows: static HBITMAP hbmBkGnd = NULL; vncAcceptDialog *_this = helper::SafeGetWindowUserData<vncAcceptDialog>(hwnd); switch (uMsg) { // Dialog has just been created case WM_INITDIALOG: { // Save the lParam into our user data so that subsequent calls have // access to the parent C++ object helper::SafeSetWindowUserData(hwnd, lParam); vncAcceptDialog *_this = (vncAcceptDialog *) lParam; // Set the IP-address string char accept_reject_mesg[512]; IniFile myIniFile; myIniFile.ReadString("admin", "accept_reject_mesg", accept_reject_mesg,512); if (strlen(accept_reject_mesg)==0) strcpy(accept_reject_mesg,"WinVNC has received an incoming connection from"); SetDlgItemText(hwnd, IDC_STATIC_TEXT1, accept_reject_mesg); SetDlgItemText(hwnd, IDC_ACCEPT_IP, _this->m_ipAddress); { char WORKDIR[MAX_PATH]; char mycommand[MAX_PATH]; if (GetModuleFileName(NULL, WORKDIR, MAX_PATH)) { char* p = strrchr(WORKDIR, '\\'); if (p == NULL) return 0; *p = '\0'; } strcpy(mycommand,WORKDIR); strcat(mycommand,"\\mylogo.bmp"); hbmBkGnd = (HBITMAP)LoadImage(NULL, mycommand, IMAGE_BITMAP, 0, 0,LR_LOADFROMFILE); } SendMessage(GetDlgItem(hwnd, IDC_ACCEPTLOGO),STM_SETIMAGE,IMAGE_BITMAP,(LPARAM)(HBITMAP)hbmBkGnd); if (SetTimer(hwnd, 1, 1000, NULL) == 0) { if (_this->m_acceptOnTimeout) EndDialog(hwnd, IDACCEPT); else EndDialog(hwnd, IDREJECT); } _this->m_timeoutCount = _this->m_timeoutSecs; char temp[256]; if (_this->m_acceptOnTimeout) sprintf(temp, "AutoAccept:%u", (_this->m_timeoutCount)); else sprintf(temp, "AutoReject:%u", (_this->m_timeoutCount)); SetDlgItemText(hwnd, IDC_ACCEPT_TIMEOUT, temp); // Attempt to mimic Win98/2000 dialog behaviour if ((vncService::IsWinNT() && (vncService::VersionMajor() <= 4)) || (vncService::IsWin95() && (vncService::VersionMinor() == 0))) { // Perform special hack to display the dialog safely if (GetWindowThreadProcessId(GetForegroundWindow(), NULL) != GetCurrentProcessId()) { // We can't set our dialog as foreground if the foreground window // doesn't belong to us - it's unsafe! SetActiveWindow(hwnd); _this->m_foreground_hack = TRUE; _this->m_flash_state = FALSE; } } if (!_this->m_foreground_hack) { SetForegroundWindow(hwnd); } // Beep MessageBeep(MB_ICONEXCLAMATION); // Return success! return TRUE; } // Timer event case WM_TIMER: if ((_this->m_timeoutCount) == 0) { if ( _this->m_acceptOnTimeout ) { EndDialog(hwnd, IDACCEPT); } else { EndDialog(hwnd, IDREJECT); } } _this->m_timeoutCount--; // Flash if necessary if (_this->m_foreground_hack) { if (GetWindowThreadProcessId(GetForegroundWindow(), NULL) != GetCurrentProcessId()) { _this->m_flash_state = !_this->m_flash_state; FlashWindow(hwnd, _this->m_flash_state); } else { _this->m_foreground_hack = FALSE; } } // Update the displayed count char temp[256]; if ( _this->m_acceptOnTimeout ) sprintf(temp, "AutoAccept: %u", (_this->m_timeoutCount)); else sprintf(temp, "AutoReject: %u", (_this->m_timeoutCount)); SetDlgItemText(hwnd, IDC_ACCEPT_TIMEOUT, temp); break; // Dialog has just received a command case WM_COMMAND: switch (LOWORD(wParam)) { // User clicked Accept or pressed return case IDACCEPT: case IDOK: EndDialog(hwnd, IDACCEPT); return TRUE; case IDREJECT: case IDCANCEL: EndDialog(hwnd, IDREJECT); return TRUE; }; break; // Window is being destroyed! (Should never happen) case WM_DESTROY: DeleteObject(hbmBkGnd); EndDialog(hwnd, IDREJECT); return TRUE; } return 0; }