|
When I got the notification about your posting, I was initially
embarassed. I usually try not to generalise so much. But then
I read the faq you pointed me to, and it outlined the method
I used in the code below my bald statement.
I perhaps could have explained it better, but if you look at the
code it has a static function recieving a pointer turning the
pointer to an object one, and calling a non-static member function.
Members of the jury, I rest my case.
Iain.
|
|
|
|
|
I don't intend to appear stubborn, but when discussing the code you're referring to, the FAQ very clearly says it's "a patch". It's meant to be used in situations where you need to supply a plain-C callback function to the API, like in EnumChildWindows() or others.
In fact, the FAQ istelf poses the question as follows: "How do I pass a pointer-to-member-function to a signal handler, X event callback, system call that starts a thread/task, etc?" It's answer is a very direct one: "Don't"
Here's the precise link: http://www.parashift.com/c++-faq-lite/pointers-to-members.html#faq-33.2[^]
The issue with plain-C callback functions and the inability to (directly) use C++ member functions is well-described at MSDN in "Calling All Members: Member Functions as Callbacks" at http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/dnarvc/html/msdn_callb.asp[^] I agree that the technique is a good one for the situation described in the FAQ.
But it's not correct to say that you can't store (and use) a pointer to member functions.
It's also not correct to say that member functions can't be used in ways very similar to regular callbacks. Here's one example from MSDN, entitled "Pointers to Member Functions and Templates" at http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/dnarvc/html/msdn_callb.asp[^]
So, maybe the jury's still out ....
Regards,
Mike
|
|
|
|
|
After Mike Dunns FAQ posting, I posted a mini-retractment. In a general windows callback (ie for
CreateThread etc) you have to use a static function. You can cast its void * parameter to the object
in question and call a "normal" member function, getting around the issue.
The mdsn_callb.asp page you pointed to also spells this out. It does include a lookup method which
may well work in circumstances. But it is still using a static as the callback, which then derives
an opbject pointer before calling the member function.
Mike Dunn did point out how to create a pointer to class member function pointer which was a new one
to me. This is a new one on me, and I can see it being very useful. But you now need to store two
pointers. Which object, and which member of that object! You can get around it, but not without non-
trivial bookkeeping. So I would consider it too much hard work, and too prone to mistakes for use as
a windows callback function.
So, to misquote myself:
"... You can't. But you can cheat, and get around the problem!".
In my experience, there's never a hard and fast CAN'T. But there is a "way too much like hard work when
much easier, simpler and safer ways exist".
In next weeks episode, "How many angels can line-dance on the side of a pin".
Iain.
|
|
|
|
|
|
Thanks Michael, this solved my issue.
i mixed up the usage on "pointer-to-function" and "pointer-to-member"
|
|
|
|
|
hi,
where to find unicows.lib for download?
thanks
|
|
|
|
|
Grab a recent platform SDK (contains DLL and lib file), or google for it.
Your sincerity about keeping the soapbox organized and civilized is so obvious. I solute your effort.
-- Anonymous, 10/18/03
|
|
|
|
|
hi,
can somebody,please tell me how to change for example,scales or width of 2D bars for tihis activeX control within the code?
|
|
|
|
|
Is there a limit on the size a key value or registry tree can have? If so, what is the maximum? To be more precise, I would like to know which key type to use (REG_DWORD, REG_SZ, etc.) to store large binary values, say more than 20 MB in size.
|
|
|
|
|
No, do not use the registry to store that much data. Use a data file in the user's Application Data dir. In 9x a single value has a limit - either 32K or 64K, I forget which. In NT the size of the entire registry has a limit, which defaults to something less than 20 MB.
--Mike--
Ericahist | CP SearchBar v2.0.2 | Homepage | RightClick-Encrypt | 1ClickPicGrabber
#include "witty-quote.h"
|
|
|
|
|
Michael Dunn wrote:
In NT the size of the entire registry has a limit, which defaults to something less than 20 MB.
My Windows 2000 box is currently sitting at 40MB.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
as far as i know there is no "real" limit for the registry size on NT.. read the ReactOS source, to get information about that!
Don't try it, just do it!
|
|
|
|
|
dafunkt wrote:
to store large binary values, say more than 20 MB in size
Why not just store them as binaries in a folder location?? And then store the string of that folder in the registry???
:walks away shocked at the concept of storing multiple 20 meg binaries in the registry:
The kindest thing you can do for a stupid person, and for the gene pool, is to let him expire of his own dumb choices.
[Roger Wright on stupid people]
We're like private member functions
[John Theal on R&D]
We're figuring out the parent thing as we go though. Kinda like setting up Linux for the first time ya' know...
[Nitron]
|
|
|
|
|
Thank you for your help first. I'd like to get the application icon (small icon on title bar) of any application. I used the API function SendMessage with WM_GETICON message to the window of that application, some applications return the handle of its application icon (eg: Windows Explorer, ...), but some do not (eg: MS Outlook, NotePad,...). Please tell me other ways to do that. Thanks a lot.
chaunguyen
|
|
|
|
|
You could go about it laterally. Assuming WM_GETICON fails...
Get the file of the executable (GetModuleFileNameEx), and pick the first icon resource in it.
Iain.
|
|
|
|
|
Thanks Iain for your early help. Your solution works, but in some case it return an icon which is not the current application icon. Anyway, that's fine, thanks.
Chau Nguyen
|
|
|
|
|
Try using SHGetFileInfo .
Software Zen: delete this;
|
|
|
|
|
Thanks a lot, Gary. Your suggestion is great. It works.
chaunguyen
|
|
|
|
|
I'm building a mfc custom control, and it includes some custom messages that are sent out to a designated CWnd when some events are triggered. for now, i've defined them as something like
#define WM_BLAH_1 WM_USER+100
#define WM_BLAH_2 WM_USER+101
....
...
what's a recommended/proper way to define my own custom messages? I'm hoping to make this so that other people can use the control without worrying about custom window message colliding with other custom messages.
thanks in advance,
|
|
|
|
|
|
ok, so im trying to add / delete some registry data on the fly in my application... my add code is working perfectly.
however, my remove code compiles 0 errors, 0 warnings, but just doesnt delete the subkey / value i want it too.
i can see it there, i gave it the right name, it executes the code, and just doesnt delete the data.
um , please help ...
HKEY hKey;
LONG lnRes = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", 0L,
KEY_ALL_ACCESS,
&hKey
);
LPCTSTR keyname = "xlaunch";
RegDeleteKey(hKey, keyname);
RegCloseKey(hKey);
thanks
todo....
:: insert inspirational text here ::
|
|
|
|
|
Hmm, it would be helpful if you'd indicate what value RegDeleteKey() is returning. Also, are you ensuring that lnRes is ERROR_SUCCESS before attempting to use hKey ?
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
yes, i made sure lnRes was ERROR_SUCCESS....,
i actually didnt catch a return from RegDeleteKey()
ill be messing w/ it some more tonight, and if I cant figure it out
ill be sure to include that in my next post.
todo....
:: insert inspirational text here ::
|
|
|
|
|
What operating system are you using? If I remember correctly deleting keys works differently in win9X than NT. Are their any values inside the key?
John
|
|
|
|
|
98SE at home, where im developing this app.
MSDN said...
Included in Windows XP, Windows 2000 Professional, Windows NT Workstation, Windows Me, Windows 98, and Windows 95, Windows Server 2003, Windows 2000 Server, and Windows NT Server.
??
todo....
:: insert inspirational text here ::
|
|
|
|