|
Hi,
Is it possible to get a list of all menu shortcuts (NOT the ones in accelerator table)that an SDI application already uses? E.g: Alt+F invokes the file menu (In resource editor, we give an "&" prefix sothat the 'F' in a "File", will have an underline).
I need to give a short cut key dialog, where the user can set his own shortcuts to invoke certain functionalities of the application, but i need to check if it is already taken.
Thankx
Dave
|
|
|
|
|
You'll have to iterate over menu - use GetMenuItemCount and GetMenuString. For each item, find the & prefix. Following letter is the Alt-something you're after. Note that two ampersands are just displayed as one in menu item.
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
The event is captured in the CListCtrl derived class
void CListCtrlEx::OnItemchanged(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
*pResult = 0;
...
}
But not in the class who uses the derived CListCtrlEx class.
// Header
...
//{{AFX_DATA(CPropDriver)
enum { IDD = IDD_DRIVERDIALOG };
CListCtrlEx m_Drivers;
...
void CSomeViewWithAListControl::OnItemchangedDriversList(NMHDR* pNMHDR, LRESULT* pResult)
{
...
}
How should I solve this ?
Greetings,
Niko
|
|
|
|
|
I guess that MFC first tries to dispatch the message to CListCtrlEx class via message reflection. Since there's a handler for LVN_ITEMCHANGED, function in CSomeView isn't called, because message was handled.
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
Thank you for your respond.
Do you know how to change this flow ?
If the message is captured by CSomeView, I could call ClistViewEx::OnItemchanged from there...
|
|
|
|
|
Your first chance to process LVN_ITEMCHANGED and other notifications sent through WM_NOTIFY message is virtual function CWnd::OnNotify. Override this in CYourView, check if notify code is LVN_ITEMCHANGED and control id corresponds to your list view. If this is the case, do whatever you need (including calls to CListCtrlEx's handler) and return TRUE.
Otherwise, just call CView::OnNotify to enable message map processing.
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
I'm sorry, but this doesn't sound like generic programming.
Is it also possible to implement this in the CListCtrlEx class.
So I don't have to change all the classes that use the CListCtrlEx class.
|
|
|
|
|
Niko Tanghe wrote:
I'm sorry, but this doesn't sound like generic programming.
Hehehe... I think you're buying buzzwords too fast. I'd say MFC isn't generic programming at all.
Back to problem: what exactly would you want to achieve: have part of LVN_ITEMCHANGING stuff in CListCtrlEx and additional processing in CYourView? Or you want to keep some code in CListCtrlEx and replace the logic completely in CView-derived class which hosts CListCtrlEx?
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
Tomasz Sowinski wrote:
Hehehe... I think you're buying buzzwords too fast. I'd say MFC isn't generic programming at all
CListCtrlEx needs to now the state/index/... of the item selected.
But the classes who use CListCtrlEx must also be able to capture LVN_ITEMCHANGED without the knowledge of the implementation of CListControlEx.
|
|
|
|
|
In this case, you'll need ON_NOTIFY_REFLECT_EX macro in CListCtrlEx message map instead of plain ON_NOTIFY_REFLECT. You'll also have to change the CListCtrl::OnItemChanged handler to return BOOL value. Return FALSE and parent windows like CYourView will have chance to process the message *after* CListCtrlEx.
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
thank you very much (for both answers to my questions)
|
|
|
|
|
Hello,
i have a class for flicker-free-drawing, there i have a global pointer to CBitmap, and in the constructor i create a CBitamp-Object via new. In the destructor i would like to delete the object, but my destructor is never called. When i exit my programm the debugger print "Detecting Memory Leaks!" and then the adress of the pointer to the CBitmap object.
What can i do? When called windows/Visual c++ the destructor?
Please help me!
|
|
|
|
|
The order in which global variables are constructed and destructes is undefined. Therfore it might happen, that the CRT cleanup stuff is called before your destructor is executed and therefore a memory leak is reported.
You should check this by adding a breakpoint to your destructer and see if it is reached.
--
Daniel Lohmann
http://www.losoft.de
|
|
|
|
|
Hello Daniel,
I have a breakpoint in the destructor, but the destructor is never called.
My problem/question:
i have this member-variable of my own class (in the header of a dialog, the member-variable is global):
CMyOwnClass m_test;
When i exit my programm the debugger print me a message "Detecting Memory Leaks!" with the adress of a CBitmap object. That CBitmap object create i via new i the constructor of CMyOwnClass. And i would like to delete the in the destructor.
When call windows/visual c++ the destructor of CMyOwnClass? NEVER?
Thank you for your reply!
|
|
|
|
|
Sorry, but this is not clear to me
klm wrote:
have this member-variable of my own class (in the header of a dialog, the member-variable is global):
CMyOwnClass m_test;
Ah, what the hell do you mean with a global member variable?
It might help if you post some code (shrinked to the necessary stuff).
--
Daniel Lohmann
http://www.losoft.de
|
|
|
|
|
Hello Daniel,
with global member variable mean i: a variable in a class, that is accessable in each function of the class.
I think the right word is: member variable.
Sorry for my bad english and the "global member variable", but i come from C and i am new Visual C++, i don't have heard member varible before i started with Visual C++
|
|
|
|
|
Hello,
i have found the error, the error was that i created the dialog where the member-variable is located via new and never delete them, and then the destructor of the base class of the member-variable never called.
|
|
|
|
|
My project use the function PlaySound() and I include Mmsystem.h and i also add winmm.lib to the project. However when i try to compile, the error occur in Mmsystem.h. It say the following:
c:\program files\microsoft visual studio\vc98\include\mmsystem.h(113) : error C2146: syntax error : missing ';' before identifier 'MMVERSION'
c:\program files\microsoft visual studio\vc98\include\mmsystem.h(113) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
Then i try to add ; before identifier 'MMVERSION' but the error message still the same. Any idea how to fix this? Do i have to get the new Mmsystem.h somewhere?
Thank in advance for helping.
laeroloc
|
|
|
|
|
You can reinstall VC, or download newest sdk from Microsoft;
This is the fragment from mmsystem.h, which compiles:
<br />
<br />
#ifdef _WIN32<br />
typedef UINT MMVERSION; <br />
#else<br />
typedef UINT VERSION; <br />
#endif
Probably You have modified the code.
Hope that helps
|
|
|
|
|
I feel like such a choad.
Out of all the Win32 Common Controls the TreeView control has
given me the most grief and the documentation is not very helpful.
In this instance (of a long series of them) I'm having a problem
with the TreeView_GetParent function. Basically I'm trying to follow
a leaf in the tree back to it's root. And do so via the following
function:
<br />
void ConstructPath(TVITEM *item,char *buffer) {<br />
HTREEITEM back = TreeView_GetParent(Tree,item->hItem);<br />
if(back == NULL) {<br />
MessageBox(MainWindow,"doesn't have parent","recursed",0);<br />
}<br />
else {<br />
TVITEM *node = (TVITEM *)back;
char name[_MAX_FNAME];<br />
memset(&name,0,_MAX_FNAME);<br />
node->mask |= TVIF_TEXT | TVIF_CHILDREN ;<br />
node->pszText = (char *)&name;<br />
node->cchTextMax = _MAX_FNAME;<br />
TreeView_GetItem(Tree,node);<br />
MessageBox(MainWindow,name,"recursed",0);<br />
ConstructPath((TVITEM*)back,buffer);
}<br />
}<br />
When run this function screws up the display of the control and returns
the absolutely wrong nodes in the tree.
Now I'm going to hazzard an educated guess that "TVITEM *node = (TVITEM *)back;"
is the problem as back is an HTREEITEM that I'm casting to a TVITEM (which
TreeView_GetParent requires yet returns a HTREEITEM. I cannot find the
definition of HTREEITEM in the help system and hoping that GetParent was written
with recursion in mind the two types might not have been far off (I know bad guess ).
Can anyone tell me what the relationshipo is between TVITEM and HTREEITEM and how I can convert one into the other (or at least point me to some clear documentation)?
Sean
|
|
|
|
|
HTREEITEM is a handle to an item in the tree (similar to the simpler index value that can be used with list controls). TVITEM is a structure that can be filled with information about an item in the tree. You can't cast between one and the other, because they are not related (other than that HTREEITEM is a handle that can be used to fill a TVITEM structure via GetItem ). HTREEITEM is not a pointer to a TVITEM .
While iterating through a tree (using GetParent, GetChild, GetPrevSibling, GetNextSibling etc.), you should use HTREEITEM s. In fact, most of the TreeView messages use an HTREEITEM to identify which item you're talking about. If you need to obtain more information about the item the HTREEITEM is referring to, use TreeView_GetItem . If hTree is the handle to the tree control you're working with, and hItem is the item you want information about, the following code could be used:
char name[_MAX_FNAME];
TVITEM itemInfo={0};
itemInfo.hItem = hItem;
itemInfo.mask = TVIF_TEXT | TVIF_CHILDREN
itemInfo.pszText=name;
itemInfo.cchTextMax=_MAX_FNAME;
TreeView_GetItem(hTree, &itemInfo);
After that code, the name array will contain the text of the item (up to _MAX_FNAME-1 characters), and itemInfo.cChildren will be 0, 1, or I_CHILDREN_CALLBACK.
"We are the knights who say Ni" (The Knights Who Say Ni)
|
|
|
|
|
Can I obtain the number of the last visible line in a CRichEditCtrl??
|
|
|
|
|
Hello!!
I want to retrieve the number of services (and their names) which are running in the system. I can do this with EnumServiceStatus() for OS NT-onwards. Can anyone please tell me how it can be done for Windows 98.
I also want to get the DeviceDriver information. The same information which is got by, EnumDeviceDrivers() and GetDeviceDriverBaseName() apis for OS Win NT onwards. I want the same info for system with Win 98. i.e.. I want the dlls and the sys file (or vxds) which are loaded in the system with Windows 98 OS.
Have a nice day
Sandeep
|
|
|
|
|
According to msdn:
Windows 95/98/Me provides a scaled-down Service Control Manager:
RegisterServiceProcess
RunServices
RunServicesOnce
Services are stored under:
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion
It should contain:
MyApp1="myapp1.exe"
MyApp2="myapp2.exe" param1 param2
MyApp3="c:\mydir\myapp3.exe"
This is how You can retrieve number of services, and their names. The other problem, is whether those "services" are still running.
Mukkie
|
|
|
|
|
I have a CString like:
"C\I386\IAS.MDB", and I want to get dbName = "IAS.MDB" out of it. I dont see anything friendly in the class memebers of CString. Any hints? Surely CStrings must be equipped with these friendly extractions???
Thanks,
ns
|
|
|
|