|
Use the MFC app wizard. Seriously. It's not worth dinking around with it manually.
|
|
|
|
|
Check the function name InitInstance(). If it is misspelt, there will be no window.
|
|
|
|
|
As sthalasayanam told, if everything is correct and you are able to build the project successfully, then definitely the problem is with 'misspelled InitInstance'
|
|
|
|
|
Ups.... That was it.... thankyou very much pals! problem solved XD
|
|
|
|
|
Hi. I'm porting some projects which were orignally built using VC98 (part of Visual STudio 6) to VS2008. So that we can get rid of VS 6 and have everything under VS2008.
Some of the projects are ATL & MFC projects, which apparently is just fine under VS 6, but not in VS2008.
Some of the projects, I have been able to port by removing the MFC includes from the stdafx.h and just including <atlstr.h> where they just needed support for CString.
But some are more MFC intensive. Here's the stdafx.h includes from one:
#include <afxwin.h> // MFC core and standard components
#include <atlbase.h>
extern CComModule _Module;
#include <atlcom.h>
This configuration throws C2065 Undeclared Identifier, C2133 Unknown Size, and C2512 No appropriate default constructor errors. (I guess it can't find the ATL classes.)
If I change the configuration to:
#include <atlbase.h>
extern CComModule _Module;
#include <atlcom.h>
#include <afxwin.h> // MFC core and standard components
I get Error 1 fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include <windows.h> c:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\afxv_w32.h 16 editclm
error.
Help is greatly appreciated.
|
|
|
|
|
Hmmm... So I guess this is really a hard thing...
|
|
|
|
|
I need to implement simple license control in B2B software (SW). My SW should be able to count the number N of simultaneously running instances of SW over current intranet and exit the process in case when N is greater than the number of purchased licenses. So that N would be the maximum number of simultaneously running instances of SW over the intranet.
I convinced that there should be existing solution to this problem (library or smth. like that) but I couldn't find any neither in internet nor at codeguru.
Could anyone suggest anything that could be useful for me?
Thanks in advance!
|
|
|
|
|
Dear all,
I have created a dialog application using Visual C++ 2008 with a menu and I haven't been able to get a check mark to show on a menu item.
In the class derived from CDialog, I declared a private member:
CMenu m_menu;
The menu IDR_MENU1 was loaded into the dialog using the resource editor.
In the OnInitDialog function of the same class:
m_menu.LoadMenuA(IDR_MENU1);
When the user selects the menu item, the check should appear. The code reached after selecting the menu item:
UINT j = m_menu.CheckMenuItem(ID_HELLO_CHOICE1, MF_BYCOMMAND | MF_CHECKED);
The value of j is 0 after being executed the first time and 8 after being executed the second time, which is what I expected. However, I still see no check mark next to the menu item. How can I get the check mark to show?
Any suggestions and help are appreciated.
Regards,
Mike
-- Modified Friday, March 26, 2010 1:20 PM
|
|
|
|
|
Dear all,
I've just found an answer (funny how this happens just a few minutes after I post the question).
In the class derived from CDialog, I changed m_menu to:
CMenu *m_menu;
In OnInitDialog, I replaced the LoadMenuA statement with:
m_menu = GetMenu();
It worked!
Regards,
Mike
|
|
|
|
|
Hi,
Does anyone know how to add a custom icon to an AfxMessageBox? I'm currently using the following line but would like to use my own icon instead of the canned ones.
AfxMessageBox("Thank you, now continuing.",MB_ICONINFORMATION);
I'm using Microsft Visual Studio C++.
Thanks!
|
|
|
|
|
|
|
Hi everyone, I was wondering if you guys could help
me out on how I should go about building this function in main
to be able to search through binary tree class(it's actually called
BinarySearchTree and is virtual from a TreeNode class, but that isn't really important).
So here is the code for BST.h that I'm trying to build the function for:
in BST.H:
typedef void (*FunctionType)(TreeItemType& anItem);
some ways BST.h uses FunctionType are...
virtual void preorderTraverse(FunctionType visit);
TreeItemType is a ADT from another class called keyeditem who's node is
of the int datatype.
I need to write a function in main to be able to work with the BST traversals.
I'm using Microsoft visual studio for the solution.
Thanks in advance!
|
|
|
|
|
To my knowledge, a binary search tree (BST) can be traversed (e.g., searched) in four different ways: pre-oder, in-order, post-order, and level-order. Other ways may exist but these are at least the most popular.
While not a direct answer to your question, I'll offer this just in case it may help. I have a very basic "binary tree" project that I refer to on occasion. Its preorder() traversal function looks like:
void preorder( node *n )
{
cout << n->data << endl;
if (n->left != 0)
preorder(n->left);
if (n->right != 0)
preorder(n->right);
} It is called from main() and is passed the address of the root node.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Thanks for your quick response.
Unfortunately, I don't think that your solution works with mine.
I tried implementing it, but the your node(in your code) behaves differently from mine.
Mine is actually called a TreeNode, and its members are private, so I can't access them.
Here, I'm going to post all of the code:
IN BST.H:
#include "TreeException.h"
#include "TreeNode.h"
typedef void (*FunctionType)(TreeItemType& anItem);
class BinarySearchTree
{
public:
BinarySearchTree();
BinarySearchTree(const BinarySearchTree& tree)
throw(TreeException);
virtual ~BinarySearchTree();
virtual bool isEmpty() const;
virtual void searchTreeInsert(const TreeItemType& newItem)
throw(TreeException);
virtual void searchTreeDelete(KeyType searchKey)
throw(TreeException);
virtual void searchTreeRetrieve(KeyType searchKey,
TreeItemType& treeItem) const
throw(TreeException);
virtual void preorderTraverse(FunctionType visit);
virtual void inorderTraverse(FunctionType visit);
virtual void postorderTraverse(FunctionType visit);
virtual BinarySearchTree& operator=(const BinarySearchTree& rhs)
throw(TreeException);
protected:
void insertItem(TreeNode *& treePtr,
const TreeItemType& newItem)
throw(TreeException);
void deleteItem(TreeNode *& treePtr, KeyType searchKey)
throw(TreeException);
void deleteNodeItem(TreeNode *& nodePtr);
void processLeftmost(TreeNode *& nodePtr,
TreeItemType& treeItem);
void retrieveItem(TreeNode *treePtr, KeyType searchKey,
TreeItemType& treeItem) const
throw(TreeException);
void copyTree(TreeNode *treePtr, TreeNode *& newTreePtr) const
throw(TreeException);
void destroyTree(TreeNode *& treePtr);
void preorder(TreeNode *treePtr, FunctionType visit);
void inorder(TreeNode *treePtr, FunctionType visit);
void postorder(TreeNode *treePtr, FunctionType visit);
TreeNode *rootPtr() const;
void setRootPtr(TreeNode *newRoot);
void getChildPtrs(TreeNode *nodePtr,
TreeNode *& leftChildPtr,
TreeNode *& rightChildPtr) const;
void setChildPtrs(TreeNode *nodePtr,
TreeNode *leftChildPtr,
TreeNode *rightChildPtr);
private:
TreeNode *root;
};
in TreeNode.h:
#include "KeyedItem.h"
typedef KeyedItem TreeItemType;
class TreeNode
{
private:
TreeNode() {}
TreeNode(const TreeItemType& nodeItem,
TreeNode *left = NULL, TreeNode *right = NULL)
: item(nodeItem), leftChildPtr(left),
rightChildPtr(right) {}
TreeItemType item;
TreeNode *leftChildPtr, *rightChildPtr;
friend class BinarySearchTree;
};
in keyeditem.h
typedef int KeyType;
class KeyedItem
{
public:
KeyedItem() {}
KeyedItem(const KeyType& keyValue)
: searchKey(keyValue) {}
KeyType getKey() const
{ return searchKey;
}
private:
KeyType searchKey;
};
Thanks again for the quick response.
|
|
|
|
|
While not complete, I came up with something like:
void MyCallback( TreeItemType& anItem )
{
cout << anItem.getKey();
}
void main( void )
{
BinarySearchTree bst;
TreeItemType key(1);
bst.searchTreeInsert(key);
bst.preorderTraverse(MyCallback);
}
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Yes I thought so too, that I had to "friend" the BST class.
But my instructions are to implement the function in main.
here's the insert function in bst.cpp:
void BinarySearchTree::searchTreeInsert(const TreeItemType& newItem)
throw(TreeException)
{
insertItem(root, newItem);
}
^^That function calls this function below(still in bst.cpp):
void BinarySearchTree::insertItem(TreeNode *& treePtr,
const TreeItemType& newItem)
throw(TreeException)
{
if (treePtr == NULL)
{
try
{
treePtr = new TreeNode(newItem, NULL, NULL);
}
catch (bad_alloc e)
{
throw TreeException(
"TreeException: insertItem cannot allocate memory");
}
}
else if (newItem.getKey() < treePtr->item.getKey())
insertItem(treePtr->leftChildPtr, newItem);
else
insertItem(treePtr->rightChildPtr, newItem);
}
|
|
|
|
|
the code you just posted:
void MyCallback( TreeItemType& anItem )
{
}
void main( void )
{
BinarySearchTree bst;
TreeItemType key(1);
bst.searchTreeInsert(key);
bst.preorderTraverse(MyCallback);
}
Its what I tried first, but i kept getting an error saying the the function MyCallBack(in your case) needs to return a FunctionType value.
|
|
|
|
|
According to the function's signature that you initially posted, it should return a void .
Member 3822532 wrote: Its what I tried first, but i kept getting an error saying the the function MyCallBack(in your case) needs to return a FunctionType value.
What line is the compiler complaining about?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Yes, exactly! And that's why I'm frustrated!
the typedef definition in BST.h:
typedef void (*FunctionType)(TreeItemType& anItem);
That means the function FunctionType is void right?
or does it mean that it is of FunctionType value and thus needs to return that value?
I know that my misunderstanding of that one line of code is what is causing me all the problems.
|
|
|
|
|
Member 3822532 wrote: That means the function FunctionType is void right?
It means that it returns a void .
What does your implementation of this function look like?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Sorry that's what I meant to say.
It returns void, but I keep getting the error that it needs to return the value FunctionType.
So here is the implementation.
This is what I did in response to the error.
I don't think this is right, but I got no error when I tried compiling the code.
FunctionType showNumber(TreeItemType& iTreeNumber)
{
return showNumber(iTreeNumber);
}
This causes a recursive error.
|
|
|
|
|
It should be:
void showNumber( TreeItemType& iTreeNumber )
{
cout << iTreeNumber.getKey();
}
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
yeah.
Before posting this problem on the boards, I had tried attaching void as the function sig:
void showNumber( TreeItemType& iTreeNumber )
{
cout << iTreeNumber.getKey();
}
and this is error i get:
"cpp(74) : error C2664: 'BinarySearchTree::preorderTraverse' : cannot convert parameter 1 from 'void' to 'FunctionType'"
then i tried this.
FunctionType showNumber( TreeItemType& iTreeNumber )
{
return showNumber(iTreeNumber);
}
for no error, but not the correct solution.
|
|
|
|
|
Then the problem is with code you've not shown. I've taken each of your code snippets and it compiles fine.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|