INT_PTR CALLBACK DlgProcGenOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_USER + 1: { MCONTACT hContact = wParam; DBCONTACTWRITESETTING *ws = (DBCONTACTWRITESETTING *)lParam; if (hContact == NULL && ws != NULL && ws->szModule != NULL && ws->szSetting != NULL && mir_strcmpi(ws->szModule, "CList") == 0 && mir_strcmpi(ws->szSetting, "UseGroups") == 0 && IsWindowVisible(hwndDlg)) CheckDlgButton(hwndDlg, IDC_DISABLEGROUPS, ws->value.bVal == 0 ? BST_CHECKED : BST_UNCHECKED); } break; case WM_DESTROY: UnhookEvent((HANDLE)GetWindowLongPtr(hwndDlg, GWLP_USERDATA)); break; case WM_INITDIALOG: opt_gen_opts_changed = 0; TranslateDialogDefault(hwndDlg); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)HookEventMessage(ME_DB_CONTACT_SETTINGCHANGED, hwndDlg, WM_USER + 1)); CheckDlgButton(hwndDlg, IDC_ONTOP, cfg::getByte("CList", "OnTop", SETTING_ONTOP_DEFAULT) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_HIDEOFFLINE, cfg::getByte(NULL, "CList", "HideOffline", SETTING_HIDEOFFLINE_DEFAULT) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_HIDEEMPTYGROUPS, cfg::getByte("CList", "HideEmptyGroups", SETTING_HIDEEMPTYGROUPS_DEFAULT) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_DISABLEGROUPS, cfg::getByte("CList", "UseGroups", SETTING_USEGROUPS_DEFAULT) ? BST_UNCHECKED : BST_CHECKED); CheckDlgButton(hwndDlg, IDC_CONFIRMDELETE, cfg::getByte("CList", "ConfirmDelete", SETTING_CONFIRMDELETE_DEFAULT) ? BST_CHECKED : BST_UNCHECKED); { DWORD caps = CallService(MS_CLUI_GETCAPS, CLUICAPS_FLAGS1, 0); if (!(caps & CLUIF_HIDEEMPTYGROUPS)) ShowWindow(GetDlgItem(hwndDlg, IDC_HIDEEMPTYGROUPS), SW_HIDE); if (!(caps & CLUIF_DISABLEGROUPS)) ShowWindow(GetDlgItem(hwndDlg, IDC_DISABLEGROUPS), SW_HIDE); if (caps & CLUIF_HASONTOPOPTION) ShowWindow(GetDlgItem(hwndDlg, IDC_ONTOP), SW_HIDE); if (caps & CLUIF_HASAUTOHIDEOPTION) { } } CheckDlgButton(hwndDlg, IDC_SHOWBOTTOMBUTTONS, cfg::dat.dwFlags & CLUI_FRAME_SHOWBOTTOMBUTTONS ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_CLISTSUNKEN, cfg::dat.dwFlags & CLUI_FRAME_CLISTSUNKEN ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_EVENTAREAAUTOHIDE, cfg::dat.dwFlags & CLUI_FRAME_AUTOHIDENOTIFY ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_EVENTAREASUNKEN, (cfg::dat.dwFlags & CLUI_FRAME_EVENTAREASUNKEN) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_ONECLK, cfg::getByte("CList", "Tray1Click", SETTING_TRAY1CLICK_DEFAULT) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_ALWAYSSTATUS, cfg::getByte("CList", "AlwaysStatus", SETTING_ALWAYSSTATUS_DEFAULT) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_ALWAYSMULTI, !cfg::getByte("CList", "AlwaysMulti", SETTING_ALWAYSMULTI_DEFAULT) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_DONTCYCLE, cfg::getByte("CList", "TrayIcon", SETTING_TRAYICON_DEFAULT) == SETTING_TRAYICON_SINGLE ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_CYCLE, cfg::getByte("CList", "TrayIcon", SETTING_TRAYICON_DEFAULT) == SETTING_TRAYICON_CYCLE ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_MULTITRAY, cfg::getByte("CList", "TrayIcon", SETTING_TRAYICON_DEFAULT) == SETTING_TRAYICON_MULTI ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_DISABLEBLINK, cfg::getByte("CList", "DisableTrayFlash", 0) == 1 ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_ICONBLINK, cfg::getByte("CList", "NoIconBlink", 0) == 1 ? BST_CHECKED : BST_UNCHECKED); if (IsDlgButtonChecked(hwndDlg, IDC_DONTCYCLE)) { Utils::enableDlgControl(hwndDlg, IDC_CYCLETIMESPIN, FALSE); Utils::enableDlgControl(hwndDlg, IDC_CYCLETIME, FALSE); Utils::enableDlgControl(hwndDlg, IDC_ALWAYSMULTI, FALSE); } if (IsDlgButtonChecked(hwndDlg, IDC_CYCLE)) { Utils::enableDlgControl(hwndDlg, IDC_PRIMARYSTATUS, FALSE); Utils::enableDlgControl(hwndDlg, IDC_ALWAYSMULTI, FALSE); } if (IsDlgButtonChecked(hwndDlg, IDC_MULTITRAY)) { Utils::enableDlgControl(hwndDlg, IDC_CYCLETIMESPIN, FALSE); Utils::enableDlgControl(hwndDlg, IDC_CYCLETIME, FALSE); Utils::enableDlgControl(hwndDlg, IDC_PRIMARYSTATUS, FALSE); } SendDlgItemMessage(hwndDlg, IDC_CYCLETIMESPIN, UDM_SETRANGE, 0, MAKELONG(120, 1)); SendDlgItemMessage(hwndDlg, IDC_CYCLETIMESPIN, UDM_SETPOS, 0, MAKELONG(cfg::getWord("CList", "CycleTime", SETTING_CYCLETIME_DEFAULT), 0)); { ptrA szPrimaryStatus(db_get_sa(NULL, "CList", "PrimaryStatus")); int item = SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_ADDSTRING, 0, (LPARAM)TranslateT("Global")); SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_SETITEMDATA, item, (LPARAM)0); int count; PROTOACCOUNT **accs; Proto_EnumAccounts(&count, &accs); for (int i = 0; i < count; i++) { if (!Proto_IsAccountEnabled(accs[i]) || CallProtoService(accs[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) == 0) continue; item = SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_ADDSTRING, 0, (LPARAM)accs[i]->tszAccountName); SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_SETITEMDATA, item, (LPARAM)accs[i]); if (!mir_strcmp(szPrimaryStatus, accs[i]->szModuleName)) SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_SETCURSEL, item, 0); } } if (CB_ERR == (int)SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_GETCURSEL, 0, 0)) SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_SETCURSEL, 0, 0); SendDlgItemMessage(hwndDlg, IDC_BLINKSPIN, UDM_SETBUDDY, (WPARAM)GetDlgItem(hwndDlg, IDC_BLINKTIME), 0); SendDlgItemMessage(hwndDlg, IDC_BLINKSPIN, UDM_SETRANGE, 0, MAKELONG(0x3FFF, 250)); SendDlgItemMessage(hwndDlg, IDC_BLINKSPIN, UDM_SETPOS, 0, MAKELONG(cfg::getWord("CList", "IconFlashTime", 550), 0)); CheckDlgButton(hwndDlg, IDC_NOTRAYINFOTIPS, cfg::dat.bNoTrayTips ? 1 : 0); CheckDlgButton(hwndDlg, IDC_APPLYLASTVIEWMODE, cfg::getByte("CList", "AutoApplyLastViewMode", 0) ? BST_CHECKED : BST_UNCHECKED); return TRUE; case WM_COMMAND: if (LOWORD(wParam) == IDC_DONTCYCLE || LOWORD(wParam) == IDC_CYCLE || LOWORD(wParam) == IDC_MULTITRAY) { Utils::enableDlgControl(hwndDlg, IDC_PRIMARYSTATUS, IsDlgButtonChecked(hwndDlg, IDC_DONTCYCLE)); Utils::enableDlgControl(hwndDlg, IDC_CYCLETIME, IsDlgButtonChecked(hwndDlg, IDC_CYCLE)); Utils::enableDlgControl(hwndDlg, IDC_CYCLETIMESPIN, IsDlgButtonChecked(hwndDlg, IDC_CYCLE)); Utils::enableDlgControl(hwndDlg, IDC_ALWAYSMULTI, IsDlgButtonChecked(hwndDlg, IDC_MULTITRAY)); } if (LOWORD(wParam) == IDC_CYCLETIME && HIWORD(wParam) != EN_CHANGE) break; if (LOWORD(wParam) == IDC_PRIMARYSTATUS && HIWORD(wParam) != CBN_SELCHANGE) break; if (LOWORD(wParam) == IDC_CYCLETIME && (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())) return 0; if (LOWORD(wParam) == IDC_BLINKTIME && (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())) return 0; SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); opt_gen_opts_changed = TRUE; break; case WM_NOTIFY: switch (((LPNMHDR)lParam)->idFrom) { case 0: switch (((LPNMHDR)lParam)->code) { case PSN_APPLY: if (!opt_gen_opts_changed) return TRUE; cfg::writeByte("CList", "HideOffline", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_HIDEOFFLINE)); { DWORD caps = CallService(MS_CLUI_GETCAPS, CLUICAPS_FLAGS1, 0); if (caps & CLUIF_HIDEEMPTYGROUPS) cfg::writeByte("CList", "HideEmptyGroups", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_HIDEEMPTYGROUPS)); if (caps & CLUIF_DISABLEGROUPS) cfg::writeByte("CList", "UseGroups", (BYTE)BST_UNCHECKED == IsDlgButtonChecked(hwndDlg, IDC_DISABLEGROUPS)); if (!(caps & CLUIF_HASONTOPOPTION)) { cfg::writeByte("CList", "OnTop", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_ONTOP)); SetWindowPos(pcli->hwndContactList, IsDlgButtonChecked(hwndDlg, IDC_ONTOP) ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); } } cfg::writeByte("CList", "ConfirmDelete", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_CONFIRMDELETE)); cfg::writeByte("CList", "Tray1Click", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_ONECLK)); cfg::writeByte("CList", "AlwaysStatus", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_ALWAYSSTATUS)); cfg::writeByte("CList", "AlwaysMulti", (BYTE)BST_UNCHECKED == IsDlgButtonChecked(hwndDlg, IDC_ALWAYSMULTI)); cfg::writeByte("CList", "TrayIcon", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_DONTCYCLE) ? SETTING_TRAYICON_SINGLE : (IsDlgButtonChecked(hwndDlg, IDC_CYCLE) ? SETTING_TRAYICON_CYCLE : SETTING_TRAYICON_MULTI))); cfg::writeWord("CList", "CycleTime", (WORD)SendDlgItemMessage(hwndDlg, IDC_CYCLETIMESPIN, UDM_GETPOS, 0, 0)); cfg::writeWord("CList", "IconFlashTime", (WORD)SendDlgItemMessage(hwndDlg, IDC_BLINKSPIN, UDM_GETPOS, 0, 0)); cfg::writeByte("CList", "DisableTrayFlash", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_DISABLEBLINK)); cfg::writeByte("CList", "NoIconBlink", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_ICONBLINK)); cfg::writeByte("CList", "AutoApplyLastViewMode", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_APPLYLASTVIEWMODE)); __setFlag(CLUI_FRAME_EVENTAREASUNKEN, IsDlgButtonChecked(hwndDlg, IDC_EVENTAREASUNKEN)); __setFlag(CLUI_FRAME_AUTOHIDENOTIFY, IsDlgButtonChecked(hwndDlg, IDC_EVENTAREAAUTOHIDE)); __setFlag(CLUI_FRAME_SHOWBOTTOMBUTTONS, IsDlgButtonChecked(hwndDlg, IDC_SHOWBOTTOMBUTTONS)); __setFlag(CLUI_FRAME_CLISTSUNKEN, IsDlgButtonChecked(hwndDlg, IDC_CLISTSUNKEN)); cfg::dat.bNoTrayTips = IsDlgButtonChecked(hwndDlg, IDC_NOTRAYINFOTIPS) ? 1 : 0; cfg::writeByte("CList", "NoTrayTips", (BYTE)cfg::dat.bNoTrayTips); { int cursel = SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_GETCURSEL, 0, 0); PROTOACCOUNT *pa = (PROTOACCOUNT *)SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_GETITEMDATA, cursel, 0); if (!pa) db_unset(NULL, "CList", "PrimaryStatus"); else cfg::writeString(NULL, "CList", "PrimaryStatus", pa->szModuleName); } pcli->pfnTrayIconIconsChanged(); cfg::writeDword("CLUI", "Frameflags", cfg::dat.dwFlags); ConfigureFrame(); ConfigureCLUIGeometry(1); ConfigureEventArea(); HideShowNotifyFrame(); SendMessage(pcli->hwndContactTree, WM_SIZE, 0, 0); SendMessage(pcli->hwndContactList, WM_SIZE, 0, 0); LoadContactTree(); /* this won't do job properly since it only really works when changes happen */ pcli->pfnClcBroadcast(CLM_AUTOREBUILD, 0, 0); PostMessage(pcli->hwndContactList, CLUIINTM_REDRAW, 0, 0); opt_gen_opts_changed = 0; return TRUE; } break; } break; } return FALSE; }
bool CGUITextBox::HandleKeyboard( UINT uMsg, WPARAM wParam, LPARAM lParam ) { if(GetFocus() && wParam==m_Hotkey){ OnHotkey(); return true; } if(GetFocus() && m_bSelectable) switch(uMsg){ case WM_KEYDOWN: switch( wParam ){ case VK_UP: PlaceCaret(m_Caretx, m_Carety-1); if( GetKeyState( VK_SHIFT ) >= 0 ) SyncSelStart(); break; case VK_DOWN: PlaceCaret(m_Caretx, m_Carety+1); if( GetKeyState( VK_SHIFT ) >= 0 ) SyncSelStart(); break; case VK_LEFT: if(m_Caretx==0 && m_Carety!=0) PlaceCaret(m_Text[m_Carety-1].length(), m_Carety-1); else PlaceCaret(m_Caretx-1, m_Carety); if( GetKeyState( VK_SHIFT ) >= 0 ) SyncSelStart(); break; case VK_RIGHT: if(m_Caretx==m_MaxCaretx && m_Carety!=m_MaxCarety) PlaceCaret(0, m_Carety+1); else PlaceCaret(m_Caretx+1, m_Carety); if( GetKeyState( VK_SHIFT ) >= 0 ) SyncSelStart(); break; default: break; } break; case WM_CHAR: switch( wParam ){ case VK_BACK: if(m_Caretx==m_SelStartx && m_Carety==m_SelStarty) DeleteTextAtCaret(); else DeleteSelectionText(); break; case VK_RETURN: if(m_bEditable){ if(m_Caretx==m_SelStartx && m_Carety==m_SelStarty) AddChar('\n'); SyncSelStart(); } break; case 24: // Ctrl-X Cut case VK_CANCEL: // Ctrl-C Copy case 22: // Ctrl-V Paste case 26: // Ctrl Z case 2: // Ctrl B case 14: // Ctrl N case 19: // Ctrl S case 4: // Ctrl D case 6: // Ctrl F case 7: // Ctrl G case 10: // Ctrl J case 11: // Ctrl K case 12: // Ctrl L case 17: // Ctrl Q case 23: // Ctrl W case 5: // Ctrl E case 18: // Ctrl R case 20: // Ctrl T case 25: // Ctrl Y case 21: // Ctrl U case 9: // Ctrl I case 15: // Ctrl O case 16: // Ctrl P case 27: // Ctrl [ case 29: // Ctrl ] case 28: // Ctrl \ break; default: if(m_bEditable){ AddChar((char)wParam); SyncSelStart(); } } return true; default: return false; } return false; }
void InitScreen( void ) { FocusWnd = GetFocus(); RestoreMainScreen( "WDWIN" ); GUISetModalDlgs( FALSE ); }
/* * DlgProcYahooOpts - Connection Options Dialog */ static INT_PTR CALLBACK DlgProcYahooOptsConn(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { DBVARIANT dbv; CYahooProto* ppro = (CYahooProto*)GetWindowLongPtr( hwndDlg, GWLP_USERDATA ); switch ( msg ) { case WM_INITDIALOG: TranslateDialogDefault( hwndDlg ); ppro = ( CYahooProto* )lParam; SetWindowLongPtr( hwndDlg, GWLP_USERDATA, lParam ); if ( !ppro->GetString( YAHOO_LOGINSERVER, &dbv )){ SetDlgItemTextA( hwndDlg, IDC_LOGINSERVER, dbv.pszVal ); DBFreeVariant( &dbv ); } else SetDlgItemTextA( hwndDlg, IDC_LOGINSERVER, ppro->GetByte( "YahooJapan", 0 ) ? YAHOO_DEFAULT_JAPAN_LOGIN_SERVER : YAHOO_DEFAULT_LOGIN_SERVER ); SetDlgItemInt( hwndDlg, IDC_YAHOOPORT, ppro->GetWord( NULL, YAHOO_LOGINPORT, YAHOO_DEFAULT_PORT ), FALSE ); SetButtonCheck( hwndDlg, IDC_YAHOO_JAPAN, ppro->GetByte( "YahooJapan", 0 ) ); return TRUE; case WM_COMMAND: switch ( LOWORD( wParam )) { case IDC_RESETSERVER: SetDlgItemTextA( hwndDlg, IDC_LOGINSERVER, YAHOO_DEFAULT_LOGIN_SERVER ); SetDlgItemInt( hwndDlg, IDC_YAHOOPORT, YAHOO_DEFAULT_PORT, FALSE ); SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; case IDC_YAHOO_JAPAN: SetDlgItemTextA( hwndDlg, IDC_LOGINSERVER, (IsDlgButtonChecked(hwndDlg,IDC_YAHOO_JAPAN)==BST_CHECKED) ? YAHOO_DEFAULT_JAPAN_LOGIN_SERVER : YAHOO_DEFAULT_LOGIN_SERVER ); // fall through and enable apply button SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; } if ( HIWORD( wParam ) == EN_CHANGE && ( HWND )lParam == GetFocus()) switch( LOWORD( wParam )) { case IDC_LOGINSERVER: case IDC_YAHOOPORT: SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); } break; case WM_NOTIFY: if (((LPNMHDR)lParam)->code == PSN_APPLY ) { BOOL reconnectRequired = FALSE/*, restartRequired = FALSE*/; char str[128]; DBVARIANT dbv; int port; GetDlgItemTextA( hwndDlg, IDC_LOGINSERVER, str, sizeof( str )); if ( ppro->GetString( YAHOO_LOGINSERVER, &dbv ) || lstrcmpA( str, dbv.pszVal )) reconnectRequired = TRUE; if ( dbv.pszVal != NULL ) DBFreeVariant( &dbv ); ppro->SetString( YAHOO_LOGINSERVER, str ); port = GetDlgItemInt( hwndDlg, IDC_YAHOOPORT, NULL, FALSE ); if ( ppro->GetWord(NULL, YAHOO_LOGINPORT, -1) != port) reconnectRequired = TRUE; ppro->SetWord( NULL, YAHOO_LOGINPORT, port); ppro->SetByte("YahooJapan", ( BYTE )IsDlgButtonChecked( hwndDlg, IDC_YAHOO_JAPAN )); /*if ( restartRequired ) MessageBoxA( hwndDlg, Translate( "The changes you have made require you to restart Miranda IM before they take effect"), Translate("YAHOO Options"), MB_OK ); else */ if ( reconnectRequired && ppro->m_bLoggedIn ) MessageBoxA( hwndDlg, Translate( "The changes you have made require you to reconnect to the Yahoo network before they take effect"), Translate("YAHOO Options"), MB_OK ); return TRUE; } break; } return FALSE; }
/* * DlgProcYahooOpts - Account Options Dialog */ static INT_PTR CALLBACK DlgProcYahooOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { DBVARIANT dbv; CYahooProto* ppro = (CYahooProto*)GetWindowLongPtr( hwndDlg, GWLP_USERDATA ); switch ( msg ) { case WM_INITDIALOG: TranslateDialogDefault( hwndDlg ); ppro = (CYahooProto*)lParam; SetWindowLongPtr( hwndDlg, GWLP_USERDATA, lParam ); if ( !ppro->GetString( YAHOO_LOGINID, &dbv )) { SetDlgItemTextA(hwndDlg,IDC_HANDLE,dbv.pszVal); DBFreeVariant(&dbv); } if ( !ppro->GetString( "Nick", &dbv )) { SetDlgItemTextA(hwndDlg,IDC_NICK,dbv.pszVal); DBFreeVariant(&dbv); } if ( !ppro->GetString( YAHOO_PASSWORD, &dbv )) { //bit of a security hole here, since it's easy to extract a password from an edit box YAHOO_CallService( MS_DB_CRYPT_DECODESTRING, strlen( dbv.pszVal )+1, ( LPARAM )dbv.pszVal ); SetDlgItemTextA( hwndDlg, IDC_PASSWORD, dbv.pszVal ); DBFreeVariant( &dbv ); } //SetButtonCheck( hwndDlg, IDC_DISABLE_UTF8, ppro->GetByte( "DisableUTF8", 0 )); SetButtonCheck( hwndDlg, IDC_USE_YAB, ppro->GetByte( "UseYAB", 1 )); SetButtonCheck( hwndDlg, IDC_SHOW_AVATARS, ppro->GetByte( "ShowAvatars", 1 )); SetButtonCheck( hwndDlg, IDC_MAIL_AUTOLOGIN, ppro->GetByte( "MailAutoLogin", 1 )); SetButtonCheck( hwndDlg, IDC_DISABLEYAHOOMAIL, !ppro->GetByte( "DisableYahoomail", 0 )); SetButtonCheck( hwndDlg, IDC_SHOW_ERRORS, ppro->GetByte( "ShowErrors", 1 )); return TRUE; case WM_COMMAND: switch ( LOWORD( wParam )) { case IDC_NEWYAHOOACCOUNTLINK: YAHOO_CallService( MS_UTILS_OPENURL, 1, ppro->GetByte( "YahooJapan", 0 ) ? (LPARAM)"http://edit.yahoo.co.jp/config/eval_register" : (LPARAM)"http://edit.yahoo.com/config/eval_register" ); return TRUE; //case IDC_DISABLE_UTF8: case IDC_USE_YAB: case IDC_SHOW_AVATARS: case IDC_MAIL_AUTOLOGIN: case IDC_SHOW_ERRORS: case IDC_DISABLEYAHOOMAIL: SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; } if ( HIWORD( wParam ) == EN_CHANGE && ( HWND )lParam == GetFocus()) switch( LOWORD( wParam )) { case IDC_HANDLE: case IDC_PASSWORD: case IDC_NICK: SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); } break; case WM_NOTIFY: if (((LPNMHDR)lParam)->code == (UINT) PSN_APPLY ) { BOOL reconnectRequired = FALSE; char str[128]; GetDlgItemTextA( hwndDlg, IDC_HANDLE, str, sizeof( str )); dbv.pszVal = NULL; if ( ppro->GetString( YAHOO_LOGINID, &dbv ) || lstrcmpA( str, dbv.pszVal )) reconnectRequired = TRUE; if ( dbv.pszVal != NULL ) DBFreeVariant( &dbv ); ppro->SetString( YAHOO_LOGINID, str ); GetDlgItemTextA( hwndDlg, IDC_PASSWORD, str, sizeof( str )); YAHOO_CallService( MS_DB_CRYPT_ENCODESTRING, sizeof( str ),( LPARAM )str ); dbv.pszVal = NULL; if ( ppro->GetString( YAHOO_PASSWORD, &dbv ) || lstrcmpA( str, dbv.pszVal )) reconnectRequired = TRUE; if ( dbv.pszVal != NULL ) DBFreeVariant( &dbv ); ppro->SetString( YAHOO_PASSWORD, str ); GetDlgItemTextA( hwndDlg, IDC_NICK, str, sizeof( str )); if (str[0] == '\0') { /* Check for empty Nick, if so delete the key in the DB */ DBDeleteContactSetting( NULL, ppro->m_szModuleName, "Nick" ); } else { /* otherwise save the new Nick */ ppro->SetString( "Nick", str ); } //ppro->SetByte("DisableUTF8", ( BYTE )IsDlgButtonChecked( hwndDlg, IDC_DISABLE_UTF8 )); ppro->SetByte("UseYAB", ( BYTE )IsDlgButtonChecked( hwndDlg, IDC_USE_YAB )); ppro->SetByte("ShowAvatars", ( BYTE )IsDlgButtonChecked( hwndDlg, IDC_SHOW_AVATARS )); ppro->SetByte("MailAutoLogin", ( BYTE )IsDlgButtonChecked( hwndDlg, IDC_MAIL_AUTOLOGIN )); ppro->SetByte("DisableYahoomail", ( BYTE )!IsDlgButtonChecked( hwndDlg, IDC_DISABLEYAHOOMAIL )); ppro->SetByte("ShowErrors", ( BYTE )IsDlgButtonChecked( hwndDlg, IDC_SHOW_ERRORS )); if (reconnectRequired ) { DBDeleteContactSetting(NULL, ppro->m_szModuleName, YAHOO_PWTOKEN); } /*if ( restartRequired ) MessageBoxA( hwndDlg, Translate( "The changes you have made require you to restart Miranda IM before they take effect"), Translate("YAHOO Options"), MB_OK ); else */ if ( reconnectRequired && ppro->m_bLoggedIn ) MessageBoxA( hwndDlg, Translate( "The changes you have made require you to reconnect to the Yahoo network before they take effect"), Translate("YAHOO Options"), MB_OK ); return TRUE; } break; } return FALSE; }
static int SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created) { SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; SDL_WindowData *data; /* Allocate the window data */ data = (SDL_WindowData *) SDL_malloc(sizeof(*data)); if (!data) { return SDL_OutOfMemory(); } data->window = window; data->hwnd = hwnd; data->hdc = GetDC(hwnd); data->created = created; data->mouse_button_flags = 0; data->videodata = videodata; window->driverdata = data; /* Associate the data with the window */ if (!SetProp(hwnd, TEXT("SDL_WindowData"), data)) { ReleaseDC(hwnd, data->hdc); SDL_free(data); return WIN_SetError("SetProp() failed"); } /* Set up the window proc function */ #ifdef GWLP_WNDPROC data->wndproc = (WNDPROC) GetWindowLongPtr(hwnd, GWLP_WNDPROC); if (data->wndproc == WIN_WindowProc) { data->wndproc = NULL; } else { SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR) WIN_WindowProc); } #else data->wndproc = (WNDPROC) GetWindowLong(hwnd, GWL_WNDPROC); if (data->wndproc == WIN_WindowProc) { data->wndproc = NULL; } else { SetWindowLong(hwnd, GWL_WNDPROC, (LONG_PTR) WIN_WindowProc); } #endif /* Fill in the SDL window with the window data */ { RECT rect; if (GetClientRect(hwnd, &rect)) { int w = rect.right; int h = rect.bottom; if ((window->w && window->w != w) || (window->h && window->h != h)) { /* We tried to create a window larger than the desktop and Windows didn't allow it. Override! */ WIN_SetWindowPositionInternal(_this, window, SWP_NOCOPYBITS | SWP_NOZORDER | SWP_NOACTIVATE); } else { window->w = w; window->h = h; } } } { POINT point; point.x = 0; point.y = 0; if (ClientToScreen(hwnd, &point)) { window->x = point.x; window->y = point.y; } } { DWORD style = GetWindowLong(hwnd, GWL_STYLE); if (style & WS_VISIBLE) { window->flags |= SDL_WINDOW_SHOWN; } else { window->flags &= ~SDL_WINDOW_SHOWN; } if (style & (WS_BORDER | WS_THICKFRAME)) { window->flags &= ~SDL_WINDOW_BORDERLESS; } else { window->flags |= SDL_WINDOW_BORDERLESS; } if (style & WS_THICKFRAME) { window->flags |= SDL_WINDOW_RESIZABLE; } else { window->flags &= ~SDL_WINDOW_RESIZABLE; } #ifdef WS_MAXIMIZE if (style & WS_MAXIMIZE) { window->flags |= SDL_WINDOW_MAXIMIZED; } else #endif { window->flags &= ~SDL_WINDOW_MAXIMIZED; } #ifdef WS_MINIMIZE if (style & WS_MINIMIZE) { window->flags |= SDL_WINDOW_MINIMIZED; } else #endif { window->flags &= ~SDL_WINDOW_MINIMIZED; } } if (GetFocus() == hwnd) { window->flags |= SDL_WINDOW_INPUT_FOCUS; SDL_SetKeyboardFocus(data->window); if (window->flags & SDL_WINDOW_INPUT_GRABBED) { RECT rect; GetClientRect(hwnd, &rect); ClientToScreen(hwnd, (LPPOINT) & rect); ClientToScreen(hwnd, (LPPOINT) & rect + 1); ClipCursor(&rect); } } /* Enable multi-touch */ if (videodata->RegisterTouchWindow) { videodata->RegisterTouchWindow(hwnd, (TWF_FINETOUCH|TWF_WANTPALM)); } /* Enable dropping files */ DragAcceptFiles(hwnd, TRUE); /* All done! */ return 0; }
/* * callback function for tab 1 options page */ INT_PTR CALLBACK DlgProcOpts_Tab1(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { switch ( msg ) { case WM_INITDIALOG: { //executed once, during each tab initialization during each miranda options open mirfoxMiranda.getMirfoxData().setTab1OptionsState(MFENUM_OPTIONS_INIT); TranslateDialogDefault(hwndDlg); //IDC1_COMBO1 SendDlgItemMessage(hwndDlg, IDC1_COMBO1, CB_ADDSTRING, 0, (LPARAM)TranslateT("just send message")); SendDlgItemMessage(hwndDlg, IDC1_COMBO1, CB_ADDSTRING, 0, (LPARAM)TranslateT("send message and open message window")); SendDlgItemMessage(hwndDlg, IDC1_COMBO1, CB_ADDSTRING, 0, (LPARAM)TranslateT("show message window with pasted message")); SendDlgItemMessage(hwndDlg, IDC1_COMBO1, CB_SETCURSEL, (int)mirfoxMiranda.getMirfoxData().leftClickSendMode - 1, 0); //IDC1_COMBO2 SendDlgItemMessage(hwndDlg, IDC1_COMBO2, CB_ADDSTRING, 0, (LPARAM)TranslateT("just send message")); SendDlgItemMessage(hwndDlg, IDC1_COMBO2, CB_ADDSTRING, 0, (LPARAM)TranslateT("send message and open message window")); SendDlgItemMessage(hwndDlg, IDC1_COMBO2, CB_ADDSTRING, 0, (LPARAM)TranslateT("show message window with pasted message")); SendDlgItemMessage(hwndDlg, IDC1_COMBO2, CB_SETCURSEL, (int)mirfoxMiranda.getMirfoxData().rightClickSendMode - 1, 0); //IDC1_COMBO3 SendDlgItemMessage(hwndDlg, IDC1_COMBO3, CB_ADDSTRING, 0, (LPARAM)TranslateT("just send message")); //disabled due to Firefox bug. opening other window while firefox menu is still open -> firefox crash //SendDlgItemMessage(hwndDlg, IDC1_COMBO3, CB_ADDSTRING, 0, (LPARAM)TranslateT("send message and open message window")); //SendDlgItemMessage(hwndDlg, IDC1_COMBO3, CB_ADDSTRING, 0, (LPARAM)TranslateT("show message window with pasted message")); SendDlgItemMessage(hwndDlg, IDC1_COMBO3, CB_SETCURSEL, (int)mirfoxMiranda.getMirfoxData().middleClickSendMode - 1, 0); //other options initialization SetDlgItemText(hwndDlg, IDC1_EDIT1, mirfoxMiranda.getMirfoxData().getClientsProfilesFilterStringPtr()->c_str()); if (mirfoxMiranda.getMirfoxData().getClientsProfilesFilterCheckbox()){ CheckDlgButton(hwndDlg, IDC1_CHECK1, BST_CHECKED); EnableWindow(GetDlgItem(hwndDlg, IDC1_EDIT1), TRUE); } else { CheckDlgButton(hwndDlg, IDC1_CHECK1, BST_UNCHECKED); EnableWindow(GetDlgItem(hwndDlg, IDC1_EDIT1), FALSE); } //other options initialization - end mirfoxMiranda.getMirfoxData().setTab1OptionsState(MFENUM_OPTIONS_WORK); return FALSE; } case WM_COMMAND: { if (mirfoxMiranda.getMirfoxData().getTab1OptionsState() != MFENUM_OPTIONS_WORK){ break; //options not inited yet } //if user changed some options controls, send info to miranda to activate ok button if ( ( ((HIWORD(wParam) == EN_CHANGE) && (HWND)lParam == GetFocus()) //edit control AND control from message has focus now || ((HIWORD(wParam) == BN_CLICKED) && (HWND)lParam == GetFocus()) //button or checkbox clicked AND control from message has focus now || (HIWORD(wParam) == CBN_DROPDOWN) //COMBOBOX clicked ) && ( LOWORD(wParam) != IDC1_BUTTON_INVALIDATE //invalidate button click doesn't activate [Apply] button. ) ) { SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); } if (LOWORD(wParam) == IDC1_CHECK1){ if (IsDlgButtonChecked(hwndDlg, IDC1_CHECK1) == BST_CHECKED){ EnableWindow(GetDlgItem(hwndDlg, IDC1_EDIT1), TRUE); } else { EnableWindow(GetDlgItem(hwndDlg, IDC1_EDIT1), FALSE); } } //if (LOWORD(wParam) == IDC1_BUTTON_INVALIDATE && HIWORD(wParam) == BN_CLICKED){ //TODO invalidate button clicked - refresh MSM's (now this button has visable=false at .rc file) //break; //} break; } case WM_NOTIFY: { //executed on each move to another options tab or after [OK] if (mirfoxMiranda.getMirfoxData().getTab1OptionsState() != MFENUM_OPTIONS_WORK){ break; //options not inited yet } if (((LPNMHDR)lParam)->idFrom == 0 && ((LPNMHDR)lParam)->code == PSN_APPLY){ //SaveOptions from tab1 mirfoxData to miranda database mirfoxMiranda.getMirfoxData().leftClickSendMode = (MFENUM_SEND_MESSAGE_MODE)( 1 + (WORD)SendDlgItemMessage(hwndDlg, IDC1_COMBO1, CB_GETCURSEL, 0, 0)); db_set_b(0, PLUGIN_DB_ID, "leftClickSendMode", (int)mirfoxMiranda.getMirfoxData().leftClickSendMode); mirfoxMiranda.getMirfoxData().rightClickSendMode = (MFENUM_SEND_MESSAGE_MODE)( 1 + (WORD)SendDlgItemMessage(hwndDlg, IDC1_COMBO2, CB_GETCURSEL, 0, 0)); db_set_b(0, PLUGIN_DB_ID, "rightClickSendMode", (int)mirfoxMiranda.getMirfoxData().rightClickSendMode); mirfoxMiranda.getMirfoxData().middleClickSendMode = (MFENUM_SEND_MESSAGE_MODE)( 1 + (WORD)SendDlgItemMessage(hwndDlg, IDC1_COMBO3, CB_GETCURSEL, 0, 0)); db_set_b(0, PLUGIN_DB_ID, "middleClickSendMode", (int)mirfoxMiranda.getMirfoxData().middleClickSendMode); if (IsDlgButtonChecked(hwndDlg, IDC1_CHECK1) == BST_CHECKED){ mirfoxMiranda.getMirfoxData().setClientsProfilesFilterCheckbox(true); db_set_b(0, PLUGIN_DB_ID, "clientsProfilesFilterCheckbox", 1); } else { mirfoxMiranda.getMirfoxData().setClientsProfilesFilterCheckbox(false); db_set_b(0, PLUGIN_DB_ID, "clientsProfilesFilterCheckbox", 2); } int opt2Len = SendDlgItemMessage(hwndDlg, IDC1_EDIT1, WM_GETTEXTLENGTH, 0, 0); wchar_t * opt2Buffer = new WCHAR[opt2Len+1]; UINT opt2NumCharCopy = GetDlgItemText(hwndDlg, IDC1_EDIT1, opt2Buffer, opt2Len+1); mirfoxMiranda.getMirfoxData().getClientsProfilesFilterStringPtr()->assign(opt2Buffer); delete[] opt2Buffer; mirfoxMiranda.getMirfoxData().normalizeClientsProfilesFilterString(SMUCONST_CSM_RECORD_VISABLETO_SIZEC_DEF); SetDlgItemText(hwndDlg, IDC1_EDIT1, mirfoxMiranda.getMirfoxData().getClientsProfilesFilterStringPtr()->c_str()); MFLogger* logger = MFLogger::getInstance(); logger->log_p(L"Options. Save clientsProfilesFilterString: [%s]", mirfoxMiranda.getMirfoxData().getClientsProfilesFilterStringPtr()->c_str()); db_set_ts(0, PLUGIN_DB_ID, "clientsProfilesFilterString", mirfoxMiranda.getMirfoxData().getClientsProfilesFilterStringPtr()->c_str()); //TODO fire actualization visableTo field at CSM record }//end of PSN_APPLY break; } case WM_DESTROY: break; } return 0; }
LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { GHOST_Event* event = 0; bool eventHandled = false; LRESULT lResult = 0; GHOST_SystemWin32* system = ((GHOST_SystemWin32*)getSystem()); GHOST_ASSERT(system, "GHOST_SystemWin32::s_wndProc(): system not initialized") if (hwnd) { GHOST_WindowWin32* window = (GHOST_WindowWin32*)::GetWindowLong(hwnd, GWL_USERDATA); if (window) { switch (msg) { // we need to check if new key layout has AltGr case WM_INPUTLANGCHANGE: system->handleKeyboardChange(); break; //////////////////////////////////////////////////////////////////////// // Keyboard events, processed //////////////////////////////////////////////////////////////////////// case WM_INPUT: { // check WM_INPUT from input sink when ghost window is not in the foreground if (wParam == RIM_INPUTSINK) { if (GetFocus() != hwnd) // WM_INPUT message not for this window return 0; } //else wParam == RIM_INPUT RAWINPUT raw; RAWINPUT* raw_ptr = &raw; UINT rawSize = sizeof(RAWINPUT); GetRawInputData((HRAWINPUT)lParam, RID_INPUT, raw_ptr, &rawSize, sizeof(RAWINPUTHEADER)); switch (raw.header.dwType) { case RIM_TYPEKEYBOARD: event = processKeyEvent(window, raw); if (!event) { GHOST_PRINT("GHOST_SystemWin32::wndProc: key event ") GHOST_PRINT(msg) GHOST_PRINT(" key ignored\n") } break; case RIM_TYPEHID: #ifdef WITH_INPUT_NDOF if (system->processNDOF(raw)) eventHandled = true; #endif break; } break; } //////////////////////////////////////////////////////////////////////// // Keyboard events, ignored //////////////////////////////////////////////////////////////////////// case WM_KEYDOWN: case WM_SYSKEYDOWN: case WM_KEYUP: case WM_SYSKEYUP: /* These functions were replaced by WM_INPUT*/ case WM_CHAR: /* The WM_CHAR message is posted to the window with the keyboard focus when * a WM_KEYDOWN message is translated by the TranslateMessage function. WM_CHAR * contains the character code of the key that was pressed. */ case WM_DEADCHAR: /* The WM_DEADCHAR message is posted to the window with the keyboard focus when a * WM_KEYUP message is translated by the TranslateMessage function. WM_DEADCHAR * specifies a character code generated by a dead key. A dead key is a key that * generates a character, such as the umlaut (double-dot), that is combined with * another character to form a composite character. For example, the umlaut-O * character (Ö) is generated by typing the dead key for the umlaut character, and * then typing the O key. */ break; case WM_SYSDEADCHAR: /* The WM_SYSDEADCHAR message is sent to the window with the keyboard focus when * a WM_SYSKEYDOWN message is translated by the TranslateMessage function. * WM_SYSDEADCHAR specifies the character code of a system dead key - that is, * a dead key that is pressed while holding down the alt key. */ case WM_SYSCHAR: /* The WM_SYSCHAR message is sent to the window with the keyboard focus when * a WM_SYSCHAR message is translated by the TranslateMessage function. * WM_SYSCHAR specifies the character code of a dead key - that is, * a dead key that is pressed while holding down the alt key. * To prevent the sound, DefWindowProc must be avoided by return */ break; case WM_SYSCOMMAND: /* The WM_SYSCHAR message is sent to the window when system commands such as * maximize, minimize or close the window are triggered. Also it is sent when ALT * button is press for menu. To prevent this we must return preventing DefWindowProc. */ if(wParam==SC_KEYMENU) return 0; break; //////////////////////////////////////////////////////////////////////// // Tablet events, processed //////////////////////////////////////////////////////////////////////// case WT_PACKET: ((GHOST_WindowWin32*)window)->processWin32TabletEvent(wParam, lParam); break; case WT_CSRCHANGE: case WT_PROXIMITY: ((GHOST_WindowWin32*)window)->processWin32TabletInitEvent(); break; //////////////////////////////////////////////////////////////////////// // Mouse events, processed //////////////////////////////////////////////////////////////////////// case WM_LBUTTONDOWN: window->registerMouseClickEvent(0); event = processButtonEvent(GHOST_kEventButtonDown, window, GHOST_kButtonMaskLeft); break; case WM_MBUTTONDOWN: window->registerMouseClickEvent(0); event = processButtonEvent(GHOST_kEventButtonDown, window, GHOST_kButtonMaskMiddle); break; case WM_RBUTTONDOWN: window->registerMouseClickEvent(0); event = processButtonEvent(GHOST_kEventButtonDown, window, GHOST_kButtonMaskRight); break; case WM_XBUTTONDOWN: window->registerMouseClickEvent(0); if ((short) HIWORD(wParam) == XBUTTON1){ event = processButtonEvent(GHOST_kEventButtonDown, window, GHOST_kButtonMaskButton4); }else if((short) HIWORD(wParam) == XBUTTON2){ event = processButtonEvent(GHOST_kEventButtonDown, window, GHOST_kButtonMaskButton5); } break; case WM_LBUTTONUP: window->registerMouseClickEvent(1); event = processButtonEvent(GHOST_kEventButtonUp, window, GHOST_kButtonMaskLeft); break; case WM_MBUTTONUP: window->registerMouseClickEvent(1); event = processButtonEvent(GHOST_kEventButtonUp, window, GHOST_kButtonMaskMiddle); break; case WM_RBUTTONUP: window->registerMouseClickEvent(1); event = processButtonEvent(GHOST_kEventButtonUp, window, GHOST_kButtonMaskRight); break; case WM_XBUTTONUP: window->registerMouseClickEvent(1); if ((short) HIWORD(wParam) == XBUTTON1){ event = processButtonEvent(GHOST_kEventButtonUp, window, GHOST_kButtonMaskButton4); }else if((short) HIWORD(wParam) == XBUTTON2){ event = processButtonEvent(GHOST_kEventButtonUp, window, GHOST_kButtonMaskButton5); } break; case WM_MOUSEMOVE: event = processCursorEvent(GHOST_kEventCursorMove, window); break; case WM_MOUSEWHEEL: /* The WM_MOUSEWHEEL message is sent to the focus window * when the mouse wheel is rotated. The DefWindowProc * function propagates the message to the window's parent. * There should be no internal forwarding of the message, * since DefWindowProc propagates it up the parent chain * until it finds a window that processes it. */ event = processWheelEvent(window, wParam, lParam); break; case WM_SETCURSOR: /* The WM_SETCURSOR message is sent to a window if the mouse causes the cursor * to move within a window and mouse input is not captured. * This means we have to set the cursor shape every time the mouse moves! * The DefWindowProc function uses this message to set the cursor to an * arrow if it is not in the client area. */ if (LOWORD(lParam) == HTCLIENT) { // Load the current cursor window->loadCursor(window->getCursorVisibility(), window->getCursorShape()); // Bypass call to DefWindowProc return 0; } else { // Outside of client area show standard cursor window->loadCursor(true, GHOST_kStandardCursorDefault); } break; //////////////////////////////////////////////////////////////////////// // Mouse events, ignored //////////////////////////////////////////////////////////////////////// case WM_NCMOUSEMOVE: /* The WM_NCMOUSEMOVE message is posted to a window when the cursor is moved * within the nonclient area of the window. This message is posted to the window * that contains the cursor. If a window has captured the mouse, this message is not posted. */ case WM_NCHITTEST: /* The WM_NCHITTEST message is sent to a window when the cursor moves, or * when a mouse button is pressed or released. If the mouse is not captured, * the message is sent to the window beneath the cursor. Otherwise, the message * is sent to the window that has captured the mouse. */ break; //////////////////////////////////////////////////////////////////////// // Window events, processed //////////////////////////////////////////////////////////////////////// case WM_CLOSE: /* The WM_CLOSE message is sent as a signal that a window or an application should terminate. */ event = processWindowEvent(GHOST_kEventWindowClose, window); break; case WM_ACTIVATE: /* The WM_ACTIVATE message is sent to both the window being activated and the window being * deactivated. If the windows use the same input queue, the message is sent synchronously, * first to the window procedure of the top-level window being deactivated, then to the window * procedure of the top-level window being activated. If the windows use different input queues, * the message is sent asynchronously, so the window is activated immediately. */ { GHOST_ModifierKeys modifiers; modifiers.clear(); system->storeModifierKeys(modifiers); event = processWindowEvent(LOWORD(wParam) ? GHOST_kEventWindowActivate : GHOST_kEventWindowDeactivate, window); /* WARNING: Let DefWindowProc handle WM_ACTIVATE, otherwise WM_MOUSEWHEEL will not be dispatched to OUR active window if we minimize one of OUR windows. */ lResult = ::DefWindowProc(hwnd, msg, wParam, lParam); break; } case WM_PAINT: /* An application sends the WM_PAINT message when the system or another application * makes a request to paint a portion of an application's window. The message is sent * when the UpdateWindow or RedrawWindow function is called, or by the DispatchMessage * function when the application obtains a WM_PAINT message by using the GetMessage or * PeekMessage function. */ event = processWindowEvent(GHOST_kEventWindowUpdate, window); ::ValidateRect(hwnd, NULL); break; case WM_GETMINMAXINFO: /* The WM_GETMINMAXINFO message is sent to a window when the size or * position of the window is about to change. An application can use * this message to override the window's default maximized size and * position, or its default minimum or maximum tracking size. */ processMinMaxInfo((MINMAXINFO *) lParam); /* Let DefWindowProc handle it. */ break; case WM_SIZE: /* The WM_SIZE message is sent to a window after its size has changed. * The WM_SIZE and WM_MOVE messages are not sent if an application handles the * WM_WINDOWPOSCHANGED message without calling DefWindowProc. It is more efficient * to perform any move or size change processing during the WM_WINDOWPOSCHANGED * message without calling DefWindowProc. */ event = processWindowEvent(GHOST_kEventWindowSize, window); break; case WM_CAPTURECHANGED: window->lostMouseCapture(); break; case WM_MOVING: /* The WM_MOVING message is sent to a window that the user is moving. By processing * this message, an application can monitor the size and position of the drag rectangle * and, if needed, change its size or position. */ case WM_MOVE: /* The WM_SIZE and WM_MOVE messages are not sent if an application handles the * WM_WINDOWPOSCHANGED message without calling DefWindowProc. It is more efficient * to perform any move or size change processing during the WM_WINDOWPOSCHANGED * message without calling DefWindowProc. */ event = processWindowEvent(GHOST_kEventWindowMove, window); break; //////////////////////////////////////////////////////////////////////// // Window events, ignored //////////////////////////////////////////////////////////////////////// case WM_WINDOWPOSCHANGED: /* The WM_WINDOWPOSCHANGED message is sent to a window whose size, position, or place * in the Z order has changed as a result of a call to the SetWindowPos function or * another window-management function. * The WM_SIZE and WM_MOVE messages are not sent if an application handles the * WM_WINDOWPOSCHANGED message without calling DefWindowProc. It is more efficient * to perform any move or size change processing during the WM_WINDOWPOSCHANGED * message without calling DefWindowProc. */ case WM_ERASEBKGND: /* An application sends the WM_ERASEBKGND message when the window background must be * erased (for example, when a window is resized). The message is sent to prepare an * invalidated portion of a window for painting. */ case WM_NCPAINT: /* An application sends the WM_NCPAINT message to a window when its frame must be painted. */ case WM_NCACTIVATE: /* The WM_NCACTIVATE message is sent to a window when its nonclient area needs to be changed * to indicate an active or inactive state. */ case WM_DESTROY: /* The WM_DESTROY message is sent when a window is being destroyed. It is sent to the window * procedure of the window being destroyed after the window is removed from the screen. * This message is sent first to the window being destroyed and then to the child windows * (if any) as they are destroyed. During the processing of the message, it can be assumed * that all child windows still exist. */ case WM_NCDESTROY: /* The WM_NCDESTROY message informs a window that its nonclient area is being destroyed. The * DestroyWindow function sends the WM_NCDESTROY message to the window following the WM_DESTROY * message. WM_DESTROY is used to free the allocated memory object associated with the window. */ break; case WM_KILLFOCUS: /* The WM_KILLFOCUS message is sent to a window immediately before it loses the keyboard focus. * We want to prevent this if a window is still active and it loses focus to nowhere*/ if(!wParam && hwnd==GetActiveWindow()) SetFocus(hwnd); case WM_SHOWWINDOW: /* The WM_SHOWWINDOW message is sent to a window when the window is about to be hidden or shown. */ case WM_WINDOWPOSCHANGING: /* The WM_WINDOWPOSCHANGING message is sent to a window whose size, position, or place in * the Z order is about to change as a result of a call to the SetWindowPos function or * another window-management function. */ case WM_SETFOCUS: /* The WM_SETFOCUS message is sent to a window after it has gained the keyboard focus. */ case WM_ENTERSIZEMOVE: /* The WM_ENTERSIZEMOVE message is sent one time to a window after it enters the moving * or sizing modal loop. The window enters the moving or sizing modal loop when the user * clicks the window's title bar or sizing border, or when the window passes the * WM_SYSCOMMAND message to the DefWindowProc function and the wParam parameter of the * message specifies the SC_MOVE or SC_SIZE value. The operation is complete when * DefWindowProc returns. */ break; //////////////////////////////////////////////////////////////////////// // Other events //////////////////////////////////////////////////////////////////////// case WM_GETTEXT: /* An application sends a WM_GETTEXT message to copy the text that * corresponds to a window into a buffer provided by the caller. */ case WM_ACTIVATEAPP: /* The WM_ACTIVATEAPP message is sent when a window belonging to a * different application than the active window is about to be activated. * The message is sent to the application whose window is being activated * and to the application whose window is being deactivated. */ case WM_TIMER: /* The WIN32 docs say: * The WM_TIMER message is posted to the installing thread's message queue * when a timer expires. You can process the message by providing a WM_TIMER * case in the window procedure. Otherwise, the default window procedure will * call the TimerProc callback function specified in the call to the SetTimer * function used to install the timer. * * In GHOST, we let DefWindowProc call the timer callback. */ break; } } else { // Event found for a window before the pointer to the class has been set. GHOST_PRINT("GHOST_SystemWin32::wndProc: GHOST window event before creation\n") /* These are events we typically miss at this point: WM_GETMINMAXINFO 0x24 WM_NCCREATE 0x81 WM_NCCALCSIZE 0x83 WM_CREATE 0x01 We let DefWindowProc do the work. */ } }
static void gwdraw(GUIWIN *gw, long fg, long bg, int bits, Char *text, int len) { register int i; GUI_WINDOW *gwp = (GUI_WINDOW *)gw; COLORREF fgc, bgc; HBRUSH hBrush, hPrevBrush; HPEN hPen, hPrevPen; HDC hDC; HFONT hFont; RECT rect; int ileft; int xleft, xcenter, xright, ytop, ycenter, ybottom, radius; UINT options; /* Italics are slanted rightward from the bottom of the character cell. * We'd like for them to look slanted from the center of the characters, * and we can achieve that effect by shifting italic text slightly leftward. */ ileft = 0; if ((bits & COLOR_GRAPHIC) != COLOR_GRAPHIC && (bits & COLOR_ITALIC)) ileft = (gwp->ycsize - 3) / 6; /* just a guess */ /* Convert fg and bg args into COLORREF values */ fgc = (COLORREF)fg; bgc = (COLORREF)bg; /* compute the update RECT */ rect.top = gwp->currow * gwp->ycsize; rect.left = gwp->curcol * gwp->xcsize + gwp->xcsize / 2; rect.bottom = rect.top + gwp->ycsize; rect.right = rect.left + gwp->xcsize * len; /* Get the window's DC */ hDC = GetDC (gwp->clientHWnd); SetMapMode (hDC, MM_TEXT); /* hide caret */ if (gwp->cursor_type != CURSOR_NONE && gwp->clientHWnd == GetFocus ()) { HideCaret (gwp->clientHWnd); gwp->cursor_type = CURSOR_NONE; } /* graphic chars are a special case */ if ((bits & COLOR_GRAPHIC) == COLOR_GRAPHIC) { /* Strip out the COLOR_GRAPHIC bits */ bits &= ~COLOR_GRAPHIC; /* Erase the area */ #ifdef FEATURE_IMAGE if (normalimage && (long)bgc == colorinfo[COLOR_FONT_NORMAL].bg) { gw_erase_rect(hDC, &rect, normalimage, gwp->scrolled); } else if (idleimage && (long)bgc == colorinfo[COLOR_FONT_IDLE].bg) { gw_erase_rect(hDC, &rect, idleimage, gwp->scrolled); } else #endif { hBrush = CreateSolidBrush (bgc); FillRect (hDC, &rect, hBrush); DeleteObject(hBrush); } /* Select the foreground color */ hPen = CreatePen(PS_SOLID, 0, fgc); hPrevPen = SelectObject(hDC, hPen); /* Find special points in the first character cell */ radius = gwp->xcsize / 3; xleft = rect.left; xright = xleft + gwp->xcsize; xcenter = (xleft + xright) / 2; ytop = rect.top; ybottom = rect.bottom; ycenter = (ytop + ybottom) / 2; /* For each graphic character... */ for (i = 0; i < len; text++, i++) { /* Draw line segments, as appropriate for this character */ if (strchr("123456|", *text)) { MoveToEx(hDC, xcenter, ytop, NULL); LineTo(hDC, xcenter, ycenter); } if (strchr("456789|", *text)) { MoveToEx(hDC, xcenter, ycenter, NULL); LineTo(hDC, xcenter, ybottom); } if (strchr("235689-", *text)) { MoveToEx(hDC, xleft, ycenter, NULL); LineTo(hDC, xcenter, ycenter); } if (strchr("124578-", *text)) { MoveToEx(hDC, xcenter, ycenter, NULL); LineTo(hDC, xright, ycenter); } if (*text == 'o') { Arc(hDC, xcenter - radius, ycenter - radius, xcenter + radius, ycenter + radius, xcenter - radius, ycenter, xcenter - radius, ycenter); } if (*text == '*') { HBRUSH oldbrush, newbrush; newbrush = CreateSolidBrush(fgc); oldbrush = SelectObject(hDC, newbrush); Pie(hDC, xcenter - radius, ycenter - radius, xcenter + radius, ycenter + radius, xcenter - radius, ycenter, xcenter - radius, ycenter); SelectObject(hDC, oldbrush); DeleteObject(newbrush); } /* Advance the points to the next cell */ xleft = xright; xcenter += gwp->xcsize; xright += gwp->xcsize; } /* Restore foreground color to its previous value, so we can delete * the local hPen object. */ SelectObject(hDC, hPrevPen); DeleteObject(hPen); } else { /* Find a font with the right bold/italic/underlined attributes */ i = 0; if (bits & COLOR_BOLD) i += 1; if (bits & COLOR_ITALIC) i += 2; if (bits & COLOR_UNDERLINED) i += 4; hFont = gwp->fonts[i]; /* prepare DC & output text */ SetTextColor(hDC, fgc); SetBkColor(hDC, bgc); SetBkMode(hDC, OPAQUE); SelectObject(hDC, hFont); options = ETO_OPAQUE | ETO_CLIPPED; #ifdef FEATURE_IMAGE if (normalimage && (long)bgc == colorinfo[COLOR_FONT_NORMAL].bg) { gw_erase_rect(hDC, &rect, normalimage, gwp->scrolled); options = ETO_CLIPPED; SetBkMode(hDC, TRANSPARENT); } else if (idleimage && (long)bgc == colorinfo[COLOR_FONT_IDLE].bg) { gw_erase_rect(hDC, &rect, idleimage, gwp->scrolled); options = ETO_CLIPPED; SetBkMode(hDC, TRANSPARENT); } #endif ExtTextOut(hDC, rect.left - ileft, rect.top, options, &rect, (char *)text, len, gwp->font_size_array); #ifdef FEATURE_IMAGE SetBkColor(hDC, bgc); SetBkMode(hDC, OPAQUE); #endif } /* If COLOR_BOXED then draw a rectangle around the text */ if (bits & (COLOR_BOXED | COLOR_LEFTBOX | COLOR_RIGHTBOX)) { /* Select the foreground color */ hPen = CreatePen(PS_SOLID, 0, fgc); hPrevPen = SelectObject(hDC, hPen); /* Draw the rectangle */ if (bits & COLOR_BOXED) { MoveToEx(hDC, rect.left, rect.top, NULL); LineTo(hDC, rect.right, rect.top); MoveToEx(hDC, rect.left, rect.bottom - 1, NULL); LineTo(hDC, rect.right, rect.bottom - 1); } if (bits & COLOR_RIGHTBOX) { MoveToEx(hDC, rect.right - 1, rect.top, NULL); LineTo(hDC, rect.right - 1, rect.bottom); } if (bits & COLOR_LEFTBOX) { MoveToEx(hDC, rect.left, rect.top, NULL); LineTo(hDC, rect.left, rect.bottom); } /* Restore foreground color to its previous value, so we can delete * the local hPen object. */ SelectObject(hDC, hPrevPen); DeleteObject(hPen); } /* release the window's device context */ ReleaseDC(gwp->clientHWnd, hDC); /* update cursor position */ gwp->curcol += len; }
INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { char str[20]; switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); CheckDlgButton(hwndDlg, IDC_UPDATEONSTARTUP, (int)UpdateOnStartup); CheckDlgButton(hwndDlg, IDC_ONLYONCEADAY, (int)OnlyOnceADay); EnableWindow(GetDlgItem(hwndDlg, IDC_ONLYONCEADAY), UpdateOnStartup); CheckDlgButton(hwndDlg, IDC_UPDATEONPERIOD, (int)UpdateOnPeriod); EnableWindow(GetDlgItem(hwndDlg, IDC_PERIOD), UpdateOnPeriod); EnableWindow(GetDlgItem(hwndDlg, IDC_PERIODSPIN), UpdateOnPeriod); EnableWindow(GetDlgItem(hwndDlg, IDC_PERIODMEASURE), UpdateOnPeriod); SendDlgItemMessage(hwndDlg, IDC_PERIODSPIN, UDM_SETRANGE, 0, MAKELONG(99, 1)); SendDlgItemMessage(hwndDlg, IDC_PERIODSPIN, UDM_SETPOS, 0, (LPARAM)Period); Edit_LimitText(GetDlgItem(hwndDlg, IDC_PERIOD), 2); mir_subclassWindow(GetDlgItem(hwndDlg, IDC_PERIOD), MyEditProc); ComboBox_InsertString(GetDlgItem(hwndDlg, IDC_PERIODMEASURE), 0, TranslateT("hours")); ComboBox_InsertString(GetDlgItem(hwndDlg, IDC_PERIODMEASURE), 1, TranslateT("days")); ComboBox_SetCurSel(GetDlgItem(hwndDlg, IDC_PERIODMEASURE), PeriodMeasure); CheckDlgButton(hwndDlg, IDC_REMINDER, (int)Reminder); if ( ServiceExists(MS_POPUP_ADDPOPUPT)) { ShowWindow(GetDlgItem(hwndDlg, IDC_NOTIFY2), SW_HIDE); ShowWindow(GetDlgItem(hwndDlg, IDC_MSG_BOXES2), SW_HIDE); ShowWindow(GetDlgItem(hwndDlg, IDC_ERRORS2), SW_HIDE); ShowWindow(GetDlgItem(hwndDlg, IDC_INFO_MESSAGES2), SW_HIDE); ShowWindow(GetDlgItem(hwndDlg, IDC_PROGR_DLG2), SW_HIDE); } else { for (int i = 1; i < POPUPS; i++) { mir_snprintf(str, SIZEOF(str), "Popups%dM", i); CheckDlgButton(hwndDlg, (i+1029), (db_get_b(NULL, MODNAME, str, DEFAULT_MESSAGE_ENABLED)) ? BST_CHECKED: BST_UNCHECKED); } } return TRUE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_UPDATEONSTARTUP: SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); EnableWindow(GetDlgItem(hwndDlg, IDC_ONLYONCEADAY), IsDlgButtonChecked(hwndDlg, IDC_UPDATEONSTARTUP)); break; case IDC_ONLYONCEADAY: SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; case IDC_UPDATEONPERIOD: { BOOL value = IsDlgButtonChecked(hwndDlg, IDC_UPDATEONPERIOD); EnableWindow(GetDlgItem(hwndDlg, IDC_PERIOD), value); EnableWindow(GetDlgItem(hwndDlg, IDC_PERIODSPIN), value); EnableWindow(GetDlgItem(hwndDlg, IDC_PERIODMEASURE), value); SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); } break; case IDC_PERIODMEASURE: if (HIWORD(wParam) == CBN_SELCHANGE) SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; case IDC_REMINDER: SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; case IDC_LINK_HOTKEY: { OPENOPTIONSDIALOG ood = { sizeof(ood) }; ood.pszGroup = "Customize"; ood.pszPage = "Hotkeys"; Options_Open(&ood); } return true; case IDC_MSG_BOXES2: case IDC_ERRORS2: case IDC_INFO_MESSAGES2: case IDC_PROGR_DLG2: if ((HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == EN_CHANGE) && (HWND)lParam == GetFocus()) SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; } break; case WM_NOTIFY: { NMHDR *hdr = (NMHDR *)lParam; if(hdr && hdr->code == UDN_DELTAPOS) SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); if (hdr && hdr->code == PSN_APPLY) { UpdateOnStartup = IsDlgButtonChecked(hwndDlg, IDC_UPDATEONSTARTUP); OnlyOnceADay = IsDlgButtonChecked(hwndDlg, IDC_ONLYONCEADAY); UpdateOnPeriod = IsDlgButtonChecked(hwndDlg, IDC_UPDATEONPERIOD); char buffer[3] = {0}; Edit_GetText(GetDlgItem(hwndDlg, IDC_PERIOD), (LPWSTR)&buffer, 2); Period = atoi(buffer); PeriodMeasure = ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_PERIODMEASURE)); InitTimer(); db_set_b(NULL, MODNAME, "UpdateOnStartup", UpdateOnStartup); db_set_b(NULL, MODNAME, "OnlyOnceADay", OnlyOnceADay); db_set_b(NULL, MODNAME, "UpdateOnPeriod", UpdateOnPeriod); db_set_dw(NULL, MODNAME, "Period", Period); db_set_b(NULL, MODNAME, "PeriodMeasure", PeriodMeasure); Reminder = IsDlgButtonChecked(hwndDlg, IDC_REMINDER); db_set_b(NULL, MODNAME, "Reminder", Reminder); if ( !ServiceExists(MS_POPUP_ADDPOPUPT)) { for (int i = 1; i < POPUPS; i++) { mir_snprintf(str, SIZEOF(str), "Popups%dM", i); db_set_b(NULL, MODNAME, str, (BYTE)(IsDlgButtonChecked(hwndDlg, (i+1029)))); } } } break; } } return FALSE; }
static INT_PTR CALLBACK JabberAddBookmarkDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { JabberAddBookmarkDlgParam* param = (JabberAddBookmarkDlgParam*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); TCHAR text[512]; JABBER_LIST_ITEM *item; switch (msg) { case WM_INITDIALOG: param = (JabberAddBookmarkDlgParam*)lParam; SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); param->ppro->m_hwndJabberAddBookmark = hwndDlg; TranslateDialogDefault(hwndDlg); if (item = param->m_item) { if (!lstrcmp(item->type, _T("conference"))) { if (!_tcschr(item->jid, _T('@'))) { //no room name - consider it is transport SendDlgItemMessage(hwndDlg, IDC_AGENT_RADIO, BM_SETCHECK, BST_CHECKED, 0); EnableWindow(GetDlgItem(hwndDlg, IDC_NICK), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_PASSWORD), FALSE); } else SendDlgItemMessage(hwndDlg, IDC_ROOM_RADIO, BM_SETCHECK, BST_CHECKED, 0); } else { SendDlgItemMessage(hwndDlg, IDC_URL_RADIO, BM_SETCHECK, BST_CHECKED, 0); EnableWindow(GetDlgItem(hwndDlg, IDC_NICK), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_PASSWORD), FALSE); SendDlgItemMessage(hwndDlg, IDC_CHECK_BM_AUTOJOIN, BM_SETCHECK, BST_UNCHECKED, 0); EnableWindow(GetDlgItem(hwndDlg, IDC_CHECK_BM_AUTOJOIN), FALSE); } EnableWindow(GetDlgItem(hwndDlg, IDC_ROOM_RADIO), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_URL_RADIO), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_AGENT_RADIO), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_CHECK_BM_AUTOJOIN), FALSE); if (item->jid) SetDlgItemText(hwndDlg, IDC_ROOM_JID, item->jid); if (item->name) SetDlgItemText(hwndDlg, IDC_NAME, item->name); if (item->nick) SetDlgItemText(hwndDlg, IDC_NICK, item->nick); if (item->password) SetDlgItemText(hwndDlg, IDC_PASSWORD, item->password); if (item->bAutoJoin) SendDlgItemMessage(hwndDlg, IDC_CHECK_BM_AUTOJOIN, BM_SETCHECK, BST_CHECKED, 0); if (SendDlgItemMessage(hwndDlg, IDC_ROOM_RADIO, BM_GETCHECK,0, 0) == BST_CHECKED) EnableWindow(GetDlgItem(hwndDlg, IDC_CHECK_BM_AUTOJOIN), TRUE); } else { EnableWindow(GetDlgItem(hwndDlg, IDOK), FALSE); SendDlgItemMessage(hwndDlg, IDC_ROOM_RADIO, BM_SETCHECK, BST_CHECKED, 0); } return TRUE; case WM_COMMAND: switch (HIWORD(wParam)) { case BN_CLICKED: switch (LOWORD (wParam)) { case IDC_ROOM_RADIO: EnableWindow(GetDlgItem(hwndDlg, IDC_NICK), TRUE); EnableWindow(GetDlgItem(hwndDlg, IDC_PASSWORD), TRUE); EnableWindow(GetDlgItem(hwndDlg, IDC_CHECK_BM_AUTOJOIN), TRUE); break; case IDC_AGENT_RADIO: case IDC_URL_RADIO: EnableWindow(GetDlgItem(hwndDlg, IDC_NICK), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_PASSWORD), FALSE); SendDlgItemMessage(hwndDlg, IDC_CHECK_BM_AUTOJOIN, BM_SETCHECK, BST_UNCHECKED, 0); EnableWindow(GetDlgItem(hwndDlg, IDC_CHECK_BM_AUTOJOIN), FALSE); break; } } switch (LOWORD(wParam)) { case IDC_ROOM_JID: if ((HWND)lParam==GetFocus() && HIWORD(wParam)==EN_CHANGE) EnableWindow(GetDlgItem(hwndDlg, IDOK), GetDlgItemText(hwndDlg, IDC_ROOM_JID, text, SIZEOF(text))); break; case IDOK: { GetDlgItemText(hwndDlg, IDC_ROOM_JID, text, SIZEOF(text)); TCHAR *roomJID = NEWTSTR_ALLOCA(text); if (param->m_item) param->ppro->ListRemove(LIST_BOOKMARK, param->m_item->jid); item = param->ppro->ListAdd(LIST_BOOKMARK, roomJID); if (SendDlgItemMessage(hwndDlg, IDC_URL_RADIO, BM_GETCHECK,0, 0) == BST_CHECKED) replaceStrT(item->type, _T("url")); else replaceStrT(item->type, _T("conference")); GetDlgItemText(hwndDlg, IDC_NICK, text, SIZEOF(text)); replaceStrT(item->nick, text); GetDlgItemText(hwndDlg, IDC_PASSWORD, text, SIZEOF(text)); replaceStrT(item->password, text); GetDlgItemText(hwndDlg, IDC_NAME, text, SIZEOF(text)); replaceStrT(item->name, (text[0] == 0) ? roomJID : text); item->bAutoJoin = (SendDlgItemMessage(hwndDlg, IDC_CHECK_BM_AUTOJOIN, BM_GETCHECK,0, 0) == BST_CHECKED); XmlNodeIq iq( param->ppro->AddIQ(&CJabberProto::OnIqResultSetBookmarks, JABBER_IQ_TYPE_SET)); param->ppro->SetBookmarkRequest(iq); param->ppro->m_ThreadInfo->send(iq); } // fall through case IDCANCEL: EndDialog(hwndDlg, 0); break; } break; case WM_JABBER_CHECK_ONLINE: if (!param->ppro->m_bJabberOnline) EndDialog(hwndDlg, 0); break; case WM_DESTROY: param->ppro->m_hwndJabberAddBookmark = NULL; break; } return FALSE; }
INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam) { int i; WORD idCtrl; char str[20] = {0}, str2[20] = {0}; switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hdlg); //Colors if (MyOptions.DefColors == byCOLOR_OWN) { CheckDlgButton(hdlg, IDC_USEOWNCOLORS, BST_CHECKED); CheckDlgButton(hdlg, IDC_USEPOPUPCOLORS, BST_UNCHECKED); CheckDlgButton(hdlg, IDC_USEWINCOLORS, BST_UNCHECKED); } if (MyOptions.DefColors == byCOLOR_WINDOWS) { CheckDlgButton(hdlg, IDC_USEOWNCOLORS, BST_UNCHECKED); CheckDlgButton(hdlg, IDC_USEPOPUPCOLORS, BST_UNCHECKED); CheckDlgButton(hdlg, IDC_USEWINCOLORS, BST_CHECKED); } if (MyOptions.DefColors == byCOLOR_POPUP) { CheckDlgButton(hdlg, IDC_USEOWNCOLORS, BST_UNCHECKED); CheckDlgButton(hdlg, IDC_USEPOPUPCOLORS, BST_CHECKED); CheckDlgButton(hdlg, IDC_USEWINCOLORS, BST_UNCHECKED); } for (i = 0; i < POPUPS; i++) { SendDlgItemMessage(hdlg, (i+42071), CPM_SETCOLOUR, 0, PopupsList[i].colorBack); SendDlgItemMessage(hdlg, (i+41071), CPM_SETCOLOUR, 0, PopupsList[i].colorText); EnableWindow(GetDlgItem(hdlg, (i+42071)), (MyOptions.DefColors == byCOLOR_OWN)); EnableWindow(GetDlgItem(hdlg, (i+41071)), (MyOptions.DefColors == byCOLOR_OWN)); } //Timeout SendDlgItemMessage(hdlg, IDC_TIMEOUT_VALUE, EM_LIMITTEXT, 4, 0); SendDlgItemMessage(hdlg, IDC_TIMEOUT_VALUE_SPIN, UDM_SETRANGE32, -1, 9999); SetDlgItemInt(hdlg, IDC_TIMEOUT_VALUE, MyOptions.Timeout, TRUE); //Mouse actions for (i = 0; i < SIZEOF(PopupActions); i++) { SendMessage(GetDlgItem(hdlg, IDC_LC), CB_SETITEMDATA, SendMessage(GetDlgItem(hdlg, IDC_LC), CB_ADDSTRING, 0, (LPARAM)TranslateTS(PopupActions[i].Text)), PopupActions[i].Action); SendMessage(GetDlgItem(hdlg, IDC_RC), CB_SETITEMDATA, SendMessage(GetDlgItem(hdlg, IDC_RC), CB_ADDSTRING, 0, (LPARAM)TranslateTS(PopupActions[i].Text)), PopupActions[i].Action); } SendDlgItemMessage(hdlg, IDC_LC, CB_SETCURSEL, MyOptions.LeftClickAction, 0); SendDlgItemMessage(hdlg, IDC_RC, CB_SETCURSEL, MyOptions.RightClickAction, 0); //Popups nitified for (i = 0; i < POPUPS; i++) { mir_snprintf(str, SIZEOF(str), "Popups%d", i); mir_snprintf(str2, SIZEOF(str2), "Popups%dM", i); CheckDlgButton(hdlg, (i+40071), (db_get_b(NULL, MODNAME, str, DEFAULT_POPUP_ENABLED)) ? BST_CHECKED: BST_UNCHECKED); CheckDlgButton(hdlg, (i+1024), (db_get_b(NULL, MODNAME, str2, DEFAULT_MESSAGE_ENABLED)) ? BST_CHECKED: BST_UNCHECKED); if (IsDlgButtonChecked(hdlg, (i+40071))) EnableWindow(GetDlgItem(hdlg, (i+1024)), FALSE); else if (i > 0) EnableWindow(GetDlgItem(hdlg, (i+1024)), TRUE); } if (!(db_get_dw(NULL, "Popup", "Actions", 0) & 1) || !ServiceExists(MS_POPUP_REGISTERACTIONS)) EnableWindow(GetDlgItem(hdlg, (40071)), FALSE); else EnableWindow(GetDlgItem(hdlg, (40071)), TRUE); return TRUE; case WM_SHOWWINDOW: if (!(db_get_dw(NULL, "Popup", "Actions", 0) & 1) || !ServiceExists(MS_POPUP_REGISTERACTIONS)) EnableWindow(GetDlgItem(hdlg, (40071)), FALSE); else EnableWindow(GetDlgItem(hdlg, (40071)), TRUE); return TRUE; case WM_COMMAND: idCtrl = LOWORD(wParam); if (HIWORD(wParam) == CPN_COLOURCHANGED) { if(idCtrl > 40070) { //It's a color picker change. idCtrl is the control id. COLORREF color = SendDlgItemMessage(hdlg, idCtrl, CPM_GETCOLOUR, 0, 0); int ctlID = idCtrl; if ((ctlID > 41070) && (ctlID < 42070)) //It's 41071 or above => Text color. PopupsList[ctlID-41071].colorText = color; else if (ctlID > 42070)//Background color. PopupsList[ctlID-42071].colorBack = color; SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0); return TRUE; } } if (HIWORD(wParam) == CBN_SELCHANGE) { if (idCtrl == IDC_LC) MyOptions.LeftClickAction = (BYTE)SendDlgItemMessage(hdlg, IDC_LC, CB_GETCURSEL, 0, 0); else if(idCtrl == IDC_RC) MyOptions.RightClickAction = (BYTE)SendDlgItemMessage(hdlg, IDC_RC, CB_GETCURSEL, 0, 0); SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0); return TRUE; } switch(idCtrl) { case IDC_USEOWNCOLORS: if (HIWORD(wParam) == BN_CLICKED) { MyOptions.DefColors = byCOLOR_OWN; BOOL bEnableOthers = TRUE; for (i = 0; i < POPUPS; i++) { EnableWindow(GetDlgItem(hdlg, (i+42071)), bEnableOthers); //Background EnableWindow(GetDlgItem(hdlg, (i+41071)), bEnableOthers); //Text } SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0); } break; case IDC_USEWINCOLORS: if (HIWORD(wParam) == BN_CLICKED) { //Use Windows colors MyOptions.DefColors = byCOLOR_WINDOWS; BOOL bEnableOthers = FALSE; for (i = 0; i < POPUPS; i++) { EnableWindow(GetDlgItem(hdlg, (i+42071)), bEnableOthers); //Background EnableWindow(GetDlgItem(hdlg, (i+41071)), bEnableOthers); //Text } SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0); } break; case IDC_USEPOPUPCOLORS: if (HIWORD(wParam) == BN_CLICKED) { //Use Popup colors MyOptions.DefColors = byCOLOR_POPUP; BOOL bEnableOthers = FALSE; for (i = 0; i < POPUPS; i++) { EnableWindow(GetDlgItem(hdlg, (i+42071)), bEnableOthers); //Background EnableWindow(GetDlgItem(hdlg, (i+41071)), bEnableOthers); //Text } SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0); } break; case IDC_PREVIEW: Title = TranslateT("Pack Updater"); Text = TranslateT("Test"); for (int i = 0; i < POPUPS; i++) { if ((!IsDlgButtonChecked(hdlg, (i+40071))) || (!IsWindowEnabled(GetDlgItem(hdlg, (i+40071))))) continue; show_popup(0, Title, Text, i, 0); } break; case IDC_TIMEOUT_VALUE: case IDC_MSG_BOXES: case IDC_ERRORS: if (!IsDlgButtonChecked(hdlg, IDC_ERRORS)) EnableWindow(GetDlgItem(hdlg, IDC_ERRORS_MSG), TRUE); else EnableWindow(GetDlgItem(hdlg, IDC_ERRORS_MSG), FALSE); if ((HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == EN_CHANGE) && (HWND)lParam == GetFocus()) SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0); break; case IDC_INFO_MESSAGES: if (!IsDlgButtonChecked(hdlg, IDC_INFO_MESSAGES)) EnableWindow(GetDlgItem(hdlg, IDC_INFO_MESSAGES_MSG), TRUE); else EnableWindow(GetDlgItem(hdlg, IDC_INFO_MESSAGES_MSG), FALSE); if ((HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == EN_CHANGE) && (HWND)lParam == GetFocus()) SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0); break; case IDC_PROGR_DLG: if (!IsDlgButtonChecked(hdlg, IDC_PROGR_DLG)) EnableWindow(GetDlgItem(hdlg, IDC_PROGR_DLG_MSG), TRUE); else EnableWindow(GetDlgItem(hdlg, IDC_PROGR_DLG_MSG), FALSE); if ((HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == EN_CHANGE) && (HWND)lParam == GetFocus()) SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0); break; case IDC_MSG_BOXES_MSG: case IDC_ERRORS_MSG: case IDC_INFO_MESSAGES_MSG: case IDC_PROGR_DLG_MSG: if ((HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == EN_CHANGE) && (HWND)lParam == GetFocus()) SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0); break; } break; case WM_NOTIFY: switch (((LPNMHDR)lParam)->code) { case PSN_RESET: //Restore the options stored in memory. LoadOptions(); InitPopupList(); return TRUE; case PSN_APPLY: //Text color char szSetting[20] = {0}; DWORD ctlColor = 0; for (i = 0; i <= POPUPS-1; i++) { ctlColor = SendDlgItemMessage(hdlg, (i+42071), CPM_GETCOLOUR, 0, 0); PopupsList[i].colorBack = ctlColor; mir_snprintf(szSetting, SIZEOF(szSetting), "Popups%iBg", i); db_set_dw(NULL, MODNAME, szSetting, ctlColor); ctlColor = SendDlgItemMessage(hdlg, (i+41071), CPM_GETCOLOUR, 0, 0); PopupsList[i].colorText = ctlColor; mir_snprintf(szSetting, SIZEOF(szSetting), "Popups%iTx", i); db_set_dw(NULL, MODNAME, szSetting, ctlColor); } //Colors db_set_b(NULL, MODNAME, "DefColors", MyOptions.DefColors); //Timeout MyOptions.Timeout = GetDlgItemInt(hdlg, IDC_TIMEOUT_VALUE, 0, TRUE); db_set_dw(NULL, MODNAME, "Timeout", MyOptions.Timeout); //Left mouse click db_set_b(NULL, MODNAME, "LeftClickAction", MyOptions.LeftClickAction); //Right mouse click db_set_b(NULL, MODNAME, "RightClickAction", MyOptions.RightClickAction); //Notified popups for (i = 0; i < POPUPS; i++) { mir_snprintf(str, SIZEOF(str), "Popups%d", i); db_set_b(NULL, MODNAME, str, (BYTE)(IsDlgButtonChecked(hdlg, (i+40071)))); mir_snprintf(str2, SIZEOF(str2), "Popups%dM", i); db_set_b(NULL, MODNAME, str2, (BYTE)(IsDlgButtonChecked(hdlg, (i+1024)))); } return TRUE; } break; //End WM_NOTIFY } return FALSE; }
/* FileOpen -- uses GetOpenFileName to prompt user for AVI and HOT filenames. Uses fileOpenMovie to load the AVI file, and playMovie and setMovie and MCI_WHERE to get it into the window and on the first frame. Uses InitHotspots() to load hotspot file. */ BOOL FileOpen(HWND hWnd) { static OPENFILENAME ofn; char szBuf[129]; char szFileName[MAXFILENAME] = ""; char szFileTitle[MAXFILENAME] = ""; char szFilterSpec [128] = /* file type filters */ "AVI Files (*.AVI)\0*.AVI\0All Files (*.*)\0*.*\0"; char szFilterSpec2 [128] = "Hotspot Files (*.HOT)\0*.HOT\0All Files (*.*)\0*.*\0"; ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = hWnd; ofn.lpstrFilter = szFilterSpec; ofn.lpstrCustomFilter = NULL; ofn.nMaxCustFilter = 0; ofn.nFilterIndex = 1; ofn.lpstrFile = szFileName; ofn.nMaxFile = MAXFILENAME; ofn.lpstrInitialDir = NULL; ofn.lpstrFileTitle = szFileTitle; ofn.nMaxFileTitle = MAXFILENAME; ofn.lpstrTitle = "Open AVI File"; ofn.lpstrDefExt = "AVI"; ofn.Flags = 0; if (!GetOpenFileName ((LPOPENFILENAME)&ofn)) return FALSE; if (pMovieInfo) // get rid of old stuff if there is { fileCloseMovie(pMovieInfo, TRUE); DeleteHotspotList(pMovieInfo); FREE(pMovieInfo); } lstrcpy(szWindowTitle, szBaseWindowTitle); lstrcat(szWindowTitle, " - "); lstrcat(szWindowTitle, szFileTitle); SetWindowText(hWnd, szWindowTitle); { // added SetProp to accomodate new drawproc HANDLE hglb; hglb = GlobalAlloc(GHND,(DWORD)(sizeof(MOVIEINFO))); if (hglb) { pMovieInfo = (PMOVIEINFO) GlobalLock(hglb); } else { pMovieInfo = NULL; } //pMovieInfo = (PMOVIEINFO) ((hglb = GlobalAlloc(GHND, (DWORD)(sizeof(MOVIEINFO)))) ? GlobalLock(hglb) : NULL); if (!pMovieInfo) return (FALSE); pMovieInfo->hwndParent = hWnd; lstrcpy(pMovieInfo->szAVIFileName, ofn.lpstrFile); fileOpenMovie(pMovieInfo, ofn.lpstrFile); SetProp(hWnd, (LPSTR) szMovieInfo,hglb); SetProp(pMovieInfo->hwndMovie, (LPSTR) szMovieInfo, hglb); { char a[256];wsprintf(a,"wnd1 %X wnd2 %X\n",hWnd,pMovieInfo->hwndMovie); OutputDebugString(a);} } //playMovie(pMovieInfo, 0); // screws up drawproc for some reason { MCI_DGV_SETVIDEO_PARMS dgv; UINT uDevice; dgv.dwValue = (DWORD) ICAVIDrawProc; //MakeProcInstance((FARPROC) ICAVIDrawProc,hInstApp); dgv.dwItem = MCI_AVI_SETVIDEO_DRAW_PROCEDURE; uDevice = pMovieInfo->wMCIDeviceID; if (uDevice) { DWORD dw; dw = mciSendCommand(uDevice, MCI_SETVIDEO, MCI_DGV_SETVIDEO_ITEM | MCI_DGV_SETVIDEO_VALUE, (DWORD) (MCI_DGV_SETVIDEO_PARMS FAR *)&dgv); OutputDebugString("set draw proc!\n"); if (dw != 0) { MessageBox(GetFocus(), "The currently installed MCIAVI does not " "support the MCI_AVI_SETVIDEO_DRAW_PROCEDURE " "command during play.","MCI Problem", MB_OK | MB_ICONHAND); } } else { MessageBox(GetFocus(),"movie info has no device id", "real bummer",MB_OK); } } setMovie(pMovieInfo, pMovieInfo->dwCurrentFrame, NULL); { RECT rcClient, rcWindow; //rcMovieBounds, rc MCI_DGV_RECT_PARMS mciRect; BOOL retcode = TRUE; /* if there is no movie yet then just get out of here */ GetClientRect(hWnd, &rcClient); /* get the parent windows rect */ GetWindowRect(hWnd, &rcWindow); mciSendCommand(pMovieInfo->wMCIDeviceID, MCI_WHERE, (DWORD)(MCI_DGV_WHERE_SOURCE), (DWORD)(LPMCI_DGV_RECT_PARMS)&mciRect); } pMovieInfo->fPlaying = FALSE; bFileLoaded = TRUE; wsprintf(szBuf, "%ld of %ld", pMovieInfo->dwCurrentFrame, pMovieInfo->dwMovieLength); SetDlgItemText(hwndDlg, ID_CURRENTFRAME, szBuf); // now try opening a HOT file memset(szFileName, 0, sizeof(szFileName)); memset(szFileTitle, 0, sizeof(szFileTitle)); memset(&ofn, 0, sizeof(OPENFILENAME)); ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = hWnd; ofn.lpstrFilter = szFilterSpec2; ofn.lpstrCustomFilter = NULL; ofn.nMaxCustFilter = 0; ofn.nFilterIndex = 1; ofn.lpstrFile = szFileName; ofn.nMaxFile = MAXFILENAME; ofn.lpstrInitialDir = NULL; ofn.lpstrFileTitle = szFileTitle; ofn.nMaxFileTitle = MAXFILENAME; ofn.lpstrTitle = "Open Hotspot File"; ofn.lpstrDefExt = "HOT"; ofn.Flags = 0; if (!GetOpenFileName ((LPOPENFILENAME)&ofn)) return TRUE; lstrcpy(pMovieInfo->szIniFileName, ofn.lpstrFile); InitHotspots(pMovieInfo, ofn.lpstrFile); if (pMovieInfo->pHotspotList && pMovieInfo->hwndMovie) { HDC hDC; hDC = GetDC(pMovieInfo->hwndMovie); DrawRects(hDC, pMovieInfo); ReleaseDC(pMovieInfo->hwndMovie, hDC); } return TRUE; }
/* FileSave -- saves hotspot into file. Uses GetSaveFileName to prompt user for filename if the MOVIEINFO doesn't have a filename, or if bGetFileName is set. */ BOOL FileSave(HWND hWnd, BOOL bGetFileName) { int hotcount; HFILE hFile; PHOTSPOT pHotspot; static OPENFILENAME ofn; static OFSTRUCT of; char szFileTitle[MAXFILENAME] = ""; char szFileName[MAXFILENAME] = ""; char szFilterSpec [128] = /* file type filters */ "Hotspot Files (*.HOT)\0*.HOT\0All Files (*.*)\0*.*\0"; BOOL bGet = TRUE; if (pMovieInfo->szIniFileName) { if (lstrlen(pMovieInfo->szIniFileName)) { bGet = FALSE; lstrcpy(szFileName, pMovieInfo->szIniFileName); } } if (bGetFileName) bGet = TRUE; if (bGet) { ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = hWnd; ofn.lpstrFilter = szFilterSpec; ofn.lpstrCustomFilter = NULL; ofn.nMaxCustFilter = 0; ofn.nFilterIndex = 1; ofn.lpstrFile = pMovieInfo->szIniFileName; ofn.nMaxFile = MAXFILENAME; ofn.lpstrInitialDir = NULL; ofn.lpstrFileTitle = szFileTitle; ofn.nMaxFileTitle = MAXFILENAME; ofn.lpstrTitle = NULL; ofn.lpstrDefExt = "HOT"; ofn.Flags = OFN_OVERWRITEPROMPT; if (!GetSaveFileName ((LPOPENFILENAME)&ofn)) { DWORD dw; dw = CommDlgExtendedError(); } } hotcount = 0; pHotspot = pMovieInfo->pHotspotList; while (pHotspot) // we'll save a hotspot count in the file to // make life easy for the load routine. { hotcount++; pHotspot = pHotspot->pNext; } pHotspot = pMovieInfo->pHotspotList; if (bGet) { lstrcpy(pMovieInfo->szIniFileName, ofn.lpstrFile); lstrcpy(szFileName, ofn.lpstrFile); } hFile = _lcreat(szFileName,0); if (!hFile == HFILE_ERROR) { MessageBox(GetFocus(),szFileName,"Can't write this file:",MB_OK); } _lwrite(hFile,"HH",2); _lwrite(hFile,&hotcount,sizeof(hotcount)); while (pHotspot) { int x; _lwrite(hFile,&pHotspot->rc.left,sizeof(pHotspot->rc.left)); _lwrite(hFile,&pHotspot->rc.top,sizeof(pHotspot->rc.top)); _lwrite(hFile,&pHotspot->rc.right,sizeof(pHotspot->rc.right)); _lwrite(hFile,&pHotspot->rc.bottom,sizeof(pHotspot->rc.bottom)); x = pHotspot->pszHotspotID ? lstrlen(pHotspot->pszHotspotID) : 0; _lwrite(hFile,&x,sizeof(x)); if (x && pHotspot->pszHotspotID) _lwrite(hFile,pHotspot->pszHotspotID,x); x = pHotspot->pszCommand ? lstrlen(pHotspot->pszCommand) : 0; _lwrite(hFile,&x,sizeof(x)); if (x && pHotspot->pszCommand) _lwrite(hFile,pHotspot->pszCommand,x); _lwrite(hFile,&pHotspot->BeginFrame,sizeof(pHotspot->BeginFrame)); _lwrite(hFile,&pHotspot->EndFrame,sizeof(pHotspot->EndFrame)); _lwrite(hFile,&pHotspot->OnClick,sizeof(pHotspot->OnClick)); _lwrite(hFile,&pHotspot->ToFrame,sizeof(pHotspot->ToFrame)); pHotspot = pHotspot->pNext; } _lclose(hFile); bModified = FALSE; lstrcpy(szWindowTitle, szBaseWindowTitle); lstrcat(szWindowTitle, " - "); lstrcat(szWindowTitle, szFileTitle); SetWindowText(hWnd, szWindowTitle); return TRUE; }
LRESULT CALLBACK NewStatusBarWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { POINT pt; switch (msg) { case WM_SETCURSOR: GetCursorPos(&pt); SendMessage(GetParent(hwnd), msg, wParam, lParam); if (pt.x == ptMouse.x && pt.y == ptMouse.y) return 1; ptMouse = pt; if (tooltip_active){ KillTimer(hwnd, TIMERID_HOVER); if (!NotifyEventHooks(hStatusBarHideToolTipEvent, 0, 0)) CallService("mToolTip/HideTip", 0, 0); tooltip_active = FALSE; } KillTimer(hwnd, TIMERID_HOVER); SetTimer(hwnd, TIMERID_HOVER, 750, 0); break; case WM_NCHITTEST: { LRESULT lr = SendMessage(GetParent(hwnd), WM_NCHITTEST, wParam, lParam); if (lr == HTLEFT || lr == HTRIGHT || lr == HTBOTTOM || lr == HTTOP || lr == HTTOPLEFT || lr == HTTOPRIGHT || lr == HTBOTTOMLEFT || lr == HTBOTTOMRIGHT) return HTTRANSPARENT; } break; case WM_ERASEBKGND: if (cfg::dat.bSkinnedStatusBar) return 1; return mir_callNextSubclass(hwnd, NewStatusBarWndProc, msg, wParam, lParam); case WM_LBUTTONDOWN: case WM_RBUTTONDOWN: KillTimer(hwnd, TIMERID_HOVER); if (!NotifyEventHooks(hStatusBarHideToolTipEvent, 0, 0)) CallService("mToolTip/HideTip", 0, 0); tooltip_active = FALSE; break; case WM_PAINT: if (cfg::shutDown || arStatusItems.getCount() == 0) return 0; if (cfg::dat.bSkinnedStatusBar) { PAINTSTRUCT ps; HDC hdc = BeginPaint(hwnd, &ps); HDC hdcMem = CreateCompatibleDC(hdc); RECT rcClient, rcWindow; DRAWITEMSTRUCT dis = {0}; BYTE windowStyle = cfg::getByte("CLUI", "WindowStyle", SETTING_WINDOWSTYLE_DEFAULT); LONG b_offset = cfg::dat.bClipBorder + (windowStyle == SETTING_WINDOWSTYLE_NOBORDER ? 2 : (windowStyle == SETTING_WINDOWSTYLE_THINBORDER ? 1 : 0)); GetClientRect(hwnd, &rcClient); GetWindowRect(hwnd, &rcWindow); pt.x = rcWindow.left; pt.y = rcWindow.top; ScreenToClient(pcli->hwndContactList, &pt); HBITMAP hbmMem = CreateCompatibleBitmap(hdc, rcClient.right, rcClient.bottom); HBITMAP hbmOld = reinterpret_cast<HBITMAP>(SelectObject(hdcMem, hbmMem)); SetBkMode(hdcMem, TRANSPARENT); HFONT hOldFont = reinterpret_cast<HFONT>(SelectObject(hdcMem, GetStockObject(DEFAULT_GUI_FONT))); BitBlt(hdcMem, 0, 0, rcClient.right, rcClient.bottom, cfg::dat.hdcBg, pt.x, pt.y, SRCCOPY); StatusItems_t *item = arStatusItems[ID_EXTBKSTATUSBAR - ID_STATUS_OFFLINE]; if (!item->IGNORED) { RECT rc = rcClient; rc.left += item->MARGIN_LEFT; rc.right -= item->MARGIN_RIGHT; rc.top += item->MARGIN_TOP; rc.bottom -= item->MARGIN_BOTTOM; DrawAlpha(hdcMem, &rc, item->COLOR, item->ALPHA, item->COLOR2, item->COLOR2_TRANSPARENT, item->GRADIENT, item->CORNER, item->BORDERSTYLE, item->imageItem); SetTextColor(hdcMem, item->TEXTCOLOR); } else SetTextColor(hdcMem, GetSysColor(COLOR_BTNTEXT)); dis.hwndItem = hwnd; dis.hDC = hdcMem; dis.CtlType = 0; int nParts = SendMessage(hwnd, SB_GETPARTS, 0, 0); for (int i = 0; i < nParts; i++) { SendMessage(hwnd, SB_GETRECT, i, (LPARAM)&dis.rcItem); OffsetRect(&dis.rcItem, 0, -b_offset); dis.itemData = SendMessage(hwnd, SB_GETTEXTA, i, 0); SendMessage(pcli->hwndContactList, WM_DRAWITEM, 0, (LPARAM)&dis); } BitBlt(hdc, 0, 0, rcClient.right, rcClient.bottom, hdcMem, 0, 0, SRCCOPY); if (hOldFont) SelectObject(hdcMem, hOldFont); SelectObject(hdcMem, hbmOld); DeleteObject(hbmMem); DeleteDC(hdcMem); EndPaint(hwnd, &ps); return 0; } break; case WM_TIMER: if (wParam == TIMERID_HOVER) { KillTimer(hwnd, TIMERID_HOVER); GetCursorPos(&pt); if (pt.x == ptMouse.x && pt.y == ptMouse.y) { ScreenToClient(hwnd, &pt); int nParts = SendMessage(hwnd, SB_GETPARTS, 0, 0); for (int i = 0; i < nParts; i++) { RECT rc; SendMessage(hwnd, SB_GETRECT, i, (LPARAM)&rc); if (PtInRect(&rc,pt)) { ProtocolData *PD = (ProtocolData *)SendMessageA(hwnd, SB_GETTEXTA, i, 0); if (PD == NULL) continue; if (NotifyEventHooks(hStatusBarShowToolTipEvent, (WPARAM)PD->RealName, 0) > 0) // a plugin handled this event tooltip_active = TRUE; else if (cfg::getDword("mToolTip", "ShowStatusTip", 0)) { WORD wStatus = (WORD)CallProtoService(PD->RealName, PS_GETSTATUS, 0, 0); BYTE isLocked = cfg::getByte(PD->RealName, "LockMainStatus", 0); TCHAR szTipText[256]; mir_sntprintf(szTipText, SIZEOF(szTipText), _T("<b>%s</b>: %s%s"), PD->RealName, pcli->pfnGetStatusModeDescription(wStatus, 0), isLocked ? _T(" (LOCKED)") : _T("")); CLCINFOTIP ti = { sizeof(ti) }; ti.isTreeFocused = (GetFocus() == pcli->hwndContactList); CallService("mToolTip/ShowTipW", (WPARAM)szTipText, (LPARAM)&ti); } break; } } } } break; } return mir_callNextSubclass(hwnd, NewStatusBarWndProc, msg, wParam, lParam); }
static LRESULT CALLBACK TalkPrjWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) { switch (Msg) { case WM_CREATE: ClearKeyBuffer(); PostMessage(hWnd, WM_SETTIMER, 2000, 0); break; case WM_SETTIMER: SetTimer(hWnd, TIMER_PRJ, wParam, NULL); break; case WM_PAINT: if (GetFocus() == hWnd) { if (ST_UK_DELAY == g_TalkInfo.unlock.dwUnLockState) { TalkUlkWndPaint(hWnd, Msg, wParam, lParam); } else { // TalkWndPaint(hWnd, Msg, wParam, lParam); TalkPrjWndPaint(hWnd, Msg, wParam, lParam); } } break; case WM_CHAR: if (GetFocus() != hWnd) { SendMessage(GetFocus(), WM_CHAR, wParam, 0l); return; } wParam = KeyBoardMap(wParam); if (wParam == KEY_RETURN) { if(ST_CO_TALKING == g_TalkInfo.talking.dwTalkState || ST_CO_WAIT_PICKUP == g_TalkInfo.talking.dwTalkState || ST_CI_TALKING == g_TalkInfo.talking.dwTalkState) { SendGMHangupCmd2Talking(); } else if(ST_ORIGINAL == g_TalkInfo.talking.dwTalkState) { memset(g_KeyInputBuffer, 0, KEY_BUF_LEN); g_KeyInputBufferLen = 0; PostMessage(hWnd, WM_CLOSE, 0, 0); } } else if ((wParam >= KEY_NUM_0) && (wParam <= KEY_NUM_9)) { ResetTimer(hWnd, TIMER_PRJ, 2000, NULL); if (g_KeyInputBufferLen < KEY_BUF_LEN) { g_KeyInputBuffer[g_KeyInputBufferLen++] = (UCHAR)wParam; } else { g_KeyInputBufferLen = 0; g_KeyInputBuffer[g_KeyInputBufferLen++] = (UCHAR)wParam; } } PostMessage(hWnd, WM_PAINT, 0, 0); break; case WM_TIMER: TalkPrjTimerProc(hWnd, Msg, wParam, lParam); break; case WM_REFRESHPARENT_WND: SetFocus(hWnd); PostMessage(hWnd, WM_PAINT, 0, 0); break; case WM_DESTROY: KillTimer(hWnd, TIMER_PRJ); // PostMessage(GetParent(hWnd), WM_REFRESHPARENT_WND, 0, 0); g_hWNDTalk = NULL; // SendMessage(GetFocus(), WM_REFRESHPARENT_WND, 0, 0); break; default: // if (WM_CLOSE == Msg) // { // RemoveOneWnd(hWnd); // } // return DefWindowProc(hWnd, Msg, wParam, lParam); DefWindowProc(hWnd, Msg, wParam, lParam); if (WM_CLOSE == Msg) { RemoveOneWnd(hWnd); } } return 0; }
void CHistoryCombo::OnMouseMove(UINT nFlags, CPoint point) { CRect rectClient; GetClientRect(&rectClient); int nComboButtonWidth = ::GetSystemMetrics(SM_CXHTHUMB) + 2; rectClient.right = rectClient.right - nComboButtonWidth; if (rectClient.PtInRect(point)) { ClientToScreen(&rectClient); CString strText = GetString(); m_ToolInfo.lpszText = (LPTSTR)(LPCTSTR)strText; HDC hDC = ::GetDC(m_hWnd); CFont *pFont = GetFont(); HFONT hOldFont = (HFONT) ::SelectObject(hDC, (HFONT) *pFont); SIZE size; ::GetTextExtentPoint32(hDC, strText, strText.GetLength(), &size); ::SelectObject(hDC, hOldFont); ::ReleaseDC(m_hWnd, hDC); if (size.cx > (rectClient.Width() - 6)) { rectClient.left += 1; rectClient.top += 3; COLORREF rgbText = ::GetSysColor(COLOR_WINDOWTEXT); COLORREF rgbBackground = ::GetSysColor(COLOR_WINDOW); CWnd *pWnd = GetFocus(); if (pWnd) { if (pWnd->m_hWnd == m_hWnd) { rgbText = ::GetSysColor(COLOR_HIGHLIGHTTEXT); rgbBackground = ::GetSysColor(COLOR_HIGHLIGHT); } } if (!m_ttShown) { ::SendMessage(m_hWndToolTip, TTM_SETTIPBKCOLOR, rgbBackground, 0); ::SendMessage(m_hWndToolTip, TTM_SETTIPTEXTCOLOR, rgbText, 0); ::SendMessage(m_hWndToolTip, TTM_UPDATETIPTEXT, 0, (LPARAM) &m_ToolInfo); ::SendMessage(m_hWndToolTip, TTM_TRACKPOSITION, 0, (LPARAM)MAKELONG(rectClient.left, rectClient.top)); ::SendMessage(m_hWndToolTip, TTM_TRACKACTIVATE, TRUE, (LPARAM)(LPTOOLINFO) &m_ToolInfo); SetTimer(1, 80, NULL); SetTimer(2, 2000, NULL); m_ttShown = TRUE; } } else { ::SendMessage(m_hWndToolTip, TTM_TRACKACTIVATE, FALSE, (LPARAM)(LPTOOLINFO) &m_ToolInfo); m_ttShown = FALSE; } } else { ::SendMessage(m_hWndToolTip, TTM_TRACKACTIVATE, FALSE, (LPARAM)(LPTOOLINFO) &m_ToolInfo); m_ttShown = FALSE; } CComboBoxEx::OnMouseMove(nFlags, point); }
// main ping options static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { HWND hw; OPENFILENAME ofn = {0}; switch ( msg ) { case WM_INITDIALOG: { TranslateDialogDefault( hwndDlg ); if(!ServiceExists(MS_FONT_REGISTER)) { SetDlgItemText(hwndDlg, IDC_STATFS, Translate("Install the FontService plugin to change the font and font colour.")); } if(ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) { hw = GetDlgItem(hwndDlg, IDC_CHK_ATTACH); EnableWindow(hw, FALSE); } CheckDlgButton(hwndDlg, IDC_CHK_ATTACH, options.attach_to_clist); SetDlgItemInt(hwndDlg, IDC_PPM, options.ping_period, FALSE); SetDlgItemInt(hwndDlg, IDC_PT, options.ping_timeout, FALSE); CheckDlgButton(hwndDlg, IDC_CHECKPOPUP, options.show_popup); CheckDlgButton(hwndDlg, IDC_CHECKPOPUP2, options.show_popup2); CheckDlgButton(hwndDlg, IDC_CHK_BLOCK, options.block_reps); CheckDlgButton(hwndDlg, IDC_CHK_LOG, options.logging); CheckDlgButton(hwndDlg, IDC_CHK_LOGCSV, options.log_csv); CheckDlgButton(hwndDlg, IDC_CHK_NOTESTICON, options.no_test_icon); SendMessage(GetDlgItem(hwndDlg, IDC_SP_INDENT), UDM_SETRANGE, 0, (LPARAM)MAKELONG(500, 0)); SendMessage(GetDlgItem(hwndDlg, IDC_SP_INDENT), UDM_SETPOS, 0, options.indent); SendMessage(GetDlgItem(hwndDlg, IDC_SP_ROWHEIGHT), UDM_SETRANGE, 0, (LPARAM)MAKELONG(500, 6)); SendMessage(GetDlgItem(hwndDlg, IDC_SP_ROWHEIGHT), UDM_SETPOS, 0, options.row_height); SetDlgItemInt(hwndDlg, IDC_RPT, options.retries, FALSE); SetDlgItemText(hwndDlg, IDC_ED_FILENAME, options.log_filename); if(!options.logging) { hw = GetDlgItem(hwndDlg, IDC_ED_FILENAME); EnableWindow(hw, FALSE); hw = GetDlgItem(hwndDlg, IDC_BTN_LOGBROWSE); EnableWindow(hw, FALSE); hw = GetDlgItem(hwndDlg, IDC_CHK_LOGCSV); EnableWindow(hw, FALSE); } if(!ServiceExists( MS_POPUP_ADDPOPUP )) { hw = GetDlgItem(hwndDlg, IDC_CHECKPOPUP); EnableWindow(hw, FALSE); hw = GetDlgItem(hwndDlg, IDC_CHECKPOPUP2); EnableWindow(hw, FALSE); hw = GetDlgItem(hwndDlg, IDC_CHK_BLOCK); EnableWindow(hw, FALSE); } return TRUE; } case WM_COMMAND: if ( HIWORD( wParam ) == EN_CHANGE && ( HWND )lParam == GetFocus()) { switch( LOWORD( wParam )) { case IDC_PPM: case IDC_PT: case IDC_ED_FILENAME: case IDC_RPT: SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); } break; } if (HIWORD( wParam ) == CBN_SELCHANGE) { SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; } if ( HIWORD( wParam ) == BN_CLICKED ) { switch( LOWORD( wParam )) { case IDC_CHK_LOG: hw = GetDlgItem(hwndDlg, IDC_ED_FILENAME); EnableWindow(hw, IsDlgButtonChecked(hwndDlg, IDC_CHK_LOG)); hw = GetDlgItem(hwndDlg, IDC_BTN_LOGBROWSE); EnableWindow(hw, IsDlgButtonChecked(hwndDlg, IDC_CHK_LOG)); hw = GetDlgItem(hwndDlg, IDC_CHK_LOGCSV); EnableWindow(hw, IsDlgButtonChecked(hwndDlg, IDC_CHK_LOG)); // drop through case IDC_CHK_LOGCSV: case IDC_CHECKPOPUP: case IDC_CHECKPOPUP2: case IDC_CHK_BLOCK: case IDC_CHK_MINMAX: case IDC_CHK_NOTESTICON: case IDC_CHK_ATTACH: SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 ); break; case IDC_BTN_VIEWLOG: CallService(PLUG "/ViewLogData", 0, 0); break; case IDC_BTN_LOGBROWSE: ofn.lStructSize = sizeof(ofn); ofn.lpstrFile = options.log_filename; ofn.hwndOwner = hwndDlg; ofn.Flags = CC_FULLOPEN; //ofn.lpstrFile[0] = '\0'; ofn.nMaxFile = sizeof(options.log_filename); ofn.lpstrFilter = "All\0*.*\0Text\0*.TXT\0"; ofn.nFilterIndex = 1; ofn.lpstrFileTitle = NULL; ofn.nMaxFileTitle = 0; ofn.lpstrInitialDir = NULL; ofn.Flags = OFN_PATHMUSTEXIST; if(GetOpenFileName(&ofn) == TRUE) { SetDlgItemText(hwndDlg, IDC_ED_FILENAME, ofn.lpstrFile); SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 ); } break; } break; } break; case WM_NOTIFY: if (((LPNMHDR)lParam)->code == UDN_DELTAPOS ) { SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 ); } if (((LPNMHDR)lParam)->code == PSN_APPLY ) { BOOL trans_success; DWORD new_ping_period = GetDlgItemInt( hwndDlg, IDC_PPM, &trans_success, FALSE); if(trans_success) { options.ping_period = new_ping_period; } DWORD new_ping_timeout = GetDlgItemInt( hwndDlg, IDC_PT, &trans_success, FALSE); if(trans_success) { options.ping_timeout = new_ping_timeout; } options.show_popup = IsDlgButtonChecked(hwndDlg, IDC_CHECKPOPUP) == BST_CHECKED; options.show_popup2 = IsDlgButtonChecked(hwndDlg, IDC_CHECKPOPUP2) == BST_CHECKED; options.block_reps = IsDlgButtonChecked(hwndDlg, IDC_CHK_BLOCK) == BST_CHECKED; options.logging = IsDlgButtonChecked(hwndDlg, IDC_CHK_LOG) == BST_CHECKED; options.log_csv = IsDlgButtonChecked(hwndDlg, IDC_CHK_LOGCSV) == BST_CHECKED; GetDlgItemText(hwndDlg, IDC_ED_FILENAME, options.log_filename, MAX_PATH); options.no_test_icon = IsDlgButtonChecked(hwndDlg, IDC_CHK_NOTESTICON) == BST_CHECKED; options.indent = SendMessage(GetDlgItem(hwndDlg, IDC_SP_INDENT), UDM_GETPOS, 0, 0); options.row_height = SendMessage(GetDlgItem(hwndDlg, IDC_SP_ROWHEIGHT), UDM_GETPOS, 0, 0); DWORD new_retries = GetDlgItemInt( hwndDlg, IDC_RPT, &trans_success, FALSE); if(trans_success) { options.retries = new_retries; } bool new_attach = (IsDlgButtonChecked(hwndDlg, IDC_CHK_ATTACH) == BST_CHECKED); if(!ServiceExists(MS_CLIST_FRAMES_ADDFRAME) && options.attach_to_clist != new_attach) AttachToClist(new_attach); options.attach_to_clist = new_attach; SaveOptions(); RefreshWindow(0, 0); if(options.logging) CallService(PLUG "/Log", (WPARAM)"options changed", 0); if(hWakeEvent) SetEvent(hWakeEvent); return TRUE; } break; } return FALSE; }
LRESULT playlist_view::on_message(HWND wnd, UINT msg, WPARAM wp, LPARAM lp) { switch (msg) { case WM_NCCREATE: wnd_playlist = wnd; initialised = true; list_playlist.add_item(this); g_playlist_message_window.add_ref(); break; case WM_CREATE: { pfc::com_ptr_t<IDropTarget_playlist> IDT_playlist = new IDropTarget_playlist(this); RegisterDragDrop(wnd, IDT_playlist.get_ptr()); if (true) { m_theme = IsThemeActive() && IsAppThemed() ? OpenThemeData(wnd, L"ListView") : NULL; SetWindowTheme(wnd, L"Explorer", NULL); } m_always_show_focus = config_object::g_get_data_bool_simple(standard_config_objects::bool_playback_follows_cursor, false); on_playlist_font_change(); create_header(true); drawing_enabled = true; m_cache.initialise(); } return 0; case WM_DESTROY: m_edit_save = false; exit_inline_edit(); m_cache.deinitialise(); RevokeDragDrop(wnd); SendMessage(wnd, WM_SETFONT, 0, 0); SendMessage(wnd_header, WM_SETFONT, 0, 0); { if (m_theme) CloseThemeData(m_theme); m_theme = NULL; } m_selection_holder.release(); break; case WM_NCDESTROY: g_playlist_message_window.release(); wnd_playlist = 0; initialised = false; list_playlist.remove_item(this); m_shown = false; // if (!list_playlist.get_count()) // { // g_playlist_entries.rebuild_all(); // } break; case WM_THEMECHANGED: { if (m_theme) CloseThemeData(m_theme); m_theme = IsThemeActive() && IsAppThemed() ? OpenThemeData(wnd, L"ListView") : 0; } break; case WM_SHOWWINDOW: if (wp == TRUE && lp == 0 && !m_shown) { static_api_ptr_t<playlist_manager> playlist_api; ensure_visible(playlist_api->activeplaylist_get_focus_item()); m_shown = true; } break; case WM_WINDOWPOSCHANGED: { LPWINDOWPOS lpwp = (LPWINDOWPOS)lp; if (!(lpwp->flags & SWP_NOSIZE)) { on_size(lpwp->cx, lpwp->cy); } } break; case WM_ERASEBKGND: return TRUE; break; case WM_PAINT: { PAINTSTRUCT ps; HDC dc_paint = BeginPaint(wnd, &ps); RECT rc_update, rc_playlist; get_playlist_rect(&rc_playlist); rc_update = ps.rcPaint; if (rc_update.top<rc_playlist.top) rc_update.top = rc_playlist.top; if (rc_update.bottom >= rc_update.top) { int item_height = get_item_height(); int start_item = (rc_update.top - rc_playlist.top) / item_height; int end_item = (rc_update.bottom - rc_playlist.top) / item_height; if (((end_item - start_item) + 1)*item_height < rc_update.bottom - rc_update.top) end_item++; { draw_items(dc_paint, start_item, 1 + (end_item - start_item)); } } EndPaint(wnd, &ps); } return 0; case WM_SETREDRAW: drawing_enabled = (wp != 0); return 0; case WM_MOUSEACTIVATE: if (GetFocus() != wnd) m_no_next_edit = true; return MA_ACTIVATE; case WM_UPDATEUISTATE: RedrawWindow(wnd_playlist, 0, 0, RDW_INVALIDATE); break; case WM_KILLFOCUS: RedrawWindow(wnd_playlist, 0, 0, RDW_INVALIDATE | RDW_UPDATENOW); m_selection_holder.release(); break; case WM_SETFOCUS: //if (msg == WM_SETFOCUS && (HWND)wp != wnd) //m_no_next_edit = true; RedrawWindow(wnd_playlist, 0, 0, RDW_INVALIDATE | RDW_UPDATENOW); m_selection_holder = static_api_ptr_t<ui_selection_manager>()->acquire(); m_selection_holder->set_playlist_selection_tracking(); break; case WM_GETDLGCODE: return DLGC_WANTALLKEYS; case WM_KEYDOWN: { static_api_ptr_t<playlist_manager> playlist_api; uie::window_ptr p_this = this; //DWORD vk_slash = VkKeyScan('/'); if (wp == VK_CONTROL) g_drag_lmb = true; if (m_prevent_wm_char_processing = process_keydown(msg, lp, wp, true)) return 0; else { SendMessage(wnd, WM_CHANGEUISTATE, MAKEWPARAM(UIS_CLEAR, UISF_HIDEFOCUS), NULL); if (wp == VK_HOME || wp == VK_DOWN || wp == VK_END || wp == VK_PRIOR || wp == VK_NEXT || wp == VK_UP) { int focus = playlist_api->activeplaylist_get_focus_item(); int total = playlist_api->activeplaylist_get_item_count(); if ((wp == VK_HOME || wp == VK_PRIOR || wp == VK_UP)) { // if (focus == 0) return 0; } if ((wp == VK_END || wp == VK_NEXT || wp == VK_DOWN)) { // if (focus == total - 1) return 0; } SCROLLINFO si; memset(&si, 0, sizeof(si)); si.cbSize = sizeof(si); si.fMask = SIF_PAGE | SIF_POS; GetScrollInfo(wnd_playlist, SB_VERT, &si); int offset = 0; int scroll = scroll_item_offset; if (wp == VK_HOME) scroll = 0; else if (wp == VK_PRIOR && focus == scroll_item_offset) scroll -= si.nPage; else if (wp == VK_UP) { if (focus <= scroll_item_offset) scroll = focus - 1; else if (focus > si.nPos + si.nPage - 1) scroll = focus - 1 - si.nPage + 1; } else if (wp == VK_DOWN) { if (focus < scroll_item_offset) scroll = focus + 1; else if (focus >= si.nPos + si.nPage - 1) scroll = focus + 1 - si.nPage + 1; } else if (wp == VK_END) scroll = total - 1; else if (wp == VK_NEXT && focus == si.nPos + si.nPage - 1) scroll += si.nPage; drawing_enabled = false; si.nPos = scroll; si.fMask = SIF_POS; scroll_item_offset = SetScrollInfo(wnd_playlist, SB_VERT, &si, true); if (wp == VK_HOME) offset = 0 - focus; else if (wp == VK_PRIOR) offset = scroll_item_offset - focus; else if (wp == VK_END) offset = total - focus - 1; else if (wp == VK_NEXT) offset = get_last_viewable_item() - focus; else if (wp == VK_DOWN) offset = 1; else if (wp == VK_UP) offset = -1; //if (offset) process_keydown(offset, ((HIWORD(lp) & KF_ALTDOWN) != 0), drawing_enabled, (HIWORD(lp) & KF_REPEAT) != 0); drawing_enabled = true; RedrawWindow(wnd_playlist, 0, 0, RDW_INVALIDATE | RDW_UPDATENOW); return 0; } else if (wp == VK_SPACE) { int focus = playlist_api->activeplaylist_get_focus_item(); set_sel_single(focus, true, false, false); return 0; } else if (wp == VK_RETURN) { bool ctrl_down = 0 != (GetKeyState(VK_CONTROL) & KF_UP); int focus = playlist_api->activeplaylist_get_focus_item(); unsigned active = playlist_api->get_active_playlist(); if (ctrl_down) { if (active != -1 && focus != -1) playlist_api->queue_add_item_playlist(active, focus); } else { // playlist_api->set_playing_playlist(active); unsigned focus = playlist_api->activeplaylist_get_focus_item(); //unsigned active = playlist_api->get_active_playlist(); //playlist_api->playlist_set_playback_cursor(active, focus); playlist_api->activeplaylist_execute_default_action(focus); //static_api_ptr_t<play_control>()->play_start(play_control::track_command_settrack); } return 0; } else if (wp == VK_SHIFT) { if (!(HIWORD(lp) & KF_REPEAT)) g_shift_item_start = playlist_api->activeplaylist_get_focus_item(); } else if (wp == VK_F2) { unsigned count = g_get_cache().active_column_get_active_count(); if (count) { unsigned focus = playlist_api->activeplaylist_get_focus_item(); if (focus != pfc_infinite) { t_size i, pcount = playlist_api->activeplaylist_get_item_count(); bit_array_bittable sel(pcount); playlist_api->activeplaylist_get_selection_mask(sel); pfc::list_t<t_size> indices; indices.prealloc(32); for (i = 0; i<pcount; i++) if (sel[i]) indices.add_item(i); /*t_size start = focus, end = focus; if (sel[start] && pcount) { while (start>0 && sel[start-1]) start--; while (end<pcount-1 && sel[end+1]) end++; }*/ unsigned count = g_get_cache().active_column_get_active_count(); unsigned column; for (column = 0; column<count; column++) { if (!g_get_columns()[g_get_cache().active_column_active_to_actual(column)]->edit_field.is_empty()) { //create_inline_edit_v2(start, end-start+1, column); create_inline_edit_v2(indices, column); break; } } } } } else if (wp == VK_DELETE) { playlist_api->activeplaylist_undo_backup(); playlist_api->activeplaylist_remove_selection(); } else if (wp == VK_F3) { standard_commands::main_playlist_search(); } /*else if (vk_slash != -1 && wp == LOWORD(vk_slash)) { HWND wnd_search = m_searcher.create(wnd); on_size(); ShowWindow(wnd_search, SW_SHOWNORMAL); ; }*/ } } break; case WM_CHAR: if (!m_prevent_wm_char_processing) { //if (!(HIWORD(lp) & KF_REPEAT)) { if ((GetKeyState(VK_CONTROL) & KF_UP)) { static_api_ptr_t<playlist_manager> playlist_api; if (wp == 1) //Ctrl-A { playlist_api->activeplaylist_set_selection(bit_array_true(), bit_array_true()); return 0; } else if (wp == 26) //Ctrl-Z { playlist_api->activeplaylist_undo_restore(); return 0; } else if (wp == 25) //Ctrl-Y { playlist_api->activeplaylist_redo_restore(); return 0; } else if (wp == 24) //Ctrl-X { playlist_utils::cut(); return 0; } else if (wp == 3) //Ctrl-C { playlist_utils::copy(); return 0; } else if (wp == 6) //Ctrl-F { standard_commands::main_playlist_search(); return 0; } else if (wp == 22) //Ctrl-V { playlist_utils::paste(wnd); return 0; } } } } break; case WM_KEYUP: if (process_keydown(msg, lp, wp, true)) return 0; break; case WM_SYSKEYUP: if (process_keydown(msg, lp, wp, true)) return 0; break; case WM_SYSKEYDOWN: { uie::window_ptr p_this = this; if (m_prevent_wm_char_processing = process_keydown(msg, lp, wp, true)) return 0; } break; case WM_LBUTTONDOWN: { if (0 && g_tooltip) { MSG message; memset(&message, 0, sizeof(MSG)); message.hwnd = wnd; message.message = msg; message.wParam = wp; message.lParam = lp; SendMessage(g_tooltip, TTM_RELAYEVENT, 0, (LPARAM)&message); } bool b_was_focused = GetFocus() == wnd; if (!b_was_focused) m_no_next_edit = true; //#ifdef INLINE_EDIT exit_inline_edit(); // g_no_next_edit = false; //#endif dragged = false; SetFocus(wnd); SetCapture(wnd); static_api_ptr_t<playlist_manager> playlist_api; g_drag_lmb = true; int focus = playlist_api->activeplaylist_get_focus_item(); drag_start_lmb.x = GET_X_LPARAM(lp); drag_start_lmb.y = GET_Y_LPARAM(lp); int item_height = get_item_height(); int idx = hittest_item(GET_X_LPARAM(lp), GET_Y_LPARAM(lp)); // int idx = ((GET_Y_LPARAM(lp) -get_header_height()) / item_height) + scroll_item_offset; // if( idx >= 0 && idx <playlist_api->activeplaylist_get_item_count() && GET_X_LPARAM(lp) < g_playlist_entries.get_total_width_actual()) if (idx >= 0) { // playlist_oper * playlist_api = playlist_api; // playlist_api->set_playback_cursor(idx); //#ifdef INLINE_EDIT m_prev_sel = (playlist_api->activeplaylist_is_item_selected(idx) && !m_wnd_edit && (playlist_api->activeplaylist_get_selection_count(2) == 1)); //#endif if (!is_visible(idx)) SendMessage(wnd_playlist, WM_VSCROLL, MAKEWPARAM(SB_LINEDOWN, 0), 0); if (wp & MK_CONTROL && wp & MK_SHIFT) { playlist_api->activeplaylist_move_selection(idx - focus); dragged = true; drag_type = 0; } else if (wp & MK_SHIFT) { drag_type = 2; dragitem = idx, dragstartitem = idx; int n = (cfg_alternative_sel ? focus : g_shift_item_start), t = idx; bool focus_sel = playlist_api->activeplaylist_is_item_selected(focus); set_sel_range(n, t, (cfg_alternative_sel != 0), (cfg_alternative_sel ? !focus_sel : false)); playlist_api->activeplaylist_set_focus_item(idx); dragged = true; } else if (wp & MK_CONTROL) { /* drag_type = 2; dragitem = idx,dragstartitem=idx; set_sel_single(idx, false, true, false); dragged = true;*/ } else if (playlist_api->activeplaylist_is_item_selected(idx)) { drag_type = 1; dragitem = idx, dragstartitem = idx; playlist_api->activeplaylist_undo_backup(); playlist_api->activeplaylist_set_focus_item(idx); dragged = false; } else { drag_type = 2; dragitem = idx, dragstartitem = idx;//item irrelevant actually; set_sel_single(idx, false, true, true); /* bit_array_bittable mask(playlist_api->activeplaylist_get_item_count()); // playlist_api->activeplaylist_is_item_selected_mask(mask); int n, t = playlist_api->activeplaylist_get_item_count(); for (n = 0;n <t;n++) { if (n==idx) mask.set(n, true); else mask.set(n, false); } console::info("crap"); playlist_api->set_sel_mask(mask); playlist_api->activeplaylist_set_focus_item(idx);*/ dragged = false; } } else { // console::info("wow"); // bit_array_bittable mask(playlist_api->activeplaylist_get_item_count()); playlist_api->activeplaylist_set_selection(bit_array_true(), bit_array_false()); dragged = true; drag_type = 0; } } break; case WM_RBUTTONUP: m_no_next_edit = false; break; case WM_MBUTTONUP: { m_no_next_edit = false; unsigned idx = hittest_item(GET_X_LPARAM(lp), GET_Y_LPARAM(lp)); playlist_mclick_actions::run(cfg_playlist_middle_action, idx != -1, idx); } break; case WM_LBUTTONUP: { if (0 && g_tooltip) { MSG message; memset(&message, 0, sizeof(MSG)); message.hwnd = wnd; message.message = msg; message.wParam = wp; message.lParam = lp; SendMessage(g_tooltip, TTM_RELAYEVENT, 0, (LPARAM)&message); } ReleaseCapture(); g_drag_lmb = false; int idx = hittest_item(GET_X_LPARAM(lp), GET_Y_LPARAM(lp), true); //((GET_Y_LPARAM(lp) -get_header_height()) / get_item_height()) + scroll_item_offset; static_api_ptr_t<playlist_manager> playlist_api; if (!dragged) { if (wp & MK_CONTROL) { // int idx_down = hittest_item(drag_start_lmb.x, drag_start_lmb.y); if (idx >= 0) set_sel_single(idx, true, true, false); } else { // int item_height = get_item_height(); // int idx = ((GET_Y_LPARAM(lp) - get_header_height()) / item_height) + scroll_item_offset; if (idx >= 0 /*&& idx < playlist_api->activeplaylist_get_item_count() && (GET_X_LPARAM(lp) < g_playlist_entries.get_total_width_actual())*/) { if (!m_no_next_edit && cfg_inline_edit && playlist_api->activeplaylist_is_item_selected(idx) && m_prev_sel /*&& !dragged*/) { //if (m_no_next_edit && GetCapture() == wnd) ReleaseCapture(); { exit_inline_edit(); if (main_window::config_get_inline_metafield_edit_mode() != main_window::mode_disabled) { m_edit_index = idx; long width; m_edit_column = hittest_column(GET_X_LPARAM(lp), width); if (m_edit_column >= 0 && !g_get_columns()[g_get_cache().active_column_active_to_actual(m_edit_column)]->edit_field.is_empty()) { m_edit_timer = (SetTimer(wnd, EDIT_TIMER_ID, GetDoubleClickTime(), 0) != 0); } } } } int focus = playlist_api->activeplaylist_get_focus_item(); set_sel_single(focus, false, false, true); } } } dragged = true; drag_type = 0; dragstartitem = 0; dragitem = 0; //#ifdef INLINE_EDIT m_no_next_edit = false; //#endif } break; case WM_MOUSEMOVE: { if (0 && g_tooltip) { MSG message; memset(&message, 0, sizeof(MSG)); message.hwnd = wnd; message.message = msg; message.wParam = wp; message.lParam = lp; SendMessage(g_tooltip, TTM_RELAYEVENT, 0, (LPARAM)&message); } const unsigned cx_drag = (unsigned)abs(GetSystemMetrics(SM_CXDRAG)); const unsigned cy_drag = (unsigned)abs(GetSystemMetrics(SM_CYDRAG)); if (!g_dragging && ((g_dragging1 && wp & MK_RBUTTON && (abs(drag_start.x - GET_X_LPARAM(lp)) > cx_drag || abs(drag_start.y - GET_Y_LPARAM(lp)) > cy_drag)) || (g_drag_lmb && (wp & MK_LBUTTON) && (wp & MK_CONTROL) && (abs(drag_start_lmb.x - GET_X_LPARAM(lp)) > 3 || abs(drag_start_lmb.y - GET_Y_LPARAM(lp)) > 3)))) { static_api_ptr_t<playlist_manager> playlist_api; metadb_handle_list data; playlist_api->activeplaylist_get_selected_items(data); if (data.get_count() > 0) { static_api_ptr_t<playlist_incoming_item_filter> incoming_api; IDataObject * pDataObject = incoming_api->create_dataobject(data); if (pDataObject) { //RegisterClipboardFormat(_T("foo_ui_columns"); if (g_tooltip) { DestroyWindow(g_tooltip); g_tooltip = 0; last_idx = -1; last_column = -1; } DWORD blah; { pfc::com_ptr_t<IDropSource_playlist> p_IDropSource_playlist = new IDropSource_playlist(this); SHDoDragDrop(get_wnd(), pDataObject, p_IDropSource_playlist.get_ptr(), DROPEFFECT_COPY, &blah); } pDataObject->Release(); } } data.remove_all(); g_dragging = false; g_dragging1 = false; g_drag_lmb = false; if (wp & MK_LBUTTON) { dragged = true; drag_type = 0; dragstartitem = 0; dragitem = 0; } } if (cfg_tooltip && (GET_Y_LPARAM(lp) > get_header_height())) { int item_height = get_item_height(); int idx = hittest_item(GET_X_LPARAM(lp), GET_Y_LPARAM(lp)); long cx; int column = hittest_column(GET_X_LPARAM(lp), cx); // unsigned act_col = g_cache.active_column_active_to_actual(column); if (column >= 0 && idx >= 0) { if (last_idx != (idx) || last_column != column) { if (!cfg_tooltips_clipped || is_item_clipped(idx, column)) { pfc::string8 src; g_cache.active_get_display_name(idx, column, src); pfc::string8 temp; titleformat_compiler::remove_color_marks(src, temp); temp.replace_char(9, 0x20); CreateToolTip(temp); } else { DestroyWindow(g_tooltip); g_tooltip = 0; last_idx = -1; last_column = -1; } POINT a; a.x = cx + 3; a.y = (idx - scroll_item_offset) * item_height + get_header_height(); ClientToScreen(wnd_playlist, &a); tooltip.top = a.y; tooltip.bottom = a.y + item_height; tooltip.left = a.x; tooltip.right = a.x + get_column_width(column); } last_idx = idx; last_column = column; } else { DestroyWindow(g_tooltip); g_tooltip = 0; last_idx = -1; last_column = -1; } } if (drag_type && (wp & MK_LBUTTON) && !(GetKeyState(VK_SHIFT) & KF_UP) && !(GetKeyState(VK_CONTROL) & KF_UP)) { RECT rc; get_playlist_rect(&rc); static_api_ptr_t<playlist_manager> playlist_api; int total = playlist_api->activeplaylist_get_item_count(); int item_height = get_item_height(); int valid_idx = hittest_item(GET_X_LPARAM(lp), GET_Y_LPARAM(lp), false); int idx = hittest_item_no_scroll(GET_X_LPARAM(lp), GET_Y_LPARAM(lp), false); // (GET_Y_LPARAM(lp) - get_header_height()) / (item_height); int items_count = ((rc.bottom - rc.top) / item_height) + 1; if ((idx + scroll_item_offset) != dragitem || GET_Y_LPARAM(lp) < get_header_height()) //(idx + scroll_item_offset) < playlist_api->activeplaylist_get_item_count() { if (idx >= items_count - 1) { bool need_redrawing = false; int focus = playlist_api->activeplaylist_get_focus_item(); SCROLLINFO si; memset(&si, 0, sizeof(si)); si.cbSize = sizeof(si); si.fMask = SIF_POS; GetScrollInfo(wnd_playlist, SB_VERT, &si); int old_offset = si.nPos; si.nPos += 3; scroll_item_offset = SetScrollInfo(wnd_playlist, SB_VERT, &si, true); if (old_offset != scroll_item_offset) need_redrawing = true; int t = scroll_item_offset + items_count - 2; //n=dragitem, if (t > total) t = total - 1; if (t != dragitem) { drawing_enabled = false; if (drag_type == 1) playlist_api->activeplaylist_move_selection((rc.bottom - rc.top) / item_height + scroll_item_offset - focus - 1); else if (drag_type == 2) { set_sel_range(dragstartitem, t, false); playlist_api->activeplaylist_set_focus_item(t); } dragitem = t; drawing_enabled = true; need_redrawing = true; } if (need_redrawing) RedrawWindow(wnd_playlist, 0, 0, RDW_INVALIDATE | RDW_UPDATENOW); } else if (idx < 0 || GET_Y_LPARAM(lp) < get_header_height() || GET_Y_LPARAM(lp) < 0) { int focus = playlist_api->activeplaylist_get_focus_item(); bool need_redrawing = false; SCROLLINFO si; memset(&si, 0, sizeof(si)); si.cbSize = sizeof(si); si.fMask = SIF_POS; GetScrollInfo(wnd_playlist, SB_VERT, &si); int old_offset = si.nPos; si.nPos -= 3; scroll_item_offset = SetScrollInfo(wnd_playlist, SB_VERT, &si, true); if (old_offset != scroll_item_offset) need_redrawing = true; if (dragitem != scroll_item_offset) { drawing_enabled = false; if (drag_type == 1) playlist_api->activeplaylist_move_selection(scroll_item_offset - focus); else if (drag_type == 2) { set_sel_range(dragstartitem, scroll_item_offset, false); playlist_api->activeplaylist_set_focus_item(scroll_item_offset); RedrawWindow(wnd_playlist, 0, 0, RDW_INVALIDATE | RDW_UPDATENOW); } dragitem = scroll_item_offset; drawing_enabled = true; need_redrawing = true; } if (need_redrawing) RedrawWindow(wnd_playlist, 0, 0, RDW_INVALIDATE | RDW_UPDATENOW); } else { int focus = playlist_api->activeplaylist_get_focus_item(); if (drag_type == 1) playlist_api->activeplaylist_move_selection(idx + scroll_item_offset - focus); else if (drag_type == 2) { if (valid_idx >= 0) { drawing_enabled = false; set_sel_range(dragstartitem, valid_idx, false); playlist_api->activeplaylist_set_focus_item(valid_idx); drawing_enabled = true; RedrawWindow(wnd_playlist, 0, 0, RDW_INVALIDATE | RDW_UPDATENOW); } } dragitem = valid_idx; dragged = true; } } } else if (!(wp & MK_LBUTTON)) drag_type = 0; } break; case WM_LBUTTONDBLCLK: { int idx = hittest_item(GET_X_LPARAM(lp), GET_Y_LPARAM(lp), true); if (idx >= 0) { //#ifdef INLINE_EDIT exit_inline_edit(); m_no_next_edit = true; //#endif //if (!is_visible(idx)) SendMessage(wnd_playlist, WM_VSCROLL, MAKEWPARAM(SB_LINEDOWN, 0),0); #if 0 // DEATH's code case WM_LBUTTONDBLCLK: { int idx = item_from_point((short)HIWORD(lp)); if (idx >= 0 && idx<(int)m_api->activeplaylist_get_item_count()) { m_api->activeplaylist_set_focus_item(idx); static_api_ptr_t<play_control>()->play_start(play_control::TRACK_COMMAND_SETTRACK); } } return 0; #endif static_api_ptr_t<playlist_manager> playlist_api; //unsigned active = playlist_api->get_active_playlist(); // playlist_api->set_playing_playlist(active); //playlist_api->playlist_set_playback_cursor(active, idx); //playlist_api->queue_flush(); unsigned focus = playlist_api->activeplaylist_get_focus_item(); playlist_api->activeplaylist_execute_default_action(focus); } else if (cfg_playlist_double.get_value().m_command != pfc::guid_null) { mainmenu_commands::g_execute(cfg_playlist_double.get_value().m_command); } dragged = true; } break; case WM_RBUTTONDOWN: { if (wnd_playlist) SetFocus(wnd_playlist); g_dragging1 = true; drag_start.x = GET_X_LPARAM(lp); drag_start.y = GET_Y_LPARAM(lp); static_api_ptr_t<playlist_manager> playlist_api; // int item_height = get_item_height(); // int idx = ((GET_Y_LPARAM(lp) - get_header_height()) / item_height) + scroll_item_offset; int idx = hittest_item(GET_X_LPARAM(lp), GET_Y_LPARAM(lp), true); if (idx != -1 && !is_visible(idx)) SendMessage(wnd_playlist, WM_VSCROLL, MAKEWPARAM(SB_LINEDOWN, 0), 0); if (idx >= 0 /*&& idx < playlist_api->activeplaylist_get_item_count() && (GET_X_LPARAM(lp) < g_playlist_entries.get_total_width_actual())*/) { if (!playlist_api->activeplaylist_is_item_selected(idx) && !(GetKeyState(VK_CONTROL) & KF_UP)) { set_sel_single(idx, false, false, true); } playlist_api->activeplaylist_set_focus_item(idx); } } break; case WM_MOUSEWHEEL: {//GET_WHEEL_DELTA_WPARAM exit_inline_edit(); if (1 || (wp & MK_CONTROL)) { LONG_PTR style = GetWindowLongPtr(wnd_playlist, GWL_STYLE); if (!(style & WS_VSCROLL) || ((wp & MK_CONTROL) && (style & WS_HSCROLL))) { if ((style & WS_HSCROLL)) { SCROLLINFO si; memset(&si, 0, sizeof(SCROLLINFO)); si.fMask = SIF_PAGE; si.cbSize = sizeof(SCROLLINFO); GetScrollInfo(wnd, SB_HORZ, &si); int new_pos = horizontal_offset; int old_pos = horizontal_offset; unsigned scroll_lines = GetNumScrollLines(); int zDelta = short(HIWORD(wp)); if (scroll_lines == -1) { scroll_lines = si.nPage > 1 ? si.nPage - 1 : 1; } else scroll_lines *= 3; int delta = MulDiv(zDelta, scroll_lines, 120); if (!si.nPage) si.nPage++; if (delta < 0 && delta*-1 > si.nPage) { delta = si.nPage*-1; if (delta >1) delta--; } else if (delta > 0 && delta > si.nPage) { delta = si.nPage; if (delta >1) delta--; } scroll(scroll_horizontally, scroll_position_delta, -delta); } return 1; } } SCROLLINFO si; memset(&si, 0, sizeof(SCROLLINFO)); si.fMask = SIF_PAGE; si.cbSize = sizeof(SCROLLINFO); GetScrollInfo(wnd, SB_VERT, &si); int new_pos = scroll_item_offset; int old_pos = scroll_item_offset; unsigned scroll_lines = GetNumScrollLines(); int zDelta = short(HIWORD(wp)); if (scroll_lines == -1) { scroll_lines = si.nPage > 1 ? si.nPage - 1 : 1; } int delta = MulDiv(zDelta, scroll_lines, 120); if (!si.nPage) si.nPage++; if (delta < 0 && delta*-1 > si.nPage) { delta = si.nPage*-1; if (delta >1) delta--; } else if (delta > 0 && delta > si.nPage) { delta = si.nPage; if (delta >1) delta--; } scroll(scroll_vertically, scroll_position_delta, -delta); } return 1; case WM_VSCROLL: { exit_inline_edit(); scroll(scroll_vertically, scroll_sb, LOWORD(wp)); } return 0; case WM_HSCROLL: { exit_inline_edit(); scroll(scroll_horizontally, scroll_sb, LOWORD(wp)); } return 0; case WM_MENUSELECT: { if (HIWORD(wp) & MF_POPUP) { m_status_override.release(); } else { if (g_main_menu_a.is_valid() || g_main_menu_b.is_valid()) { unsigned id = LOWORD(wp); bool set = false; pfc::string8 desc; if (g_main_menu_a.is_valid() && id < MENU_B_BASE) { set = g_main_menu_a->get_description(id - MENU_A_BASE, desc); } else if (g_main_menu_b.is_valid()) { contextmenu_node * node = g_main_menu_b->find_by_id(id - MENU_B_BASE); if (node) set = node->get_description(desc); } service_ptr_t<ui_status_text_override> p_status_override; if (set) { get_host()->override_status_text_create(p_status_override); if (p_status_override.is_valid()) { p_status_override->override_text(desc); } } m_status_override = p_status_override; } } } break; case WM_CONTEXTMENU: { uie::window_ptr p_this_temp = this; if ((HWND)wp == wnd_header) { POINT pt = { (short)LOWORD(lp), (short)HIWORD(lp) }; POINT temp; temp.x = pt.x; temp.y = pt.y; ScreenToClient(wnd_header, &temp); HDHITTESTINFO hittest; hittest.pt.x = temp.x; hittest.pt.y = temp.y; SendMessage(wnd_header, HDM_HITTEST, 0, (LPARAM)&hittest); enum { IDM_ASC = 1, IDM_DES = 2, IDM_SEL_ASC, IDM_SEL_DES, IDM_AUTOSIZE, IDM_PREFS, IDM_EDIT_COLUMN, IDM_CUSTOM_BASE }; HMENU menu = CreatePopupMenu(); HMENU selection_menu = CreatePopupMenu(); if (!(hittest.flags & HHT_NOWHERE)) { uAppendMenu(menu, (MF_STRING), IDM_ASC, "&Sort ascending"); uAppendMenu(menu, (MF_STRING), IDM_DES, "Sort &descending"); uAppendMenu(selection_menu, (MF_STRING), IDM_SEL_ASC, "Sort a&scending"); uAppendMenu(selection_menu, (MF_STRING), IDM_SEL_DES, "Sort d&escending"); uAppendMenu(menu, MF_STRING | MF_POPUP, (UINT)selection_menu, "Se&lection"); uAppendMenu(menu, (MF_SEPARATOR), 0, ""); uAppendMenu(menu, (MF_STRING), IDM_EDIT_COLUMN, "&Edit this column"); uAppendMenu(menu, (MF_SEPARATOR), 0, ""); uAppendMenu(menu, (MF_STRING | (cfg_nohscroll ? MF_CHECKED : MF_UNCHECKED)), IDM_AUTOSIZE, "&Auto-sizing columns"); uAppendMenu(menu, (MF_STRING), IDM_PREFS, "&Preferences"); uAppendMenu(menu, (MF_SEPARATOR), 0, ""); pfc::string8 playlist_name; static_api_ptr_t<playlist_manager> playlist_api; playlist_api->activeplaylist_get_name(playlist_name); pfc::string8_fast_aggressive filter, name; int s, e = columns.get_count(); for (s = 0; s<e; s++) { bool add = false; switch (columns[s]->filter_type) { case FILTER_NONE: { add = true; break; } case FILTER_SHOW: { if (wildcard_helper::test(playlist_name, columns[s]->filter, true)) { add = true; /* g_columns.get_string(s, name, STRING_NAME); uAppendMenu(menu,MF_STRING|MF_CHECKED,IDM_CUSTOM_BASE+s,name);*/ } } break; case FILTER_HIDE: { if (!wildcard_helper::test(playlist_name, columns[s]->filter, true)) { add = true; /* g_columns.get_string(s, name, STRING_NAME); uAppendMenu(menu,MF_STRING|MF_CHECKED,IDM_CUSTOM_BASE+s,name);*/ } } break; } if (add) { uAppendMenu(menu, MF_STRING | (columns[s]->show ? MF_CHECKED : MF_UNCHECKED), IDM_CUSTOM_BASE + s, columns[s]->name); } } } else { uAppendMenu(menu, (MF_STRING | (cfg_nohscroll ? MF_CHECKED : MF_UNCHECKED)), IDM_AUTOSIZE, "&Auto-sizing columns"); uAppendMenu(menu, (MF_STRING), IDM_PREFS, "&Preferences"); } menu_helpers::win32_auto_mnemonics(menu); int cmd = TrackPopupMenu(menu, TPM_RIGHTBUTTON | TPM_NONOTIFY | TPM_RETURNCMD, pt.x, pt.y, 0, wnd, 0); DestroyMenu(menu); if (cmd == IDM_ASC) { g_set_sort(hittest.iItem, false); } else if (cmd == IDM_DES) { g_set_sort(hittest.iItem, true); } else if (cmd == IDM_SEL_ASC) { g_set_sort(hittest.iItem, false, true); } else if (cmd == IDM_SEL_DES) { g_set_sort(hittest.iItem, true, true); } else if (cmd == IDM_EDIT_COLUMN) { g_set_tab("Columns"); cfg_cur_prefs_col = g_cache.active_column_active_to_actual(hittest.iItem); //get_idx static_api_ptr_t<ui_control>()->show_preferences(columns::config_get_playlist_view_guid()); } else if (cmd == IDM_AUTOSIZE) { cfg_nohscroll = cfg_nohscroll == 0; update_all_windows(); pvt::ng_playlist_view_t::g_on_autosize_change(); } else if (cmd == IDM_PREFS) { static_api_ptr_t<ui_control>()->show_preferences(columns::config_get_main_guid()); } else if (cmd >= IDM_CUSTOM_BASE) { if (t_size(cmd - IDM_CUSTOM_BASE) < columns.get_count()) { columns[cmd - IDM_CUSTOM_BASE]->show = !columns[cmd - IDM_CUSTOM_BASE]->show; //g_columns //if (!cfg_nohscroll) g_save_columns(); //g_cache.flush_all(); g_reset_columns(); update_all_windows(); pvt::ng_playlist_view_t::g_on_columns_change(); } } return 0; } else if ((HWND)wp == wnd) { //DWORD mp = GetMessagePos(); POINT px, pt = { GET_X_LPARAM(lp), GET_Y_LPARAM(lp) }; static_api_ptr_t<playlist_manager> playlist_api; if (playlist_api->activeplaylist_get_selection_count(1) > 0 && 1) { if (pt.x == -1 && pt.y == -1) { int focus = playlist_api->activeplaylist_get_focus_item(); unsigned last = get_last_viewable_item(); if (focus == -1 || focus < scroll_item_offset || focus > last) { px.x = 0; px.y = 0; } else { RECT rc; get_playlist_rect(&rc); px.x = 0; unsigned item_height = get_item_height(); px.y = (focus - scroll_item_offset)*(item_height)+item_height / 2 + rc.top; } pt = px; MapWindowPoints(wnd, HWND_DESKTOP, &pt, 1); } else { px = pt; ScreenToClient(wnd, &px); //int idx = hittest_item(px.x, px.y); //if (!is_visible(idx)) // SendMessage(wnd_playlist, WM_VSCROLL, MAKEWPARAM(SB_LINEDOWN, 0),0); } // int idx = hittest_item(px.x, px.y); enum { ID_PLAY = 1, ID_CUT, ID_COPY, ID_PASTE, ID_SELECTION, ID_CUSTOM_BASE = 0x8000 }; HMENU menu = CreatePopupMenu();//LoadMenu(core_api::get_my_instance(),MAKEINTRESOURCE(IDR_TREEPOPUP)); service_ptr_t<mainmenu_manager> p_manager_selection; service_ptr_t<contextmenu_manager> p_manager_context; p_manager_selection = standard_api_create_t<mainmenu_manager>(); contextmenu_manager::g_create(p_manager_context); if (p_manager_selection.is_valid()) { p_manager_selection->instantiate(mainmenu_groups::edit_part2_selection); p_manager_selection->generate_menu_win32(menu, ID_SELECTION, ID_CUSTOM_BASE - ID_SELECTION, standard_config_objects::query_show_keyboard_shortcuts_in_menus() ? contextmenu_manager::FLAG_SHOW_SHORTCUTS : 0); if (GetMenuItemCount(menu) > 0) uAppendMenu(menu, MF_SEPARATOR, 0, ""); } AppendMenu(menu, MF_STRING, ID_CUT, L"Cut"); AppendMenu(menu, MF_STRING, ID_COPY, L"Copy"); if (playlist_utils::check_clipboard()) AppendMenu(menu, MF_STRING, ID_PASTE, L"Paste"); AppendMenu(menu, MF_SEPARATOR, 0, NULL); if (p_manager_context.is_valid()) { const keyboard_shortcut_manager::shortcut_type shortcuts[] = { keyboard_shortcut_manager::TYPE_CONTEXT_PLAYLIST, keyboard_shortcut_manager::TYPE_CONTEXT }; p_manager_context->set_shortcut_preference(shortcuts, tabsize(shortcuts)); p_manager_context->init_context_playlist(standard_config_objects::query_show_keyboard_shortcuts_in_menus() ? contextmenu_manager::FLAG_SHOW_SHORTCUTS : 0); p_manager_context->win32_build_menu(menu, ID_CUSTOM_BASE, -1); } menu_helpers::win32_auto_mnemonics(menu); MENU_A_BASE = ID_SELECTION; MENU_B_BASE = ID_CUSTOM_BASE; g_main_menu_a = p_manager_selection; g_main_menu_b = p_manager_context; int cmd = TrackPopupMenu(menu, TPM_RIGHTBUTTON | TPM_NONOTIFY | TPM_RETURNCMD, pt.x, pt.y, 0, wnd, 0); if (m_status_override.is_valid()) { m_status_override.release(); } DestroyMenu(menu); if (cmd) { if (cmd == ID_CUT) { playlist_utils::cut(); } else if (cmd == ID_COPY) { playlist_utils::copy(); } else if (cmd == ID_PASTE) { playlist_utils::paste(wnd); } else if (cmd >= ID_SELECTION && cmd<ID_CUSTOM_BASE) { if (p_manager_selection.is_valid()) { p_manager_selection->execute_command(cmd - ID_SELECTION); } } else if (cmd >= ID_CUSTOM_BASE) { if (p_manager_context.is_valid()) { p_manager_context->execute_by_id(cmd - ID_CUSTOM_BASE); } } } g_main_menu_a.release(); g_main_menu_b.release(); } // contextmenu_manager::win32_run_menu_context_playlist(wnd, 0, config_object::g_get_data_bool_simple(standard_config_objects::bool_show_keyboard_shortcuts_in_menus, true) ? contextmenu_manager::FLAG_SHOW_SHORTCUTS : 0); } } return 0; //#ifdef INLINE_EDIT case WM_PARENTNOTIFY: { if (wp == WM_DESTROY) { if (m_wnd_edit && (HWND)lp == m_wnd_edit) m_wnd_edit = 0; } } break; case MSG_KILL_INLINE_EDIT: exit_inline_edit(); return 0; #if 1 case WM_COMMAND: switch (wp) { case (EN_CHANGE << 16) | 667: { m_edit_changed = true; } break; } break; #endif case WM_TIMER: { if (wp == EDIT_TIMER_ID) { create_inline_edit_v2(m_edit_index, m_edit_column); if (m_edit_timer) { KillTimer(wnd_playlist, EDIT_TIMER_ID); m_edit_timer = false; } return 0; } } break; //#endif case WM_NOTIFY: switch (((LPNMHDR)lp)->idFrom) { case ID_PLAYLIST_TOOLTIP: switch (((LPNMHDR)lp)->code) { case TTN_SHOW: RECT rc, rc_tt; rc = tooltip; GetWindowRect(g_tooltip, &rc_tt); int offset = MulDiv(get_item_height() - rc_tt.bottom + rc_tt.top, 1, 2); rc.top += offset; SetWindowPos(g_tooltip, NULL, rc.left, rc.top, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); return TRUE; } break; case 5001: switch (((LPNMHDR)lp)->code) { case HDN_BEGINTRACKA: case HDN_BEGINTRACKW: { return (cfg_nohscroll ? TRUE : FALSE); } case HDN_ENDDRAG: { if (((LPNMHEADERA)lp)->iButton == 0) { if (((LPNMHEADERA)lp)->pitem && (((LPNMHEADERA)lp)->pitem->mask & HDI_ORDER)) { int from = ((LPNMHEADERA)lp)->iItem; int to = ((LPNMHEADERA)lp)->pitem->iOrder; if (to >= 0 && from != to) { int act_from = g_cache.active_column_active_to_actual(from), act_to = g_cache.active_column_active_to_actual(to); columns.move(act_from, act_to); //if (!cfg_nohscroll) g_save_columns(); g_reset_columns(); update_all_windows(); pvt::ng_playlist_view_t::g_on_columns_change(); } } else { } } return (TRUE); } case HDN_DIVIDERDBLCLICK: if (!cfg_nohscroll) { static_api_ptr_t<playlist_manager> playlist_api; HDC hdc; hdc = GetDC(wnd_playlist); int size; pfc::string8 text; SelectObject(hdc, g_font); int w = 0, n, t = playlist_api->activeplaylist_get_item_count(); for (n = 0; n<t; n++) { // playlist_api->format_title(n, text, g_playlist_entries.get_display_spec(((LPNMHEADER)lp)->iItem), NULL); g_cache.active_get_display_name(n, ((LPNMHEADER)lp)->iItem, text); size = ui_helpers::get_text_width_color(hdc, text, text.length()); if (size > w) w = size; } // g_playlist_entries.get_column(((LPNMHEADER)lp)->iItem)->_set_width(w+5); columns[g_cache.active_column_active_to_actual(((LPNMHEADER)lp)->iItem)]->width = w + 15; ReleaseDC(wnd_playlist, hdc); update_all_windows(); g_save_columns(); pvt::ng_playlist_view_t::g_on_column_widths_change(); } return 0; case HDN_ITEMCLICK: { bool des = false; static_api_ptr_t<playlist_manager> playlist_api; unsigned col; bool descending; bool sorted = g_cache.active_get_playlist_sort(col, &descending); if (sorted && col == ((LPNMHEADER)lp)->iItem) des = !descending; g_set_sort(((LPNMHEADER)lp)->iItem, des /*, playlist_api->activeplaylist_get_selection_count(1) && cfg_sortsel != 0*/); } break; case HDN_ITEMCHANGED: { if (!cfg_nohscroll) { if (((LPNMHEADER)lp)->pitem->mask & HDI_WIDTH) columns[g_cache.active_column_active_to_actual(((LPNMHEADER)lp)->iItem)]->width = ((LPNMHEADER)lp)->pitem->cxy; update_all_windows(wnd_header); g_save_columns(); pvt::ng_playlist_view_t::g_on_column_widths_change(); } } break; } break; } } return DefWindowProc(wnd, msg, wp, lp); }
void PaintClc(HWND hwnd, struct ClcData *dat, HDC hdc, RECT * rcPaint) { HDC hdcMem; RECT clRect; int y, indent, index, fontHeight; struct ClcGroup *group; HFONT hOldFont; DWORD style = GetWindowLong(hwnd, GWL_STYLE); int status = GetGeneralisedStatus(); int grey = 0, groupCountsFontTopShift; HBRUSH hBrushAlternateGrey = NULL; // yes I know about GetSysColorBrush() COLORREF tmpbkcolour = style & CLS_CONTACTLIST ? (dat->useWindowsColours ? GetSysColor(COLOR_3DFACE) : dat->bkColour) : dat->bkColour; if (dat->greyoutFlags & pcli->pfnClcStatusToPf2(status) || style & WS_DISABLED) grey = 1; else if (GetFocus() != hwnd && dat->greyoutFlags & GREYF_UNFOCUS) grey = 1; GetClientRect(hwnd, &clRect); if (rcPaint == NULL) rcPaint = &clRect; if (IsRectEmpty(rcPaint)) return; y = -dat->yScroll; hdcMem = CreateCompatibleDC(hdc); HBITMAP hBmpOsb = CreateBitmap(clRect.right, clRect.bottom, 1, GetDeviceCaps(hdc, BITSPIXEL), NULL); HBITMAP hOldBitmap = (HBITMAP)SelectObject(hdcMem, hBmpOsb); { TEXTMETRIC tm; hOldFont = (HFONT)SelectObject(hdcMem, dat->fontInfo[FONTID_GROUPS].hFont); GetTextMetrics(hdcMem, &tm); groupCountsFontTopShift = tm.tmAscent; SelectObject(hdcMem, dat->fontInfo[FONTID_GROUPCOUNTS].hFont); GetTextMetrics(hdcMem, &tm); groupCountsFontTopShift -= tm.tmAscent; } if (style & CLS_GREYALTERNATE) hBrushAlternateGrey = CreateSolidBrush(GetNearestColor(hdcMem, RGB(GetRValue(tmpbkcolour) - 10, GetGValue(tmpbkcolour) - 10, GetBValue(tmpbkcolour) - 10))); ChangeToFont(hdcMem, dat, FONTID_CONTACTS, &fontHeight); SetBkMode(hdcMem, TRANSPARENT); { HBRUSH hBrush; hBrush = CreateSolidBrush(tmpbkcolour); FillRect(hdcMem, rcPaint, hBrush); DeleteObject(hBrush); if (dat->hBmpBackground) { BITMAP bmp; HDC hdcBmp; int x, y; int maxx, maxy; int destw, desth; // XXX: Halftone isnt supported on 9x, however the scretch problems dont happen on 98. SetStretchBltMode(hdcMem, HALFTONE); GetObject(dat->hBmpBackground, sizeof(bmp), &bmp); hdcBmp = CreateCompatibleDC(hdcMem); SelectObject(hdcBmp, dat->hBmpBackground); y = dat->backgroundBmpUse & CLBF_SCROLL ? -dat->yScroll : 0; maxx = dat->backgroundBmpUse & CLBF_TILEH ? clRect.right : 1; maxy = dat->backgroundBmpUse & CLBF_TILEV ? maxy = rcPaint->bottom : y + 1; switch (dat->backgroundBmpUse & CLBM_TYPE) { case CLB_STRETCH: if (dat->backgroundBmpUse & CLBF_PROPORTIONAL) { if (clRect.right * bmp.bmHeight < clRect.bottom * bmp.bmWidth) { desth = clRect.bottom; destw = desth * bmp.bmWidth / bmp.bmHeight; } else { destw = clRect.right; desth = destw * bmp.bmHeight / bmp.bmWidth; } } else { destw = clRect.right; desth = clRect.bottom; } break; case CLB_STRETCHH: if (dat->backgroundBmpUse & CLBF_PROPORTIONAL) { destw = clRect.right; desth = destw * bmp.bmHeight / bmp.bmWidth; } else { destw = clRect.right; desth = bmp.bmHeight; } break; case CLB_STRETCHV: if (dat->backgroundBmpUse & CLBF_PROPORTIONAL) { desth = clRect.bottom; destw = desth * bmp.bmWidth / bmp.bmHeight; } else { destw = bmp.bmWidth; desth = clRect.bottom; } break; default: //clb_topleft destw = bmp.bmWidth; desth = bmp.bmHeight; break; } for (; y < maxy; y += desth) { if (y < rcPaint->top - desth) continue; for (x = 0; x < maxx; x += destw) StretchBlt(hdcMem, x, y, destw, desth, hdcBmp, 0, 0, bmp.bmWidth, bmp.bmHeight, SRCCOPY); } DeleteDC(hdcBmp); } } group = &dat->list; group->scanIndex = 0; indent = 0; for (index = 0; y < rcPaint->bottom;) { if (group->scanIndex == group->cl.count) { group = group->parent; indent--; if (group == NULL) break; group->scanIndex++; continue; } if (y > rcPaint->top - dat->rowHeight) { int iImage = -1; int selected = index == dat->selection && (dat->showSelAlways || dat->exStyle & CLS_EX_SHOWSELALWAYS || GetFocus() == hwnd) && group->cl.items[group->scanIndex]->type != CLCIT_DIVIDER; int hottrack = dat->exStyle & CLS_EX_TRACKSELECT && group->cl.items[group->scanIndex]->type != CLCIT_DIVIDER && dat->iHotTrack == index; SIZE textSize, countsSize, spaceSize; int width, checkboxWidth; char *szCounts; //alternating grey if (style & CLS_GREYALTERNATE && index & 1) { RECT rc; rc.top = y; rc.bottom = rc.top + dat->rowHeight; rc.left = 0; rc.right = clRect.right; FillRect(hdcMem, &rc, hBrushAlternateGrey); } //setup if (group->cl.items[group->scanIndex]->type == CLCIT_GROUP) ChangeToFont(hdcMem, dat, FONTID_GROUPS, &fontHeight); else if (group->cl.items[group->scanIndex]->type == CLCIT_INFO) { if (group->cl.items[group->scanIndex]->flags & CLCIIF_GROUPFONT) ChangeToFont(hdcMem, dat, FONTID_GROUPS, &fontHeight); else ChangeToFont(hdcMem, dat, FONTID_CONTACTS, &fontHeight); } else if (group->cl.items[group->scanIndex]->type == CLCIT_DIVIDER) ChangeToFont(hdcMem, dat, FONTID_DIVIDERS, &fontHeight); else if (group->cl.items[group->scanIndex]->type == CLCIT_CONTACT && group->cl.items[group->scanIndex]->flags & CONTACTF_NOTONLIST) ChangeToFont(hdcMem, dat, FONTID_NOTONLIST, &fontHeight); else if (group->cl.items[group->scanIndex]->type == CLCIT_CONTACT && ((group->cl.items[group->scanIndex]->flags & CONTACTF_INVISTO && GetRealStatus(group->cl.items[group->scanIndex], status) != ID_STATUS_INVISIBLE) || (group->cl.items[group->scanIndex]->flags & CONTACTF_VISTO && GetRealStatus(group->cl.items[group->scanIndex], status) == ID_STATUS_INVISIBLE) ) ) { // the contact is in the always visible list and the proto is invisible // the contact is in the always invisible and the proto is in any other mode ChangeToFont(hdcMem, dat, group->cl.items[group->scanIndex]->flags & CONTACTF_ONLINE ? FONTID_INVIS : FONTID_OFFINVIS, &fontHeight); } else if (group->cl.items[group->scanIndex]->type == CLCIT_CONTACT && !(group->cl.items[group->scanIndex]->flags & CONTACTF_ONLINE)) ChangeToFont(hdcMem, dat, FONTID_OFFLINE, &fontHeight); else ChangeToFont(hdcMem, dat, FONTID_CONTACTS, &fontHeight); GetTextExtentPoint32(hdcMem, group->cl.items[group->scanIndex]->szText, lstrlen(group->cl.items[group->scanIndex]->szText), &textSize); width = textSize.cx; if (group->cl.items[group->scanIndex]->type == CLCIT_GROUP) { szCounts = pcli->pfnGetGroupCountsText(dat, group->cl.items[group->scanIndex]); if (szCounts[0]) { GetTextExtentPoint32A(hdcMem, " ", 1, &spaceSize); ChangeToFont(hdcMem, dat, FONTID_GROUPCOUNTS, &fontHeight); GetTextExtentPoint32A(hdcMem, szCounts, lstrlenA(szCounts), &countsSize); width += spaceSize.cx + countsSize.cx; } } if ((style & CLS_CHECKBOXES && group->cl.items[group->scanIndex]->type == CLCIT_CONTACT) || (style & CLS_GROUPCHECKBOXES && group->cl.items[group->scanIndex]->type == CLCIT_GROUP) || (group->cl.items[group->scanIndex]->type == CLCIT_INFO && group->cl.items[group->scanIndex]->flags & CLCIIF_CHECKBOX)) checkboxWidth = dat->checkboxSize + 2; else checkboxWidth = 0; //background if (selected) { int x = dat->leftMargin + indent * dat->groupIndent + checkboxWidth + dat->iconXSpace - 2; ImageList_DrawEx(dat->himlHighlight, 0, hdcMem, x, y, min(width + 5, clRect.right - x), dat->rowHeight, CLR_NONE, CLR_NONE, dat->exStyle & CLS_EX_NOTRANSLUCENTSEL ? ILD_NORMAL : ILD_BLEND25); SetTextColor(hdcMem, dat->selTextColour); } else if (hottrack) SetHotTrackColour(hdcMem, dat); //checkboxes if (checkboxWidth) { RECT rc; HANDLE hTheme = OpenThemeData(hwnd, L"BUTTON"); rc.left = dat->leftMargin + indent * dat->groupIndent; rc.right = rc.left + dat->checkboxSize; rc.top = y + ((dat->rowHeight - dat->checkboxSize) >> 1); rc.bottom = rc.top + dat->checkboxSize; DrawThemeBackground(hTheme, hdcMem, BP_CHECKBOX, group->cl.items[group->scanIndex]->flags & CONTACTF_CHECKED ? (hottrack ? CBS_CHECKEDHOT : CBS_CHECKEDNORMAL) : (hottrack ? CBS_UNCHECKEDHOT : CBS_UNCHECKEDNORMAL), &rc, &rc); CloseThemeData(hTheme); } //icon if (group->cl.items[group->scanIndex]->type == CLCIT_GROUP) iImage = group->cl.items[group->scanIndex]->group->expanded ? IMAGE_GROUPOPEN : IMAGE_GROUPSHUT; else if (group->cl.items[group->scanIndex]->type == CLCIT_CONTACT) iImage = group->cl.items[group->scanIndex]->iImage; if (iImage != -1) { /*COLORREF colourFg=dat->selBkColour; int mode=ILD_NORMAL; if(selected) mode=ILD_SELECTED; else if(hottrack) {mode=ILD_FOCUS; colourFg=dat->hotTextColour;} else if(group->cl.items[group->scanIndex]->type==CLCIT_CONTACT && group->cl.items[group->scanIndex]->flags&CONTACTF_NOTONLIST) {colourFg=dat->fontInfo[FONTID_NOTONLIST].colour; mode=ILD_BLEND50;} ImageList_DrawEx(himlCListClc,iImage,hdcMem,dat->leftMargin+indent*dat->groupIndent+checkboxWidth,y+((dat->rowHeight-16)>>1),0,0,CLR_NONE,colourFg,mode); */ // this doesnt use CLS_CONTACTLIST since the colour prolly wont match anyway COLORREF colourFg = dat->selBkColour; int mode = ILD_NORMAL; if (hottrack) { colourFg = dat->hotTextColour; } else if (group->cl.items[group->scanIndex]->type == CLCIT_CONTACT && group->cl.items[group->scanIndex]->flags & CONTACTF_NOTONLIST) { colourFg = dat->fontInfo[FONTID_NOTONLIST].colour; mode = ILD_BLEND50; } if (group->cl.items[group->scanIndex]->type == CLCIT_CONTACT && dat->showIdle && (group->cl.items[group->scanIndex]->flags & CONTACTF_IDLE) && GetRealStatus(group->cl.items[group->scanIndex], ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE) mode = ILD_SELECTED; ImageList_DrawEx(himlCListClc, iImage, hdcMem, dat->leftMargin + indent * dat->groupIndent + checkboxWidth, y + ((dat->rowHeight - 16) >> 1), 0, 0, CLR_NONE, colourFg, mode); } //text if (group->cl.items[group->scanIndex]->type == CLCIT_DIVIDER) { RECT rc; rc.top = y + (dat->rowHeight >> 1); rc.bottom = rc.top + 2; rc.left = dat->leftMargin + indent * dat->groupIndent; rc.right = rc.left + ((clRect.right - rc.left - textSize.cx) >> 1) - 3; DrawEdge(hdcMem, &rc, BDR_SUNKENOUTER, BF_RECT); TextOut(hdcMem, rc.right + 3, y + ((dat->rowHeight - fontHeight) >> 1), group->cl.items[group->scanIndex]->szText, lstrlen(group->cl.items[group->scanIndex]->szText)); rc.left = rc.right + 6 + textSize.cx; rc.right = clRect.right; DrawEdge(hdcMem, &rc, BDR_SUNKENOUTER, BF_RECT); }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // 获取窗口状态 BOOL CXPGetState(PCLASSXP pCxp) { PCLASSXP p; UINT uCheck; // 设置禁用和焦点状态 pCxp->lState = _CXPGetStyle(WS_DISABLED) ? CXPS_DISABLED : 0; _ExIf(pCxp->hWnd == GetFocus(), _CXPSetState(CXPS_FOCUS)); switch (pCxp->uClass) { case CXPC_BUTTON: switch (_CXPGetStyle(BS_TYPEMASK)) { case BS_DEFPUSHBUTTON: // 默认按钮 _CXPSetState(CXPS_DEFAULT); case BS_PUSHBUTTON: // 普通按钮 break; case BS_CHECKBOX: // 复选框 case BS_AUTOCHECKBOX: // 自动复选框 case BS_3STATE: // 三状态复选框 case BS_AUTO3STATE: // 自动三状态复选框 case BS_RADIOBUTTON: // 单选框 case BS_AUTORADIOBUTTON: // 自动单选框 if (!_CXPGetStyle(BS_PUSHLIKE)) { pCxp->pDraw = CXPDrawCheckBox; } break; default: // 自绘按钮、组合框和其它未知类型 return FALSE; } uCheck = (LONG) SendMessage(pCxp->hWnd, BM_GETCHECK, 0, 0); if (uCheck == BST_CHECKED) { _CXPSetState(CXPS_CHECKED); } else if (uCheck == BST_INDETERMINATE) { _CXPSetState(CXPS_INDETERMINATE); } break; case CXPC_EDITBOX: if (!_CXPGetStyle(WS_BORDER) && !(GetWindowLong(pCxp->hWnd, GWL_EXSTYLE) & (WS_EX_CLIENTEDGE | WS_EX_STATICEDGE))) { return FALSE; } _ExIf(_CXPGetStyle(ES_READONLY), _CXPSetState(CXPS_READONLY)); break; case CXPC_COMBOBOX: if (_CXPGetStyle(CBS_TYPEMASK) == CBS_SIMPLE) { _CXPSetState(CXPS_SIMPLECMB); } break; case CXPC_SPINBOX: _ExIf(_CXPGetStyle(UDS_HORZ), _CXPSetState(CXPS_HORIZON)); _ExIf(_CXPGetStyle(UDS_ARROWKEYS), _CXPSetState(CXPS_ACCELSPIN)); _ExIf(_CXPGetStyle(UDS_ALIGNLEFT), _CXPSetState(CXPS_LEFTSPIN)); _ExIf(_CXPGetStyle(UDS_ALIGNRIGHT), _CXPSetState(CXPS_RIGHTSPIN)); // 设置旧伙伴 p = (PCLASSXP) pCxp->lParam; _ExIf(p, p->lParam = 0); p = (PCLASSXP) GetProp((HWND) SendMessage(pCxp->hWnd, UDM_GETBUDDY, 0, 0), TEXT("ClassXP")); if (p && (p->uClass == CXPC_EDITBOX)) { // 设置新伙伴 p->lParam = (LPARAM) pCxp; pCxp->lParam = (LPARAM) p; } break; } return TRUE; }
static LRESULT CALLBACK ParentWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { if (uMsgCreate && message == uMsgCreate) { static HWND hwndPrevFocus; static BOOL fCancelDisabled; if (wParam) { childwnd = FindWindowEx((HWND) lParam, NULL, "#32770", NULL); hwndL = GetDlgItem(childwnd, 1016); hwndB = GetDlgItem(childwnd, 1027); HWND hwndP = GetDlgItem(childwnd, 1004); HWND hwndS = GetDlgItem(childwnd, 1006); if (childwnd && hwndP && hwndS) { // Where to restore focus to before we disable the cancel button hwndPrevFocus = GetFocus(); if (!hwndPrevFocus) hwndPrevFocus = hwndP; if (IsWindowVisible(hwndL)) ShowWindow(hwndL, SW_HIDE); else hwndL = NULL; if (IsWindowVisible(hwndB)) ShowWindow(hwndB, SW_HIDE); else hwndB = NULL; RECT wndRect, ctlRect; GetClientRect(childwnd, &wndRect); GetWindowRect(hwndS, &ctlRect); HWND s = g_hwndStatic = CreateWindow( "STATIC", "", WS_CHILD | WS_CLIPSIBLINGS | SS_CENTER, 0, wndRect.bottom / 2 - (ctlRect.bottom - ctlRect.top) / 2, wndRect.right, ctlRect.bottom - ctlRect.top, childwnd, NULL, hModule, NULL ); DWORD dwStyle = WS_CHILD | WS_CLIPSIBLINGS; dwStyle |= GetWindowLong(hwndP, GWL_STYLE) & PBS_SMOOTH; GetWindowRect(hwndP, &ctlRect); HWND pb = g_hwndProgressBar = CreateWindow( "msctls_progress32", "", dwStyle, 0, wndRect.bottom / 2 + (ctlRect.bottom - ctlRect.top) / 2, wndRect.right, ctlRect.bottom - ctlRect.top, childwnd, NULL, hModule, NULL ); long c; c = SendMessage(hwndP, PBM_SETBARCOLOR, 0, 0); SendMessage(hwndP, PBM_SETBARCOLOR, 0, c); SendMessage(pb, PBM_SETBARCOLOR, 0, c); c = SendMessage(hwndP, PBM_SETBKCOLOR, 0, 0); SendMessage(hwndP, PBM_SETBKCOLOR, 0, c); SendMessage(pb, PBM_SETBKCOLOR, 0, c); // set font long hFont = SendMessage((HWND) lParam, WM_GETFONT, 0, 0); SendMessage(pb, WM_SETFONT, hFont, 0); SendMessage(s, WM_SETFONT, hFont, 0); ShowWindow(pb, SW_SHOWNA); ShowWindow(s, SW_SHOWNA); fCancelDisabled = EnableWindow(GetDlgItem(hwnd, IDCANCEL), TRUE); SendMessage(hwnd, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(hwnd, IDCANCEL), TRUE); } else childwnd = NULL; } else if (childwnd) { if (hwndB) { ShowWindow(hwndB, SW_SHOWNA); hwndB = NULL; } if (hwndL) { ShowWindow(hwndL, SW_SHOWNA); hwndL = NULL; } // Prevent wierd stuff happening if the cancel button happens to be // pressed at the moment we are finishing and restore the previous focus // and cancel button states SendMessage(hwnd, WM_NEXTDLGCTL, (WPARAM)hwndPrevFocus, TRUE); SendMessage(GetDlgItem(hwnd, IDCANCEL), BM_SETSTATE, FALSE, 0); if (fCancelDisabled) EnableWindow(GetDlgItem(hwnd, IDCANCEL), FALSE); if (g_hwndStatic) { DestroyWindow(g_hwndStatic); g_hwndStatic = NULL; } if (g_hwndProgressBar) { DestroyWindow(g_hwndProgressBar); g_hwndProgressBar = NULL; } childwnd = NULL; } } else if (message == WM_COMMAND && LOWORD(wParam) == IDCANCEL) { g_cancelled = 1; } else { return CallWindowProc( (WNDPROC) lpWndProcOld, hwnd, message, wParam, lParam ); } return 0; }
/* * DlgProcYahooOpts - Connection Options Dialog */ static INT_PTR CALLBACK DlgProcYahooOptsIgnore(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { YList *l; CYahooProto* ppro = (CYahooProto*)GetWindowLongPtr( hwndDlg, GWLP_USERDATA ); switch ( msg ) { case WM_INITDIALOG: TranslateDialogDefault( hwndDlg ); ppro = ( CYahooProto* )lParam; SetWindowLongPtr( hwndDlg, GWLP_USERDATA, lParam ); if ( ppro->GetByte( "IgnoreUnknown", 0 )) { CheckDlgButton(hwndDlg, IDC_OPT_IGN_UNKNOWN, 1); EnableWindow( GetDlgItem(hwndDlg, IDC_IGN_ADD), 0); EnableWindow( GetDlgItem(hwndDlg, IDC_IGN_REMOVE), 0); EnableWindow( GetDlgItem(hwndDlg, IDC_YIGN_EDIT), 0); EnableWindow( GetDlgItem(hwndDlg, IDC_YIGN_LIST), 0); } else CheckDlgButton(hwndDlg, IDC_OPT_IGN_LIST, 1); /* show our current ignore list */ LOG(("[DlgProcYahooOptsIgnore] Grabbing current ignore list...")) l = (YList *)ppro->GetIgnoreList(); while (l != NULL) { struct yahoo_buddy *b = (struct yahoo_buddy *) l->data; LOG(("[DlgProcYahooOptsIgnore] Buddy: %s", b->id )) SendMessageA(GetDlgItem(hwndDlg,IDC_YIGN_LIST), LB_ADDSTRING, 0, (LPARAM)b->id); l = l->next; } LOG(("[DlgProcYahooOptsIgnore] End of Ignore List...")) return TRUE; case WM_COMMAND: switch ( LOWORD( wParam )) { case IDC_OPT_IGN_UNKNOWN: case IDC_OPT_IGN_LIST: if (( HWND )lParam != GetFocus()) return 0; EnableWindow( GetDlgItem(hwndDlg, IDC_IGN_ADD), LOWORD( wParam ) == IDC_OPT_IGN_LIST); EnableWindow( GetDlgItem(hwndDlg, IDC_IGN_REMOVE), LOWORD( wParam ) == IDC_OPT_IGN_LIST); EnableWindow( GetDlgItem(hwndDlg, IDC_YIGN_EDIT), LOWORD( wParam ) == IDC_OPT_IGN_LIST); EnableWindow( GetDlgItem(hwndDlg, IDC_YIGN_LIST), LOWORD( wParam ) == IDC_OPT_IGN_LIST); SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; case IDC_IGN_ADD: if (!ppro->m_bLoggedIn) MessageBoxA(hwndDlg, Translate("You need to be connected to Yahoo to add to Ignore List."), Translate("Yahoo Ignore"), MB_OK| MB_ICONINFORMATION); else { char id[128]; int i = GetDlgItemTextA( hwndDlg, IDC_YIGN_EDIT, id, sizeof( id )); if (i < 3) { MessageBoxA(hwndDlg, Translate("Please enter a valid buddy name to ignore."), Translate("Yahoo Ignore"), MB_OK| MB_ICONINFORMATION); break; } i = SendMessageA(GetDlgItem(hwndDlg,IDC_YIGN_LIST), LB_FINDSTRINGEXACT,(WPARAM) -1, (LPARAM)id); if (i != LB_ERR ) { MessageBoxA(hwndDlg, Translate("The buddy is already on your ignore list. "), Translate("Yahoo Ignore"), MB_OK | MB_ICONINFORMATION); break; } ppro->IgnoreBuddy(id, 0); SendMessageA(GetDlgItem(hwndDlg,IDC_YIGN_LIST), LB_ADDSTRING, 0, (LPARAM)id); SetDlgItemTextA( hwndDlg, IDC_YIGN_EDIT, "" ); } break; case IDC_IGN_REMOVE: { int i; char id[128]; if (!ppro->m_bLoggedIn) { MessageBoxA(hwndDlg, Translate("You need to be connected to Yahoo to remove from the Ignore List."), Translate("Yahoo Ignore"), MB_OK| MB_ICONINFORMATION); break; } i = SendMessage(GetDlgItem(hwndDlg,IDC_YIGN_LIST), LB_GETCURSEL, 0, 0); if (i == LB_ERR) { MessageBoxA(hwndDlg, Translate("Please select a buddy on the ignore list to remove."), Translate("Yahoo Ignore"), MB_OK| MB_ICONINFORMATION); break; } SendMessageA(GetDlgItem(hwndDlg,IDC_YIGN_LIST), LB_GETTEXT, i, (LPARAM)id); ppro->IgnoreBuddy(id, 1); SendMessage(GetDlgItem(hwndDlg,IDC_YIGN_LIST), LB_DELETESTRING, i, 0); } } break; case WM_NOTIFY: if (((LPNMHDR)lParam)->code == PSN_APPLY ) { ppro->SetByte("IgnoreUnknown", ( BYTE )IsDlgButtonChecked( hwndDlg, IDC_OPT_IGN_UNKNOWN )); return TRUE; } break; } return FALSE; }
LRESULT CALLBACK LuaScriptProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { RECT r; RECT r2; int dx1, dy1, dx2, dy2; switch(uMsg) { case WM_INITDIALOG: { if(std::find(LuaScriptHWnds.begin(), LuaScriptHWnds.end(), hDlg) == LuaScriptHWnds.end()) { LuaScriptHWnds.push_back(hDlg); Build_Main_Menu(); } if (Full_Screen) { while (ShowCursor(false) >= 0); while (ShowCursor(true) < 0); } HANDLE hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_LUA)); SendMessage(hDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon); // remove the 30000 character limit from the console control SendMessage(GetDlgItem(hDlg, IDC_LUACONSOLE),EM_LIMITTEXT,0,0); GetWindowRect(HWnd, &r); dx1 = (r.right - r.left) / 2; dy1 = (r.bottom - r.top) / 2; GetWindowRect(hDlg, &r2); dx2 = (r2.right - r2.left) / 2; dy2 = (r2.bottom - r2.top) / 2; int windowIndex = std::find(LuaScriptHWnds.begin(), LuaScriptHWnds.end(), hDlg) - LuaScriptHWnds.begin(); int staggerOffset = windowIndex * 24; r.left += staggerOffset; r.right += staggerOffset; r.top += staggerOffset; r.bottom += staggerOffset; // push it away from the main window if we can const int width = (r.right-r.left); const int width2 = (r2.right-r2.left); if(r.left+width2 + width < GetSystemMetrics(SM_CXSCREEN)) { r.right += width; r.left += width; } else if((int)r.left - (int)width2 > 0) { r.right -= width2; r.left -= width2; } SetWindowPos(hDlg, NULL, r.left, r.top, NULL, NULL, SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW); LuaPerWindowInfo info; { RECT r3; GetClientRect(hDlg, &r3); info.width = r3.right - r3.left; info.height = r3.bottom - r3.top; } LuaWindowInfo[hDlg] = info; RegisterWatcherThread(hDlg); OpenLuaContext((int)hDlg, PrintToWindowConsole, OnStart, OnStop); DragAcceptFiles(hDlg, TRUE); return true; } break; case WM_MENUSELECT: case WM_ENTERSIZEMOVE: Clear_Sound_Buffer(); break; case WM_SIZING: { // enforce a minimum window size LPRECT r = (LPRECT) lParam; int minimumWidth = 333; int minimumHeight = 117; if(r->right - r->left < minimumWidth) if(wParam == WMSZ_LEFT || wParam == WMSZ_TOPLEFT || wParam == WMSZ_BOTTOMLEFT) r->left = r->right - minimumWidth; else r->right = r->left + minimumWidth; if(r->bottom - r->top < minimumHeight) if(wParam == WMSZ_TOP || wParam == WMSZ_TOPLEFT || wParam == WMSZ_TOPRIGHT) r->top = r->bottom - minimumHeight; else r->bottom = r->top + minimumHeight; } return TRUE; case WM_SIZE: { // resize or move controls in the window as necessary when the window is resized LuaPerWindowInfo& windowInfo = LuaWindowInfo[hDlg]; int prevDlgWidth = windowInfo.width; int prevDlgHeight = windowInfo.height; int dlgWidth = LOWORD(lParam); int dlgHeight = HIWORD(lParam); int deltaWidth = dlgWidth - prevDlgWidth; int deltaHeight = dlgHeight - prevDlgHeight; for(int i = 0; i < numControlLayoutInfos; i++) { ControlLayoutInfo layoutInfo = controlLayoutInfos[i]; ControlLayoutState& layoutState = windowInfo.layoutState[i]; HWND hCtrl = GetDlgItem(hDlg,layoutInfo.controlID); int x,y,width,height; if(layoutState.valid) { x = layoutState.x; y = layoutState.y; width = layoutState.width; height = layoutState.height; } else { RECT r; GetWindowRect(hCtrl, &r); POINT p = {r.left, r.top}; ScreenToClient(hDlg, &p); x = p.x; y = p.y; width = r.right - r.left; height = r.bottom - r.top; } switch(layoutInfo.horizontalLayout) { case ControlLayoutInfo::RESIZE_END: width += deltaWidth; break; case ControlLayoutInfo::MOVE_START: x += deltaWidth; break; default: break; } switch(layoutInfo.verticalLayout) { case ControlLayoutInfo::RESIZE_END: height += deltaHeight; break; case ControlLayoutInfo::MOVE_START: y += deltaHeight; break; default: break; } SetWindowPos(hCtrl, 0, x,y, width,height, 0); layoutState.x = x; layoutState.y = y; layoutState.width = width; layoutState.height = height; layoutState.valid = true; } windowInfo.width = dlgWidth; windowInfo.height = dlgHeight; RedrawWindow(hDlg, NULL, NULL, RDW_INVALIDATE); } break; case WM_COMMAND: { switch(LOWORD(wParam)) { case IDC_BUTTON_LUABROWSE: { LuaPerWindowInfo& info = LuaWindowInfo[hDlg]; char Str_Tmp [1024]; // shadow added because the global one is unreliable strcpy(Str_Tmp,info.filename.c_str()); SendDlgItemMessage(hDlg,IDC_EDIT_LUAPATH,WM_GETTEXT,(WPARAM)512,(LPARAM)Str_Tmp); char* bar = strchr(Str_Tmp, '|'); if(bar) *bar = '\0'; DialogsOpen++; Clear_Sound_Buffer(); if(Change_File_L(Str_Tmp, Lua_Dir, "Load Lua Script", "Gens Lua Script\0*.lua*\0All Files\0*.*\0\0", "lua", hDlg)) { SendDlgItemMessage(hDlg,IDC_EDIT_LUAPATH,WM_SETTEXT,0,(LPARAM)Str_Tmp); } DialogsOpen--; } break; case IDC_BUTTON_LUAEDIT: { LuaPerWindowInfo& info = LuaWindowInfo[hDlg]; char Str_Tmp [1024]; // shadow added because the global one is unreliable strcpy(Str_Tmp,info.filename.c_str()); SendDlgItemMessage(hDlg,IDC_EDIT_LUAPATH,WM_GETTEXT,(WPARAM)512,(LPARAM)Str_Tmp); char LogicalName[1024], PhysicalName[1024]; bool exists = ObtainFile(Str_Tmp, LogicalName, PhysicalName, "luaview", s_nonLuaExtensions, sizeof(s_nonLuaExtensions)/sizeof(*s_nonLuaExtensions)); bool created = false; if(!exists) { FILE* file = fopen(Str_Tmp, "r"); if(!file) { file = fopen(Str_Tmp, "w"); if(file) { created = true; exists = true; strcpy(PhysicalName, Str_Tmp); } } if(file) fclose(file); } if(exists) { // tell the OS to open the file with its associated editor, // without blocking on it or leaving a command window open. if((int)ShellExecute(NULL, "edit", PhysicalName, NULL, NULL, SW_SHOWNORMAL) == SE_ERR_NOASSOC) if((int)ShellExecute(NULL, "open", PhysicalName, NULL, NULL, SW_SHOWNORMAL) == SE_ERR_NOASSOC) ShellExecute(NULL, NULL, "notepad", PhysicalName, NULL, SW_SHOWNORMAL); } if(created) { UpdateFileEntered(hDlg); } } break; case IDC_EDIT_LUAPATH: { switch(HIWORD(wParam)) { case EN_CHANGE: { UpdateFileEntered(hDlg); } break; } } break; case IDC_BUTTON_LUARUN: { HWND focus = GetFocus(); HWND textbox = GetDlgItem(hDlg, IDC_EDIT_LUAPATH); if(focus != textbox) SetActiveWindow(HWnd); LuaPerWindowInfo& info = LuaWindowInfo[hDlg]; char Str_Tmp [1024]; // shadow added because the global one is completely unreliable strcpy(Str_Tmp,info.filename.c_str()); char LogicalName[1024], PhysicalName[1024]; bool exists = ObtainFile(Str_Tmp, LogicalName, PhysicalName, "luarun", s_nonLuaExtensions, sizeof(s_nonLuaExtensions)/sizeof(*s_nonLuaExtensions)); Update_Recent_Script(LogicalName, info.subservient); RunLuaScriptFile((int)hDlg, PhysicalName); } break; case IDC_BUTTON_LUASTOP: { PrintToWindowConsole((int)hDlg, "user clicked stop button\r\n"); SetActiveWindow(HWnd); StopLuaScript((int)hDlg); } break; case IDC_NOTIFY_SUBSERVIENT: { LuaPerWindowInfo& info = LuaWindowInfo[hDlg]; info.subservient = lParam ? true : false; } break; //case IDOK: case IDCANCEL: { LuaPerWindowInfo& info = LuaWindowInfo[hDlg]; if(info.filename.empty()) { if (Full_Screen) { while (ShowCursor(true) < 0); while (ShowCursor(false) >= 0); } DialogsOpen--; DragAcceptFiles(hDlg, FALSE); KillWatcherThread(hDlg); LuaScriptHWnds.erase(remove(LuaScriptHWnds.begin(), LuaScriptHWnds.end(), hDlg), LuaScriptHWnds.end()); LuaWindowInfo.erase(hDlg); CloseLuaContext((int)hDlg); Build_Main_Menu(); EndDialog(hDlg, true); } } return true; } return false; } break; case WM_CLOSE: { LuaPerWindowInfo& info = LuaWindowInfo[hDlg]; PrintToWindowConsole((int)hDlg, "user closed script window\r\n"); StopLuaScript((int)hDlg); if(info.started) { // not stopped yet, wait to close until we are, otherwise we'll crash info.closeOnStop = true; return false; } if (Full_Screen) { while (ShowCursor(true) < 0); while (ShowCursor(false) >= 0); } DialogsOpen--; DragAcceptFiles(hDlg, FALSE); KillWatcherThread(hDlg); LuaScriptHWnds.erase(remove(LuaScriptHWnds.begin(), LuaScriptHWnds.end(), hDlg), LuaScriptHWnds.end()); LuaWindowInfo.erase(hDlg); CloseLuaContext((int)hDlg); Build_Main_Menu(); EndDialog(hDlg, true); } return true; case WM_DROPFILES: { HDROP hDrop = (HDROP)wParam; DragQueryFile(hDrop, 0, Str_Tmp, 1024); DragFinish(hDrop); SendDlgItemMessage(hDlg,IDC_EDIT_LUAPATH,WM_SETTEXT,0,(LPARAM)Str_Tmp ); UpdateFileEntered(hDlg); } return true; } return false; }
BOOL CSelectPluginDlg::PreTranslateMessage(MSG *pMsg) //--------------------------------------------------- { // Use up/down keys to navigate in tree view, even if search field is focussed. if(pMsg != nullptr && pMsg->message == WM_KEYDOWN && (pMsg->wParam == VK_UP || pMsg->wParam == VK_DOWN) && GetFocus() != &m_treePlugins) { HTREEITEM selItem = m_treePlugins.GetSelectedItem(); if(selItem == nullptr) { selItem = m_treePlugins.GetRootItem(); } while((selItem = m_treePlugins.GetNextItem(selItem, pMsg->wParam == VK_UP ? TVGN_PREVIOUSVISIBLE : TVGN_NEXTVISIBLE)) != nullptr) { int nImage, nSelectedImage; m_treePlugins.GetItemImage(selItem, nImage, nSelectedImage); if(nImage != IMAGE_FOLDER) { m_treePlugins.SelectItem(selItem); m_treePlugins.EnsureVisible(selItem); return TRUE; } } return TRUE; } return CDialog::PreTranslateMessage(pMsg); }
INT_PTR Twindow::msgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_INITDIALOG: resizeDialog(); init(); //subClass(); break; case WM_DESTROY: { THWNDs wnds; getChildWindows(m_hwnd, wnds); for (THWNDs::const_iterator wnd = wnds.begin(); wnd != wnds.end(); wnd++) { ::Twidget *item = Twidget::getDlgItem(*wnd); if (item) { item->restore(); delete item; } } ::Twidget *item = Twidget::getDlgItem(m_hwnd); if (item) { item->restore(); delete item; } if (red) { DeleteObject(red); } red = NULL; break; } case WM_HSCROLL: if (onTrack(bindsHtrack, lParam)) { return TRUE; } break; case WM_VSCROLL: if (onTrack(bindsVtrack, lParam)) { return TRUE; } break; case WM_COMMAND: { if (bindsCheckbox) for (int i = 0; bindsCheckbox[i].idc; i++) if (bindsCheckbox[i].idc == LOWORD(wParam)) { if (bindsCheckbox[i].idff < 0) { cfgSet(-bindsCheckbox[i].idff, !getCheck(LOWORD(wParam))); } else { cfgSet(bindsCheckbox[i].idff, getCheck(LOWORD(wParam))); } if (bindsCheckbox[i].onClick) { (this->*bindsCheckbox[i].onClick)(); } return TRUE; } if (bindsRadiobutton) for (int i = 0; bindsRadiobutton[i].idc; i++) if (bindsRadiobutton[i].idc == LOWORD(wParam) && getCheck(LOWORD(bindsRadiobutton[i].idc))) { cfgSet(bindsRadiobutton[i].idff, bindsRadiobutton[i].val); if (bindsRadiobutton[i].onClick) { (this->*bindsRadiobutton[i].onClick)(); } return TRUE; } if (bindsButton) if (HIWORD(wParam) == BN_CLICKED) // works also for static for (int i = 0; bindsButton[i].idc; i++) if (bindsButton[i].idc == LOWORD(wParam) && bindsButton[i].onClick) { (this->*bindsButton[i].onClick)(); return TRUE; } if (HIWORD(wParam) == EN_CHANGE && !isSetWindowText) { if (LOWORD(wParam) == IDC_ED_HELP && tr->translateMode) { onEditChange(); } if (bindsEditInt) for (int i = 0; bindsEditInt[i].idc; i++) if (bindsEditInt[i].idc == LOWORD(wParam)) { HWND hed = GetDlgItem(m_hwnd, bindsEditInt[i].idc); if (hed != GetFocus()) { return FALSE; } repaint(hed); eval(hed, bindsEditInt[i].min, bindsEditInt[i].max, bindsEditInt[i].idff); if (bindsEditInt[i].onClick) { (this->*bindsEditInt[i].onClick)(); } return TRUE; } if (bindsEditReal) for (int i = 0; bindsEditReal[i].idc; i++) if (bindsEditReal[i].idc == LOWORD(wParam)) { HWND hed = GetDlgItem(m_hwnd, bindsEditReal[i].idc); if (hed != GetFocus()) { return FALSE; } repaint(hed); eval(hed, bindsEditReal[i].min, bindsEditReal[i].max, bindsEditReal[i].idff, bindsEditReal[i].mult); if (bindsEditReal[i].onClick) { (this->*bindsEditReal[i].onClick)(); } return TRUE; } } else if (HIWORD(wParam) == CBN_SELCHANGE) { if (bindsCombobox) for (int i = 0; bindsCombobox[i].idc; i++) if (bindsCombobox[i].idc == LOWORD(wParam)) { switch (bindsCombobox[i].mode) { case BINDCBX_DATA: cfgSet(bindsCombobox[i].idff, (int)cbxGetCurItemData(bindsCombobox[i].idc)); break; case BINDCBX_SEL: cfgSet(bindsCombobox[i].idff, cbxGetCurSel(bindsCombobox[i].idc)); break; case BINDCBX_TEXT: cfgSet(bindsCombobox[i].idff, cbxGetCurText(bindsCombobox[i].idc)); break; case BINDCBX_DATATEXT: cfgSet(bindsCombobox[i].idff, (const char_t*)cbxGetCurItemData(bindsCombobox[i].idc)); break; } if (bindsCombobox[i].onClick) { (this->*bindsCombobox[i].onClick)(); } return TRUE; } } break; } case WM_CTLCOLOREDIT: if (bindsEditInt) if (onCtlColorEdit(bindsEditInt, lParam, wParam)) { return INT_PTR(getRed()); } if (bindsEditReal) if (onCtlColorEdit(bindsEditReal, lParam, wParam)) { return INT_PTR(getRed()); } break; } return defMsgProc(uMsg, wParam, lParam); }
/*virtual*/ void CWndToolBar::OnMessage(CWnd* pSender, ui16 code, ui32 data) { if ( code == ToWord('g', 'i') ) { const CBarItem *pItems = GetMenuItems(); m_nFocus = (ui8)data; CWnd* pFocus = GetFocus(); SendMessage( GetParent(), ToWord('L', 'E'), (NATIVEPTR)pItems[m_nFocus].m_pWndMenu ); if ( GetFocus() == pFocus ) { // else the focus was stolen by the current wnd SetFocus(); } } if ( code == ToWord('g', 'o') ) { const char* strId = (const char*)data; int nItem = Find( strId ); code = ToWord('g', '2'); data = nItem; } if ( ( code == ToWord('M', 'C') || code == ToWord('M', 'D') ) && data ) { // select menu item by mouse position bool* pProcess = (bool*)data; *pProcess = false; int nOldFocus = m_nFocus; int nNewFocus = _FindItemByPoint( BIOS::MOUSE::GetX() ); if ( nNewFocus != -1 && nNewFocus != nOldFocus ) { m_nFocus = nNewFocus; SetFocus(); ChangeFocus(nOldFocus); Invalidate(); } } if ( code == ToWord('g', '2') ) { const CBarItem *pItems = GetMenuItems(); int nItem = data; if ( nItem == -1 ) return; SendMessage( GetParent(), ToWord('L', 'D'), (NATIVEPTR)pItems[m_nFocus].m_pWndMenu ); if ( pItems[nItem].m_eType == CBarItem::IMain ) m_nFocus = nItem+1; else m_nFocus = nItem; SendMessage( GetParent(), ToWord('L', 'E'), (NATIVEPTR)pItems[m_nFocus].m_pWndMenu ); SetFocus(); SendMessage( GetParent(), ToWord('L', 'R'), 0 ); Settings.Runtime.m_nMenuItem = m_nFocus; } }
// subclass for dialog item LRESULT CALLBACK InternalEmulatorInputDialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData) { auto d = (DialogData *)dwRefData; switch (uMsg) { case WM_PAINT: { HDC hdc; PAINTSTRUCT ps; HANDLE hOldFont; TCHAR szText[200]; RECT rect; SIZE sz; int x, y; // Get a device context for this window hdc = BeginPaint(hWnd, &ps); auto hFont = CreateFont(14, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_OUTLINE_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, VARIABLE_PITCH, TEXT("Arial")); SelectObject(hdc, hFont); // Set the text colours SetTextColor(hdc, d->fgColor); SetBkColor(hdc, d->bgColor); // Find the text to draw GetWindowText(hWnd, szText, sizeof(szText)); // Work out where to draw GetClientRect(hWnd, &rect); // Find out how big the text will be GetTextExtentPoint32(hdc, szText, lstrlen(szText), &sz); // Center the text x = (rect.right - sz.cx) / 2; y = (rect.bottom - sz.cy) / 2; // Draw the text ExtTextOut(hdc, x, y, ETO_OPAQUE, &rect, szText, lstrlen(szText), 0); DeleteObject(hFont); EndPaint(hWnd, &ps); break; } case WM_KEYDOWN: { if (LOWORD(wParam) == VK_DELETE) { d->setting.type = InternalEmulatorInputType::KEY; d->setting.value = 0; d->fgColor = RGB(255, 0, 0); d->bgColor = RGB(0, 255, 0); auto s = GetButtonText(d); SetWindowText(hWnd, s.c_str()); } else if (IsValidKey(LOWORD(wParam))) { //d->fgColor = GetSysColor(COLOR_WINDOWTEXT); //d->bgColor = GetSysColor(COLOR_WINDOW); d->setting.type = InternalEmulatorInputType::KEY; d->setting.value = lParam; d->fgColor = RGB(255, 0, 0); d->bgColor = RGB(0, 255, 0); auto s = GetButtonText(d); SetWindowText(hWnd, s.c_str()); } else { d->fgColor = RGB(0, 255, 0); d->bgColor = RGB(255, 0, 0); } InvalidateRect(GetParent(hWnd), NULL, false); break; } case WM_TIMER: { if (hWnd == GetFocus()) { if (JoystickPoll(GetParent(hWnd), d)) { //d->fgColor = GetSysColor(COLOR_WINDOWTEXT); //d->bgColor = GetSysColor(COLOR_WINDOW); auto s = GetButtonText(d); SetWindowText(hWnd, s.c_str()); InvalidateRect(GetParent(hWnd), NULL, false); } } SetTimer(hWnd, 747, 125, NULL); break; } case WM_CHAR: { break; } case WM_SETFOCUS: { if (!d->timerActive) { SetTimer(hWnd, 777, 125, NULL); d->timerActive = true; } d->fgColor = RGB(255, 0, 0); d->bgColor = RGB(0, 255, 0); InvalidateRect(GetParent(hWnd), NULL, false); break; } case WM_KILLFOCUS: { d->fgColor = GetSysColor(COLOR_WINDOWTEXT); d->bgColor = GetSysColor(COLOR_WINDOW); InvalidateRect(GetParent(hWnd), NULL, false); break; } default: return DefSubclassProc(hWnd, uMsg, wParam, lParam); } return 0; }
LRESULT pascal HexViewWndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam) { switch (iMsg) { case WM_CREATE: { PHV p = Mem_Alloc(MEMF_ZEROINIT, sizeof(HexViewInfo)); HDC hDC = GetDC(0); int nHeight = -MulDiv(9, GetDeviceCaps(hDC, LOGPIXELSY), 72); ReleaseDC(0,hDC); p->hCreateFont = CreateFont(nHeight,0,0,0,FW_NORMAL,FALSE,FALSE,FALSE,ANSI_CHARSET,OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,FIXED_PITCH,"Courier New"); p->hFont = p->hCreateFont; p->BuffSize = 512; p->idCtl = GetWindowLong(hWnd, GWL_ID); SetWindowLong(hWnd, GWL_PHEXVIEW, (LONG)p); if (!hPenGutter) { hPenGutter = CreatePen(PS_SOLID,1,RGB(192,192,192)); hBrushRow = CreateSolidBrush(RGB(208,228,246)); } break; } case WM_SETFONT: { // PHV p = (PHV)GetWindowLong(hWnd,GWL_PHEXVIEW); // p->hFont = (HFONT)wParam; // if (lParam) InvalidateRect(hWnd, NULL, FALSE); break; } case WM_GETFONT: { PHV p = (PHV)GetWindowLong(hWnd,GWL_PHEXVIEW); return (LRESULT)(p->hFont); } case WM_GETDLGCODE: return DLGC_WANTARROWS; case WM_ERASEBKGND: return 1; case WM_PRINTCLIENT: PaintControl(hWnd, (HDC)wParam); break; case WM_PAINT: { PAINTSTRUCT ps; HDC hDC = (wParam ? (HDC)wParam : BeginPaint(hWnd,&ps)); PaintControl(hWnd, hDC); if (wParam) ValidateRect(hWnd,NULL); else EndPaint(hWnd, &ps); break; } case WM_LBUTTONDOWN: { PHV p = (PHV)GetWindowLong(hWnd,GWL_PHEXVIEW); UINT oldCaret = p->iCaret; HandleMouseClick(hWnd,LOWORD(lParam),HIWORD(lParam)); if (p->iCaret != oldCaret) SendMessage(GetParent(hWnd),WM_COMMAND,MAKEWPARAM(p->idCtl,HVN_OFFSET_CHANGED),(LPARAM)hWnd); if (GetFocus()==hWnd) RepaintControl(hWnd); else SetFocus(hWnd); break; } case WM_KEYDOWN: { PHV p = (PHV)GetWindowLong(hWnd,GWL_PHEXVIEW); UINT oldCaret = p->iCaret; if (wParam == VK_LEFT) { if (oldCaret) p->iCaret--; } else if (wParam==VK_RIGHT) { if ((oldCaret+1) < p->BuffSize) p->iCaret++; } else if (wParam==VK_UP) { if (oldCaret>=COLS) p->iCaret -= COLS; else SendMessage(GetParent(hWnd),WM_COMMAND, MAKEWPARAM(p->idCtl,HVN_LINEUP),(LPARAM)hWnd); } else if (wParam==VK_DOWN) { if ((oldCaret+COLS) < p->BuffSize) p->iCaret += COLS; else SendMessage(GetParent(hWnd),WM_COMMAND, MAKEWPARAM(p->idCtl,HVN_LINEDOWN),(LPARAM)hWnd); } else if (wParam==VK_PRIOR) { SendMessage(GetParent(hWnd),WM_COMMAND, MAKEWPARAM(p->idCtl,HVN_PAGEUP),(LPARAM)hWnd); return 0; } else if (wParam==VK_NEXT) { SendMessage(GetParent(hWnd),WM_COMMAND, MAKEWPARAM(p->idCtl,HVN_PAGEDOWN),(LPARAM)hWnd); return 0; } if (p->iCaret != oldCaret) { RepaintControl(hWnd); SendMessage(GetParent(hWnd),WM_COMMAND,MAKEWPARAM(p->idCtl,HVN_OFFSET_CHANGED),(LPARAM)hWnd); } break; } case WM_SETFOCUS: case WM_KILLFOCUS: case HVM_REPAINT: RepaintControl(hWnd); break; /* ctrl-specific messages */ case HVM_GETBUFFPTR: { PHV p = (PHV)GetWindowLong(hWnd,GWL_PHEXVIEW); return (LRESULT)(p->buffer); } case HVM_SETBUFFSIZE: { PHV p = (PHV)GetWindowLong(hWnd,GWL_PHEXVIEW); p = Mem_ReAlloc(p,MEMF_ZEROINIT,sizeof(HexViewInfo)-512+wParam); p->BuffSize = (UINT)wParam; if (p->iCaret>p->BuffSize) p->iCaret = 0; if (lParam) RepaintControl(hWnd); // Can be used to set a new buffer size. wParam = new buffer size in bytes. // Returns TRUE on success. // IMPORTANT NOTE: any previously stored buffer pointer will be invalidated // by this function. break; } case HVM_GETOFFSET: { PHV p = (PHV)GetWindowLong(hWnd,GWL_PHEXVIEW); return (LRESULT)(p->iCaret); } case HVM_SETOFFSET: { PHV p = (PHV)GetWindowLong(hWnd,GWL_PHEXVIEW); if (wParam<p->BuffSize && wParam!=p->iCaret) { p->iCaret = (UINT)wParam; if (lParam) RepaintControl(hWnd); } return (LRESULT)(p->iCaret); } case HVM_GETDIMENSIONS: { PHV p = (PHV)GetWindowLong(hWnd,GWL_PHEXVIEW); HDC hDC = GetDC(0); HFONT hFont = SelectObject(hDC,p->hFont); int w,h; SIZE step; GetCharSpacing(hDC,&step); SelectObject(hDC,hFont); ReleaseDC(0,hDC); h = step.cy+Y_PAD; w = step.cx*(3 + 3*COLS) + COLS*X_PAD + 16; return MAKELRESULT(w,h); } case WM_NCDESTROY: { PHV p = (PHV)GetWindowLong(hWnd,GWL_PHEXVIEW); p->hBm = SelectObject(p->hMemDC, p->hBm); DeleteObject(p->hBm); DeleteDC(p->hMemDC); if (p->hCreateFont) DeleteObject(p->hCreateFont); Mem_Free(p); break; } default: return DefWindowProc(hWnd,iMsg,wParam,lParam); } return 0; }
/* * Set the state of the items in the main * program menu. */ void Explorerplusplus::SetProgramMenuItemStates(HMENU hProgramMenu) { LONG WindowStyle; UINT ItemToCheck; UINT ListViewStyle; BOOL bVirtualFolder; UINT uViewMode; m_pShellBrowser[m_iObjectIndex]->GetCurrentViewMode(&uViewMode); bVirtualFolder = m_pActiveShellBrowser->InVirtualFolder(); lEnableMenuItem(hProgramMenu,IDM_FILE_COPYITEMPATH,CheckItemSelection()); lEnableMenuItem(hProgramMenu,IDM_FILE_COPYUNIVERSALFILEPATHS,CheckItemSelection()); lEnableMenuItem(hProgramMenu,IDM_FILE_SETFILEATTRIBUTES,CheckItemSelection()); lEnableMenuItem(hProgramMenu,IDM_FILE_OPENCOMMANDPROMPT,!bVirtualFolder); lEnableMenuItem(hProgramMenu,IDM_FILE_SAVEDIRECTORYLISTING,!bVirtualFolder); lEnableMenuItem(hProgramMenu,IDM_FILE_COPYCOLUMNTEXT,m_nSelected && (uViewMode == VM_DETAILS)); lEnableMenuItem(hProgramMenu,IDM_FILE_RENAME,IsRenamePossible()); lEnableMenuItem(hProgramMenu,IDM_FILE_DELETE,IsDeletionPossible()); lEnableMenuItem(hProgramMenu,IDM_FILE_DELETEPERMANENTLY,IsDeletionPossible()); lEnableMenuItem(hProgramMenu,IDM_FILE_PROPERTIES,CanShowFileProperties()); lEnableMenuItem(hProgramMenu,IDM_EDIT_UNDO,m_FileActionHandler.CanUndo()); lEnableMenuItem(hProgramMenu,IDM_EDIT_PASTE,CanPaste()); lEnableMenuItem(hProgramMenu,IDM_EDIT_PASTESHORTCUT,CanPaste()); lEnableMenuItem(hProgramMenu,IDM_EDIT_PASTEHARDLINK,CanPaste()); /* The following menu items are only enabled when one or more files are selected (they represent file actions, cut/copy, etc). */ /* TODO: Split CanCutOrCopySelection() into two, as some items may only be copied/cut (not both). */ lEnableMenuItem(hProgramMenu,IDM_EDIT_COPY,CanCutOrCopySelection()); lEnableMenuItem(hProgramMenu,IDM_EDIT_CUT,CanCutOrCopySelection()); lEnableMenuItem(hProgramMenu,IDM_EDIT_COPYTOFOLDER,CanCutOrCopySelection() && GetFocus() != m_hTreeView); lEnableMenuItem(hProgramMenu,IDM_EDIT_MOVETOFOLDER,CanCutOrCopySelection() && GetFocus() != m_hTreeView); lEnableMenuItem(hProgramMenu,IDM_EDIT_WILDCARDDESELECT,m_nSelected); lEnableMenuItem(hProgramMenu,IDM_EDIT_SELECTNONE,m_nSelected); lEnableMenuItem(hProgramMenu,IDM_EDIT_SHOWFILESLACK,m_nSelected); lEnableMenuItem(hProgramMenu,IDM_EDIT_RESOLVELINK,m_nSelected); lCheckMenuItem(hProgramMenu,IDM_VIEW_STATUSBAR,m_bShowStatusBar); lCheckMenuItem(hProgramMenu,IDM_VIEW_FOLDERS,m_bShowFolders); lCheckMenuItem(hProgramMenu,IDM_VIEW_DISPLAYWINDOW,m_bShowDisplayWindow); lCheckMenuItem(hProgramMenu,IDM_TOOLBARS_ADDRESSBAR,m_bShowAddressBar); lCheckMenuItem(hProgramMenu,IDM_TOOLBARS_MAINTOOLBAR,m_bShowMainToolbar); lCheckMenuItem(hProgramMenu,IDM_TOOLBARS_BOOKMARKSTOOLBAR,m_bShowBookmarksToolbar); lCheckMenuItem(hProgramMenu,IDM_TOOLBARS_DRIVES,m_bShowDrivesToolbar); lCheckMenuItem(hProgramMenu,IDM_TOOLBARS_APPLICATIONTOOLBAR,m_bShowApplicationToolbar); lCheckMenuItem(hProgramMenu,IDM_TOOLBARS_LOCKTOOLBARS,m_bLockToolbars); lCheckMenuItem(hProgramMenu,IDM_VIEW_SHOWHIDDENFILES,m_pActiveShellBrowser->QueryShowHidden()); lCheckMenuItem(hProgramMenu,IDM_FILTER_APPLYFILTER,m_pActiveShellBrowser->GetFilterStatus()); lEnableMenuItem(hProgramMenu,IDM_ACTIONS_NEWFOLDER,!bVirtualFolder); lEnableMenuItem(hProgramMenu,IDM_ACTIONS_SPLITFILE,(m_pActiveShellBrowser->QueryNumSelectedFiles() == 1) && !bVirtualFolder); lEnableMenuItem(hProgramMenu,IDM_ACTIONS_MERGEFILES,m_nSelected > 1); lEnableMenuItem(hProgramMenu,IDM_ACTIONS_DESTROYFILES,m_nSelected); WindowStyle = GetWindowLong(m_hActiveListView,GWL_STYLE); ListViewStyle = (WindowStyle & LVS_TYPEMASK); ItemToCheck = GetViewModeMenuId(uViewMode); CheckMenuRadioItem(hProgramMenu,IDM_VIEW_THUMBNAILS,IDM_VIEW_EXTRALARGEICONS,ItemToCheck,MF_BYCOMMAND); lEnableMenuItem(hProgramMenu,IDM_FILE_CLOSETAB,TabCtrl_GetItemCount(m_hTabCtrl)); lEnableMenuItem(hProgramMenu,IDM_GO_BACK,m_pActiveShellBrowser->IsBackHistory()); lEnableMenuItem(hProgramMenu,IDM_GO_FORWARD,m_pActiveShellBrowser->IsForwardHistory()); lEnableMenuItem(hProgramMenu,IDM_GO_UPONELEVEL,m_pActiveShellBrowser->CanBrowseUp()); lEnableMenuItem(hProgramMenu,IDM_VIEW_AUTOSIZECOLUMNS,uViewMode == VM_DETAILS); if(uViewMode == VM_DETAILS) { /* Disable auto arrange menu item. */ lEnableMenuItem(hProgramMenu,IDM_ARRANGEICONSBY_AUTOARRANGE,FALSE); lCheckMenuItem(hProgramMenu,IDM_ARRANGEICONSBY_AUTOARRANGE,FALSE); lEnableMenuItem(hProgramMenu,IDM_VIEW_GROUPBY,TRUE); } else if(uViewMode == VM_LIST) { /* Disable group menu item. */ lEnableMenuItem(hProgramMenu,IDM_VIEW_GROUPBY,FALSE); /* Disable auto arrange menu item. */ lEnableMenuItem(hProgramMenu,IDM_ARRANGEICONSBY_AUTOARRANGE,FALSE); lCheckMenuItem(hProgramMenu,IDM_ARRANGEICONSBY_AUTOARRANGE,FALSE); } else { lEnableMenuItem(hProgramMenu,IDM_VIEW_GROUPBY,TRUE); lEnableMenuItem(hProgramMenu,IDM_ARRANGEICONSBY_AUTOARRANGE,TRUE); lCheckMenuItem(hProgramMenu,IDM_ARRANGEICONSBY_AUTOARRANGE,m_pActiveShellBrowser->QueryAutoArrange()); } SetArrangeMenuItemStates(hProgramMenu); }