April 15, 2003 Programmer Notes Title: Sending a log QSO request to DXbase 2005 /* Sample code below demonstrates the technique using VC++ For information on using this technique with VB, consult the Microsoft KnowledgeBase and search for article Q176058 entitled HowTo: Pass string data between applications using SendMessage */ YourViewClass::OnLogToDXbase(void) { /******************************************************************************** This information pertains to DXbase 2004 and later. It describes how to pass a logging request to DXbase while DXbase is running. Previous versions of DXbase do not support this interface and the call to FindWindow listed below will fail. Therefore, there is no special need for the calling Application to worry about DXbase release levels. DXbase expects to receive a # delimited string in a CopyData struct. The string must end with the # symbol Only the callsign is required, other fields are optional. The delimiter should be passed even though a field may be skipped as in AA4LU#599#599#14070#BillyBob#PSK31# or AA4LU####### or AA4LU#599#599##### DXbase will default any fields not passed. Allowable fields are callsign, RSTr, RSTs, Freq in Khz, opr name, mode ( using a valid DXbase mode string). The sequence or order of the field values must be as defined here. There are no field tags in the string therefore DXbase expects that if values are passed, they will be in the order listed here. DXbase will truncate callsign to be max of 15 characters DXbase will use default of 599 if rst values passed exceed 3 characters The frequency passed must be in Khz as in the following examples: 14070 14070.0 14070.00 ( do not exceed two decimal places ) Do NOT pass any frequency format except Khz. The following examples will cause an incorrect log entry in DXbase: 14.070 14.070.00 1407000 14070.000 If no frequency is passed, DXbase will either query the HF radio to get the frequency or it will use defaults set in DXbase by the user. **********************************************************************************/ CYourDoc* pDoc = GetDocument(); if( pDoc->m_sTheirCall.IsEmpty()) return; char lpBuf[501]; //bigger than needed but allows for expansion later CString csRSTR, csRSTS; //let's protect called app by making sure we pass a value //receiving app will also protect so this is just extra care if(pDoc->m_sTextRSTR.IsEmpty()) csRSTR = _T("599"); else csRSTR = pDoc->m_sTextRSTR; if(pDoc->m_sTextRSTS.IsEmpty()) csRSTS = _T("599"); else csRSTS = pDoc->m_sTextRSTS; sprintf(lpBuf, "%s#%s#%s#%s#%s##", pDoc->m_sTheirCall, csRSTR, csRSTS, pDoc->m_sTextFREQ, pDoc->m_sTheirName pDoc->m_sMode); DWORD nCount = strlen(lpBuf); CWnd *pDXBwnd = CWnd::FindWindow("DXbase", NULL); if(pDXBwnd) { //Found the DXbase window COPYDATASTRUCT cds; cds.dwData = 10001; //fixed value ( always use this for DXbase ) cds.cbData = nCount; cds.lpData = (void*) lpBuf; pDXBwnd->SendMessage(WM_COPYDATA, (WPARAM)AfxGetApp()->m_pMainWnd->GetSafeHwnd(), (LPARAM) &cds); } }