|
Thanks - although not quite what I was after, I'm now convinced I need some non standard STL stuff from STLPort to make it work the way I want. However, it only works if I make CWnd above CTraceWnd, can you tell me why STL cannot do the cast ?
Thanks.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
I have a CListCtrl derived class and I want to recieve notification when a user resizes the columns so I can make sure they dynamically resize and never have a scrolling portion. But none of my attempts to catch this message are working. I found an article that subclasses the CHeaderCtrl - is this the only way, or does anyone know of another way ? I just want tis one stupid message....
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
|
I know about the messages, but overriding them using class wizard does *nothing*. Or have I got something else wrong and am just blaming this ? I went into class wizard, chose HDN_TRACK, put an AfxMessageBox in there and started sliding the things about to try and get a response. I'm using a splitter SDI app.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
hmm... I just tried it with an Explorer-style app, handling the HDN_* messages in the list view, and it looks like ClassWizard has a bug. It makes ON_NOTIFY_REFLECT macros for the header messages, which is totally wrong. For example, change:
ON_NOTIFY_REFLECT(HDN_DIVIDERDBLCLICK, OnDividerdblclick) to
ON_NOTIFY(HDN_DIVIDERDBLCLICK, 0, OnDividerdblclick) The header control always has ID 0, that's the reason for the 0 above.
--Mike--
My really out-of-date homepage
Buffy's on. Gotta go, bye!
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan.
|
|
|
|
|
Thanks Mike, but I did this, handling the message in my CListCtrl derived class and changing the macro to ON_NOTIFY, inserting a 0 between the other two arguments. It is never called.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
I did something like this about 6 months ago, so my memory is a bit rusty.
This worked for me anyway, but with some flickering of the scrollbars (I never could figure out how to get a shot at resizing the headers before the listctrl tried to draw them)
Here's a skeleton of the code I used.
BOOL CNumbersListCtrl::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
NMHDR* pNMHDR = (NMHDR*)lParam;
HD_NOTIFY *phdn = (HD_NOTIFY *)lParam;
switch(phdn->hdr.code)
{
case HDN_BEGINTRACK:
{
TRACE(_T("CNumbersListCtrl::OnNotify -- HDN_BEGINTRACK Trapped\n"));
return(FALSE);
break;
}
case HDN_ENDTRACK:
{
TRACE(_T("CNumbersListCtrl::OnNotify -- HDN_ENDTRACK Trapped\n"));
if (phdn->iItem == 0)
{
TRACE(_T("CNumbersListCtrl::OnNotify -- Resising right to fit\n"));
}
else if (phdn->iItem == 1)
{
TRACE(_T("CNumbersListCtrl::OnNotify -- Resising left to fit\n"));
}
break;
}
}
return CListCtrl::OnNotify(wParam, lParam, pResult);
}
|
|
|
|
|
Thanks, but this did not work. Right now I am doing this in OnNotify:
GetAsyncKeyState(VK_LBUTTON);
if (GetAsyncKeyState(VK_LBUTTON) && 4294967284 == pnmh->code)
{
CRect rc;
GetClientRect(&rc);
SetColumnWidth(1, rc.Width() - GetColumnWidth(0));
}
if I change that big number to HDM_ITEMCHANGINGA, HDM_ITEMCHANGEDA, or the W equivelants ( or drop the A or W ) it either does nothing or crashes. I am certain the two messages I get are ITEMCHANGED and ITEMCHANGING. The HDM_TRACK message is a phantom - it is NEVER sent ASAIK.
I've tried several things and in the end I've concluded that CListCtrl is rubbish. It works for me as it stands, although it flickers and jumps when the mouse button is raised. I'm interested if you have any comments.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
Christian Graus wrote:
Thanks, but this did not work. Right now I am doing this in OnNotify:
Ok. I remeber that I had alot of trouble catching the HDN_BEGINTRACK, not to mention the HDN_TRACK (AFAIR I never got it). I know I got the above code to work and Ive glanced through the rest of the code to see if I did anything special somewhere else, but I cant find anything suspicious. Also, that project was for WinCE, but the page that explained how to catch the header notification was for the desktop so I assumed it would work there too. I wish I still had that link, but it was like 6 months ago so it probably went in the trashbin some time ago. Ill do a bit of research after work today and post here if I find anything usefull.
Christian Graus wrote:
and in the end I've concluded that CListCtrl is rubbish.
So true.
|
|
|
|
|
I did some testing yesterday. I create a subclassed CListCtrl in a childview and the only extra stuff I have is this in OnNotify (see below). It keeps the total column width to 240 the whole time and doesnt flicker at all (as opposed to the CE version of CListCtrl, which decides to draw the bottom scrollbar each time before I get a chance to resize the columns)
The only diffrence with this and the earlier version is that I look for HDN_xxxA and HDN_xxxW instead of just HDN_xxx.
Let me know if you still cant get it to work.
BOOL CNumbersListCtrl::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
HD_NOTIFY *phdn = (HD_NOTIFY *)lParam;
switch(phdn->hdr.code)
{
case HDN_BEGINTRACKA:
case HDN_BEGINTRACKW:
{
TRACE(_T("CNumbersListCtrl::OnNotify -- HDN_BEGINTRACK Trapped\n"));
SetRedraw(false);
return(FALSE);
break;
}
case HDN_ENDTRACKA:
case HDN_ENDTRACKW:
{
int windowsize = 225;
TRACE(_T("CNumbersListCtrl::OnNotify -- HDN_ENDTRACK Trapped\n"));
SCROLLINFO si;
if (GetScrollInfo(SB_VERT, &si))
{
if ((int) si.nPage <= (si.nMax-si.nMin))
windowsize = 225;
else
windowsize = 240;
}
else
windowsize = 240;
if (phdn->iItem == 0)
{
int left = phdn->pitem->cxy;
TRACE(_T("CNumbersListCtrl::OnNotify -- Resize right to fit\n"));
SetColumnWidth(1, windowsize - left);
}
else if (phdn->iItem == 1)
{
int right = phdn->pitem->cxy;
TRACE(_T("CNumbersListCtrl::OnNotify -- Resize left to fit\n"));
SetColumnWidth(0, windowsize - right);
}
SetRedraw(true);
Invalidate();
break;
}
}
return CListCtrl::OnNotify(wParam, lParam, pResult);
}
|
|
|
|
|
Thanks - I had tried this but it just bombed out when I handled these messages. I'll have a look at this code to see what I was doing wrong.
I was actually trying to catch TRACKA and TRACKW though, I'm starting to think these are never sent.
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
You're right, it doesn't work.
The way I get tracking notifications is by subclassing the header control of the list control in a user defined control and then adding handlers in that sub-classed control.
BEGIN_MESSAGE_MAP(CMyHeaderCtrl, CHeaderCtrl)
ON_NOTIFY_REFLECT(HDN_BEGINTRACKA, OnHdnBegintrack)
ON_NOTIFY_REFLECT(HDN_BEGINTRACKW, OnHdnBegintrack)
ON_NOTIFY_REFLECT(HDN_ENDTRACKA, OnHdnEndtrack)
ON_NOTIFY_REFLECT(HDN_ENDTRACKW, OnHdnEndtrack)
END_MESSAGE_MAP()
void CMyHeaderCtrl::OnHdnBegintrack(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMHEADER phdr = reinterpret_cast<LPNMHEADER>(pNMHDR);
*pResult = 0;
}
void CMyHeaderCtrl::OnHdnEndtrack(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMHEADER phdr = reinterpret_cast<LPNMHEADER>(pNMHDR);
*pResult = 0;
}
As you can see CMyHeaderCtrl is derived from CHeaderCtrl and is recieving all notification messages related to tracking.
I guess I don't need to explain how to subclass the header control to you. Here is what I used..
CDlg::OnInitDialog()
{ ...
m_MyListCtrl.InsertColumn(0, "First");
m_MyListCtrl.InsertColumn(1, "Second");
CHeaderCtrl* pHeaderCtrl = m_MyListCtrl.GetHeaderCtrl();
ASSERT_VALID(pHeaderCtrl);
if(pHeaderCtrl && pHeaderCtrl->GetSafeHwnd())
VERIFY(m_MyHeaderCtrl.SubclassWindow(pHeaderCtrl->m_hWnd));
...
}
Hope this helps.
Regards.
// Fazlul
Get RadVC today! Play RAD in VC++
http://www.capitolsoft.com
|
|
|
|
|
I just noticed the angle brackets were eaten up by CP script.
void CMyHeaderCtrl::OnHdnBegintrack(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMHEADER phdr = reinterpret_cast< LPNMHEADER >(pNMHDR);
*pResult = 0;
}
void CMyHeaderCtrl::OnHdnEndtrack(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMHEADER phdr = reinterpret_cast < LPNMHEADER > (pNMHDR);
*pResult = 0;
}
// Fazlul
Get RadVC today! Play RAD in VC++
http://www.capitolsoft.com
|
|
|
|
|
Thanks - I've done this, but it doesn't seem to send any message during a tracking operation ( tried TRACKA and TRACKW ), only before and after.
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
Well, it actually worked on my system. Let me zip the test project and send that to you.
// Fazlul
Get RadVC today! Play RAD in VC++
http://www.capitolsoft.com
|
|
|
|
|
Thanks for the email, but I'm afraid I've not made myself clear. I get BEINGTRACK and ENDTRACK variants, but I can't get a message *during* the tracking operation.
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
I see what your're getting at. Perhaps I got confused with BEGIN and END track messages I saw in several replies.
I did some quick test using message trapping option of Spy++, and it seems that HDN_TRACK is not caught. However I saw HDN_ITEMCHANGINGW notification as I changed the sizes of header items. Thus I guess you can use that as a workaround. Here is the quick code I wrote:
BEGIN_MESSAGE_MAP(CMyHeaderCtrl, CHeaderCtrl)
ON_NOTIFY_REFLECT(HDN_BEGINTRACKA, OnHdnBegintrack)
ON_NOTIFY_REFLECT(HDN_BEGINTRACKW, OnHdnBegintrack)
ON_NOTIFY_REFLECT(HDN_ENDTRACKA, OnHdnEndtrack)
ON_NOTIFY_REFLECT(HDN_ENDTRACKW, OnHdnEndtrack)
ON_NOTIFY_REFLECT(HDN_ITEMCHANGINGW, OnHdnItemChanging)
ON_NOTIFY_REFLECT(HDN_ITEMCHANGINGA, OnHdnItemChanging)
END_MESSAGE_MAP()
void CMyHeaderCtrl::OnHdnItemChanging(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMHEADER phdr = reinterpret_cast<LPNMHEADER>(pNMHDR);
*pResult = 0;
}
Let me know if it helps.
// Fazlul
Get RadVC today! Play RAD in VC++
http://www.capitolsoft.com
|
|
|
|
|
I have keyboard hook installed in my app, when my parent window is visible it works just fine to press the specific key that do something, but when I press the Hide button in my parent window to hide the parent window and then try to press the same key it KERNEL32.DLL crash!
I have two keys that are "hooked"... one of them works but not the other. That one that works is to sjow the parent window... hm.. confusing isn't it?
Kernel32 isn't that the file that has to do with the user inputs?
so, is it my CALLBACK for the keyboard hook?
------------------------------
©0d3 ©®4©k3® - That's me!
------------------------------
|
|
|
|
|
I've found something interesting!
When the app is visible and has FOCUS it works fine with both keys, but when it's no FOCUS.. it crashes!!
hmmm
------------------------------
©0d3 ©®4©k3® - That's me!
------------------------------
|
|
|
|
|
where is your callback declared ?
I assume that it is located in your program.
to make a global hook, the callback must be placed in a dll.
|
|
|
|
|
You got it!
I've just tried it and now it works!!
THANKS!
------------------------------
©0d3 ©®4©k3® - That's me!
------------------------------
|
|
|
|
|
I've developed a little systray app using the SystemTray and Wininet wrappers here, but it's memory usage appears to be way more than it should. By using NT4's Task Manager, it's using 3444k, and other programs (like Apache, an FTP client, and Cacheman) use way less (<1mb!). The only program that comes close in memory usage is my web browser!
Any ideas on how to optimize its memory usage? I applied a bunch of exe size optimizations from the tips section, and got my size down to 26.5k, and now I want to un-bloat its memory usage.
|
|
|
|
|
|
Ok, so size doesn't matter; I still want to know why, out those 20+ processes, mine is by far the biggest (not counting the web browser)!
|
|
|
|
|
The size that you see in Task Manager is the size of all the DLLs that are mapped in your address space. You've said that it is a SysTray app, that maps SHELL32.DLL into your space - that is 2.5MB right there. You use WININET.DLL that is 500K more. If you use MFC that is another 1MB. KERNEL32.DLL 700+K, NTDLL.DLL 500K. Look at Dependency Walker and see all the DLLs that are being used by your program. All those other programs you are talking about obviously do not use that many DLLs for one reason or the other.
|
|
|
|
|