|
HTTP
Best regards,
Eugene Pustovoyt
|
|
|
|
|
Hi,
use this code.
#include <afxinet.h>
//assumes server, port and URL names have been initialized
CInternetSession session("My Session");
CHttpConnection* pServer = NULL;
CHttpFile* pFile = NULL;
try
{
CString strServerName;
INTERNET_PORT nPort;
INTERNET_PROXY_INFO proxyinfo;
proxyinfo.dwAccessType = INTERNET_OPEN_TYPE_PROXY;
proxyinfo.lpszProxy = CStrProxy;
proxyinfo.lpszProxyBypass = NULL;
session.SetOption(INTERNET_OPTION_PROXY, (LPVOID)&proxyinfo, sizeof(INTERNET_PROXY_INFO));
pServer = session.GetHttpConnection(strServerName, nPort);
pFile = pServer->OpenRequest(CHttpConnection::HTTP_VERB_GET, strObject);
pFile->AddRequestHeaders(szHeaders);
pFile->SendRequest();
pFile->QueryInfoStatusCode(dwRet);
if (dwRet == HTTP_STATUS_OK)
{
UINT nRead = pFile->Read(szBuff, 1023);
while (nRead > 0)
{
//read file...
}
}
delete pFile;
delete pServer;
}
catch (CInternetException* pEx)
{
//catch errors from WinInet
}
session.Close();
Have A Nice Day
Murali.M
|
|
|
|
|
I don't understand what a szHeaders string must contains!?
Best regards,
Eugene Pustovoyt
|
|
|
|
|
const TCHAR szHeaders[] =
_T("Accept: text/*\r\nMozilla/3.0 (compatible; My Browser/1.0)\r\n");
|
|
|
|
|
But in this code I don't see an authorizing on the proxy. I need it.
Best regards,
Eugene Pustovoyt
|
|
|
|
|
Hi,
Could anyone provide some pointers on download management concepts. The Download Management would essentially mean download acceleration, download resumption if connection fails etc. I would like to know how all this is done and any sample code if possible.
Thanks and Regards,
Abhishek.
Learning is a never ending process of Life.
|
|
|
|
|
Basically, it relies on the range capability of HTTP and the restart capability of FTP.
For download acceleration (where this does not mean altering the configuration of the TCP/IP stack, which has happened to me a few times with this sort of software), the client requests different ranges on different connections. This gets around the bandwidth throttles that some sites apply on a per-connection basis. It can also sometimes help to have an additional connection if the first one stalls.
Some accelerators communicate with their authors' website, to discover mirrors of the content (Go!Zilla used to do this). The download manager then connects to multiple mirror sites, dividing the content between them.
The specification for HTTP/1.1 says, 'A single-user client SHOULD NOT maintain more than 2 connections with any server or proxy.' Download accelerators often break this rule.
Resuming a download is much the same - for HTTP, you set the Range header to start at the point that failed, while for FTP you use the REST command to indicate where you want to restart. However, the server may not understand the command - you may need to fall back to retrieving the whole.
I believe the WinInet DLL does allow setting restart points, although I think you have to add to the headers (HTTP) or send the command explicitly (FTP). WinInet enforces the two connection limit mentioned above.
|
|
|
|
|
Thanks a lot Mike for your help.
Could you suggest me some online resource where I can do a detailed study on this subject and where I can find some sample code on how exactly this can be done.
I would be greatful if you could provide me with this info.
Thanks
Abhishek.
Learning is a never ending process of Life.
|
|
|
|
|
Hi there. Can anyone advise me on how to open a image file like JPEG in a MFC application? I have written a MFC application and need to add in the open image file option. Can anyone tell me how to do it? Thank you for any advise.
|
|
|
|
|
|
|
You can also go for GDI+ apis to do the same.
I Touched Osama Bin Ladens Bushy Beard
|
|
|
|
|
It is well-known that the PostThreadMessage function ,only for thread,places (posts) a message in the message queue of the specified thread and then returns without waiting for the thread to process the message.
Q: Whether there is a function which ,similar to SendMessage in function,but for thread not window,sends the specified message to a thread and does not return until the thread has processed the message.
Rap off for you,for me,for our human.
|
|
|
|
|
Hello, guys.
Check this out:
<br />
void CCtrlsDlg::OnDblclkList(NMHDR* pNMHDR, LRESULT* pResult) <br />
{<br />
LPNMITEMACTIVATE pIA = (LPNMITEMACTIVATE)pNMHDR;<br />
*pResult = 0;<br />
<br />
if((-1 == (m_nItem = pIA->iItem)) || (0 == (m_nSubitem = pIA->iSubItem))) <br />
return;<br />
<br />
CRect rc;<br />
m_ctrlList.GetSubItemRect(pIA->iItem, pIA->iSubItem, LVIR_BOUNDS, rc);<br />
<br />
if(!m_pEdit)<br />
m_pEdit = new CEdit;<br />
<br />
CString strText = m_ctrlList.GetItemText(m_nItem, m_nSubitem);<br />
<br />
m_pEdit->Create(WS_CHILD | WS_VISIBLE | WS_BORDER, rc, &m_ctrlList, 12);<br />
m_pEdit->ModifyStyleEx(0, WS_EX_CLIENTEDGE, 0);<br />
m_pEdit->SetWindowText(strText);<br />
m_pEdit->SetSel(0, -1);<br />
m_pEdit->SetFocus();<br />
}<br />
This whole thing displays an edit box for CListCtrl's subitems, but as CEdit control is created it has some odd look - it looks like edit control from Windows 3.1 rather anything else. Where's the problem?
|
|
|
|
|
I'm guessing that you are seeing the System font which looks very old.
Try
m_pEdit->ModifyStyleEx(0, WS_EX_CLIENTEDGE, 0);<br />
m_pEdit->SetFont(&newfont);<br />
m_pEdit->SetWindowText(strText);
where newfont is a CFont that you find acceptable.
Paul Hooper
If you spend your whole life looking over your shoulder, they will get you from the front instead.
|
|
|
|
|
I want to change the data field of Default key. So that my application can be listed and launched from right mouse click
|
|
|
|
|
Hi,
in C# there is an option to set refer url property to HttpWebRequest Class. how can set this vc++. i using CInternetSession,CHttpConnection,CHttpFile. Any one help to me.
Thanks in Advance
Murali.M
|
|
|
|
|
Hi,
in CHttpConnection::OpenRequest() third parameter is the referurl.
|
|
|
|
|
I have done Wh_getmessage hook.
In my filter function i have typecast the Wm_char message
like Say if Char 'A' is pressed i send the char 'A' as it is to the application.
NOw if user press 'B' then what i am doing is changing the Char 'B' to BackSpace character.
TO this point the application is working properly in all application for it is a system wide hook , where pressing of B removes 'A' for B is a backspace character
A , B->backspace
out put = NUll
Now what i am doing is using PostMessage api i am sendging 2 characters to that application which is active
Say POSTMESSAGE(C ,D)
I got these problems:
1. The character C when posted to the application , my filter function is called again and( i have defined a rule for C where if the user type
C then change to E) and i expected C to be printed in the application , but instead E is coming.
I have to find a way how to prevent this ie the postmessage which i have send to the application looping through my filter funcion again and again.
___________________________________________________________________________
2. If i declare like this
A , B->backspace character , Postmessage(C,D)
Expected output
CD
Output obtained in notepad and photoshop
AC and D is removed(Wrong)
Output obtaied in all other application
CD(correct)
_________________________________________________________________________
3. So i tried this method
A , B->NULL , Postmessage(backSpace,C,D)
Expected output
CD
Output obtained in notepad and photoshop
CD(correct)
Output obtaied in all other application
AC and D is removed(Wrong)
Could anyone tell me how i can overcome these problems
Thanks in advance
with regards
vimal
|
|
|
|
|
Anyone knows any face facial detection software that is available free on the website?
Becos I am doing a project on analysis of facial expression and I need to place trackers on the face and output coordinate values
Anyone who can help me pls reply me
I am most grateful
|
|
|
|
|
|
Hi all,
I'm writing an application need to run on pretty much every version of Windows out there. The only major problem I've struck is with scrollbars. I've laid out the child windows within the parent window, calculated the range required, populated a SCROLLINFO struct and used SetScrollInfo() to pass it in. On Win98SE onwards, it all works perfectly - but on 95 and 98, no scrollbars. However, if you open a couple of files, forcing it through the process it will start working - and from then on, perfect. In case it helps, the relevant piece of code (for the vertical scrollbar. HOrziontal shows the same symptoms):
(m_ScrollableArea.Height() is a CRect, and yes, it does have valid values)
<br />
SCROLLINFO SI ;<br />
SI.cbSize = sizeof( SCROLLINFO ) ;<br />
SI.fMask = SIF_RANGE ;<br />
<br />
SI.nMin = 0 ;<br />
int M = m_ScrollableArea.Height()/m_YIncrement ;<br />
m_YRange = ( M*m_YIncrement ) + m_YIncrement ;<br />
SI.nMax = m_YRange ; <br />
M = 0 ;<br />
<br />
SetScrollInfo( SB_VERT, &SI, TRUE ) ;<br />
Any ideas? It's like the API on 95/98 is acting unreliably, but I've got to be doing something to make it happen. Any help would be greatly appreciated - this one is driving me nuts...
--Shane
You can sometimes count every orange on a tree, but never all the treees in a single orange.
|
|
|
|
|
This is a far shot, but perhaps your window needs to get it's Non-Client-Area re-calculated to make space for the Scroll-Bars (maybe it's messed up in 95/8...)
Anyhows, I need to do for my own Scroll-Bars so perhaps Microsoft went the same way
SetWindowPos(0,0,0,0,0,SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE);
This will force your window into recalculating it's non-client area and perhaps add/remove scroll-bars as necessary.
|
|
|
|
|
Gave it a go, but no cigar. Did find out one thing, though; Windows 98SE/NT/2K onwards, scrollbars handled by the window itself are part of the client area, updated by the system, but still within the client area (do a GetClientRect() with and without scrollbars, and they'll be the same). 95/98, they're part of the non-client area (I tried forcing a repaint of the non-client area but that didn't help either). GetClientRect() changes with/without scrollbars...
Anyway, I'll keep hammering at it - unfortunately it's a must-fix problem for this project. Thanks for the help
--Shane
You can sometimes count every orange on a tree, but never all the treees in a single orange.
|
|
|
|
|
Are you sure about this ?
I'm pretty sure that at-least from Windows-2000 and up, Scroll-Bars are in the Non-Client-Area, as in they are returned by GetWindowRect but not by GetClientRect.
If you want to disable Scroll-Bars, there are many ways that range from Handling OnNcCalcSize and not allowing windows to make space for it's scroll-bar, and up to using the Flat-Scroll Bar API FS_EnableScroll I believe dose the work...
|
|
|
|
|