|
I am attempting to access a value that the user chooses in a Combo Box.
I use :
DWORD_PTR data = m_Combo.GetItemData(m_Combo.GetCurSel());
This returns 0 to me all the time. When i check the m_Combo.GetCurSel() value, it returns the correct index. but the m_Combo.GetItemData just returns 0 for the value at that index all the time.
Am i using this correctly first off and can anyone explain why this may be happening?
|
|
|
|
|
You don't use GetItemData to retrieve the text. Take a look at GetLBText[^] instead (GetItemData is for retrieving some data that you associated with the string).
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
Can you expand or give an example when you say that GetItemData is used to retrieve some data associated with the string?
Thanks,
|
|
|
|
|
|
I think you are mixing the string in the combo box (which can represent a value) and the data associated with this string. These are two different things.
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
LCI wrote: This returns 0 to me all the time.
Which is probably correct, if you did not use SetItemData() to store the value.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi..
Is it possible to detect that Windows has restated or has just been powered on?
Kind regards
/Kim
|
|
|
|
|
Not unless you already have an application up and running to detect such an event.
Check out the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run registry key.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
What you mean by has just been powered
Just is an inaccurat term. If you mean that you have an application violently terminating due to system shutdown and restart then your application should leave enough traces to recover itself.
I suppose that Win32 will have an interface to give you the latest loggin time of the current user if that's help.
|
|
|
|
|
The problem is. I have made a Win32 service application witch is set to automatic start up.
For some reaches, the application unexpectedly terminates. But when I start the application with Service Manager is starts with out errors.
But I have thought about this function, witch can tell me how long the system has been up an running.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/gettickcount.asp
Then I will try to make a delay for about 10 seconds. when system up time is less then 10 minutes.
/Kim
|
|
|
|
|
I have the folowing code for a function that reads a string from the COM5 port and then adds it to a table in the database. The value that i should read from COM is smth like "FFFFAAAAAAAAAA000C" but i only get "F". What's wrong?
void CMina_sView::OnListenCom5()
{
CSerial serial;
LONG lLastError = ERROR_SUCCESS;
DWORD dwBytesRead ;
char szBuffer[17];
char * point;
// Attempt to open the serial port (COM5)
lLastError = serial.Open(_T("COM5"),0,0,false);
// Setup the serial port (9600,8N1, which is the default setting)
lLastError = serial.Setup(CSerial::EBaud9600,CSerial::EData8,CSerial::EParNone,CSerial::EStop1);
// Register only for the receive event
lLastError = serial.SetMask(CSerial::EEventBreak |
CSerial::EEventCTS |
CSerial::EEventDSR |
CSerial::EEventError |
CSerial::EEventRing |
CSerial::EEventRLSD |
CSerial::EEventRecv);
lLastError = serial.SetupReadTimeouts(CSerial::EReadTimeoutNonblocking);
// Wait for an event
lLastError = serial.WaitEvent();
// Save event
const CSerial::EEvent eEvent = serial.GetEventType();
// Handle ring event
// Handle data receive event
if (eEvent & CSerial::EEventRecv)
{
do
{
// Read data from the COM-port
lLastError = serial.Read(szBuffer,sizeof(szBuffer)-1,&dwBytesRead);
// Finalize the data, so it is a valid string
szBuffer[dwBytesRead] = '\0';
}
while (dwBytesRead == sizeof(szBuffer)-1);
wchar_t* lpszBuffer = (wchar_t*)calloc(dwBytesRead+1, sizeof(WCHAR));
::MultiByteToWideChar(CP_ACP, 0, szBuffer, -1, lpszBuffer, dwBytesRead+1);
m_pSet->AddNew();
m_pSet->m_Nume="asas";
m_pSet->m_Serie=lpszBuffer;
CTime time = CTime::GetCurrentTime();
m_pSet->m_Data=time;
UpdateData(TRUE);
if (m_pSet->CanUpdate())
m_pSet->Update();
m_pSet->Requery();
UpdateData(FALSE);
m_pSet->Close();
m_pSet->Open();
Invalidate();
UpdateWindow();
}
serial.Close();
}
|
|
|
|
|
First, if you expect people to read that much code, for the love of god format it. Use the pre tag below this box.
Second, you already asked this question. David Crow gave you a good answer. Go read it.
Third, you should be trying to figure out if the bug is in your reading code or your string conversion code. Hence David's question.
earl
|
|
|
|
|
Hello all, by refering to article http://www.codeproject.com/internet/rpcintro1.asp, i was wondering if i allocate an memory at server side, the return the pointer.
// Server function.
const char* Server::Output()
{
m_pVar = new char[1024];
return m_pVar
}
m_pVar is Server class member. Server will delete m_pVar in its destructor. However, may I know once the Client receive the pointer,
// Client code
const char* m_pClientPointer = Output();
does client need to perform deletion on m_pClientPointer?
Thank you!
|
|
|
|
|
Hi All,
I am working on an application that allows the user to upload files on a FTP Server. Now when I use the code below to iterate through the files on the server I just get a '.' and nothing else.
BOOL bResult=true;
WIN32_FIND_DATA w32fdFtpFile;
HINTERNET hInetFindFile=::FtpFindFirstFile(hInetConn,"*.*",&w32fdFtpFile,0,0);
if(hInetFindFile !=(HINTERNET)NULL)
{
while(bResult)
{
bResult=::InternetFindNextFile(hInetFindFile ,&w32fdFtpFile);
}
}
InternetCloseHandle (hInetFindFile);
Can someone point out what I am doing wrong here.
Thanks for any help.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
change your filter to just * instead of *.* so you won't require a period somewhere in the name.
earl
|
|
|
|
|
Are there files in the folder opened by FtpFindFirstFile() ? Does the while loop run indefinitely, or just once?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Thanks for replying David. Yes there are files on the server.It shows me only one '.' and nothing else.Any suggestions on how I get all the files.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
_AnShUmAn_ wrote: Yes there are files on the server.
I did not ask if there were files on the server. I asked if there were files in a specific folder. Since you specified a relative path, rather than an absolute path, to FtpFindFirstFile() , you may very well be in a folder (i.e., CWD) that has no files.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi David,
Can you put some light on how can I set the path of the folder on the FTP Server whose files I want to display in my application
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Check out FtpSetCurrentDirectory() and FtpGetCurrentDirectory() .
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Thanks again David. I managed to get that working earlier.
Can you provide me a link on how could I set up a callback function for InternetStatusCallback. At present I am doing this way
hInetOpen = InternetOpen("MyFTPClient",INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,INTERNET_FLAG_ASYNC);
INTERNET_STATUS_CALLBACK inetStatusCallback =InternetSetStatusCallback(hInetOpen ,(INTERNET_STATUS_CALLBACK)InternetStatusCallback );
if(inetStatusCallback == INTERNET_INVALID_STATUS_CALLBACK)
{
CString szErrMsg;
szErrMsg.Format("%s: %d", "InternetData : InternetSetStatusCallback: ",GetLastError());
return false;
}
I am getting an error "type cast' : cannot convert from 'overloaded-function' to 'INTERNET_STATUS_CALLBACK'
"
Thanks.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
-- modified at 8:46 Friday 21st July, 2006
|
|
|
|
|
_AnShUmAn_ wrote: I am getting an error "type cast' : cannot convert from 'overloaded-function' to 'INTERNET_STATUS_CALLBACK'
"
You failed to indicate the offending statement. How is InternetStatusCallback() defined?
_AnShUmAn_ wrote: szErrMsg.Format("%s: %d", "InternetData : InternetSetStatusCallback: ",GetLastError());
GetLastError() returns a DWORD , not an int .
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
|
So which statement is the compiler complaining about?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Everything compiles fine. Just the callback function isn't called.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|