|
I have a WTL project based on the ClistViewCtrl class. I’m trying to left mouse button down to select an item in the list. The NM_CLICK is supposed to respond to LmouseDown, but doesn’t..The MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown) does but the call GetSelectedIndex() (in ..\atlctrls.h) returns xFFFFFFFF. Not what I expect. Any suggestions ? Also what should I cast the lparam to in the message handler?
|
|
|
|
|
Hey,
I'll assume you tring to handle all the message you mentioned in your list-view control.
First to get the NM_CLICK notification to work (as well as any other notification) you need to reflect the notifications back from the mainframe (this is a standard procedure, thought MFC does a nice job of hidding it from us). To do this use the REFLECT_NOTIFICATIONS () macro in you mainframe's message map (or what ever window is the list-view's parent). Also, when you handle the message use REFLECTED_NOTIFY_CODE_HANDLER in you list-view message map.
Second the reason I think your getting a wrong result from GetSelectedIndex () in your WM_LBUTTONDOWN message handler is because you are probably not letting Windows do its default processing (selecting the item), simply make call to DefWindowProc () before you try and get the selected item's index -- also note that this function only works with single selection list-views.
> Also what should I cast the lparam to in the message handler?
no need to cast, just use:
CPoint point ( GET_X_LPARAM ( lParam ), GET_Y_LPARAM ( lParam ) );
Hope this helps.
-Ben
"Its funny when you stop doing things not because they’re wrong, but because you might get caught." - Unknown
|
|
|
|
|
Here's something that has always bugged me -
Say we have a context menu that pops up when an item in a tree or list view is right-clicked. The command for that item is sent.. somewhere, say to the main window. How can I associate that command with the item that spawned it? There's no room in the command message for any kind of handle to the item, item ID, or anything like that.
I've done this before on smaller apps, and have used various kludges (space the commands properly and add an item ID to the command number, etc.) but I'm never happy with the solutions I come up with. Does anyone have a suggestion?
|
|
|
|
|
In my code, the command message handlers just retrieve the selected item in the control. Simple, eh?
--Mike--
http://home.inreach.com/mdunn/
#include "buffy_sig"
|
|
|
|
|
Umm guess that was a stupid question, wasn't it . Of course that works. In my own defencse, I was thinging back on another, similar project, where I had something much more complicated to do. the weight of my esperience is starting to slow me down .
Thanks for the help -
|
|
|
|
|
Umm guess that was a stupid question, wasn't it
No no no, it was an easy question. Big difference.
--Mike--
http://home.inreach.com/mdunn/
#include "buffy_sig"
|
|
|
|
|
When you minimize an application, a huge amount of memory is decommited back to the system (You can check this with the Windows Taskmanager)... Does anyone know how to force this inside the application, without minimizing the mainwindow ?
|
|
|
|
|
_heapmin() can do this to a degree. As far as I know it is the only way to release memory back to the OS in Win32.
|
|
|
|
|
SetProcessWorkingSetSize. Available on NT/2K only.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
Thank you very much, the both of you for making time... You soulved a huge problem I was struggling with... Thankx
|
|
|
|
|
Is there a standard method for opening a file with it's default/associated file opener?
One has, for instance, the path to "C:\mytxt.doc" and wants to use the user-defined viewer (usually Word) to open this without having to check the configurated association tables
Thanx.
Per Pusling
|
|
|
|
|
Check ShellExecute and ShellExecuteEx.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
Yep, ShellExecute() does just this. Pass your document filename, and a verb of "open" and the API will launch the associated program.
--Mike--
http://home.inreach.com/mdunn/
#include "buffy_sig"
|
|
|
|
|
Hello everyone,
I'm trying to do a file search from my application, So I was wondering if there is a way to employ windows File Search (Start -> Find -> File or Folder) functionality through any kind of APIs
Thanks in advance for your help.
Fady
|
|
|
|
|
Do you need to use the CFileFind class
or the FindFirstFile function.
Look in the MSDN into Api reference\FileI/O\Functions.
Carlos Antollini.
|
|
|
|
|
Try to use the functions "FindFirstFile" and "FindNextFile"
|
|
|
|
|
Hi,
Yes, Windows use of FindFile and FindNextFile, but you must write algorithm ...
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Thanks For all of you who responded, all the answers were good. But what I'm looking for is how to invoke the already existing windows Find functionality.
Basically I want to get around writing my own Find algorithm by employing windows Find algorithm.
Thanks again for your help
Fady
|
|
|
|
|
I have a problem with an Oracle DLL I'm using... This DLL contains a memory leak... But because this DLL runs in the same address space as my executable, my program can't perform many actions because it's memory usage increases significantly... Does anyone know how to run a piece of code in a seperate address space, so that when this code is done, the memory is automaticly commited to the system... I'm quit desperate on this one
|
|
|
|
|
What Oracle product are you trying to use?
I use the Oracle Objects for OLE, version 8, for a whole lot of production code and have not ever experienced a memory leak with it. Lately I've also been researching the use OLE DB consumer templates with the Oracle provider and again haven't experienced any memory leaks.
That's not to say that I haven't come upon other bugs with the product, but that's a horse of a different colour
Chris
|
|
|
|
|
I'm using the Oracle Forms Open API's... They are a disease for batch processing, since they don't commit all memory pages after closing the forms file...
|
|
|
|
|
Sorry, but I have no experience using the Oracle Forms product, so I'd just be guessing.
No offense, but for me if I start having to 'struggle' with a third party product, it is usually because I'm trying to use the product to do something that the developer had either never intended or has to be done a very specific way. Try checking through the Oracle MetaLink site to see if anyone else might be able to help you.
Chris
|
|
|
|
|
hi,
okay, this is my question.
I have a bmp file and i like to get the pixel value,,,,,, this is what i do:
CClientDC dc(this);
int Value = dc.GetPixel(point);
the above code gives me a very large number, I like to know if i could use Gray Scale and get the pixel value, just to have a smaller number for simplicity.
Thanks
Ehsan Behboudi
|
|
|
|
|
GetPixel doesn't really give you a "very large number". it gives you a COLORREF which is actually four small numbers packed into a 4-byte DWORD.
here's a simple way to convert that RGB value to gray scale:
COLORREF clr = GetPixel(point);
BYTE grayValue = (BYTE)(int)((GetRValue(clr) + GetGValue(clr) + GetBValue(clr)) / 3);
this isn't perfect, but it's simple.
-c
------------------------------
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
BYTE grayValue = (BYTE)(int)((GetRValue(clr) + GetGValue(clr) + GetBValue(clr)) / 3);
This is not the best conversion, because the eye does not register R, G, and B equally. The following (adapted from Frederik Lundh's Python Imaging Library), implements the International Telecommunications Union's recommended luminance conversion.
BYTE Grayscale(BYTE red, BYTE green, BYTE blue)
{
return static_cast<BYTE> (( 299u * static_cast<DWORD>(red)
+ 587u * static_cast<DWORD>(green)
+ 114u * static_cast<DWORD>(blue) ) / 1000u);
}
He was allying himself to science, for what was science but the absence of prejudice backed by the presence of money? --- Henry James, The Golden Bowl
|
|
|
|