|
Dear All,
I am currently working on a C project.I need to port the code into Win Mobile 5.0 which is currently working in Win 32.I need to implement ctime( ),gmtime( ),strptime( ),localtime( ),mktime( ).Please help me to implement these in Win Mobile 5.0.
|
|
|
|
|
Wow! New user id? Cool. Please ask it in the Mobile Development forum, as I already said yesterday. Or is that you've asked it there too?
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Spying on the User
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/codeProject$$>
|
|
|
|
|
I want to pass text of a combobox in my form to crystal report to use as header title.
How can I do this?
|
|
|
|
|
Hi,
I am trying to understand "__declspec(thread)" and where it is declared
My situation is I have a DLL which is implicitly bound (hope that is the right term) many threads access the DLL
I do some processing in the DLL_THREAD_ATTACH message
Lets say I declare a pointer with __declspec(thread) attribute in the Global Section of the DLL
e.g. __declspec(thread) char *thread_ptr;
In the process that calls the DLL there exists a function which is multithreaded (many threads execute this function)
lets call it funca() How do I access thread_ptr in funca or better yet how do I declare it
e.g. extern __declspec(thread) char *thread_ptr not sure
|
|
|
|
|
see the guidelines in the remark section of [__declspec( thread ) declarator^]
how ever your example is correct, extern keyword is not required if the declaration is in the same file of funca() definition
|
|
|
|
|
I guess the Linker would know that the __declspec(thread) char *threadptr in the DLL and the__declspec(thread) char *threadptr in main->funca() are one and the same if the DLL is implictly (hope that is the right term) Loaded by the process/.exe
|
|
|
|
|
I am not very mych expert in VC++. i need to draw some airplane like shape and need to move it. or simply just moveit to new coordinates. right now i am generating the new coordinatees and drawing a circle in the new position. but i need to dwaw some 2 d aircraft like shape.
here is a part of my code
for (i=0;i<m_SizeOfArray;i++)
{
GraphRegion->Ellipse(Points[i].x-5,Points[i].y+5,5+Points[i].x,Points[i].y-5);
}
it generates circle in new positions.or can anyone tell me how u can load an image to new positions.
i badly need the solution.
|
|
|
|
|
I guess you can use CDC of your frame. When dragging you image you have to clear it and redraw it in new position. Clear your image by using XOR at same coordinates. Do not clear the entire area for performance.
|
|
|
|
|
Mmmm,
If the "plane" is always the same... why don't you try to draw it right first, without movements... then get the first point (let's say the front of the cabine) and take it like "point_start" then base all the other points to this one in a function.
Then a loop with invalidate / erase background and the call to your function with the new "start_point".
an example in "grosso modo":
The static figure
dc.MoveTo (100, 100);
dc.LineTo (125, 125);
dc.LineTo (100, 150);
dc.LineTo (100, 100);
The dinamic function
void draw_shape (int x, int y);
{
dc.MoveTo (x, y);
dc.LineTo (x + 25, y + 25);
dc.LineTo (x, y + 50);
dc.LineTo (x, y);
}
for (int i = 0; i < 10; i++)
draw_shape (0 + i, 100);
Or the other possibility...
You can draw your plane in a bitmap using resource editor, give it a name and then use it with BitBlt
CClientDC dc(this);
CDC dcNewMem;
dcNewMem.CreateCompatibleDC (&dc);
CBitmap bmPlane;
BITMAP bmTemp;
if (bmPlane.m_hObject != NULL)
bmPlane.DeleteObject();
bmNewIn.LoadBitmap (IDB_PLANE);
bmNewIn.GetObject(sizeof(bmTemp), &bmTemp);
dcNewMem.SelectObject(&bmPlane);
dc.BitBlt(x, y, bmTemp.bmWidth, bmTemp.bmHeight, &dcNewMem, 0, 0, SRCCOPY);
}
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
it is working. but porblem is if the new point is too close then it shows like a line. is there any way to delete the previous shape while i m drawing the same shape in new location.
i need ur help.
|
|
|
|
|
To delete previous contents on the screen you can call Invalidate () at the beginning of your function.
I made it in my project coding the OnDraw () function taking the starting point for visible things from the document and, when I wanted to update the window after a function I made:
Invalidate ();
UpdateWindow (); // for active view
// or: pDoc->UpdateAllViews (NULL); //to redraw all opened views although not active
Hope it helps
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
In OnSize , I wrote like:
m_btn.MoveWindow(&rc,TRUE);
...
Invalidate();
|
|
|
|
|
followait wrote: Invalidate();
Try RedrawWindow() specifying the RDW_ALLCHILDREN flag.
|
|
|
|
|
|
Hi all,
I am making this pauseresume downloader http version:
hOpen = InternetOpen("PauseResumeDemo",INTERNET_OPEN_TYPE_PRECONFIG ,NULL, NULL, NULL);
if(!hOpen)
{
return false;
}
DWORD dwContext = 123;
strStaus.Format("Connecting to server..");
GetDlgItem(IDC_STATIC_STATUSNEW)->SetWindowText(strStaus);
if ( !(hConnect = InternetConnect ( hOpen, "10.5.1.4/downloads/managepoint" , INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0 , 0) ) )
{
CString strMsg;
string strReposeFromServer;
GetLastResponse(strReposeFromServer);
strMsg.Format("Error:%d\nDescription:%s", GetLastError(), strReposeFromServer.c_str());
AfxMessageBox(strMsg, MB_OK);
return false;
}
strStaus.Format("Finding out if this server supoprts Pause & Resume..");
GetDlgItem(IDC_STATIC_STATUSNEW)->SetWindowText(strStaus);
now this works fine up to this point
LPCTSTR lpszVerb = "GET";
LPCTSTR lpszObjectName = "/";
LPCTSTR lpszVersion = NULL;
LPCTSTR lpszReferrer = NULL;
LPCTSTR *lplpszAcceptTypes = NULL;
DWORD dwOpenRequestFlags = INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP |
INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS |
INTERNET_FLAG_KEEP_CONNECTION |
INTERNET_FLAG_NO_AUTH |
INTERNET_FLAG_NO_AUTO_REDIRECT |
INTERNET_FLAG_NO_COOKIES |
INTERNET_FLAG_NO_UI |
INTERNET_FLAG_RELOAD;
DWORD dwOpenRequestContext = 0;
HINTERNET hRequest = HttpOpenRequest(hConnect, lpszVerb, lpszObjectName, lpszVersion,
lpszReferrer, lplpszAcceptTypes,
dwOpenRequestFlags, dwOpenRequestContext);
sendReq = HttpSendRequest(hRequest, NULL, 0, NULL, 0);
HttpSendRequest returns falls however if i change the url to just 10.5.1.4 it returns true however the file that should be downloaded isnt there.
What can i do and what should i do after?
Thanks
Jayjay
|
|
|
|
|
monsieur_jj wrote: What can i do and what should i do after?
HttpSendRequest will set an error that is accessable via GetLastError[^]. You can add something like this to get an error description:
DWORD dwErr = GetLastError();
LPTSTR lpMsgBuf = NULL;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,NULL,dwErr,MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),(LPTSTR) &lpMsgBuf,0,NULL);
TRACE(_T("ERROR: %s\n"),lpMsgBuf);
LocalFree(lpMsgBuf);
Note that you must place the code immediately following the call to HttpSendRequest().
Best Wishes,
-David Delaune
|
|
|
|
|
David,
Actually there is no error it just returns false.
Thanks
|
|
|
|
|
monsieur_jj wrote: Actually there is no error it just returns false.
Strange.
The only other thing that stands out to me is the line:
LPCTSTR *lplpszAcceptTypes = NULL;
I am not sure if NULL is compliant with the W3C [^]standards. Try changing it to
Accept: text
or
Accept: *
If I am incorrect and NULL is a valid header value then I can only recommend taking a look at the MFC sample code TEAR[^] provided by Microsoft. I have successfully modified and used that sample in projects in the past.
Best Wishes,
-David Delaune
|
|
|
|
|
This is my new code, I believe the code finally locates the zip file however the download is incomplete and i cant open the zip file. The zip file should be around 500mb i only get 2kb.
<br />
hOpen = InternetOpen("PauseResumeDemo",INTERNET_OPEN_TYPE_PRECONFIG ,NULL, NULL, NULL);<br />
if(!hOpen)<br />
{<br />
return false;<br />
}<br />
<br />
DWORD dwContext = 123;<br />
<br />
strStaus.Format("Connecting to server..");<br />
GetDlgItem(IDC_STATIC_STATUSNEW)->SetWindowText(strStaus);<br />
<br />
if ( !(hConnect = InternetConnect ( hOpen, "10.5.1.4" , INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0 , 0) ) )<br />
{<br />
CString strMsg;<br />
string strReposeFromServer;<br />
GetLastResponse(strReposeFromServer);<br />
strMsg.Format("Error:%d\nDescription:%s", GetLastError(), strReposeFromServer.c_str());<br />
AfxMessageBox(strMsg, MB_OK);<br />
return false;<br />
}<br />
<br />
strStaus.Format("Finding out if this server supoprts Pause & Resume..");<br />
GetDlgItem(IDC_STATIC_STATUSNEW)->SetWindowText(strStaus);<br />
<br />
hHttpRequest = HttpOpenRequest( hConnect, "GET", "downloads/", NULL, NULL, NULL, 0, 0);<br />
hHttpRequest = HttpOpenRequest( hConnect, "GET", "Managepoint/", NULL, NULL, NULL, 0, 0);<br />
hHttpRequest = HttpOpenRequest( hConnect, "GET", strFileNameAtServer.c_str(), NULL, NULL, NULL, 0, 0);<br />
<br />
if(FindPauseResumeSupported(hHttpRequest))<br />
{<br />
strStaus.Format("Pause & Resume Supported..");<br />
GetDlgItem(IDC_STATIC_STATUSNEW)->SetWindowText(strStaus);<br />
}<br />
else<br />
{<br />
strStaus.Format("Pause & Resume not Supported..");<br />
GetDlgItem(IDC_STATIC_STATUSNEW)->SetWindowText(strStaus);<br />
}<br />
<br />
<br />
double dCurrentFileSize;<br />
<br />
if(IfLocalFileExist(strTmpFileName.c_str(), &dCurrentFileSize)) <br />
{<br />
dOffsetToSeek = dCurrentFileSize;<br />
}<br />
<br />
<br />
if ( !(pFile = fopen (strTmpFileName.c_str(), "ab" ) ) )<br />
{<br />
CString strMsg;<br />
strMsg.Format("Error:%d", GetLastError());<br />
AfxMessageBox(strMsg, MB_OK); <br />
return false;<br />
}<br />
<br />
if(dOffsetToSeek >=0)<br />
{<br />
strStaus.Format("Seeking to local file...");<br />
GetDlgItem(IDC_STATIC_STATUSNEW)->SetWindowText(strStaus);<br />
<br />
int n = fseek(pFile, dOffsetToSeek, SEEK_SET);<br />
}<br />
<br />
<br />
dwBytesWrrittenToFile = dOffsetToSeek;<br />
GetDlgItem(IDC_BUTTON2)->EnableWindow(TRUE);<br />
<br />
do<br />
{<br />
PUMPMESSAGE();<br />
<br />
Sleep(100);<br />
<br />
strStaus.Format("Sending RETRIVE..");<br />
GetDlgItem(IDC_STATIC_STATUSNEW)->SetWindowText(strStaus);<br />
<br />
if(m_bStopped)<br />
{<br />
strStaus.Format("Stopped..");<br />
GetDlgItem(IDC_STATIC_STATUSNEW)->SetWindowText(strStaus);<br />
<br />
AfxMessageBox("Download aborted\nThere is an incomplete temp file 'Temp_ManagePoint431InstallerBuild_47.zip' at current directory. Don't delete it just check it out. It has useful data downloaded so far...\nOnce you are done click Start again, now download will start from exact location where it left off");<br />
<br />
m_bStopped = FALSE;<br />
bInComplete = TRUE;<br />
GetDlgItem(IDC_BUTTON1)->EnableWindow(TRUE);<br />
GetDlgItem(IDC_BUTTON2)->EnableWindow(FALSE);<br />
break;<br />
}<br />
<br />
if (!InternetReadFile (hHttpRequest, (LPVOID)pBuffer, dwToRead, &dwSize) )<br />
{<br />
fclose (pFile);<br />
CString strMsg;<br />
string strReposeFromServer;<br />
GetLastResponse(strReposeFromServer);<br />
strMsg.Format("Error:%d\nDescription:%s", GetLastError(), strReposeFromServer.c_str());<br />
AfxMessageBox(strMsg, MB_OK); <br />
return false;<br />
}<br />
if (!dwSize)<br />
{<br />
m_ProgressCtl.SetPos(100);<br />
CString strTmpPercentage;<br />
strTmpPercentage.Format("Percentage Completed:%d%%", 100);<br />
GetDlgItem(IDC_STATIC_PERCENTAGE)->SetWindowText(strTmpPercentage);<br />
break;
}<br />
else<br />
{<br />
fwrite(pBuffer, sizeof (char), dwSize , pFile);<br />
<br />
dwBytesWrrittenToFile = dwBytesWrrittenToFile + dwSize;<br />
<br />
int nPercentageComplete = (int)floor(((dwBytesWrrittenToFile) * 100)/dFileSize);<br />
<br />
CString strTmpPercentage;<br />
strTmpPercentage.Format("Percentage Completed:%d%%", nPercentageComplete);<br />
GetDlgItem(IDC_STATIC_PERCENTAGE)->SetWindowText(strTmpPercentage);<br />
<br />
int nLower, nUpper;<br />
m_ProgressCtl.GetRange(nLower, nUpper );<br />
<br />
m_ProgressCtl.SetPos(((nUpper-nLower)/100) * nPercentageComplete);<br />
}<br />
}
while (TRUE);<br />
<br />
fflush (pFile);<br />
fclose (pFile);<br />
delete [] pBuffer;<br />
<br />
<br />
if(!bInComplete)<br />
{<br />
strStaus.Format("Renaming file at local machine..");<br />
GetDlgItem(IDC_STATIC_STATUSNEW)->SetWindowText(strStaus);<br />
<br />
if(!MoveFile(strTmpFileName.c_str(), strFileNameAtLocalMachine.c_str() ))<br />
{<br />
CString strMsg;<br />
strMsg.Format("Error:%d", GetLastError());<br />
AfxMessageBox(strMsg, MB_OK); <br />
<br />
}<br />
strStaus.Format("Done..");<br />
GetDlgItem(IDC_STATIC_STATUSNEW)->SetWindowText(strStaus);<br />
}<br />
<br />
if(!bInComplete)<br />
{<br />
AfxMessageBox("File has downloaded..");<br />
GetDlgItem(IDC_BUTTON2)->EnableWindow(FALSE);<br />
GetDlgItem(IDC_BUTTON1)->EnableWindow(FALSE);<br />
}<br />
<br />
if(hConnect)<br />
InternetCloseHandle(hConnect);<br />
if(hOpen)<br />
InternetCloseHandle(hOpen);<br />
if(hOpenFile)<br />
InternetCloseHandle(hOpenFile);<br />
<br />
return TRUE;<br />
|
|
|
|
|
Hello!
Its very difficult to debug your code remotely. To better format your code postings in the future I would recommend wrapping the text in the CODE then the PRE tags. Makes it much easier to read when its formatted correctly.
If your goal is to simply download a remote file then perhaps you can use CInternetSession[^] rather than the WinInet classes.
Here is a sample of how to read a remote file over HTTP and write it locally. Much easier!
I pulled this code snippit from an old project. It was inside a CWinThread derived class for multi-threaded downloads.
char httpbuff[512];
CInternetSession Session;
CStdioFile *remotefile = Session.OpenURL(_T("http://www.somewhere.com/somepath/somefile.zip") ,1,INTERNET_FLAG_TRANSFER_BINARY | INTERNET_FLAG_RELOAD);
CFile myfile(_T("\\Path\\To\\Somewhere\\Local"), CFile::modeCreate|CFile::modeWrite|CFile::typeBinary);
int iBytes;
while (iBytes = remotefile->Read(httpbuff, 512))
{
myfile.Write(httpbuff, iBytes);
}
If you also need the filesize for a progress bar then you can use CHttpFile::QueryInfo() to get that information. CHttpConnection::OpenRequest() returns CHttpFile.
Best Wishes,
-David Delaune
|
|
|
|
|
Does CInternetSession have pause resume capability?
Thanks,
David
|
|
|
|
|
My program is:
#include "stdafx.h"
#include "stdio.h"
#include "windows.h"
#include "string.h"
#define SERVICENAME "test"
int InstallService();
int main(int argc, char* argv[])
{
InstallService();
return 0;
}
int InstallService()
{
SC_HANDLE sh = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
if(!sh)
{
exit(1);
}
SC_HANDLE rh = CreateService(
sh,
SERVICENAME,
SERVICENAME,
SERVICE_ALL_ACCESS,
SERVICE_WIN32_OWN_PROCESS,
SERVICE_AUTO_START,
SERVICE_ERROR_NORMAL,
"c:\windows\notepad.exe",
NULL,
NULL,
NULL,
NULL,
NULL);
if(!rh)
{
if (GetLastError() == ERROR_SERVICE_EXISTS)
{
exit(1);
}
else
{
puts("error CreateService");
CloseServiceHandle(sh);
exit(1);
}
}
return 1;
}
when i use "sc start test",something wrong:"[sc] StartService FAILED 1053",Why?????
|
|
|
|
|
Definition of Error 1053: ERROR_SERVICE_REQUEST_TIMEOUT: The service did not respond to the start or control request in a timely fashion.
Best Wishes,
-David Delaune
|
|
|
|
|
After restart ,the program open notepad.exe,then the notepad.exe closed automatically.
Why???
How to resolve the program????
|
|
|
|
|