|
Fareed Rizkalla wrote: ...a URL catcher.
Who is throwing them?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
What do you mean who is throwing them?
I initialized my application to listen on the Clipboard.
Then I created a timer that would open the Clipboard to check if their is a URL it could use.
So my timer opens the Clipboard and checks if their is a certain data type stored in it.
However I was unable to detect the URLs I copied from my browser as CF_TEXT, CF_UNICODE and CF_OEMTEXT.
However when I copied a MD5 checksum file it triggered all of the above data types as available.
|
|
|
|
|
Fareed Rizkalla wrote: Then I created a timer that would open the Clipboard to check if their is a URL it could use.
So my timer opens the Clipboard and checks if their is a certain data type stored in it.
Why not call EnumClipboardFormats() to see what formats are currently available?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
You have ! in front of the IsClipboardFormatAvailable() calls, which looks wrong.
--Mike--
|
|
|
|
|
It can be send data to remote server from CString ?
Here is "original code" :
bool CSmtp::SendData()
{
int idx = 0,res,nLeft = strlen(SendBuf);
assert(SendBuf);
if(RecvBuf == NULL)
return false;
while(nLeft > 0)
{
if( res = send(hSocket,&SendBuf[idx],nLeft,0) == SOCKET_ERROR)
{
m_oError = CSMTP_WSA_SEND;
return false;
}
if(!res)
break;
nLeft -= res;
idx += res;
}
return true;
}
which I want to convert into :
BOOL CSmtp::SendData()
{
if(send(m_hSocket,m_sSendBuf,1024,0) == == SOCKET_ERROR)
{
m_nError = CSMTP_WSA_SEND;
return FALSE;
}
return TRUE;
}
m_sSendBuf is CString data member
|
|
|
|
|
mesajflaviu wrote: if(send(m_hSocket,m_sSendBuf,1024,0) == == SOCKET_ERROR)
I would use
if ( send( m_hSocket, m_sSendBuf, m_sSendBuf.GetLength(), 0) == SOCKET_ERROR)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
You haven't mentioned what exactly you're problem is.
Is there a compiler error or is the data not being sent correctly?
There is a chance that you get a compiler error because the send function takes a const char* parameter and a CString in UNICODE builds contains a wchar_t array.
If this is a problem use CStringA explicitly.
CStringA sSendBuf = m_sSendBuf;
send(m_hSocket, sSendBuf, sSendBuf.GetLength(), 0);
|
|
|
|
|
Thank you all , seems to work !!! You make a happy man !
|
|
|
|
|
I use the PickIconDlg function that returns the path to module and index # of icon.
How can I get the resource id of that icon?
Thanks
|
|
|
|
|
I want to use google translator through an application I wrote the following code but it always time out what's my problem.
CString szTranReq(L"/translate_a/t?client=t&sl=en&tl=tr");
CString szText(L"text=Hello");
CString szServer(L"www.google.com");
DWORD inetPort = 80;
CInternetSession inetSession(::AfxGetAppName(), 1, PRE_CONFIG_INTERNET_ACCESS, NULL, NULL, NULL);
inetSession.SetOption(INTERNET_OPTION_CONNECT_TIMEOUT, 1000 * 3);
inetSession.SetOption(INTERNET_OPTION_CONNECT_BACKOFF, 1000);
inetSession.SetOption(INTERNET_OPTION_CONNECT_RETRIES, 1);
CHttpConnection* pInetHttpConnection = inetSession.GetHttpConnection(szServer, inetPort, NULL, NULL);
CHttpFile* pHttpFile = pInetHttpConnection->OpenRequest(
CHttpConnection::HTTP_VERB_POST,
szTranReq, NULL, 1, NULL, NULL,
INTERNET_FLAG_EXISTING_CONNECT | INTERNET_FLAG_DONT_CACHE);
pHttpFile->AddRequestHeaders(L"Host: www.google.com\r\n", HTTP_ADDREQ_FLAG_ADD_IF_NEW);
pHttpFile->AddRequestHeaders(L"User-Agent: Mozilla/5.0\r\n", HTTP_ADDREQ_FLAG_ADD_IF_NEW);
pHttpFile->AddRequestHeaders(L"Accept-Encoding: deflate\r\n", HTTP_ADDREQ_FLAG_ADD_IF_NEW);
pHttpFile->AddRequestHeaders(L"content-length: 10\r\n", HTTP_ADDREQ_FLAG_ADD_IF_NEW);
pHttpFile->AddRequestHeaders(L"Connection: Close\r\n", HTTP_ADDREQ_FLAG_ADD_IF_NEW);
pHttpFile->SendRequest();
DWORD dwRet;
pHttpFile->QueryInfoStatusCode(dwRet);
SendRequest() Method always timeout.
|
|
|
|
|
Hi,
I know that rich edit controls have thier own interface
but would any one know which of the CDC
methods are available and at what point
to a rich edit
Specfically I would like to set the Font and
text Color initially
|
|
|
|
|
A device context is used to render the content of the richedit to a device to intialise the width for word breaks.
use CRichEditCtrl::SetDefaultCharFormat to set the default format of the text.
It takes a CHARFORMAT2 to structure where you can set the font and the textcolor.
Remember to initialize the cbSize with the size of CHARFORMAT2 and to set the dwMask Member to flag which properties you want to set.
Use CRichEditCtrl::SetSelectionCharFormat() to format the selected text.
When set SetWordWrapMode() you should also call SetTargetDevice to set the width of a line.
Use FormatRange to render the content to a device.
|
|
|
|
|
In other words all these Richedit methods act as interface
to CClientDC object
|
|
|
|
|
I didn't get you real question!
CRichEditCtrl is a control an displays its content in the wm_paint event to the paint dc.
Only if the control should calculate sizes or draw it's content a device context is needed.
If you require a "WYSIWYG" you should apply the device context of the desired device.
If you want to calculate the size or want to draw it to a context you have to call FormatRange Method and apply the deviceContext of the target device to the formatrange structure.
If you want to learn, how richeditctrl realy works, see MSDN : Rich Edit Control Examples[^]
|
|
|
|
|
Thought if you wanted to CDC::SetTextColor you would need need ther Device COntext but like you said in a Earlier post you can use
SetCharformat for that
|
|
|
|
|
How can receive data from server , with Windows Sockets recv(SOCKET s,char FAR* buf,int len,int flags); function , into CString object ? Here is my trial :
BOOL CSmtp::ReceiveData()
{
if(recv(m_hSocket,&m_sRecvBuf,m_sRecvBuf.GetLength(),0) == SOCKET_ERROR)
{
m_nError = CSMTP_WSA_RECV;
return FALSE;
}
return TRUE;
}
m_sRecvBuf is member CString data
|
|
|
|
|
Supposing you are doing a ANSI build, this is one of the rare occasion where GetBuffer method is appropriate, for instance:
...
int result = recv( m_hSocket, m_sRecvBuf.GetBuffer(N), N, 0);
m_sRecvBuf.ReleaseBuffer();
if(result == SOCKET_ERROR)
{
..
}
...
where N is the number of requested bytes (number of your choice).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Seems to work !
BOOL CSmtp::ReceiveData()
{
if(recv(m_hSocket,m_sRecvBuf.GetBuffer(1024),1024,0) == SOCKET_ERROR)
{
m_nError = CSMTP_WSA_RECV;
return FALSE;
}
m_sRecvBuf.ReleaseBuffer();
return TRUE;
}
|
|
|
|
|
I've modified my previous reply: you should call ReleaseBuffer when the recv fails too.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
You are right , I will modified ! Thanks !
|
|
|
|
|
Hi
After I exited my APP, I always found following message:
Detected memory leaks!
Dumping objects ->
{201} normal block at 0x003BFEE0, 52 bytes long.
Data: < ; ; ; > E0 FE 3B 00 E0 FE 3B 00 E0 FE 3B 00 CD CD CD CD
{200} normal block at 0x003BFE88, 28 bytes long.
Data: < > 00 00 00 00 CD CD CD CD CD CD CD CD CD CD CD CD
Object dump complete.
How can I locate them?
Best regards,
|
|
|
|
|
|
Thank you for your reply. Is there any other software can detect potential memory leaks in the code?
Best regards,
|
|
|
|
|
There's lots of commercial products (BoundsChecker springs to mind).
|
|
|
|
|
Is there a free one? Is there a VS built-in tool for use?
|
|
|
|