|
I have an application that handles the LVN_GETDISPINFO notification from a view ClistViewCtrl. The listview contents is in an array so I just call m_view.SetItemCountEx( m_Count, 0 ); to tell the listview how many rows I have and then handle all the icons and text when the listview sends a LVN_GETDISPINFO notification.
I wanted to go further and also store the state information in my array as well so the LVN_SETDISPINFO would be a great help there.
When I add the LVN_SETDISPINFO and LVN_ODSTATECHANGED notifications they never come up in the message map of the mainfram window. Is there anyone that knows why this is or have any tips on how to get information on how it should be done to make it work?
All input will be very appreciated.
I put some trace code in the message map but there is nothing about either the ANSI or UNICODE notification showing up. No message comes up in Spy++ either. There is probably something missing but I can not figure out what. I have not seen a working example of the LVN_SETDISPINFO so I have no reference.
When I try m_view.SetCallbackMask( LVIS_FOCUSED ); It seams to understand this because the focus has disappeared from the list, and if I also add the LVIS_SELECTED the selections also disappears unless I set the state my self in LVN_GETDISPINFO.
I have followed this group, searched the internet and been to MSDN and read in the help for CListViewCtrl, the only thing I found was about WM_NOTIFYFORMAT that I also put in.
Below is excerpts from the source.
Thanks in advance
Ulf
In the _tWinMain:
iccx.dwSize = sizeof(iccx);
iccx.dwICC = ICC_WIN95_CLASSES;
//iccx.dwICC = ICC_COOL_CLASSES | ICC_BAR_CLASSES | ICC_LISTVIEW_CLASSES;
BOOL bRet = ::InitCommonControlsEx(&iccx);
The definition of the ClistViewCtrl as follows:
typedef CWinTraits<ws_child |="" ws_visible="" ws_clipsiblings="" ws_clipchildren="" |ws_vscroll="" lvs_report="" lvs_showselalways="" lvs_singlesel="" lvs_shareimagelists="" |lvs_ownerdata,="" ws_ex_clientedge=""> LexinUpdateTraits;
class CLexinUpdateView : public CWindowImpl<clexinupdateview, clistviewctrl,="" lexinupdatetraits="">, public CCustomDraw<clexinupdateview>
{
public:
DECLARE_WND_SUPERCLASS(NULL, ListViewCtrl::GetWndClassName())
typedef CWindowImpl<clexinupdateview, clistviewctrl=""> winbaseClass;
BEGIN_MSG_MAP(CLexinUpdateView)
MESSAGE_HANDLER(WM_CREATE, OnCreate)
NOTIFY_CODE_HANDLER(HDN_ITEMCLICKA, OnHeaderClicked)
NOTIFY_CODE_HANDLER(HDN_ITEMCLICKW, OnHeaderClicked)
//CHAIN_MSG_MAP(winbaseClass)
END_MSG_MAP()
BOOL PreTranslateMessage(MSG* pMsg)
{
pMsg;
return FALSE;
}
The definition of the mainframe is as follows:
class CMainFrame : public CFrameWindowImpl<cmainframe>,public CUpdateUI<cmainframe>, public CMessageFilter, public CIdleHandler
{
public:
DECLARE_FRAME_WND_CLASS(NULL, IDR_MAINFRAME)
typedef CFrameWindowImpl<cmainframe> winbaseClass;
virtual BOOL PreTranslateMessage(MSG* pMsg)
{
if(CFrameWindowImpl<cmainframe>::PreTranslateMessage(pMsg))
return TRUE;
return m_view.PreTranslateMessage(pMsg);
}
public:
BEGIN_MSG_MAP(CMainFrame)
MESSAGE_HANDLER(WM_CREATE, OnCreate)
MESSAGE_HANDLER(WM_CLOSE, OnClose)
MESSAGE_HANDLER(WM_NOTIFYFORMAT, OnNotifyFormat)
NOTIFY_HANDLER(IDC_LISTVIEW,LVN_SETDISPINFO,OnSetdispinfoLexinview)
NOTIFY_HANDLER(IDC_LISTVIEW,LVN_GETDISPINFO,OnGetdispinfoLexinview)
NOTIFY_HANDLER(IDC_LISTVIEW,LVN_ODSTATECHANGED,OnODStateChangedLexinview)
CHAIN_MSG_MAP(CUpdateUI<cmainframe>)
CHAIN_MSG_MAP(winbaseClass)
END_MSG_MAP()
// Message handlers
LRESULT OnCreate( UINT, WPARAM, LPARAM, BOOL& );
LRESULT OnClose( UINT, WPARAM, LPARAM, BOOL& );
LRESULT OnNotifyFormat( UINT, WPARAM, LPARAM, BOOL& );
LRESULT OnSetdispinfoLexinview(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
LRESULT OnGetdispinfoLexinview(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
LRESULT OnODStateChangedLexinview(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
The list view is initialised as follows in the mainframe OnCreate():
m_hWndClient = m_view.Create(m_hWnd, rcDefault, NULL, 0, 0, IDC_LISTVIEW);
ATLASSERT(::IsWindow(m_hWndClient));
// Style must be set for edit labels and ownerdraw
m_view.SetExtendedListViewStyle( LVS_EX_FULLROWSELECT|LVS_EX_HEADERDRAGDROP|LVS_EX_INFOTIP );
m_view.InitImageList( IDB_LIST_STATES );
//m_view.SetCallbackMask( LVIS_FOCUSED|LVIS_SELECTED );
m_view.SetCallbackMask( LVIS_FOCUSED );
|
|
|
|
|
Hey Folks,
When doing a "malloc" what causes it to return NULL?
I have a customer who is using our product and the application fails because it is unable to create a buffer. This application ( a propritary db server ), uses quite a bit of memory (maybe 20-30 meg at a time)...
As a test, I wrote a simple while loop to see what it would take for "malloc" to fail.... I made near 800 calls to malloc ( 1meg ) before I got a NULL ptr.
What are some of the limits of memory an application can use considering virutal memory/paging etc..
Is there a function call I can use to see EXACTLY how much memory a process is using? (would implement this in the code to see if MAYBE we have a leak).
Any thoughts?
Mike
doner@obtain.com
|
|
|
|
|
When doing a "malloc" what causes it to return NULL?
The reason for malloc to return NULL is of course that the memory request could not be fulfilled. That can be caused by:- Having consumed so much memory that too little remains available,
- requesting an exceedingly large amount of memory (
nSize being too large), - the memory being too fragmented to allocate a contiguous chukn of memory the size requested, which could happen if your program does massive allocations/deallocations of chunks of various sizes and runs for a sufficiently long time.
What are some of the limits of memory an application can use considering virutal memory/paging etc..
The maximum amount of addressable virtual memory is 2GB (subtract some memory consumed by C run-time library and so). That means the maximum memory a process can ever expect to be able to allocate. When it comes to reality, the total amount available depends on the size of the swap file --your 800MB limit seems reasonable.
Is there a function call I can use to see EXACTLY how much memory a process is using? (would implement this in the code to see if MAYBE we have a leak).
GlobalMemoryStatus. Regards,
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
To accomplish smooth, fast graphics that don't flicker which is better, double buffering or private DC's?
Mark Lenz
|
|
|
|
|
I'm having a problem where it looks like I'm running out of device contexts. I have a control which looks kinda like a fuel guage. The value that the needle represents is updated about every second, so the needle must be redrawn about every second. I have about 4 or 5 of these controls in my view. When I have been displaying the view for about 3 minutes, things start to get weird. All of my fonts revert to a standard font and it starts to draw white where there was supposed to another color. This starts to affect the title bar, making it white. Sometimes it even starts to affect other applications.
Does anyone know what's happening and maybe what I could do to stop this?
I have looked everywhere, Google, MSDN, MSJ and mailing list archives, but I don't really know what's going on so I don't really know what to look for.
Thanks.
Mark Lenz
|
|
|
|
|
I bet you're on 9x, right? That usually means you've exhausted your process's GDI resources or filled the GDI heap (which is limited to 64K on 9x, due to 16-bit limitations). Are you making new GDI objects (pens, brushes, etc.) every time you paint your control? And if so, are you deleting those objects?
--Mike--
"COM didn't solve the old version of DLL hell - it just provided us with a new and improved version of hell."
-- John Simmons, 1/22/2002
My really out-of-date homepage
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan.
|
|
|
|
|
You're right, I am on Windows 98.
I have been using SaveDC() and RestoreDC(). I also declare all of my GDI objects that I will need in my OnPaint method at the beginning, so that they are all on the same scope. So, everytime the OnPaint() method is called I SaveDC() and create new GDI objects, use them, and when I'm done call RestoreDC() and the objects should be deleted when they go out of scope.
Am I doing this wrong?
Thanks.
Mark Lenz
|
|
|
|
|
As Mr. Dunn mentioned above, Windows 98 is very sensitive to resource leaks. However, you can usually detect when this is happening on Windows 2000 by using the task manager. Display the processes page, use the View->Select Columns menu to display the GDI Objects column, and watch the number for your application. If there is a constant increase while it is running, then you've detected the resource leak (this is safer than running the app in Win95/Win98, since resource leaks can cause those OSs to become unstable).
Once you can quickly identify the resource leak, modify your code by commenting out lines that create and use GDI resources, one at a time. In this way you should be able to identify which resources are not being released.
The method you're describing sounds like it should be working; however, because you're relying on automatic deletion of the objects there is no easy way to verify that it is successful. Inserting temporary DeleteObject() calls before the objects go out of scope might also be a good way to narrow down the search:
VERIFY(gdiObj.DeleteObject());
If this line ASSERT()s, then you've found a problem.
And if you can reduce your problem to a few lines of code (i.e.
<br />
CPen pen(PS_SOLID, 1, RGB(0,255,0));<br />
int nSave = dc.SaveDC();<br />
dc.SelectObject(&pen);<br />
VERIFY(dc.RestoreDC(nSave));<br />
VERIFY(pen.DeleteObject());<br /> ) then post it here, & someone will prolly figure it out.
farewell goodnight last one out turn out the lightsSmashing Pumpkins, Tales of a Scorched Earth
|
|
|
|
|
So, you're still making a lot of GDI objects, since you repaint the controls often. First thing I'd suggest is to move the GDI objects so they're memeber variables of the control classes, so that you only create the objects once.
And btw, the problem doesn't appear on 2000 because NT doesn't have the 16-bit limitations that 9x does.
--Mike--
"COM didn't solve the old version of DLL hell - it just provided us with a new and improved version of hell."
-- John Simmons, 1/22/2002
My really out-of-date homepage
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan.
|
|
|
|
|
I see the problem in Windows 98, but I can't duplicate it in Windows 2000.
Mark Lenz
|
|
|
|
|
Hi,
Does anybody know how to find out from the windows api's if a cdrom drive is a CDR/CDRW drive.
I have used GetDriveType( "D:" ) but this only shows that the drive is a CDROM.
Any ideas ??
Adrian
|
|
|
|
|
I don't know if this works, but perhaps you could try GetFileAttributes on the drive root and see if the directory is read-only?
/moliate
|
|
|
|
|
Hello,
I want export a class in a MFC dll...
class AFX_EXT_CLASS CMyClass : public CMyOtherClass // in other dll linked
{
...
};
and after build:
CMyClass.cpp(19) : warning C4273: CMyClass::CMyClass': inconsistent dll linkage. dllexport assumed.
CMyClass_MSA.cpp(28) : warning C4273: CMyClass::~CMyClass': inconsistent dll linkage. dllexport assumed.
Linking...
Creating library ...
MyClass.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) const CMyClass::`vftable'" (__imp_??_7CMyClass@@6B@)
I don't understand. Please, help me!
Thank you.
Friendly.
|
|
|
|
|
|
|
De poco sirve este enlace tronco.
Pure garbage!
Anybody fixed???
|
|
|
|
|
Hi Guys,
did somebody know how to list HTTP Directory.
Please Help its URGENT....
Thanx in advance
Best Regards
Sonu
|
|
|
|
|
How do I make a display window using visual C++ which shows OpenGL as a child to the application??
|
|
|
|
|
1.) Is MFC thread-safe by itself?
I played aruond with Joseph Newcomers (veryvery good) Queue-class and dicoverd, that it works fine without any syncs! So I used CLists directly in an MT-App and it works fine!
2.) Can I build a CDialogBAR from an in memory resource, a DLGTEMPLATE?
I prefer memorybased Dialogs then .rc-based one for several reasons and I wanna do so with DialogBars, too. Is it possible?
What do you think about DLGTEMPLATE-Dialogs at all, any pros or contras?
mfg HintiFlo
|
|
|
|
|
I've inherited a class CMyPrintDialog from CPrintDialog, and it's initialisation happens in OnInitDialog(). OnInitDialog is only called in the release version. In the debug version, the dialog remains uninitialised!
Does anyone know why?
Thanks
Jonnie
|
|
|
|
|
Woah, you mean that if you put a breakpoint inside the OnInitDialog function, it never stops there? The only possible explanation is that it's using another class. Check and make sure you don't already have a class with the same name defined somewhere else. I got bitten by this problem a long time ago -- redefining a class somewhere else with the same name. I don't remember why the compiler or linker never caught it, but it drove me nuts for a long time before I discovered it.
Regards,
Alvaro
|
|
|
|
|
I've run into this problem in the past; it appears to be either a bug in some versions of MFC, or small version differences: debug EXEs compiled (and working) on one developer's machine would fail to work on another. Installing the latest service pack fixed it for me. You might also try just re-installing the version you have (if you don't have access to the latest service pack, or have a slow internet connection for instance), but i can't say whether this will have any effect or not.
farewell goodnight last one out turn out the lightsSmashing Pumpkins, Tales of a Scorched Earth
|
|
|
|
|
Thanks for your help. It was an MFC bug fixed in the Visual Studio 6.0 Service Pack 1. Works like a dream now.
Jonnie
|
|
|
|
|
Hi,
I have the following code
WNDCLASS wc;
// Source window
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = NULL;//(WNDPROC)SourceWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;//UD_MAIN_WINDOW_EXTRA_BYTE;
wc.hInstance = A_hInst;
wc.hIcon = LoadIcon( A_hInst, MAKEINTRESOURCE(ICO_UMAXLOGO) );
wc.hCursor = LoadCursor( NULL, IDC_ARROW );
wc.hbrBackground = (HBRUSH) GetStockObject( LTGRAY_BRUSH );
wc.lpszMenuName = NULL;
wc.lpszClassName = kMAIN_WINDOW_CLASS; // define in TW_LAYOT.H
if( !RegisterClass( &wc ) )
return FALSE;
But RegisterClass() fails in windows 98.
Can anyone pl help me.
Neha
|
|
|
|
|
Apart from RegisterClassEx being a better function to use, what is the error returned from GetLastError when RegisterClass fails?
Michael
|
|
|
|
|