|
I'll just put on my headbanging helmet...
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> "It doesn't work, fix it" does not qualify as a bug report. <
> Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
|
|
|
|
|
Hey, sorry for being nosey but i am just curious, could you solve this problem in the end, and if yes, how did you?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Leela: Fry, you're wasting your life sitting in front of that TV. You need to get out and see the real world.
Fry: But this is HDTV. It's got better resolution than the real world <
|
|
|
|
|
Actually, I haven't found a permanent solution yet and I don't know if I'll be able to find the time to do it, which really sucks because this is going to eat away at me until I can find a solution.
I wasn't, now I am, then I won't be anymore.
|
|
|
|
|
Hi!
I've to display a wide char string as right justified. How to do this?
|
|
|
|
|
take a look at the documentation for the function you would use to draw it without justification of any kind and see if it support right-justification.
if not, see DrawTextEx[^]
|
|
|
|
|
Chris Losinger wrote: see DrawTextEx[^]
I think this function can be used if I configured a MFC project? I'm not supposed to use MFC.
|
|
|
|
|
DrawTextEx is not an MFC function
|
|
|
|
|
It is just a plain Windows API function (CDC::DrawTextEx is a MFC method).
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]
|
|
|
|
|
It really depends what you are using to display the string. A string is not justified, it is just a sequence of characters. You have to draw the string somewhere in order to display it justified. How to do that really depends on what API you are using to draw or display the string. So, if you tell us how you draw the string then maybe will be able to help.
|
|
|
|
|
The above code works fine if no proxy authentication at server side. It fails as soon as proxy authentication is applied.
Please help me to sort out whre i am wrong. Any kind of help appreciated.
CInternetSession ises(NULL,1,INTERNET_OPEN_TYPE_PROXY, _T("192.168.9.10:8080"),NULL);
CFile* file=new CFile();//There might occur a connection error
try
{
CString url = _T("http://someurl.com/somepath";)
DWORD dwFlags = INTERNET_FLAG_TRANSFER_ASCII | INTERNET_FLAG_EXISTING_CONNECT;
file = ises.OpenURL(url);//CInternetSession::OpenURL(url) returns a source code in CHttpFile;
}
catch(CInternetException* e)
{ //If an error occured, show messagebox with errorcode
} //catch(CInternetException *ex)
catch(CException *ex)
{
WCHAR str[500];
DWORD errorCode = GetLastError();
ex->GetErrorMessage(str, GetLastError());
AfxMessageBox(str);
}
CString result;
UINT len=1024;
char buf[1024];
source=L"";
while(len > 0)
{
len=file->Read(buf,1024);
if(len>0)
result.Append(CString(buf),len);
}
file->Close();
ises.Close();
Thanks and Regards,
Amar Mhetre
|
|
|
|
|
try below code to set proxy settings,may be it will help you...
CInternetSession ises;
INTERNET_PROXY_INFO proxyinfo;
proxyinfo.dwAccessType = INTERNET_OPEN_TYPE_PROXY;
proxyinfo.lpszProxy = "192.168.9.10:8080";
proxyinfo.lpszProxyBypass = NULL;
ises.SetOption(INTERNET_OPTION_PROXY,(LPVOID)&proxyinfo,sizeof(INTERNET_PROXY_INFO));
|
|
|
|
|
Thanx for your reply.
This will set the proxy, but my problem may be to set the credentials for the proxy ( username and password ). THe way "ises.SetOption()" fails for INTERNET_OPTION_PROXY_USERNAME and INTERNET_OPTION_PROXY_PASSWORD. Is there any other way to set user name and pasword.
Thanx once again for ur reply.
|
|
|
|
|
|
Thanks for the links. I allready gone through the links and found solution.
It should as follows....
HINTERNET hOpenHandle, hConnectHandle, hResourceHandle;WORD dwError, dwErrorCode;
hOpenHandle = InternetOpen(NULL,INTERNET_OPEN_TYPE_PROXY, _T("192.168.9.10:8080"), NULL, INTERNET_FLAG_SECURE);
// _T("192.168.9.10:8080") is proxy with port number
DWORD dwServiceType = AFX_INET_SERVICE_HTTP;
CString szServer, szObject;
INTERNET_PORT nPort;
AfxParseURL (strURL, dwServiceType, szServer, szObject, nPort);
// strURL is any URL whose data to retrieve say http://www.google.com
hConnectHandle = InternetConnect(hOpenHandle,szServer,INTERNET_INVALID_PORT_NUMBER,
_T("test1"), _T("test"), INTERNET_SERVICE_HTTP, 0, 0);
// _T("test1"), _T("test") is username and password for proxy at my server
hResourceHandle = HttpOpenRequest(hConnectHandle, _T("GET"), szObject, NULL, NULL, NULL,
INTERNET_FLAG_KEEP_CONNECTION, 0);
resend:
HttpSendRequest(hResourceHandle, NULL, 0, NULL, 0);
DWORD dwStatus;
DWORD dwStatusSize = sizeof(dwStatus);
HttpQueryInfo(hResourceHandle, HTTP_QUERY_FLAG_NUMBER |
HTTP_QUERY_STATUS_CODE, &dwStatus, &dwStatusSize, NULL);
dwErrorCode = hResourceHandle ? ERROR_SUCCESS : GetLastError();
dwError = InternetErrorDlg(this->GetSafeHwnd(), hResourceHandle, dwErrorCode,
FLAGS_ERROR_UI_FILTER_FOR_ERRORS | FLAGS_ERROR_UI_FLAGS_CHANGE_OPTIONS | FLAGS_ERROR_UI_FLAGS_GENERATE_DATA, NULL);
if (dwError == ERROR_INTERNET_FORCE_RETRY)
goto resend;
DWORD dwNumberOfBytesRead;
char sz[1024];
int result;
do
{
result = InternetReadFile(hResourceHandle, sz, 1023, &dwNumberOfBytesRead);
sz[dwNumberOfBytesRead] = '\0';
int x = strlen(sz);
strResult += sz;
memset(sz, 0, 1024);
} while(result && dwNumberOfBytesRead != 0);
return strResult;
I was trying/searching this for two days and finally this is done. For others who want proxy authentication, can refer this code. But still there has to be a way by using CInternetSession as it is wrapper to WinInet API's used above. I am happy now that code is working fine now.
Thanks once again for your help.
|
|
|
|
|
In a dialog box application, a text box is placed on dialog and CString variable is used for text box.
To update data in text box i write some value in CSting variable and call UpdateData(False). But it gives assertion error in debug mode. No error in release mode. How to solve it.
There is a button on dialog box and onclick function for this button. In onclick function for button i call one function say disp. disp function display another dialog (call its DoModal()). When another dialog display i click on cancel button and it works fine.
I also call disp function from pretranslate message (for any key press). When disp function display another dialog and i click on cancel button an error occur (wincore.cpp). Why this error comming. How to avoid that
|
|
|
|
|
You could start by telling us which assert fails. What does it say?
|
|
|
|
|
I'll check what's error message and update here
|
|
|
|
|
MKC002 wrote: To update data in text box i write some value in CSting variable and call UpdateData(False). But it gives assertion error in debug mode. No error in release mode. How to solve it.
You could start by using a CEdit object instead (of CString ) and simply call its SetWindowText() method. Much cleaner and less prone to error.
"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
|
|
|
|
|
Yes but i am updating text on dialog box (on a static control) after some interval (say 10 secs). If i use SetWindowText then static control on dialog box flick.
While UpdateData(FALSE) does not flick.
No error in release mode.
|
|
|
|
|
MKC002 wrote: If i use SetWindowText then static control on dialog box flick.
Which indicates to me that you are doing something fundamentally wrong. Are you doing the update in a loop of some sort? Are other things happening at the same time?
"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
|
|
|
|
|
Not in a loop. I am updating only 1 time.
But i am doing from a thread.
I have dialog class pointer in thread class. From thread call i call a function of dialog class and pass string in that function which update data on static control.
dialog class function is like
dialogclass::func(TCHAR *str)
{
Staticstr = str;
UpdateData(FALSE);
}
where Staticstr is of cstring type and used for static control
|
|
|
|
|
MKC002 wrote: But i am doing from a thread.
Very bad idea to do that.
"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
|
|
|
|
|
Then which way i should select to display text on dialog
I am using thread to do some backend work which takes time and i need to update information on dialog so that user should be able to know what's going on
modified on Monday, October 18, 2010 5:59 AM
|
|
|
|
|
MKC002 wrote: Then which way i should select to display text on dialog...
Post a message from the secondary thread to the primary thread (the one that owns the UI).
"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
|
|
|
|
|
Hi,
How to get file creation date and time?
|
|
|
|