|
Are you by chance defining your CompareFunc function inside some namespace or class? I've tried to replicate your problem but everything works fine (i.e. CListCtrl::SortItems merrily accepts ::CompareFunc .) Could you post a little more code to see the thing in context?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I am getting a nagging feeling that I have misunderstood something totally wrong here...
This the file with the middle part snipped:
int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
// don't take this part seriously
if (lParam1 > lParam2) {
return -1; }
else {
return 0; }
}
// WsInfoView.cpp : implementation of the CWsInfoView class
//
#include "stdafx.h"
#include "WsInfo.h"
...yadda yadda yadda....
and then the ending of the file:
void CWsInfoView::DoFullList()
{
CListCtrl& ctlList = GetListCtrl();
ctlList.SetExtendedStyle(LVS_EX_GRIDLINES);
<snipped inserting="" items="" into="" the="" report="" view="">
ListView_SortItems(
m_hWnd,
::CompareFunc, 0);
}
CompareFunc is visible in MSVC6++ as "globals"
|
|
|
|
|
Ummm... You have defined CompareFunc at the very beginning of WsInfoView.cpp ? If so, please try moving it after the #include s.
I agree with you that the thing should work, but as it doesn't there's no option but to look for the unlikely.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thank you! It worked after I moved the CompareFunc
after #include "stdafx.h". I dunno why but it did!
I also had time to try that Microsoft example and I
(since I placed the functions the same way as earlier)
got the same error message.
Now I can go and eat in peace!
|
|
|
|
|
Well, the reason for this strange behavior is the manner in which VC++ manages precompiled headers (like "stdafx.h" ). For some reason, it seems to ignore everything that comes before the precompiled header inclusion. I think this is even a documented glitch.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I want to use #pragma warning().But where can I find the corresponding warning specifier?
Thx ahead.
|
|
|
|
|
Here's a complete list of VC++ compiler errors and warnings.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi,
I am designing and developing a voice and telephony related project with C programming and TAPI 2.0. I need a voice modem and use this modem to make a phone call. My question is as follows.
After I make a phone call, how, can I know somebody already "picks up" the phone call ? I need to know when or if somebody picks up the phone because my program needs to do audio playback on the phone.
Any response would be appreciated !
|
|
|
|
|
I guess you initiated the call with lineMakeCall . If so, after this function returns providing an HCALL for the call, the callback function the program registers with lineInitialize will start receiving notifications about the progress of the call. The connection establishment is signaled by the LINE_CALLSTATE message with call state param LINECALLSTATE_CONNECTED .
If you're new to TAPI programming you may want to have a look at Michael Dunn's TAPI site (this Michael Dunn is not the Michael Dunn from CP, I think.)
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks ! Your response really helps !!
|
|
|
|
|
A lot depends on the capabilities of your modem. Most modems send a Connected Call State as soon as they connect and the other end starts ringing, not when the person answers at the other end.
Michael
|
|
|
|
|
Hi.
I would like to create a custom class exception handler. I want to use it for arbitrary exceptions that are not part of the exception library.
I am having a problem with such a class. Here is the code for that exception class.
-----
#ifndef CEXCEPTIONHANDLE_H
#define CEXCEPTIONHANDLE_H
class ExceptionHandle
{
public:
ExceptionHandle(const char *error) : eMessage(error) {}
const char *what() const throw()
{
return eMessage;
}
private:
const char *eMessage;
};
#endif
-----
I basic want to *throw* a character string to the exception handle. Afterward, have a catch function to call what().
Here is an example of a try/catch.
----
try
{
function(x);
}
catch (ExceptionHandle *e)
{
cerr << e->what();
}
-----
function(int X)
{
if (X == 0)
throw ExceptionHandle("Error: X equals zero.");
}
-----
The program I am working on works, but it crashes whenever "throw ExceptionHandle("Error: X equals zero.");" occurs.
Does anyone know what is wrong with my design and/or implementation?
Thanks,
Kuphryn
|
|
|
|
|
I'm just guessing here, but a simple problem is the fact that you're storing a const char pointer in your exception class.
Regardless of the throw/catch stuff, when you call the exception constructor with the static text, all you're doing is setting your char * to point to the start of the "Error: X equals..." stuff. As soon as that goes out of scope, the memory allocated to the string is destroyed, and your const char * in the exception class will point at garbage.
Instead, either create a new char buffer and copy the string into it, or use a CString instead (it will keep a copy of the string for later use):
class ExceptionHandle
{
public:
ExceptionHandle(const char *error) : eMessage(error) {}
const char *what()
{
return (LPCTSTR)eMessage;
}
private:
CString eMessage;
};
------------------------
Derek Waters
derek@lj-oz.com
|
|
|
|
|
Okay. Thanks.
Oluseyi mentioned something about added "const throw()" to the constructor and derived it from exception.
I will try that and use a string instead of char * tomorrow.
I will post an update.
Kuphryn
|
|
|
|
|
Although the objection posed by Derek is IMHO a valid one, it is not what is causing the problem in your particular example. function throws an ExceptionHandle , whereas the catch block accepts a pointer to ExceptionHandle : thus it is not catching the exception thrown by function . Replace the exception handler with
catch (ExceptionHandle& e)
{
cerr << e.what();
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Okay. Thanks.
I believe the problem was due to these pointer related calls:
-----
const char *eMessage
-----
and/or
-----
catch (ExceptionHandle *e)
-----
I will do two things.
1) I will replace "const char *eMessage" with "const string eMessage."
2) I will replace "catch (ExceptionHandle *e)" with "catch (ExceptionHandle &e)."
First, is the problem caused by "*e" pointing to something that no longer exists? How can that be if I am throwing an exception each time?
I can also add "new" to "throw...new."
-----
throw new ExceptionHandle("test");
-----
Which ones of these changes should *fix* the problem most elegantly?
Thanks,
Kuphryn
P.S. A member at Gamedev mentioned about deriving exception classes from the *exception* library. How important is that?
|
|
|
|
|
In my MFC MDI App, I need to keep the pointer to the CFile object from CArchive in CMyDocument::Serialize (my override). This pointer must point to a valid object after the exit from Serialize, hence the use of a member variable to hold the CFile * returned from CArchive::GetFile()->Duplicate().
My question is: when my CMyDocument object is destroyed, what do I do with the CFile * I hold in my class.
Logically, I would flush the file and close it. closing it poses no problem, but the flush throws an exception. What do I do with the pointer? Do I call
delete on it?
Is there a more elegant way doing this?
Tx
Michel
|
|
|
|
|
Michou wrote:
My question is: when my CMyDocument object is destroyed, what do I do with the CFile * I hold in my class.
Don't do anything. The CFile object gets destroyed along with the CArchive object. What you have is a duplicarte pointer. Internally it uses _dup I believe, to get an additional handle.
Nish
CPUA # 0x0666
Sonork ID 100.9786 voidmain
www.busterboy.org
|
|
|
|
|
Hi,
I would like to know if anyone knows a good link to an article or a tutorial that would explain how to create an AppWizard.
// JS Paquet
cout << "Thank you all" << endl;
|
|
|
|
|
I think the MSDN cd kit that came with VC 6 had an example appwizard.
- Matt Newman
-Sonork ID: 100.11179:BestSnowman
Frankly AOL should stick to what it does best: Fooling millions of americans into believing that it, AOL, is the web. -Paul Watson
|
|
|
|
|
I want to write an ActiveX shim for a Netscape-style plugin; however, I cannot locate the plugin code Plugins apparently do not contain a type library so #import doesn't work. Can anyone with some experience accessing a plugin dll from C++ give me a tip as to how to accomplish this or point me to some documentation?
David Ness
|
|
|
|
|
I want to create, show, and delete various CWnd or CWnd derived Windows:
<br />
void MyFoo(CRuntimeClass *pWndClass,...)<br />
{<br />
<br />
CWnd* pWnd = pWndClass->CreateObject();<br />
pWnd->Create(..);
...<br />
pWnd->ShowWindow(SW_SHOW);<br />
...<br />
pWnd->DestroyWindow();
delete (pWnd)
}<br />
pWnd can be any type of windows (e.r., CDialog, CFormView, CView,...). The problem is: if pWnd is a dialog or CDialog-derived object, it works ok. But if pWnd is derived from CView or CWnd but not from CDialog, the delete statement in the above function doesn't work with an error message as access denied (0xc0000005). So why doing that?
//
|
|
|
|
|
CView objects delete themselves using a delete this
So you should not delete CView and CView derived classes.
I am confused about your CWnd problem though.
Nish
CPUA # 0x0666
Sonork ID 100.9786 voidmain
www.busterboy.org
|
|
|
|
|
Do you mean that every CView type class dynamically created should be deleted by itself within its class?
In my original example, the pWnd has a valid memory address, but the members of pWnd are not "valid", e.g., pWnd->hWnd = 0xddddddddd. I don't know how comes that.
|
|
|
|
|
Hi,
could you please answer a simple question:
my view shows initially grayed (not active) vertical and horizontal scrollbars, and I only want the first one.
I tried
BOOL CMyEditView::PreCreateWindow(CREATESTRUCT& cs)
{
cs.style &= ~WS_HSCROLL;
return CEditView::PreCreateWindow(cs);
}
but the horizontal scrollbars stayed.
How can I get rid of them?
Thanks
R.
|
|
|
|