|
Try using AppendMenu(...) to add the menu or InsertMenu(...) if you don`t just want to add it to the end. As for saving the menu, I don`t know how you`d do that or even why you`d want to? If you want the appended menu to appear as a popup, remember to specify the MF_POPUP flag with the (UINT)yourMenuName.m_hMenu as the menu id you want appended, followed by a caption. If you just want to add a new *ITEM* instead of a whole submenu you can use the MF_STRING with a menu command id and then what caption you want the menu item to display.
Alan.
"When I left you I was but the learner, now I am the Master" - Darth Vader
|
|
|
|
|
Hello!
Could somebody tell me how to associate some data (text) with any item in the Tree?
For example: In the left side of my dialog box - Tree, right side - Edit. When I click on any item on the Tree -- some text appears in the Edit.
How can I do it?
Thank you.
|
|
|
|
|
Here are some pointers to help you a bit:
1. When you add an entry to the tree control:
CString *p_strData = new CString;
Which dynamically allocates a new CString. Then, use the Item data part of your tree item to store this pointer:
m_MyTreeCtrk.SetItemData( hItem, (DWORD) (CString *) p_strData );
hItem is the HTREEITEM handle from when you added the tree item to the control. p_strData is cast to a DWORD to jam it into the item data. This works because a pointer is 32 bits and so is a dword.
Then, handle some treeview notifications, probably the sel_changed one, and extract the pointer from the item data:
CString *p_strData=(CString *) (DWORD) GetItemData(hItem);
then you can SetWindowText with the CString to populate your edit control. Update the data in the same way.
Remeber, it is critical that as you delete items from the tree, you first get their item data memeber back as a CString, and delete it. Otherwise you'll get a lot of memory leakage.
Hope that helps.
Jon
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
Hello chaps,
Im doing rather a complex SQL query containing temporary tables, 'GROUP BY', 'INTO', 'HAVING' and 'JOIN'. Im trying to use CRecordset but am having difficulty.
Alternatively my query could be made into a stored procedure which requires two variables, I looked at ExecuteSQL() but found it didnot return a recordset. I need to access a record set from the query.
I have managed to connect my C++ project to the correct SQL Server 7 database and are having trouble with returning a record set.
Please any comments?
Philip Shepherd
RF Design/ Software Engineer
|
|
|
|
|
This sounds similar to a problem I was having a couple of days ago.
I have a stored proc that returns a set of data. In query analyzer it worked fine, however when trying to get the data into an ADO recordset, it would come back empty.
My solution was to include a 'SET NOCOUNT ON' statement at the beginning of the stored proc. This suppresses the 'x rows affected' message.
Hope this helps in someway.
|
|
|
|
|
Use the libodbc++ library instead of the MFC database classes.
|
|
|
|
|
Use ADO, rather then the ODBC MFC CRecordset Class
See ADO samples here
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado270/htm/mdmscadocodeexamplesinvisualc.asp
|
|
|
|
|
Hi all,
I maked instance of CComboBox class (my class name is CMyCombo) !
and i wrote some new functions in new class ...
In one of functions i must put value to the Editbox in my form (dialog).
How can i do that ?
I mean putting value to editbox from my new class !
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Hadi_Rezaie wrote:
I maked instance of CComboBox class (my class name is CMyCombo) !
and i wrote some new functions in new class ...
In one of functions i must put value to the Editbox in my form (dialog).
How can i do that ?
I mean putting value to editbox from my new class !
Doing this will mean your new Combo will not be reusable, which makes it a bad design. However, all you do is ( assuming your Editbox is a member variable called m_Edit, m_szText is a member variable containing the text to put into it, and your class is called CHadiDlg )
CHadiDlg * pDlg = dynamic_cast<CHaduDlg*>(GetParent());
ASSERT(pDlg);
pDlg->m_Edit.SetWindowText(m_szText);
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
|
|
|
|
|
Hi,
I am developing an Aplication to watch/manage my IDS Nodes. It runs fine when I run in Release mode. Once I go to Debug I get the Assertion.
// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
Any help appreciated...
Thanks in advance,
Dan
|
|
|
|
|
Where is the assert that's failing. An assert means you have a bug in your code; look for comments at the assert to tell you what it's checking for.
--Mike--
http://home.inreach.com/mdunn/
While I can't be correct on all matters, I can make the reassuring claim that where I am inaccurate, I am at least definitively inaccurate.
your with and
Sonork - 100.10414 AcidHelm
|
|
|
|
|
I sent you the Assertion I am getting in a seperate mail.
It is failing on...(BTW, this is a SDI Application)
// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
This doesn't mean it is not my code, but it won't let me debug to find the Assertion...any ideas??
Thanks in advance,
Dan
|
|
|
|
|
Click Retry when you get the assert-failed message box to drop into the debugger.
--Mike--
http://home.inreach.com/mdunn/
While I can't be correct on all matters, I can make the reassuring claim that where I am inaccurate, I am at least definitively inaccurate.
your with and
Sonork - 100.10414 AcidHelm
|
|
|
|
|
It has arrived to me a short time ago. The program crashed at the return of a function. I only checked the "link incrementaly" option in debug mode. If it works in release mode...your code is probably not the probleme.
|
|
|
|
|
In the registry is in HKEY_CURRENT_USER/Network
path, where some(!) network drive UNC paths can
be found. Now I wonder where are the rest???
I am trying to make a program that will show the
paths. I have tried it on several computers, and
I have found that not all the network drives are
listed in the registry.
How could I read the UNC path for ALL network drives?
API functions for that??
|
|
|
|
|
Marko wrote:
API functions for that??
Maybe NetUseEnum is what you're after...
The NetUseEnum function lists all current connections between the local computer and resources on remote servers.
|
|
|
|
|
Thanks, you showed me the right way.
I started searching information about NetUseEnum and ended up with WNetGetConnection, which does the trick.
|
|
|
|
|
Hello MFC gurus. I'm looking for some link/source on documentation on how to create/implement application that uses plugins. The only solution that I came up to is making external plugins - by limiting the functions in the dll, and I think that this isn't the way that the plugins should work. If I want external dll - I could simply write a program that does the specified functions. My point is that I want my dll to be the part that does everything but it should get/do/set data inside my main program. It's something like the winamp's general purpose dll's or like the way BO2K is done, but I can't figure out how to implement a plugin technique in my application. Any
help/link/source/book suggestions are welcome.
Greetings,
Deian
|
|
|
|
|
Hello,
I am creating an application that utilizes CryptoAPI and concerned whether it is possible to hack and extract my DES/RSA keys [which are hard coded in my app. and imported into CryptoAPI using CryptImportKey()] from it using one of the following methods:
(1) replacing the CryptoAPI dll (advapi32.dll) with some dll that will be loaded between the CryptoAPI dll and the executable. This dll will store the keys in some db and then forward the call to the CryptoAPI dll. The user might not even be aware that this is happening.
(2) Since the CryptoAPI methods are exported by name and their addresses are known - it is possible to run the application under a debugger, put a breakpoint in memory in the function CrypyImportKey() and using assmebler knowledge track down the location in memory of the passed parameters and reveal the key.
Anybody got any knowledge whether any of these is possible?
Thanks a lot!
|
|
|
|
|
I think that you may be confusing the key with the password.
Lets say a hacker virus got onto your compuetr, then it managed to fool your anti-virus into thinking that changing a system dll is ok. Then the hacker finds and passes the key to himself. This part of cause is possible, so I'm not saying it can't be done somehow. We have to assume that not all software users are as aware as us here of how important security on a PC is.
Anyway, all he has then is the key, not the password.
If you were using this program for, say, a secure site, then you would pass the key to your users, depending on your security system it could be
. once only
. on a per day basis
. per log in is not a good one for public traffic because a hacker only has to keep pounding you with login attempts to get a pattern to your security, which is something that I read recently. The hole is this case was blocked. (I refuse to say it was on a Linux site, cos I have mates on there).
. and others
The key is used on the local machine with the users password to create a, erm, dam dam, I've forgotten the proper word for it, lets call it a ReturnValue (I'm sure I'll remember the word in a minute).
From then on, its that ReturnValue that is used to log in the user and identify his traffic (if you intend to go that far, which is wise since if it needs secure users it also needs secure messaging in my book).
The imaginary hacker who stole the key has to still know or hack the password, plus has to work out which of the algorithms you used. He has to be carefull incase your key is date/time related so must keep his computer within a timeframe.
I'm not saying hacking Crypt's can't be done, but unless too much info is given to potential hackers, its a long time consuming process.
What is that word for the returned value? its in my head somewhere.....
We do it for the joy of seeing the users struggle.
|
|
|
|
|
Hello,
Well I have this funny problem. I want to add items to my combo box in a child dialog box from my parent dialog box just before the child is shown.
To do this I have the following line
ChildDlg.m_ComboBox.AddString("Some Text");
I even tried
ChildDlg.m_ComboBox.InsertString(0, "Some Text");
I made sure too that the member variable m_ComboBox in the class ChildDlg referred to the contro (not the value) of my Combo box.
What is wrong?
Thanks,
Mike
|
|
|
|
|
Hi Mike, you have to tell us what the funny problem is. e.g. the app crashed (hm... thats really helpful), combo box not being updated, etc...
Oh, and in which message handler are you calling the "AddString"/"InsertString" methods?
|
|
|
|
|
Well the application crashes.
I have a main dialog box and in one of the functions I create a child dialog box which has the member variable m_ComboBox as public.
So in my main dialog box I have
CChildDialog ChildDlg;
ChildDlg.m_ComboBox.AddString("Some Text");
ChildDlg.DoModal();
And then when I run this application, it crashes.
So to test again I tried to Add a string to the combobox in the constructor of my child dialog but the application still crashed!
What shall I do?
|
|
|
|
|
Hello, the codegurus around the world.;)
I think that DoModal() must call OnInitDialog() in CChildDialog.
So, the location between ChilDlg and DoModal() will not
create ComboBox yet.
So, I think that you had better put AddString(...) in OnInitDialog()
of CChildDialog.
CChildDialog ChildDlg;
ChildDlg.m_string = _T("Some Text");
ChildDlg.DoModal();
And in OnInitDialog() of ChildDlg
m_ComboBox.AddString (m_string);
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
But there is no OnInitDialog() in my child dialog class!!
Even when I tried to override OnInitDialog (hoping it was there in CDialog) it did not have it already defined in the base class.
|
|
|
|