|
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?
|
|
|
|
|
|
{201} normal block at 0x003BFEE0, 52 bytes long.
that '201' means the 201st allocation is the one that caused the leak. if the leak always appears with that '201', then you can use _CrtSetBreakAlloc to cause an assertion when that alloc happens - and then you can work back up the call stack to see where the allocation happened.
so, put _CrtSetBreakAlloc(201); somewhere early in your application's initialization (i always put it in my C*App::InitInstance), run your app, and wait for the assert.
|
|
|
|
|
If your running Visual Studio 2010 the trial!
Go to the Analyze menu, select Run Code Analysis on Only <your project="" name="">!
|
|
|
|
|
Hi,
In my application, I need to check whether my system is remotely connected and if connected
I need to get the ipaddress of the remote system.
Any suggestions or links would be helpful.
Thanks
Satya
Today is a gift, that's why it is called the present.
|
|
|
|
|
Have you tried NetWkstaUserEnum() ?
"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
|
|
|
|
|
Hello All,
consider following code
try
{
function();
}
catch(//what typr should expect)
{
}
fuction is develope from other one and he not mention the type of exception he returning..
/////////////////////////////////////////////////////
if i use this code
catch(std::exception & s)
{
cout<<s.what();
}
i get error in vs2008
Error is :--
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
Please help ,
thanks.
|
|
|
|
|
Use:
try
{
}
catch(...)
{
}
To catch all exception types. Good luck!
|
|
|
|
|
Thanks for Reaply,
But how can I get type of thown exception.
whether he is throwing int,char*,of any user define data type.
So that I can Identify what type of execption is occur.
|
|
|
|