//-------------------------------------------------------------------
//
// Function: LookupUsingUKPhoneCodes
// Platform: Windows 95/NT 4
// Compiler: Microsoft Visual C++ 4.2 / MFC 4.2
// Overview: Sends a string to UK Phone Codes to lookup
// Parameters:
// const char* NumberOrString - pass the exchange name or
// beginning of the number.
//
// Notes : This function checks whether UK Phone Codes is installed
// by checking its registry entries. It checks whether
// UK Phone Codes is running and, if so, sends the correct
// hot key to it.
//
// Copyright Mark Williams/MediaWeb 1999. This function may be freely
// used and modified as long as this comment header and copyright
// message is preserved.
//-------------------------------------------------------------------
// History :
// Date | Author | Comments
// ----------+----------------+--------------------------------------
// 07/12/1999|Mark Williams | Initial version
// | |
//
//-------------------------------------------------------------------
void LookupUsingUKPhoneCodes(const char* NumberOrString)
{
HKEY hKey;
// Check that UK Phone Codes is installed
if (RegOpenKeyEx(HKEY_CURRENT_USER,
"Software\\MediaWeb\\UK Phone Codes\\Settings",
0, KEY_READ, &hKey) != ERROR_SUCCESS)
{
AfxMessageBox("UK Phone Codes Not Installed");
return;
}
CString strToLookup = NumberOrString;
// Copy text into clipboard
if (OpenClipboard(NULL))
{
HANDLE hMem = ::GlobalAlloc(GMEM_MOVEABLE|GMEM_DDESHARE ,
strToLookup.GetLength()+1);
if (!hMem) return;
LPSTR lpStr = (LPSTR)::GlobalLock(hMem);
strcpy(lpStr, strToLookup);
::GlobalUnlock(hMem);
VERIFY(::SetClipboardData(CF_TEXT, hMem));
::CloseClipboard();
} else
{
AfxMessageBox("Failed to open the clipboard!");
return;
}
CWnd *pWnd;
DWORD dwLen = sizeof(DWORD);
DWORD dwKeyEn = 0;
::RegQueryValueEx(hKey, "HotkeyEnable", NULL, NULL,
(LPBYTE)&dwKeyEn, &dwLen);
if (dwKeyEn && (pWnd = CWnd::FindWindow("#32770","UK Phone Codes")))
{
DWORD dwHotkey = 0x78, dwHotmod = 0;
// Read Hotkey settings for UK Phone Codes. Use the correct
// default values.
::RegQueryValueEx(hKey, "Hotkey", NULL, NULL,
(LPBYTE)&dwHotkey, &dwLen);
::RegQueryValueEx(hKey, "Hotmod", NULL, NULL,
(LPBYTE)&dwHotmod, &dwLen);
// WM_HOTKEY is 0x0312.
// If you have a fixed hot key then:
// dwHotkey can be set the the virtual key code e.g. VK_F12
// for F12 key.
// dwHotmod is set to 0, 1 (Alt), 2 (Ctrl), or 4 (Shift)
pWnd->SendMessage(WM_HOTKEY, 100, MAKELONG(dwHotmod, dwHotkey));
} else
{
AfxMessageBox("UK Phone Codes not running/hotkey not enabled");
}
}
[ Back to MediaWeb
Home Page ]
Copyright © MediaWeb