|
Thanks for example....
I want to know about this line.
CCtrlDrawContext(CClientDC* pcDC, const CRect& cRect);
Can i pass these two parameter manual?i cann't understand example which is given by you?Please explain more details.
|
|
|
|
|
MsmVc wrote: Can i pass these two parameter manual?
Yes, for example,
as it shown in the function void CYourDialog::OnButtonClick()
virtual void BeHappy() = 0;
|
|
|
|
|
Sorry i am not geting what you want to tell me.
I think this part is header file.
class CCtrlDrawContext
{
CClientDC* m_pcCtrlDC;
CRect m_cCtrlRect;
public:
CCtrlDrawContext(CClientDC* pcDC, const CRect& cRect);
~CCtrlDrawContext();
cons CRect& GetRect() { return cRect; };
CDC* GetDC() { return m_pcCtrlDC; };
};
Now my code is
class CTestDlg : public CDialog
{
public:
CTestDlg(CWnd* pParent = NULL);
How can i pass this parameter
CClientDC* pcDC, const CRect& cRect
Please help me
|
|
|
|
|
For example :
void CYourDialog::OnButton4Click()
{
CRect cStaticRect;
m_cwndStatic.GetClientRect(cStaticRect);
AfxBeginThread((AFX_THREADPROC) ThreadLoop,
new CCtrlDrawContext(new CClientDC(&m_cwndStatic),
cStaticRect));
}
virtual void BeHappy() = 0;
|
|
|
|
|
i add your code but error show here
parnew CCtrlDrawContext(new CClientDC(&m_cwndStatic), cStaticRect));
Error
error C2661: 'CTestDlg::CTestDlg' : no overloaded function takes 2 arguments
|
|
|
|
|
Please see your starting post -
you have to modify your void CTestDlg::OnBnClickedButton4()
(the Context class could be placed in the same *.cpp file,
but above the CTestDlg implementation)
virtual void BeHappy() = 0;
|
|
|
|
|
Now i place code in .cpp file and all code give by you.Still i am getting error.
error C2039: 'GetRect' : is not a member of 'CTestDlg
|
|
|
|
|
Try the following :
0. Repair the state of your project (see your starting post)
1. Place the new context class at the top of your cpp, after the include block
2. Modify your OnClick function
3. Modify your ThreadLoop function
virtual void BeHappy() = 0;
|
|
|
|
|
Sorry it's not working for me.
But i want to say once again Thanks for Discussion.
|
|
|
|
|
Don't use a thread to do this use a timer.
|
|
|
|
|
OnNotify(HWND hDlg, int idCtrl, NMHDR *pnmh)
{
switch(pnmh->code)
{
case LVN_BEGINDRAG:
{
}
}
}
My code is like this
even after the dragging column of ListView i m not able catch the drag event inside case LVN_BEGINDRAG
am i missing something??
thanks in advance
|
|
|
|
|
Hello world,
I don't have any idea how do to make connection to a database using the language C. I preserve if it would be to SQL server.
Thanks
|
|
|
|
|
You may use, for instance ODBC , there are a lot of articles, here at CodeProject , in the database section [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
If you are using mysql then just have a look with the APIs provided by mysql
[^]
Величие не Бога может быть недооценена.
|
|
|
|
|
Take a look at documentation for the CDatabase and CRecordset MFC classes.
I believe this will be the easiest for a beginner.
In particular look at the CDatabase::Open[^] method.
|
|
|
|
|
Hi
How could I write my xml document with indention By MSMXL6
Is there any way to cofigure this
a sample code my clear the case
regards
|
|
|
|
|
The only way i've been able to do this was to apply a XSL transform to the XML before saving it using the transformNodeToObject method of MSXML.
Good luck.
M.
Watched code never compiles.
|
|
|
|
|
Hi,
would any one where I can download or define a cursor such as the one in VIsual Studio uses when stepping thru code ???
also that round bullet used to signify breakpoint is nice dont know if that something I can define and or Load from my resource file
thankx
|
|
|
|
|
The ordinary VS project setup that installs some application on computer does not delete files that were changed during program usage.
If installing that setup again on the same computer those files are not replaced with those from setup either.
How to enable setup to remove all files from and folders in spite the files were changed or added others?
Чесноков
|
|
|
|
|
a.h: static ClassOne *one;
a.cpp: ClassOne::one = this; //So, can I do it like this?
But an error has occured: "expected constructor, destructor, or type conversion before '=' token"
modified on Thursday, April 15, 2010 9:54 PM
|
|
|
|
|
In a.cpp, try:
ClassOne *one = this;
What was I thinking?
modified on Thursday, April 15, 2010 10:44 PM
|
|
|
|
|
If I understand what you are asking, then it should be something like this:
- a.h
class ClassOne {
void SetRef();
};
static ClassOne* one;
- a.cpp
one(0);
inline void ClassOne::SetRef() {one = this;}
Your problems are:
- "this" is only valid inside class member methods.
- You do not need to have "ClassOne::" infront of "one" unless it is a static member of the class (it is declared within the scope of the class).
If "one" is a static member, this a.cpp would be as follows:
ClassOne * ClassOne::one(0);
inline void ClassOne::SetRef() {ClassOne::one = this;}
|
|
|
|
|
It seems you are confusing classes with instances (that is the same as confusing types with variables) local and global scope and linkage.
Assuming the declaration you provided are at file scope (that is, not enclosed in some other braces) one is a pointer to a ClassOne object. It exist at global level (the pointer!) and have only local visibility (local in respect to the cpp file that "sees" it, that are all the cpp files that include the h file - in other words, static has very few sense in h files)
ClassOne::one does not exist, since one is global, and not a part of ClassOne (hence the compiler doesn't know what to do), and than, this is meaningless since you are not inside a member function body.
At this point we cannot correct, since we cannot figure out what you where trying to do.
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
if you need a global object create one. If not you dont need a global pointer.
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
I have to display the contents of a binary tree in its "tree" form rather than a string of numbers.
I have a solution(i think) on how I'm suppose to display it.
My problem is that I keep getting a link error that looks like this:
"b11.obj : error LNK2001: unresolved external symbol "public: void __thiscall AVLTreeType<int>::rnl_inorderTraversal(void (__cdecl*)(int ..."
I know its the display hierarchy component of the program specifically, but I don't know what.
I'm using Visual Studio 08.
Thanks in advance.
and sorry for the long post.
I just thought people would at least want the functional parts of the binary tree class code.
here's most of the binary tree class code:
at the very bottom is the rnl_inorderTraversal function I'm having trouble with.
#include <iostream>
using namespace std;
template<class T>
struct AVLNode
{
T info;
int bfactor;
AVLNode<T> *llink;
AVLNode<T> *rlink;
};
template <class T>
class AVLTreeType
{
public:
void insert(const T &newItem);
void postorderTraversal(void (*visit)(T&) );
void rnl_inorderTraversal(void (*visit)(T&,int));
int treeHeight();
int treeNodeCount();
int treeLeavesCount();
void destroyTree();
AVLTreeType();
private:
AVLNode<T>* root;
void rotateToLeft(AVLNode<T>* &root);
void rotateToRight(AVLNode<T>* &root);
void balanceFromLeft(AVLNode<T>* &root);
void balanceFromRight(AVLNode<T>* &root);
void insertIntoAVL(AVLNode<T>* &root,AVLNode<T> *newNode, bool& isTaller);
void rnl_inorder(AVLNode<T> *p,void(*visit)(T&,int),int);
void postorder(AVLNode<T> *p, void (*visit)(T&) );
void destroy(AVLNode<T>* &p);
};
template<class T>
void AVLTreeType<T>::rotateToLeft(AVLNode<T>* &root)
{
AVLNode<T> *p;
if(root == NULL)
cerr<<"Error in the tree."<<endl;
else
if(root->rlink == NULL)
cerr<<"Error in the tree:"
<<" No right subtree to rotate."<<endl;
else
{
p = root->rlink;
root->rlink = p->llink;
p->llink = root;
root = p;
}
}
template<class T>
void AVLTreeType<T>::rotateToRight(AVLNode<T>* &root)
{
AVLNode<T> *p;
if(root == NULL)
cerr<<"Error in the tree."<<endl;
else
if(root->llink == NULL)
cerr<<"Error in the tree:"
<<" No left subtree to rotate."<<endl;
else
{
p = root->llink;
root->llink = p->rlink;
p->rlink = root;
root = p;
}
}
template<class T>
void AVLTreeType<T>::balanceFromLeft(AVLNode<T>* &root)
{
AVLNode<T> *p;
AVLNode<T> *w;
p = root->llink;
switch(p->bfactor)
{
case -1: root->bfactor = 0;
p->bfactor = 0;
rotateToRight(root);
break;
case 0: cerr<<"Error: Cannot balance from the left."<<endl;
break;
case 1: w = p->rlink;
switch(w->bfactor)
{
case -1: root->bfactor = 1;
p->bfactor = 0;
break;
case 0: root->bfactor = 0;
p->bfactor = 0;
break;
case 1: root->bfactor = 0;
p->bfactor = -1;
}
w->bfactor = 0;
rotateToLeft(p);
root->llink = p;
rotateToRight(root);
}
}
template<class T>
void AVLTreeType<T>::balanceFromRight(AVLNode<T>* &root)
{
AVLNode<T> *p;
AVLNode<T> *w;
p = root->rlink;
switch(p->bfactor)
{
case -1: w = p->llink;
switch(w->bfactor)
{
case -1: root->bfactor = 0;
p->bfactor = 1;
break;
case 0: root->bfactor = 0;
p->bfactor = 0;
break;
case 1: root->bfactor = -1;
p->bfactor = 0;
}
w->bfactor = 0;
rotateToRight(p);
root->rlink = p;
rotateToLeft(root);
break;
case 0: cerr<<"Error: Cannot balance from the right."<<endl;
break;
case 1: root->bfactor = 0;
p->bfactor = 0;
rotateToLeft(root);
}
}
template<class T>
void AVLTreeType<T>::insert(const T &newItem)
{
bool isTaller = false;
AVLNode<T> *newNode;
newNode = new AVLNode<T>;
newNode->info = newItem;
newNode->bfactor = 0;
newNode->llink = NULL;
newNode->rlink = NULL;
insertIntoAVL(root, newNode, isTaller);
}
template<class T>
void AVLTreeType<T>::insertIntoAVL(AVLNode<T>* &root,
AVLNode<T> *newNode,
bool& isTaller)
{
if(root == NULL)
{
root = newNode;
isTaller = true;
}
else
if(root->info == newNode->info)
cerr<<"No duplicates are allowed."<<endl;
else
if(root->info > newNode->info)
{
insertIntoAVL(root->llink, newNode, isTaller);
if(isTaller)
switch(root->bfactor)
{
case -1: balanceFromLeft(root);
isTaller = false;
break;
case 0: root->bfactor = -1;
isTaller = true;
break;
case 1: root->bfactor = 0;
isTaller = false;
}
}
else
{
insertIntoAVL(root->rlink, newNode, isTaller);
if(isTaller)
switch(root->bfactor)
{
case -1: root->bfactor = 0;
isTaller = false;
break;
case 0: root->bfactor = 1;
isTaller = true;
break;
case 1: balanceFromRight(root);
isTaller = false;
}
}
}
template <class T>
void AVLTreeType<T>::postorderTraversal(void (*visit)(T& item) )
{
postorder(root, *visit);
}
template <class T>
void AVLTreeType<T>::postorder(AVLNode<T> *p,
void (*visit)(T& item) )
{
if(p != NULL)
{
postorder(p->llink, *visit);
postorder(p->rlink, *visit);
(*visit)(p->info);
}
}
template <class T>
void AVLTreeType<T>::destroy(AVLNode<T>* &p)
{
if(p != NULL)
{
destroy(p->llink);
destroy(p->rlink);
delete p;
p = NULL;
}
}
template <class T>
void AVLTreeType<T>::destroyTree()
{
destroy(root);
}
template<class T>
AVLTreeType<T>::AVLTreeType()
{
root=NULL;
}
template<class T>
void rnl_inorderTraversal(void(*visit)(T&,int))
{
int iLevel=0;
rnl_inorder(root,*visit,iLevel);
}
template<class T>
void rnl_inorder(AVLNode<T> *p,void(*visit)(T&,int),int)
{
if(p != NULL)
{
iLevel+1;
rnl_inorder(p->rlink,*visit,iLevel);
(*visit)(p->info);
rnl_inorder(p->llink,*visit,iLevel)
}
}
here's the code for main.
specifically, the areas which rnl_inorderTraversal is used.
#include <iostream>
#include <iomanip>
#include"avlTree.h"
#include <fstream>
using namespace std;
template<class T>
void displayHierarchial(T& anItem, int level);
int main()
{
AVLTreeType<int> cTree1;
cTree1.insert(1);
cTree1.insert(2);
cTree1.insert(4);
cTree1.rnl_inorderTraversal(displayHierarchial);
return 0;
template<class T>
void displayHierarchial (T& anItem, int level)
{
cout <<level<<".) "<< anItem<<' ';
}
|
|
|
|