|
Hello,
I am new to this forum, so howdy!
I am using Visual C++ 6.
I have a weird problem with SetItemText when trying to use multiple CListCtrls.
I have mail that I am reading from a POP3 server and trying to put it in separate CListCtrls based on certain mail header entries.
Here is a snippet of code that is causing the problems:
<snip>
for (msg_num=1;msg_num<=num_msgs;msg_num++)
{
cmsg_num.Format(_T("%d"), msg_num);
POP_messages[msg_num].pop_num = msg_num;
POP_messages[msg_num].msg_num = msg_num;
if (m_pop3handle.GetMailSubject(msg_num, &msg))
{
if (strcmp(classified,"Ham") == 0) {
POP_messages[msg_num].Subject = msg;
m_listHam.InsertItem(nItem,(LPCTSTR)msg);
} else {
POP_messages[msg_num].Subject = msg;
m_listSpam.InsertItem(nItem,(LPCTSTR)msg);
}
}
else
{
m_pop3handle.GetLastError(&msg);
m_edtMsg += msg+"\r\n";
}
if (m_pop3handle.GetMailSender(msg_num, &msg))
{
if (strcmp(classified,"Ham") == 0) {
POP_messages[msg_num].From = msg;
m_listHam.SetItemText(nItem,1,(LPCTSTR)msg);
} else {
POP_messages[msg_num].From = msg;
m_listSpam.SetItemText(nItem,1,(LPCTSTR)msg);
AfxMessageBox((LPCTSTR)msg);
}
}
else
{
m_pop3handle.GetLastError(&msg);
m_edtMsg += msg+"\r\n";
}
if (strcmp(classified,"Ham") == 0) {
m_listHam.SetItemText(nItem,2, (LPCTSTR)cmsg_num);
m_listHam.SetItemText(nItem,3, "");
} else {
m_listSpam.SetItemText(nItem,2, "");
m_listSpam.SetItemText(nItem,3, "");
}
nItem++;
} // End for (msg_num=1;msg_num<=num_msgs;msg_num++)
<snip>
Now the problem is, that all the InsertItem calls get set properly, but only the SetItemText values for the first row get set. That is, none of the other rows get values set in the second and third columns.
The MessageBox show valid data coming through the msg variable, but SetItemText is not successful (i.e,returns 0).
Anybody ever seen a problem like this?
Now, if I let everything come into a single CListCtrl, then all the SetItemText calls return successfully and values are placed in the
second and third columns.
Another weirdness is that is I double up on the InsertItem statements, i.e.,
<snip>
if (strcmp(classified,"Ham") == 0) {
POP_messages[msg_num].Subject = msg;
m_listHam.InsertItem(nItem,(LPCTSTR)msg);
m_listHam.InsertItem(nItem,(LPCTSTR)msg);
} else {
POP_messages[msg_num].Subject = msg;
m_listSpam.InsertItem(nItem,(LPCTSTR)msg);
m_listSpam.InsertItem(nItem,(LPCTSTR)msg);
}
<snip>
then I get a row as before, with data in just the first column, followed by a row with data in all three columns, where the first column entry is the same as the previous row.
That is, I get something like the following:
<subject>
<subject> <email address=""> <msg num="">
<subject>, <email address="">, and <msg num=""> actually have values.
Any help would be greatly appreciated. Please reply via email also.
Thanks,
Murrah
otrcomm@isp-systems.com
|
|
|
|
|
Hi guys,
I want to know that how i can send and recieve messages to msn online users through my own program. For this, i was reading Microsoft RTC, but i haven't found any solution yet. Does RTC provide the mechanism of communication with msn online users? if not then what would be the solution ?
Common Man
|
|
|
|
|
Either use the COM API of MSN
or implement the protocol yourself
an example is here[^]
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Hi all,
I was thinking of starting my own little project, and, well... it looks like I don't know where to begin.
Well, actually, I kind of do: I can handle the UI part of it and some other parts too, but there are still a few very essential pieces missing. Namely:
* Opening a video file (AVI or MPEG) or an audio file (MP2, MP3, AVI, MPEG, WAV etc) for reading and finding out its format
* Loading the next frame from the opened video file
* Seeking to a specific frame and loading it
* Opening a video or an audio file for writing
* Letting the user choose codecs for the output file
* Saving a frame and/or audio data into an opened file
The main idea is to hide all the complexity of handling video files behind a simpler construct (e.g. data sources and streams). Once that I get to that level of abstraction, it will be easy to write UI and processing because I wouldn't have to worry about details.
So... that said, I am having trouble finding any tutorials or code examples that will get me started. There are quite a few DirectX tutorials on the 'Net, for example, that walk you through the basic tasks and give you the code to work with. MSDN is all good and nice, but it's not exactly the best resource for a beginner.
Now the question is... does anybody know of any tutorials, FAQs, sample code or anything else that could help me?
Thanks
M.C.
|
|
|
|
|
M.C. wrote:
MSDN is all good and nice, but it's not exactly the best resource for a beginner.
Beginner of what?
C++ ?
Windows development?
Multimedia programming?
DirectX development?
You are not likely to find any articles or examples anywhere for a specific API that targets a beginner C++ developer. Conversely, for an experienced C++ Windows developer the MSDN information on DirectX APIs should be all one needs to get started.
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
Beginner in multimedia programming. I have the rest covered reasonably well.
As for MSDN: Had I found it to be "all I need", I wouldn't have posted here. You are right, it's good as a resource for people who already know where to begin. For those who don't, such as myself, it's a highly confusing chaos of information, both relevant and irrelevant to what I need. The end result is that I need a starting point in the form of tutorials and sample code, which brings me to my original post.
M.C.
|
|
|
|
|
DirectShow
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Hm. Interesting...
Can it be used for both encoding and decoding, or is it for decoding only?
|
|
|
|
|
I suspect both, but I've only used it to decode, to give me specs on mp3's.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Very interesting. I think this is about as close as I can get to what I need... who would've thought Microsoft would do something right, eh? (Er... wrong forum for this kind of remark I guess. Oops )
Anyway, thanks for your help.
M.C.
|
|
|
|
|
Dear developers,
I am a newbie in visual C++ and windows programming. I need to make an application that run as a background process and probaly there is no GUI involved. Anybody can give me some pointers?
And also I would like to know, how you make an application that stays in Windows task bar? (at the right side of windows task bar, like yahoo messenger, msn messenger, etc.)
Many thanks,
Wayut
|
|
|
|
|
pointer 1) Use the "Search button at CodeProject and http://msdn.microsoft.com
pointer 2) For background process research "NT Service"
pointer 3) For Tray Icon in task bar research Shell_NotifyIcon()
-pete
|
|
|
|
|
This is the exact information I'm looking for.
Thank you,
Wayut
|
|
|
|
|
|
probably the easiest way to do run it as a process is this one:
for a win32 api.
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
while (true)
{
}
return 0;
}
to hide it to tray you have to make more steps:
NOTIFYICONDATA niData;
HINSTANCE hInst;
#define SWM_ENABLED WM_APP + 1 //
#define SWM_EXIT WM_APP + 2 // close the window
BOOL bEnabled = FALSE;
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow);
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// Perform application initialization:
if (!InitInstance (hInstance, nCmdShow)) return FALSE;
// Main message loop:
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int) msg.wParam;
return 0;
}
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
// store instance handle and create dialog
hInst = hInstance;
HWND hWnd = CreateDialog( hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, (DLGPROC)fereastra );
if (!hWnd) return FALSE;
// Fill the NOTIFYICONDATA structure and call Shell_NotifyIcon
ZeroMemory(&niData,sizeof(NOTIFYICONDATA));
niData.cbSize = sizeof(NOTIFYICONDATA);
niData.uID = 1;
niData.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
niData.hIcon = (HICON)LoadImage(hInstance,MAKEINTRESOURCE(IDI_ICON1),
IMAGE_ICON, GetSystemMetrics(SM_CXSMICON),
GetSystemMetrics(SM_CYSMICON),LR_DEFAULTCOLOR);
strcpy(niData.szTip, "Tray Icon");
niData.hWnd = hWnd;
niData.uCallbackMessage = WM_APP;
// Add icon to tray
Shell_NotifyIcon(NIM_ADD, &niData);
// free icon handle
if(niData.hIcon && DestroyIcon(niData.hIcon))
{
niData.hIcon = NULL;
}
return TRUE;
}
gabby
|
|
|
|
|
I am curious if the following procedure is either not possible or if I am doing it wrong.
I have the following declaration for a list
<br />
CList<CEraCls, CEraCls&> m_List;<br />
in my implementation class I run the following command
<br />
CEraCls pEra = FindEra(EraString);<br />
m_List.Find(pEra);<br />
I get a compile errror in <afxtempl.h> warning me about this function
<br />
template<class TYPE, class ARG_TYPE><br />
BOOL AFXAPI CompareElements(const TYPE* pElement1, const ARG_TYPE* pElement2)<br />
{<br />
ASSERT(AfxIsValidAddress(pElement1, sizeof(TYPE), FALSE));<br />
ASSERT(AfxIsValidAddress(pElement2, sizeof(ARG_TYPE), FALSE));<br />
<br />
return *pElement1 == *pElement2;<br />
}<br />
where the return statement at the end has an issue
binary '==' : no operator defined which takes a left-hand operand of type 'const class CEraCls(or there is no acceptable conversion)
Does anyone see what the issue might be? I thought I could use Find in this fashion. Is this not correct?
Thanks!
|
|
|
|
|
You'll have to overload the "==" operator for your class CEraCls, which does the comparing. After you overloaded the operator, the code should compile just fine.
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|
|
overloading with the following code produced no change in compile results.
bool CErasCls::operator ==(const CErasCls &Array)
{
if( m_Code == Array.m_Code &&
m_Description == Array.m_Description &&
m_Synopsis == Array.m_Synopsis)
return true;
else
return false;
}
|
|
|
|
|
the operator== takes 2 parameters:
<br />
bool operator==(const CEraCls &lhs, const CEraCls &rhs)<br />
{<br />
}<br />
And the overloadeded operator doesn't need to be a member of the class (I don't think it does matter though).
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|
|
I thought of that and that didn't work either , however the following solution DID work.
<br />
bool operator==(const CEraCls &pCopy) const<br />
{<br />
}<br />
go figure.
thanks for the tip though.
|
|
|
|
|
hi,
can someone please explain me with simple words whats the diffrence between CxxxDoc and CxxxView?
Help please...
Avi.
|
|
|
|
|
The class CxxxDoc contains information used by CxxxView.
The CxxxView (often called just "view" or GUI) is the window that a user can actual see.
The CxxxDoc (often called "document") is the class where the data is stored. The document class is also used for serialisation.
If you want to know more about the MFC Doc/View architecture, I suggest you read some articles about it.
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|
|
ok, i read and understood the architechture...
but now i have more complicated question (plz help...) -
if i want to query a table from a DB,
should the query operation be at the CxxxDoc and the query results should be shown by the CxxxView?
thanks again, Avi.
|
|
|
|
|
Yes, that's the best solution .
|
|
|
|
|
how do i transfer data from CxxxDoc to CxxxView?
Avi
|
|
|
|
|