[RsWitch-cvs] CVS: rswitch MainFrm.cpp,1.2,1.3
Status: Alpha
Brought to you by:
bcrochet
|
From: Zak P. <ref...@us...> - 2001-03-11 03:50:36
|
Update of /cvsroot/rswitch/rswitch
In directory usw-pr-cvs1:/tmp/cvs-serv12013
Modified Files:
MainFrm.cpp
Log Message:
many changes - fixed the editing of channels, and added saving to the registry
Index: MainFrm.cpp
===================================================================
RCS file: /cvsroot/rswitch/rswitch/MainFrm.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** MainFrm.cpp 2000/12/03 21:18:52 1.2
--- MainFrm.cpp 2001/03/11 03:52:27 1.3
***************
*** 19,22 ****
--- 19,25 ----
// $Log$
+ // Revision 1.3 2001/03/11 03:52:27 refinersfire
+ // many changes - fixed the editing of channels, and added saving to the registry
+ //
// Revision 1.2 2000/12/03 21:18:52 bcrochet
// * Added ReadHotKeyListFromRegistry
***************
*** 91,128 ****
void CMainFrame::EnableAllHotkeys(bool bEnable)
{
! if ( bEnable )
! {
! if ( RegisterHotKey( m_hWnd, 0x01, MOD_CONTROL, ALLHANDS ) == 0 )
! {
! printf( "Hot key creation failed! (1)\n" );
! }
! if ( RegisterHotKey( m_hWnd, 0x02, MOD_CONTROL, OFFENSE ) == 0 )
! {
! printf( "Hot key creation failed! (2)\n" );
! }
! if ( RegisterHotKey( m_hWnd, 0x03, MOD_CONTROL, DEFENSE ) == 0 )
! {
! printf( "Hot key creation failed! (3)\n" );
! }
! }
! else
! {
! UnregisterHotKey( m_hWnd, 0x01 );
! UnregisterHotKey( m_hWnd, 0x02 );
! UnregisterHotKey( m_hWnd, 0x03 );
! }
}
boolean CMainFrame::ReadHotKeyListFromRegistry( HotKeyList& hkList )
{
! CHotKeyEntry* pHotKey = new CHotKeyEntry( HOTKEYF_CONTROL, (WORD)'C', "rw.clantmp.org", "d" );
! hkList.push_back( *pHotKey );
! delete pHotKey;
! return true;
}
boolean CMainFrame::WriteHotKeyListToRegistry( HotKeyList& hkList )
{
! return true;
}
--- 94,220 ----
void CMainFrame::EnableAllHotkeys(bool bEnable)
{
! long listSize = m_hkList.size();
!
! if ( bEnable )
! {
! for(long i=0; i < listSize; i++)
! {
! if ( RegisterHotKey( m_hWnd, i, m_hkList[i].GetModifiers(), m_hkList[i].GetVirtKey() ) == 0 )
! {
! printf( "Hot key creation failed!\n" );
! }
! }
! }
! else
! {
! for(long i=0; i < listSize; i++)
! {
! UnregisterHotKey( m_hWnd, i);
! }
! }
}
boolean CMainFrame::ReadHotKeyListFromRegistry( HotKeyList& hkList )
{
! HKEY hKey;
!
! CString baseKey = "Software\\RsWitch";
! char keyName[MAX_PATH];
!
! if( RegOpenKeyEx( HKEY_LOCAL_MACHINE, baseKey, 0, KEY_ALL_ACCESS, &hKey ) == ERROR_SUCCESS )
! {
! for(long i=0; RegEnumKey(hKey, i, keyName, MAX_PATH) == ERROR_SUCCESS; i++)
! {
! HKEY subKey;
!
! if(RegOpenKeyEx(hKey, keyName, 0, KEY_ALL_ACCESS, &subKey) == ERROR_SUCCESS)
! {
! DWORD size;
! DWORD keyType;
!
! DWORD modifier;
! size = 4;
! RegQueryValueEx(subKey, "modifier", NULL, &keyType, (unsigned char*)&modifier, &size);
!
! DWORD virtKey;
! size = 4;
! RegQueryValueEx(subKey, "virtKey", NULL, &keyType, (unsigned char*)&virtKey, &size);
!
! CHotKeyEntry::EHotKeyType type;
! size = 4;
! RegQueryValueEx(subKey, "type", NULL, &keyType, (unsigned char*)&type, &size);
!
! char servername[MAX_PATH];
! size = MAX_PATH;
! RegQueryValueEx(subKey, "servername", NULL, &keyType, (unsigned char*)servername, &size);
!
! char channel[MAX_PATH];
! size = MAX_PATH;
! RegQueryValueEx(subKey, "channel", NULL, &keyType, (unsigned char*)channel, &size);
!
! hkList.push_back( CHotKeyEntry( modifier, virtKey, servername, channel) );
!
! RegCloseKey(subKey);
! }
! }
!
! RegCloseKey(hKey);
! }
!
! return true;
}
boolean CMainFrame::WriteHotKeyListToRegistry( HotKeyList& hkList )
{
! HKEY hKey;
! CString baseKey = "Software\\RsWitch\\";
!
! long listSize = hkList.size();
!
! CString key;
!
! for(long i=0; i<listSize; i++)
! {
! key.Format(_T("%s%d"), baseKey,i);
!
! if(RegOpenKeyEx( HKEY_LOCAL_MACHINE, key, 0, KEY_ALL_ACCESS, &hKey ) != ERROR_SUCCESS )
! {
! RegCreateKey( HKEY_LOCAL_MACHINE, key, &hKey);
! }
!
! DWORD modifier= hkList[i].GetModifiers();
! RegSetValueEx(hKey, "modifier", NULL, REG_DWORD, (unsigned char*)&modifier, sizeof(modifier));
!
! DWORD virtKey= hkList[i].GetVirtKey();
! RegSetValueEx(hKey, "virtKey", NULL, REG_DWORD, (unsigned char*)&virtKey, sizeof(virtKey));
!
! CHotKeyEntry::EHotKeyType type = hkList[i].GetHotKeyType();
! RegSetValueEx(hKey, "type", NULL, REG_DWORD, (unsigned char*)&type, sizeof(type));
!
! CString servername = hkList[i].GetServerName();
! RegSetValueEx(hKey, "servername", NULL, REG_SZ, (unsigned char*)(LPCTSTR)servername, servername.GetLength()+1);
!
! CString channel = hkList[i].GetChannelName();
! RegSetValueEx(hKey, "channel", NULL, REG_SZ, (unsigned char*)(LPCTSTR)channel, channel.GetLength()+1);
!
! RegCloseKey(hKey);
! }
!
! //Delete off all extra keys
!
! key.Format(_T("%s%d"), baseKey,i);
!
! while( RegOpenKeyEx( HKEY_LOCAL_MACHINE, key, 0, KEY_ALL_ACCESS, &hKey ) == ERROR_SUCCESS )
! {
! RegCloseKey(hKey);
! RegOpenKeyEx( HKEY_LOCAL_MACHINE, baseKey, 0, KEY_ALL_ACCESS, &hKey);
! RegDeleteKey(hKey, CString(i));
! RegCloseKey(hKey);
!
! i++;
! key.Format(_T("%s%d"), baseKey,i);
! }
!
! return true;
}
***************
*** 310,356 ****
LRESULT CMainFrame::OnHotkey(WPARAM wParam, LPARAM lParam)
{
! if ( LOWORD( lParam ) == MOD_CONTROL )
! {
! if ( HIWORD( lParam ) == ALLHANDS )
! {
! NOTIFYICONDATA nid;
! nid.cbSize = sizeof( NOTIFYICONDATA );
! nid.hWnd = m_hWnd;
! nid.uID = 0x1000;
! nid.uFlags = NIF_TIP;
! lstrcpyn( nid.szTip, "RsWitch - All Hands", sizeof( "RsWitch - All Hands" ) );
!
! Shell_NotifyIcon( NIM_MODIFY, &nid );
!
! JoinRogerWilcoChannel( CString("12.25.192.166"), CString("A"), CString("") );
! }
! else if ( HIWORD( lParam ) == OFFENSE )
! {
! NOTIFYICONDATA nid;
! nid.cbSize = sizeof( NOTIFYICONDATA );
! nid.hWnd = m_hWnd;
! nid.uID = 0x1000;
! nid.uFlags = NIF_TIP;
! lstrcpyn( nid.szTip, "RsWitch - Offense", sizeof( "RsWitch - Offense" ) );
!
! Shell_NotifyIcon( NIM_MODIFY, &nid );
!
! JoinRogerWilcoChannel( CString("12.25.192.166"), CString("O"), CString("") );
! }
! else if ( HIWORD( lParam ) == DEFENSE )
! {
! NOTIFYICONDATA nid;
! nid.cbSize = sizeof( NOTIFYICONDATA );
! nid.hWnd = m_hWnd;
! nid.uID = 0x1000;
! nid.uFlags = NIF_TIP;
! lstrcpyn( nid.szTip, "RsWitch - Defense", sizeof( "RsWitch - Defense" ) );
!
! Shell_NotifyIcon( NIM_MODIFY, &nid );
!
! JoinRogerWilcoChannel( CString("12.25.192.166"), CString("D"), CString("") );
! }
! }
! return 0;
}
--- 402,426 ----
LRESULT CMainFrame::OnHotkey(WPARAM wParam, LPARAM lParam)
{
! //look for a key sequence we may have in list
! HotKeyList::iterator i;
!
! for(i=m_hkList.begin(); i != m_hkList.end(); i++)
! {
! if ( LOWORD( lParam ) == i->GetModifiers() && HIWORD( lParam ) == i->GetVirtKey() )
! {
! NOTIFYICONDATA nid;
! nid.cbSize = sizeof( NOTIFYICONDATA );
! nid.hWnd = m_hWnd;
! nid.uID = 0x1000;
! nid.uFlags = NIF_TIP;
! lstrcpyn( nid.szTip, "RsWitch - All Hands", sizeof( "RsWitch - All Hands" ) );
!
! Shell_NotifyIcon( NIM_MODIFY, &nid );
!
! JoinRogerWilcoChannel( i->GetServerName(), i->GetChannelName(), CString("") );
! }
! }
!
! return 0;
}
***************
*** 407,412 ****
void CMainFrame::OnProperties()
{
! CMainConfigDlg dlg;
! dlg.DoModal();
}
--- 477,485 ----
void CMainFrame::OnProperties()
{
! EnableAllHotkeys(false);
! CMainConfigDlg dlg;
! dlg.DoModal();
! WriteHotKeyListToRegistry(m_hkList);
! EnableAllHotkeys(true);
}
|