|
I am having problems with fixing the errors.
|
|
|
|
|
Er, yes. You ah, you already made that clear in your first post.
What specifically is giving you a problem?
"When I was 5 years old, my mother always told me that happiness was the key to life. When I went to school, they asked me what I wanted to be when I grew up. I wrote down 'happy'. They told me I didn't understand the assignment, and I told them they didn't understand life." - John Lennon
|
|
|
|
|
That error I am not sure how to fix it and I am pretty sure more errors will come up after it.
I did attach a file with the error log in it.
|
|
|
|
|
There is one error and one warning shown there. The solution to each are in the messages!
1. Warning - arising from one of the VS supplied files.
2. Error - the compiler isn't prepared to treat a const char* as a const byte*
To solve, follow the directions.
I.e
1. Add the /EHsc switch to the command line. - "cl /EHsc aes.cpp"
2. Goto line 29 of aes.cpp and cast the first parameter of DefaultEncryptorWithMAC to be a const byte*
Something like: DefaultEncryptorWithMAC( (const byte*)firstParam, secondParam, thirdParam);
"When I was 5 years old, my mother always told me that happiness was the key to life. When I went to school, they asked me what I wanted to be when I grew up. I wrote down 'happy'. They told me I didn't understand the assignment, and I told them they didn't understand life." - John Lennon
|
|
|
|
|
|
Bother.
I'd actually downloaded the project yesterday that you shared at MediaFire or wherever it was. I've just tried the page you linked to here, but only saw the ability to browse 10 sample projects. Going back to the article's main page also only gives the ability to download any one of the 10 samples.
So, I gave it a go and carried-on anyway - loading the SLN file in your zip.I converted it to one that VS2010 was happy with and hit build. Great, no problem - it builds just fine.
--
Next, I created a new win32, console project in the solution.(called Member10657083) I copied the contents of your aes.cpp file and replaced the contents of "Member10657083.cpp" with it. I also uncommented the #include stdafx.h line.
Upon trying to build, I didn't get that warning you had, but still got the same error.
Mistakenly, I changed
new DefaultEncryptorWithMAC(
password.c_str(),
into
new DefaultEncryptorWithMAC(
(const char*)password.c_str(),
Of course, the error was exactly the same. Realizing my mistake, I then changed it to:
new DefaultEncryptorWithMAC(
(const byte*)password.c_str(),
and tried again. Bingo! The project compiled. While the project didn't successfully build, it was only linker errors, since I didn't add any to the new project. I'm tired and very rarely use VS, so I'm not going to tackle that tonight.
Hope this helps. Let me know how you get on.
"When I was 5 years old, my mother always told me that happiness was the key to life. When I went to school, they asked me what I wanted to be when I grew up. I wrote down 'happy'. They told me I didn't understand the assignment, and I told them they didn't understand life." - John Lennon
|
|
|
|
|
That did change things but it seems to have created quite a few linker errors on my end as well.
|
|
|
|
|
Hi,
I am making a gui for an application, which requires me to invoke a windows command prompt inside a MFC gui window.I am very new to MFC, I will highly appreciate, if somebody can give an idea, how to invoke a windows command prompt inside a MFC window.
|
|
|
|
|
Opening a command prompt window is not related to MFC. It can be performed by any Windows application using ShellExecute[^]:
ShellExecute(NULL, _T("open"), _T("cmd.exe"), _T("/k"), NULL, SW_SHOW);
ShellExecute starts cmd.exe here which opens the shell. The /k parameter specifies that the shell is not closed immediately but requires closing the window or typing 'exit' (type 'help cmd' in a shell to list available options). The fifth parameter can be used to specify a directory.
|
|
|
|
|
Hi,
I want to embedd the command prompt inside a mfc window, can u suggest some template and how to do this.
Thanks,
Kamlendra
|
|
|
|
|
|
Why do you need a command prompt? Much better to use a label for the question, and an edit control (CEdit ) for the response.
|
|
|
|
|
I have some structures in my application (which is pretty big). To test certain error conditions, I have to input wrong values to these variables and send across another system (using udp sockets). How can I use the treeview to populate all the structures and upon user selection of one of the node (the struct variable), i wants to input error values and update the same structure variable in my app. Here is the sample
Quote: hRoot = m_TreeView.InsertItem(_T("Messages"), 0, 1);
hMainMsg = m_TreeView.InsertItem("XXXXX", 0, 1, hRoot);
hSubMsg = m_TreeView.InsertItem("MsgHdr", 2, 3, hMainMsg);
m_TreeView.InsertItem(_T("msgId"), 4, 5, hSubMsg);
m_TreeView.InsertItem(_T("InfId"), 4, 5, hSubMsg);
m_TreeView.InsertItem(_T("Seq No"), 4, 5, hSubMsg);
m_TreeView.InsertItem(_T("msgLen"), 4, 5, hSubMsg);
m_TreeView.InsertItem(_T("timeStamp"), 4, 5, hSubMsg);
in double click event,
HTREEITEM nodSelected = m_TreeView.GetSelectedItem();
CString strSelected = m_TreeView.GetItemText(nodSelected);
HTREEITEM hParent = nodSelected;
while (hParent = m_TreeView.GetParentItem(hParent))
{
CString strParent = m_TreeView.GetItemText(hParent);
if (strcmp(strParent,"Messages")==0)
break;
m_TreeView.SetItemState(hParent, TVIS_BOLD, TVIS_BOLD);
strSelected = strParent + "." + strSelected;
}
m_txtMsg = strSelected + "=";
for ex. m_txtMsg will be now "XXXXX.msgHdr.msgId=<some value="">"
Is there any way to use this text data to assign as my variable
Please help.
|
|
|
|
|
You can only set the content of a structure by referring to it by address (aka pointer/reference). So rather than adding the item as text to each tree node, you should create a structure item, populate it with the data, and save its address in the node.
|
|
|
|
|
Thank you for the answer.
I checked the methods to insertitem to treeview. (Quote: HTREEITEM InsertItem( LPTVINSERTSTRUCT lpInsertStruct );
HTREEITEM InsertItem(UINT nMask, LPCTSTR lpszItem, int nImage, int nSelectedImage, UINT nState, UINT nStateMask, LPARAM lParam, HTREEITEM hParent, HTREEITEM hInsertAfter ) etc..
So how can I save address of a variable in the node? Can u please share the code segment for the same or any link to the same.
|
|
|
|
|
|
Yes, I used the SetItemData() and GetItemData() methods with lparam. I am passing the (DWORD)<structure var="">. But the variables are of different data types. the value has to be changed for the selected variable. I have lots of fields in the struct and 8 structures are there in the tree. Compare and set values for each fields will be cumbersome. Can you give proper guidance.
thank you
|
|
|
|
|
Sorry, I don't understand what you are asking, or what you mean by "I am passing the (DWORD)". You should create your structures, populate them with the relevant data, and then take their address as a pointer, which you send in the lParam field. You then have direct access to each structure in the relevant tree node.
|
|
|
|
|
Sorry to post you incomplete question. I mean the address of the variable I am passing in the lParam.
But again in my GetDataItem() method, i have to typecast to the corresponding variable. is it?
for eg.
typedef struct address
{
CString houseName;
CString placeName;
int cnrtyCode;
char pinCode[6];
};
typedef struct node
{
CString Name;
int Age;
float Height;
address adrs;
};
this is my structure. and
HTREEITEM hItems, hRoot;
TVINSERTSTRUCT tvInsert;
pNode->Name = "Shibu";
pNode->adrs.cnrtyCode = 91;
pNode->adrs.houseName = "House No 23";
pNode->adrs.placeName = "Bnglr";
pNode->Height = 5.5;
pNode->Age = 28;
hRoot = m_tree.InsertItem(_T("Personal Data"), 0, 1);
tvInsert.hParent = hRoot;
tvInsert.hInsertAfter = NULL;
tvInsert.item.mask = TVIF_TEXT | TVIF_PARAM;
tvInsert.item.pszText = "Name";
hItems = m_tree.InsertItem(&tvInsert);
m_tree.SetItemData(hItems, DWORD(&pNode->Name));
.......
.....
tvInsert.item.pszText = "Age";
hItems = m_tree.InsertItem(&tvInsert);
m_tree.SetItemData(hItems, DWORD(&pNode->Age));
Now my requirement is when i select the treeitem, associated value has to be displayed in a label. Also i have to change the value (through text box entry ; one text box only) of the selected item. Each value ( name,age etc.) are of different data types.
first i tried by passing address of pNode. then how to check my selection (whether user selected name/age/..).
Please help me with a code portion.
|
|
|
|
|
I am not sure that I understand what you mean or what you are trying to do. Presumably you have some nodes that are addresses, so you should add some key as the nodename, and then a pointer to the address structure as the item data. And for the other nodes you have some other type. But I am having trouble visualising exactly why you are using a TreeView in this instance.
|
|
|
|
|
As my actual structure is pretty huge as I mentioned earlier, designing a form with label & textbox for each one is difficult. So I planned to use treeview to list the items and one text box to enter value.
my form is simple with 1 treeview, label and textbox.
in this case,my requirement is when i select the treeitem, associated value has to be displayed in a label and change the value through text box.
Hope you are clear with my struct.
|
|
|
|
|
That sounds quite straightforward, so I do not really understand what the problem is. If the user selects the "Name" node, then you display the name, and if it gets changed, save the new information from the textbox. But perhpas you should be looking more at your overall design.
|
|
|
|
|
Yes exactly. So this design will not work for this requirement. is it?
any how thank you for the interest and help provided.
|
|
|
|
|
I was wondering what is the best way to set constanta in C/C++. Using a header file with all constants set as #defines? Kind of like:
#define pi (3.1416f)
#define gravity_m_div_sqrt_secs (9.81f)
Or, set as static members of a class?
#ifndef __COMMON__
#define __COMMON__
class Common{
public:
static float k_pi;
static float k_gravity_m_div_sqrt_secs;
};
#include "Common.h"
float Common::k_pi = 3.1416f;
float Common::k_gravity_m_div_sqrt_secs = 9.81f;
It think is better to set 'em as a class, because sometimes you need to access them in any part of the code. And if you modify any one of them, the compilation time will be faster. But then I think how much RAM will these constants will be use, so in that case #defines are useful.
I really want to know your opinion.
|
|
|
|
|
Waaaay... back in the 90s, the company's guru said to always use define s -- to save memory. We know better now.
|
|
|
|
|