|
I am trying to get into custom controls and one problem is getting into owner draw buttons (derived from CButton).
Can anyone suggest a good tutorial on this as most stuff on owner draw seems quite advanced.
Thanks in advance.
Elaine (fluffy tigress emoticon here)
Would you like to meet my teddy bear ?
|
|
|
|
|
Well, there is a bit in "Programming VC++ 6.0" (Kruglinski, Wingo, Shepherd), Chapter 11, example 11D. In fact, there is an electronic variant of the book but it's a bit too large (about 11 Mb)
Hope this helps.
|
|
|
|
|
There are several nice articles on this site. You probably want to read through a couple of them before you get started, it shouldn't be too bad (most of the pain in doing custom or customized controls is dealing with backwards Windows crap...), so if you hit a specific problem you can always ask here.
---
Shog9
If I could sleep forever, I could forget about everything...
|
|
|
|
|
I have a function that return variant.How can I cast it to CString?
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
VARIANT v;
CString strValue;
//TCHAR sz[5];
VariantInit(&v);
v.vt = VT_BSTR;
v.bstrVal = strValue.AllocSysString();
//v.bstrVal = SysAllocString(sz);
//do something with variant
SysFreeString(v.bstrVal);
VariantClear(&v);
another way around
Variant v;
//variant gets value
CString strValue(v.bstrVal);
hope it helps
DanielO
|
|
|
|
|
Thats perfect.Thanks a lot.
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
Can any one tell m how to convert Variant to std::srting and char *
|
|
|
|
|
|
CString s( _variant_t(FunctionReturningVariant()) );
Concussus surgo.
When struck I rise.
|
|
|
|
|
|
Nishant S wrote:
Is there any way to pass a user defined param to a WH_CBT hook?
AFAIK, not directly. Is your hook thread or global?
Tomasz Sowinski -- http://www.shooltz.com
What is "scratch" and why can everything be made from it?
|
|
|
|
|
|
Nishant S wrote:
The hook proc is a static method of a class. I want to pass the instance pointer to the hook proc as I need to access some instance variables there
You have a variety of solutions to consider, from simple global variable through static data members to super-dooper object-oriented function adapters.
I'd create another static method which gets the parameter, stores it in private static member and calls SetWindowsHookEx with address of static hook proc.
Tomasz Sowinski -- http://www.shooltz.com
What is "scratch" and why can everything be made from it?
|
|
|
|
|
Tomasz Sowinski wrote:
I'd create another static method which gets the parameter, stores it in private static member and calls SetWindowsHookEx with address of static hook proc.
Nope. I want thread-safety. Right now I am thinking in terms of using a CMapPtrToPtr.
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
Nishant S wrote:
Right now I am thinking in terms of using a CMapPtrToPtr.
Beware of CG, who's going to jump in and tell you that CMapPtrToPtr is a donkey crap and you should use std::map instead
If you're going to stick with CMap-based container, consider the typed variants (CTypedMapxxx). Or - you could use thread-local storage, which basically gives you per-thread statics. Check TlsXXX functions or __declspec(thread).
Tomasz Sowinski -- http://www.shooltz.com
What is "scratch" and why can everything be made from it?
|
|
|
|
|
Nishant S wrote:
Nope. I want thread-safety. Right now I am thinking in terms of using a CMapPtrToPtr
To map what exactly to what?
If you need thread safety, you could also use a thread local static class variable to store the instance pointer.
Of course, I would recommend to use a super-dooper object-oriented function adapter just as described in my article Use member functions for C-style callbacks and threads - a general solution
--
Daniel Lohmann
http://www.losoft.de
(Hey, this page is worth looking! You can find some free and handy NT tools there )
|
|
|
|
|
Check out the technique i used for hooks in this article. Maximilian Hänel introduced me to this technique (which is very similar to what ATL uses) in his WTL port; it uses a template wrapping a few asm instructions & a class pointer to store both along *with* the callback address.
---
Shog9
If I could sleep forever, I could forget about everything...
|
|
|
|
|
I'm a bit lost here. How can I add a popupmenu to, let's say, a listcontrol. The listcontrol is a member(m_ctrlList) of a dialog.
I've got already this:
CMenu menuPopup;
menuPopup.LoadMenu(IDR_POPUP_MENU);
Somebody knows what to do next? tnx...
[VISUAL STUDIO 6.0] [MFC] [WIN98/2]
Bluute tette!
|
|
|
|
|
menuPopup.GetSubMenu(0)->TrackPopupMenu(...);
This assumes that you want to show the leftmost submenu. Usually there's only one, but some people like to aggregate all right-click popups used in application in one menu resource.
You'll find detailed info on TrackPopupMenu arguments in MSDN.
Tomasz Sowinski -- http://www.shooltz.com
What is "scratch" and why can everything be made from it?
|
|
|
|
|
I've added this:
menu.GetSubMenu(0)->TrackPopupMenu(TPM_LEFTALIGN|TPM_RIGHTBUTTON,0,0,this);
I receive an access violation when running in CMenu::TrackPopupMenu, m_hMenu is NULL.
[VISUAL STUDIO 6.0] [MFC] [WIN98/2]
Bluute tette!
|
|
|
|
|
frisco wrote:
I receive an access violation when running in CMenu::TrackPopupMenu, m_hMenu is NULL.
That's because you don't have a popup menu. You've probably defined all items on top level. TrackPopupMenu can't use that - move the items into popup menu.
Tomasz Sowinski -- http://www.shooltz.com
What is "scratch" and why can everything be made from it?
|
|
|
|
|
In the resource browser, under the menu folder, I've got one menu resource called IDR_POPUP_MENU. Where and what should I add there, cause if we add a popupmenu there, we can't give it an ID, and if I add a normal menuitem, an error occures.
[VISUAL STUDIO 6.0] [MFC] [WIN98/2]
Bluute tette!
|
|
|
|
|
Never mind... it works
[VISUAL STUDIO 6.0] [MFC] [WIN98/2]
Bluute tette!
|
|
|
|
|
hi all,
i have a program started from SDK (no mfc) and i need add a listbox to it.
i've created a listbox on the screen with CreateWindowEX(). but, i don't know how to add and remove data from it.
could anyone give me idea?
i have included MFC support in the project. but, i write with IDE. i don't know how to add a CListBox to a program from SDK. do u think it is easier using CListBox instead of starting API?
pls give me some idea!
thanks,
jim
|
|
|
|
|
Check the MSDN for documentation for listbox messages and notifications. Their identifiers start with LB_ and LBN_ prefixes.
Tomasz Sowinski -- http://www.shooltz.com
What is "scratch" and why can everything be made from it?
|
|
|
|