Exemple #1
0
BOOL CClient::SendClipFormat(CClipFormat* pCF)
{
	CSendInfo Info;
	LPVOID pvData = GlobalLock(pCF->m_hgData);
	INT_PTR length = GlobalSize(pCF->m_hgData);
	UCHAR* pOutput = NULL;
	int nLenOutput = 0;
	CTextConvert Convert;
	BOOL bRet = FALSE;

	LogSendRecieveInfo(StrF(_T("BEFORE Encrypt clip data %d"), length));

	if(m_SendSocket.m_pEncryptor)
	{
		if(m_SendSocket.m_pEncryptor->Encrypt((UCHAR*)pvData, (int)length, g_Opt.m_csPassword, pOutput, nLenOutput))
		{
			LogSendRecieveInfo(StrF(_T("AFTER Encrypt clip data %d"), nLenOutput));

			Info.m_lParameter1 = nLenOutput;

			//Send over as UTF-8
			CStringA dest;
			if(CTextConvert::ConvertToUTF8(GetFormatName(pCF->m_cfType), dest))
			{
				strncpy(Info.m_cDesc, dest, sizeof(Info.m_cDesc));
				Info.m_cDesc[sizeof(Info.m_cDesc)-1] = 0;
			}

			if(m_SendSocket.SendCSendData(Info, MyEnums::DATA_START) == FALSE)
				return FALSE;

			m_SendSocket.SendExactSize((char*)pOutput, nLenOutput, false);

			m_SendSocket.m_pEncryptor->FreeBuffer(pOutput);

			bRet = TRUE;
		}
		else
		{
			LogSendRecieveInfo("Failed to encrypt data");
			return FALSE;
		}
	}
	else
	{
		ASSERT(!"SendItem::Encryption not initialized");
		LogSendRecieveInfo("SendItem::Encryption not initialized");	
	}

	GlobalUnlock(pCF->m_hgData);
	
	if(m_SendSocket.SendCSendData(Info, MyEnums::DATA_END) == FALSE)
		return FALSE;

	return bRet;
}
INT_PTR COleClipSource::PutFormatOnClipboard(CClipFormats *pFormats)
{
	Log(_T("Start of put format on clipboard"));

	CClipFormat* pCF;
	INT_PTR	count = pFormats->GetSize();
	bool bDelayedRenderCF_HDROP = false;
	INT_PTR i = 0;

	//see if the html format is in the list
	//if it is the list we will not paste CF_TEXT
	for(i = 0; i < count; i++)
	{
		pCF = &pFormats->ElementAt(i);

		if(pCF->m_cfType == theApp.m_RemoteCF_HDROP)
		{
			bDelayedRenderCF_HDROP = true;
		}
	}

	for(i = 0; i < count; i++)
	{
		pCF = &pFormats->ElementAt(i);

		if(bDelayedRenderCF_HDROP)
		{
			if(pCF->m_cfType == CF_HDROP)
			{
				LogSendRecieveInfo("Added delayed cf_hdrop to clipboard");
				DelayRenderData(pCF->m_cfType);
			}

			continue;
		}

		wchar_t * stringData = (wchar_t *) GlobalLock(pCF->m_hgData);
		int size = (int) GlobalSize(pCF->m_hgData);
		CString cs(stringData);
		GlobalUnlock(pCF->m_hgData);
		
		Log(StrF(_T("Setting clipboard type: %s to the clipboard"), GetFormatName(pCF->m_cfType)));

		CacheGlobalData(pCF->m_cfType, pCF->m_hgData);
		pCF->m_hgData = 0; // OLE owns it now
	}

	pFormats->RemoveAll();

	m_bLoadedFormats = true;

	Log(_T("End of put format on clipboard"));

	return count;
}  
//##ModelId=474D30760272
bool CClip_ImportExport::ExportToSqliteDB(CppSQLite3DB &db)
{
	bool bRet = false;
	try
	{
		//Add to Main Table
		m_Desc.Replace(_T("'"), _T("''"));
		db.execDMLEx(_T("insert into Main values(NULL, %d, '%s');"), CURRENT_EXPORT_VERSION, m_Desc);
		long lId = (long)db.lastRowId();

		//Add to Data table
		CClipFormat* pCF;
		CppSQLite3Statement stmt = db.compileStatement(_T("insert into Data values (NULL, ?, ?, ?, ?);"));

		for(int i = m_Formats.GetSize()-1; i >= 0 ; i--)
		{
			pCF = & m_Formats.ElementAt(i);

			stmt.bind(1, lId);
			stmt.bind(2, GetFormatName(pCF->m_cfType));
			long lOriginalSize = GlobalSize(pCF->m_hgData);
			stmt.bind(3, lOriginalSize);

			const unsigned char *Data = (const unsigned char *)GlobalLock(pCF->m_hgData);
			if(Data)
			{
				//First compress the data
				long lZippedSize = compressBound(lOriginalSize);
				Bytef *pZipped = new Bytef[lZippedSize];
				if(pZipped)
				{				
					int nZipReturn = compress(pZipped, (uLongf *)&lZippedSize, (const Bytef *)Data, lOriginalSize);
					if(nZipReturn == Z_OK)
					{
						stmt.bind(4, pZipped, lZippedSize);
					}

					delete []pZipped;
					pZipped = NULL;
				}
			}
			GlobalUnlock(pCF->m_hgData);

			stmt.execDML();
			stmt.reset();

			m_Formats.RemoveAt(i);
		}

		bRet = true;
	}
	CATCH_SQLITE_EXCEPTION_AND_RETURN(false)

	return bRet;
}
Exemple #4
0
/****************************************************************************
 *                                                                          *
 *  FUNCTION   : CreateXactionWindow()                                      *
 *                                                                          *
 *  PURPOSE    : Creates a transaction window for the given transaction     *
 *               under the given conversation window.                       *
 *                                                                          *
 *  RETURNS    : TRUE  - If successful.                                     *
 *               FALSE - otherwise.                                         *
 *                                                                          *
 ****************************************************************************/
HWND CreateXactionWindow(
HWND hwndMDI,
XACT *pxact)
{
    PSTR pszFmt, pszItem;
    PSTR pData;
    HWND hwnd;
    
    pszItem = GetHSZName(pxact->hszItem);
    pszFmt = GetFormatName(pxact->wFmt);
    pData = GetTextData(pxact->hDdeData);

    /*
     *   Útype/optsÄÄÄÄÄÄÄ ITEM ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄretÄ¿    GWW_WUSER=pxact
     *   ³                                         ³
     *   ³                                         ³
     *   ³                                         ³
     *   ³                                         ³
     *   ³                 DATA                    ³
     *   ³                                         ³
     *   ³                                         ³
     *   ³                                         ³
     *   ³                                         ³
     *   Àstate/errorÄÄÄÄÄ FORMAT ÄÄÄÄÄÄÄÄÄÄResultÄÙ
     */
    hwnd = CreateInfoCtrl((LPSTR)pData,
            (int)SendMessage(hwndMDI, UM_GETNEXTCHILDX, 0, 0L),
            (int)SendMessage(hwndMDI, UM_GETNEXTCHILDY, 0, 0L),
            200, 100, hwndMDI, hInst,
            Type2String(pxact->wType, pxact->fsOptions), pszItem, NULL,
            "Starting", (LPSTR)pszFmt, NULL,
            ICSTY_SHOWFOCUS, 0, (DWORD)(LPSTR)pxact);
    MyFree(pszItem);
    MyFree(pszFmt);
    MyFree(pData);
    return(hwnd);
}
const char* SkImageDecoder::getFormatName() const {
    return GetFormatName(this->getFormat());
}
void CCopyProperties::LoadDataFromCClip(CClip &Clip)
{
	COleDateTime dtTime(Clip.m_Time.GetTime());
	m_eDate = dtTime.Format();
	
	COleDateTime lastPasteDate(Clip.m_lastPasteDate.GetTime());
	m_lastPasteDate = lastPasteDate.Format();

	m_description.SetWindowText(Clip.m_Desc);
	
	if(Clip.m_dontAutoDelete)
	{
		m_bNeverAutoDelete = TRUE;
	}
	else
	{
		m_bNeverAutoDelete = FALSE;
	}

	m_hotKeyGlobal = Clip.m_globalShortCut;

	m_GroupCombo.SetCurSelOnItemData(Clip.m_parentId);

	m_HotKey.SetHotKey(LOBYTE(Clip.m_shortCut), (HIBYTE(Clip.m_shortCut) & ~HOTKEYF_EXT));
	m_HotKey.SetRules(HKCOMB_A, 0);
	if(HIBYTE(Clip.m_shortCut) & HOTKEYF_EXT)
	{
		::CheckDlgButton(m_hWnd, IDC_CHECK_WIN, BST_CHECKED);
	}

	m_moveToGroupHotKeyGlobal = Clip.m_globalMoveToGroupShortCut;

	m_MoveToGrouHotKey.SetHotKey(LOBYTE(Clip.m_moveToGroupShortCut), (HIBYTE(Clip.m_moveToGroupShortCut) & ~HOTKEYF_EXT));
	m_MoveToGrouHotKey.SetRules(HKCOMB_A, 0);
	if(HIBYTE(Clip.m_moveToGroupShortCut) & HOTKEYF_EXT)
	{
		::CheckDlgButton(m_hWnd, IDC_CHECK_WIN_MOVE_TO_GROUP, BST_CHECKED);
	}

	m_QuickPasteText.SetWindowText(Clip.m_csQuickPaste);

	CString cs;
	CClipFormat* pCF;
	INT_PTR count = Clip.m_Formats.GetSize();
	for(int i = 0; i < count; i++)
	{
		pCF = &Clip.m_Formats.GetData()[i];
		if(pCF)
		{
			cs.Format(_T("%s, %d"), GetFormatName(pCF->m_cfType), GlobalSize(pCF->m_hgData));
			int nIndex = m_lCopyData.AddString(cs);
			
			if(m_lCopyID == -1 && pCF->m_dataId == -1)
				m_lCopyData.SetItemData(nIndex, i);
			else
				m_lCopyData.SetItemData(nIndex, pCF->m_dataId);
		}
	}

	int selectedRow = m_lCopyData.GetCount()-1;
	if(selectedRow >= 0 && selectedRow < m_lCopyData.GetCount())
	{
		m_lCopyData.SetSel(selectedRow);
		m_lCopyData.SetCurSel(selectedRow);
		m_lCopyData.SetCaretIndex(selectedRow);
		m_lCopyData.SetAnchorIndex(selectedRow);
	}

	if(Clip.m_bIsGroup == FALSE)
	{
		::ShowWindow(::GetDlgItem(m_hWnd, IDC_STATIC_HOT_KEY_MOVE_TO_GROUP), SW_HIDE);
		::ShowWindow(::GetDlgItem(m_hWnd, IDC_HOTKEY_MOVE_TO_GROUP), SW_HIDE);
		::ShowWindow(::GetDlgItem(m_hWnd, IDC_CHECK_WIN_MOVE_TO_GROUP), SW_HIDE);
		::ShowWindow(::GetDlgItem(m_hWnd, IDC_HOT_KEY_GLOBAL_MOVE_TO_GROUP), SW_HIDE);

		CRect anchorRect;
		::GetWindowRect(::GetDlgItem(m_hWnd, IDC_STATIC_HOT_KEY_MOVE_TO_GROUP), &anchorRect);
		ScreenToClient(&anchorRect);
		

		HWND hwnd = ::GetTopWindow(this->GetSafeHwnd());
		// while we have a valid hwnd, 
		// loop through all child windows
		while (hwnd)
		{
			CRect rect;
			::GetWindowRect(hwnd, &rect);
			ScreenToClient(&rect);

			if(rect.top > anchorRect.bottom)
			{
				::MoveWindow(hwnd, rect.left, 
					rect.top - (anchorRect.Height()+4), rect.Width(), 
					rect.Height(), TRUE);
			}

			// do something with the hwnd
			// and get the next child control's hwnd
			hwnd = ::GetNextWindow(hwnd, GW_HWNDNEXT);
		}

		CRect rect2;
		::GetWindowRect(m_hWnd, &rect2);

		::MoveWindow(m_hWnd, rect2.left, 
				rect2.top, rect2.Width(), 
				rect2.Height() - (anchorRect.Height()+4), TRUE);
	}
}
Exemple #7
0
//
//	IDataObject::SetData
//
HRESULT __stdcall CDataObject::SetData(FORMATETC *pFormatEtc, STGMEDIUM *pMedium,  BOOL fRelease)
{
	_ASSERTE(pMedium && pMedium->pUnkForRelease==NULL);

	#ifdef _DEBUG
	LPCWSTR pszName = GetFormatName(pFormatEtc->cfFormat, true);
	DWORD nData = (DWORD)-1;
	if (lstrcmp(pszName, L"IsShowingLayered")==0
		|| lstrcmp(pszName, L"IsShowingText")==0
		|| lstrcmp(pszName, L"DragContext")==0
		|| lstrcmp(pszName, L"UsingDefaultDragImage")==0
		|| lstrcmp(pszName, L"DragSourceHelperFlags")==0
		|| lstrcmp(pszName, L"DragWindow")==0
		|| lstrcmp(pszName, L"DisableDragText")==0
		)
	{
		LPDWORD pdw = (LPDWORD)GlobalLock(pMedium->hGlobal);
		if (pdw)
		{
			nData = *pdw;
		}
		GlobalUnlock(pMedium->hGlobal);
	}

	wchar_t szDbg[255];
	_wsprintf(szDbg, SKIPLEN(countof(szDbg)) L"CDataObject::SetData {cfFormat=%s, lindex=%i, tymed=x%02X(%u)}, {tymed=x%02X}",
		GetFormatName(pFormatEtc->cfFormat), pFormatEtc->lindex, pFormatEtc->tymed, pFormatEtc->tymed, pMedium->tymed);
	if (nData != (DWORD)-1)
	{
		int nLen = lstrlen(szDbg);
		_wsprintf(szDbg+nLen, SKIPLEN(countof(szDbg)-nLen) L", Data=x%02X(%u)", nData, nData);
	}
	wcscat_c(szDbg, L"\n");
	DEBUGSTRDATA(szDbg);
	#endif

	DEBUGTEST(bool bNew = false);
	LONG nIndex = LookupFormatEtc(pFormatEtc);

	if (nIndex >= 0)
	{
		if ((pMedium != &(m_Data[nIndex].StgMedium)) && (pMedium->hGlobal != &(m_Data[nIndex].StgMedium)))
		{
			if (m_Data[nIndex].fRelease)
			{
				ReleaseStgMedium(&m_Data[nIndex].StgMedium);
			}
			else
			{
				ZeroStruct(m_Data[nIndex].StgMedium);
			}
		}
		else
		{
			Assert((pMedium != &(m_Data[nIndex].StgMedium)) && (pMedium->hGlobal != &(m_Data[nIndex].StgMedium)));
		}
	}
	else //	if (nIndex < 0)
	{
		DEBUGTEST(bNew = true);
		_ASSERTE(nIndex < 0);

		DragData newItem = {};
		newItem.FormatEtc = *pFormatEtc;
		nIndex = m_Data.push_back(newItem);
	}

	m_Data[nIndex].fUsed = TRUE;
	m_Data[nIndex].fRelease = fRelease;
	m_Data[nIndex].StgMedium = *pMedium;

	return S_OK;
}
Exemple #8
0
//
//	IDataObject::GetData
//
HRESULT __stdcall CDataObject::GetData(FORMATETC *pFormatEtc, STGMEDIUM *pMedium)
{
	int idx;

	#ifdef _DEBUG
	wchar_t szDbg[200];
	#endif

	//
	// try to match the requested FORMATETC with one of our supported formats
	//
	if ((idx = LookupFormatEtc(pFormatEtc)) == -1)
	{
		#ifdef _DEBUG
		_wsprintf(szDbg, SKIPLEN(countof(szDbg)) L"!!! CDataObject::LookupFormatEtc(%s) failed\n", GetFormatName(pFormatEtc->cfFormat));
		DEBUGSTRDATA(szDbg);
		#endif
		return DV_E_FORMATETC;
	}

	#ifdef _DEBUG
	_wsprintf(szDbg, SKIPLEN(countof(szDbg)) L"CDataObject::GetData {cfFormat=%s, lindex=%i, tymed=x%02X(%u)})",
		GetFormatName(pFormatEtc->cfFormat), pFormatEtc->lindex, pFormatEtc->tymed, pFormatEtc->tymed);
	LPCWSTR pszName = GetFormatName(pFormatEtc->cfFormat, true);
	DWORD nData = (DWORD)-1;
	if (lstrcmp(pszName, L"IsShowingLayered")==0
		|| lstrcmp(pszName, L"IsShowingText")==0
		|| lstrcmp(pszName, L"DragContext")==0
		|| lstrcmp(pszName, L"UsingDefaultDragImage")==0
		|| lstrcmp(pszName, L"DragSourceHelperFlags")==0
		|| lstrcmp(pszName, L"DragWindow")==0
		|| lstrcmp(pszName, L"DisableDragText")==0
		)
	{
		LPDWORD pdw = (LPDWORD)GlobalLock(m_Data[idx].StgMedium.hGlobal);
		if (pdw)
		{
			nData = *pdw;
			int nLen = lstrlen(szDbg);
			_wsprintf(szDbg+nLen, SKIPLEN(countof(szDbg)-nLen) L", Data=x%02X(%u)", nData, nData);
		}
		GlobalUnlock(m_Data[idx].StgMedium.hGlobal);
	}
	wcscat_c(szDbg, L"\n");
	DEBUGSTRDATA(szDbg);
	#endif


	HRESULT hr = DV_E_FORMATETC;


	switch (m_Data[idx].FormatEtc.tymed)
	{
		case TYMED_HGLOBAL:
			//ReleaseStgMedium(pMedium);
			pMedium->hGlobal = DupMem(m_Data[idx].StgMedium.hGlobal);
			pMedium->pUnkForRelease = NULL; // m_Data[idx].StgMedium.pUnkForRelease;
			hr = S_OK;
			break;

		case TYMED_ISTREAM:
			_ASSERTE(pMedium->pstm != m_Data[idx].StgMedium.pstm);
			//ReleaseStgMedium(pMedium);
			pMedium->pstm = m_Data[idx].StgMedium.pstm;
			if (m_Data[idx].StgMedium.pstm)
				m_Data[idx].StgMedium.pstm->AddRef();
			pMedium->pUnkForRelease = m_Data[idx].StgMedium.pUnkForRelease;
			hr = S_OK;
			break;

		case TYMED_ISTORAGE:
			_ASSERTE(pMedium->pstg != m_Data[idx].StgMedium.pstg);
			//ReleaseStgMedium(pMedium);
			pMedium->pstg = m_Data[idx].StgMedium.pstg;
			if (m_Data[idx].StgMedium.pstg)
				m_Data[idx].StgMedium.pstg->AddRef();
			pMedium->pUnkForRelease = m_Data[idx].StgMedium.pUnkForRelease;
			hr = S_OK;
			break;
		default:
			AssertMsg(L"Unsupported value in m_Data[idx].FormatEtc.tymed");
	}

	if (hr == S_OK)
	{
		//
		// found a match! transfer the data into the supplied storage-medium
		//
		pMedium->tymed			 = m_Data[idx].FormatEtc.tymed;
		//Assert(pMedium->pUnkForRelease==NULL && m_Data[idx].StgMedium.pUnkForRelease==NULL);
		//pMedium->pUnkForRelease  = NULL;
	}
	else
	{
		#ifdef _DEBUG
		_wsprintf(szDbg, SKIPLEN(countof(szDbg)) L"!!! CDataObject::GetData(tymed=%u) failed", m_Data[idx].FormatEtc.tymed);
		DEBUGSTRDATA(szDbg);
		//_ASSERTE(FALSE && "Unsupported tymed!");
		#endif
	}

	return hr;
}
Exemple #9
0
void GenAudioID::Trigger(const std::string& src_dir, const std::string& dst_file)
{
	Json::Value val;

	// audio
	{
		wxArrayString files;
		ee::FileHelper::FetchAllFiles(src_dir + "\\audio", files);

		int idx = val.size();

		for (auto& file : files)
		{
			if (file.find("manga_") == std::string::npos) {
				continue;
			}
			Json::Value item;
			item["id"] = idx;
			item["name"] = "audio/" + GetFormatName(file.ToStdString());
			val[idx++] = item;
		}
		for (auto& file : files)
		{
			if (file.find("manga_") != std::string::npos) {
				continue;
			}
			Json::Value item;
			item["id"] = idx;
			item["name"] = "audio/" + GetFormatName(file.ToStdString());
			val[idx++] = item;
		}
	}

	// sound
	{
		wxArrayString files;
		ee::FileHelper::FetchAllFiles(src_dir + "\\sound", files);

		int idx = val.size();
		for (auto& file : files)
		{
			Json::Value item;
			item["id"] = idx;
			item["name"] = "sound/" + GetFormatName(file.ToStdString());
			val[idx++] = item;
		}
	}

	// music
	{
		wxArrayString files;
		ee::FileHelper::FetchAllFiles(src_dir + "\\music", files);

		int idx = val.size();
		for (auto& file : files)
		{
			Json::Value item;
			item["id"] = idx;
			item["name"] = "music/" + GetFormatName(file.ToStdString());
			val[idx++] = item;
		}
	}

	Json::StyledStreamWriter writer;
	std::locale::global(std::locale(""));
	std::ofstream fout(dst_file.c_str());
	std::locale::global(std::locale("C"));
	writer.write(fout, val);
	fout.close();
}
Exemple #10
0
/****************************************************************************
 *                                                                          *
 *  FUNCTION   : DdeCallback()                                              *
 *                                                                          *
 *  PURPOSE    : This handles all callbacks from the DDEML.  This handles   *
 *               updating of the associated conversation and any special    *
 *               testing cases such as blocking callbacks etc.              *
 *                                                                          *
 *               For the most part, clients only handle advise data and     *
 *               asynchronous transaction completion here.                  *
 *                                                                          *
 *  RETURNS    : Results vary depending on transaction type.                *
 *                                                                          *
 ****************************************************************************/
HDDEDATA EXPENTRY DdeCallback(
WORD wType,
WORD wFmt,
HCONV hConv,
HSZ hsz1,
HSZ hsz2,
HDDEDATA hData,
DWORD lData1,
DWORD lData2)
{
    HWND hwnd;
    CONVINFO ci;
    XACT *pxact;

    if (hConv) {
        /*
         * update conversation status if it changed.
         */
        MYCONVINFO *pmci;
        
        ci.cb = sizeof(CONVINFO);
	if (!DdeQueryConvInfo(hConv,(DWORD) QID_SYNC, &ci) || (!IsWindow((HWND)ci.hUser))) {
            /*
             * This conversation does not yet have a corresponding MDI window
             * or is disconnected.
             */
            return 0;
        }
        if (pmci = (MYCONVINFO *)GetWindowWord((HWND)ci.hUser, 0)) {
            if (pmci->ci.wStatus != ci.wStatus ||
                    pmci->ci.wConvst != ci.wConvst ||
                    pmci->ci.wLastError != ci.wLastError) {
                /*
                 * Things have changed, updated the conversation window.
                 */
                InvalidateRect((HWND)ci.hUser, NULL, TRUE);
            }
            if (ci.wConvst & ST_INLIST) {
                /*
                 * update the associated list window (if any) as well.
                 */
                if (hwnd = FindListWindow(ci.hConvList))
                    InvalidateRect(hwnd, NULL, TRUE);
            }
        }
    }

    /*
     * handle special block on next callback option here.  This demonstrates
     * the CBR_BLOCK feature.
     */
    if (fBlockNextCB && !(wType & XTYPF_NOBLOCK)) {
        fBlockNextCB = FALSE;
        return(CBR_BLOCK);
    }

    /*
     * handle special termination here.  This demonstrates that at any time
     * a client can drop a conversation.
     */
    if (fTermNextCB && hConv && wType != XTYP_DISCONNECT) {
        fTermNextCB = FALSE;
        MyDisconnect(hConv);
        return(0);
    }

    /*
     * Now we begin sort out what to do.
     */
    switch (wType) {
    case XTYP_REGISTER:
    case XTYP_UNREGISTER:
        /*
         * This is where the client would insert code to keep track of
         * what servers are available.  This could cause the initiation
         * of some conversations.
         */
        break;

    case XTYP_DISCONNECT:
        if (fAutoReconnect) {
            /*
             * attempt a reconnection
             */
            if (hConv = DdeReconnect(hConv)) {
                AddConv(ci.hszServiceReq, ci.hszTopic, hConv, FALSE);
                return 0;
            }
        }
        
        /*
         * update conv window to show its new state.
         */
        SendMessage((HWND)ci.hUser, UM_DISCONNECTED, 0, 0);
        return 0;
        break;

    case XTYP_ADVDATA:
        /*
         * data from an active advise loop (from a server)
         */
        Delay(wDelay);
        hwnd = FindAdviseChild((HWND)ci.hUser, hsz2, wFmt);
        if (!IsWindow(hwnd)) {
            PSTR pszItem, pszFmt;
            /*
             * AdviseStart window is gone, make a new one.
             */
            pxact = (XACT *)MyAlloc(sizeof(XACT));
            pxact->wType = wType;
            pxact->hConv = hConv;
            pxact->wFmt = wFmt;
            pxact->hszItem = hsz2;
            DdeKeepStringHandle(idInst, hsz2);
            
            pszItem = GetHSZName(hsz2);
            pszFmt = GetFormatName(wFmt);
            
            hwnd = CreateInfoCtrl(NULL, 
                    (int)SendMessage((HWND)ci.hUser, UM_GETNEXTCHILDX, 0, 0L),
                    (int)SendMessage((HWND)ci.hUser, UM_GETNEXTCHILDY, 0, 0L),
                    200, 100,
                    (HWND)ci.hUser, hInst,
                    Type2String(wType, 0), (LPSTR)pszItem, NULL,
                    NULL, (LPSTR)pszFmt, NULL,
                    ICSTY_SHOWFOCUS, 0, (DWORD)(LPSTR)pxact);
                    
            MyFree(pszFmt);
            MyFree(pszItem);

            if (!IsWindow(hwnd))
                return(DDE_FNOTPROCESSED); 
        }
        if (!hData) {
            /*
             * XTYPF_NODATA case - request the info. (we do this synchronously
             * for simplicity)
             */
            hData = DdeClientTransaction(NULL, 0L, hConv, hsz2, wFmt,
                    XTYP_REQUEST, DefTimeout, NULL);
        }
        if (hData) {
            PSTR pData;
            /*
             * Show incomming data on corresponding transaction window.
             */
            pData = GetTextData(hData);
            SendMessage(hwnd, ICM_SETSTRING, ICSID_CENTER, (DWORD)(LPSTR)pData);
            MyFree(pData);
            DdeFreeDataHandle(hData);
        }
        SendMessage(hwnd, ICM_SETSTRING, ICSID_LL, (DWORD)(LPSTR)"Advised");
        return(DDE_FACK);
        break;
        
    case XTYP_XACT_COMPLETE:
        /*
         * An asynchronous transaction has completed.  Show the results.
         *
         * ...unless the XOPT_BLOCKRESULT is chosen.
         */
        
        ci.cb = sizeof(CONVINFO);
        if (DdeQueryConvInfo(hConv, lData1, &ci) &&
                IsWindow((HWND)ci.hUser) && 
                (pxact = (XACT *)GetWindowWord((HWND)ci.hUser, GWW_WUSER))) {
                
            if (pxact->fsOptions & XOPT_BLOCKRESULT) {
                pxact->fsOptions &= ~XOPT_BLOCKRESULT;
                return(CBR_BLOCK);
            }
            
            pxact->Result = lData2;
            pxact->ret = hData;
            CompleteTransaction((HWND)ci.hUser, pxact);
        }
        break;
    }
}
long CDittoRulerRichEditCtrl::GetTypeFlags(long lID)
{
	long lRet = stNONE;

	try
	{
		CLIPFORMAT cfType = CF_TEXT;
		CppSQLite3Query q = theApp.m_db.execQueryEx(_T("SELECT lID FROM Data WHERE lParentID = %d AND strClipboardFormat = '%s'"), lID, GetFormatName(cfType));
		if(q.eof() == false)
		{
			lRet |= stCF_TEXT;
		}

		cfType = CF_UNICODETEXT;
		q = theApp.m_db.execQueryEx(_T("SELECT lID FROM Data WHERE lParentID = %d AND strClipboardFormat = '%s'"), lID, GetFormatName(cfType));
		if(q.eof() == false)
		{
			lRet |= stCF_UNICODETEXT;
		}

		cfType = RegisterClipboardFormat(_T("Rich Text Format"));
		q = theApp.m_db.execQueryEx(_T("SELECT lID FROM Data WHERE lParentID = %d AND strClipboardFormat = '%s'"), lID, GetFormatName(cfType));
		if(q.eof() == false)
		{
			lRet |= stRTF;
		}
	}
	CATCH_SQLITE_EXCEPTION

	return lRet;
}