|
I have to give a data tip on every record(each recod contains three points) on mygraph.For this i am creating
Button controls for every point in for loop as like
MyFuntion(){
for(firstrecord,somerecords(nearly25),lastrecord)
{
CButton *pCon=new CButton;//start point
CButton *pCon1=new CButton;//peak point
CButton *pCon2=new CButton;//end point
pCon.Create(_TEXT(""),WS_VISIBLE|BS_FLAT,CRect,this,Number)
pCon1.Create(_TEXT(""),WS_VISIBLE|BS_FLAT,CRect,this,Number)
pCon2.Create(_TEXT(""),WS_VISIBLE|BS_FLAT,CRect,this,Number)
m_datatip.AddTip(Text,pCon,Number);
m_datatip.AddTip(Text,pCon1,Number);
m_datatip.AddTip(Text,pCon2,Number);
}
}
I am calling this function from OnPaint.
For very first this code is working exactly.When ever
i am calling this function next time the controls not destroying.
I used "delete [] control" ,"delete control" in various places in my function and i didn't get the solution.
Please help me ,
Where can I delete these created controls for callling the Myfunction next time.
|
|
|
|
|
In your header...
typedef CList<cbutton*, cbutton*=""> ButtonList;
class CYourDialog or CWindow.....
{
ButtonList m_listButtons;
}
and when you create the buttons in your cpp implementation file...
m_listButtons.AddTail(pCon1)
m_listButtons.AddTail(pCon2)
... etc
and when your ready to delete the buttons, preferrable as the window/dialog is closing..
while (!m_listButtons.IsEmpty())
delete m_listButtons.RemoveTail();
Normski - Windows Professional Programmer
|
|
|
|
|
Thank you for your Information.
I used this code in my project ,but i didn't detroy all my created buttons.
I am using like this...
MyFunction()
{
CButton *pCon;
for(int i=0;i<15;i++)
{
pCon=new CButton;
pCon->create(_TEXT(""),WS_VISIBLE,CRect(),this,i);
m_buttonlist.AddTail(pCon);
}
//
//my remaining code
//
while(!m_buttonlist.ISEmpty())
{
m_buttonlist.RemoveTail();
pCon->DestroyWindow();
}
In the above attempt the last created button only destroyed.
How can destroy all the created buttons in the for loop;
please help me.
anju
|
|
|
|
|
>while(!m_buttonlist.ISEmpty())
>{
>m_buttonlist.RemoveTail();
>pCon->DestroyWindow();
>}
You forgot to get the pointer to the button when you removed the tail.
while(!m_buttonlist.ISEmpty())
{
pCon = m_buttonlist.RemoveTail();
pCon->DestroyWindow();
}
|
|
|
|
|
ARRRRRAGGGGHHHHHHH!!!!!!!! DELETE!!!!!!!!!!!!!
while(!m_buttonlist.IsEmpty())
{
pCon = m_buttonlist.RemoveTail();
pCon->DestroyWindow();
delete pCon; //always delete when creating with 'new'
}
|
|
|
|
|
thank u sir,
Now the code workig exactly what i need,
once again thank you sir.
|
|
|
|
|
Hi, codegurus from worldwide.
I want to change my IP address and it seems nobody can help me. But i'm tring again now asking all of you.
It is about static IP on any WIN95/98/NT platforms. I know IPCONFIG on NT and WINIPCFG on WIN95/98 is able to do that using inetmib1.dll. So that i've tried to do my job using inetmib1.dll and i managed to do everything but changing those read-write MIBII attributes, including IP address.
For solving my problem, I promise 1000x for that guru of all codegurus in the world and i'll be his fan forever.
Accept my apologize for not such a good English.
|
|
|
|
|
Hi
i see this code in most of the downloaded examples
but what does this code really do ?
Is Dumping of DC really required ?
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#ifdef _DEBUG
void CviewTwo::AssertValid() const
{
CView::AssertValid();
}
void CviewTwo::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
#endif //_DEBUG
parag
|
|
|
|
|
I have a frame window with multiple different views in. One of them is active at any given time.
When I resize the window, the currently active view behaves fine, but when I switch to one of the others, they keep the size they were before.
So how can I size my view to be as big as the client area of the frame window it is in.
LP
|
|
|
|
|
Hi all!
When a branch is clicked, how do I retrieve the information of its parent and grandParent?
I have not been able to find help in GetParent()and GetParentItem() in the msdn (the help is confusing.)
Thank you
Vu
vucsuf
|
|
|
|
|
CTreeCtrl::GetParentItem
HTREEITEM GetParentItem( HTREEITEM hItem );
Return Value: The handle of the parent item; otherwise NULL.
Parameters: hItem - Handle of a tree item.
Remarks: Call this function to retrieve the parent of hItem.
--Mike--
http://home.inreach.com/mdunn/
"....." -- Silent Bob
your with and
|
|
|
|
|
Hi I'm developing an app using CHtmlView and I need to handle bidirectional comunication between my derived CHtmlView class, and one CMouse class that handles mouse events. When some action is done with the moose, i handle the events, and based in some values i must call a function from the derived CHtmlView class. Any idea how can I get this done?? Tnx
|
|
|
|
|
Give each class a pointer to the instance of the other. You'll need in at least one case to put a dummy class declaration in the .h file, and #include the real one in the .cpp, or you'll have a circular include thing happening.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
Nop doesn't work or i'm not getting it. Could u give me an example? Tnx
|
|
|
|
|
It *does* work, it's the only way really to do it. Post the code you're using and I'd be glad to have a look at it.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
I've got a CHtml2View class that it's inherited from CHtmlView.
And I've got another one CMouse that handle mouse events. Somebody(I don't remember his name..) give me this code for getting mouse events. This is inside
CHml2View::OnDocumentComplete
CWnd * m_Wnd = GetWindow( GW_CHILD );
if (m_Wnd)
{
m_Wnd = m_Wnd->GetWindow( GW_CHILD );
if (m_Wnd)
{
m_Wnd = m_Wnd->GetWindow( GW_CHILD );
if (m_Wnd)
{
m_MouseWnd.SubclassWindow(m_Wnd->m_hWnd);
}
}
}
This m_mouseWnd is an instance of my CMouse class. And in the .h file of CHtml2View i've got an #include "Mouse.h" and the public variable m_mouseWnd in CMouse i've got a function that handle the right button click event. Like this
OnRButtonDown(UINT nFlags, CPoint point)
This part is workin, but i need to call back a funtion of CHtml2View called Execute, and I dont'k know how to do it, if I do an #include "Html2View.h" in Mouse.h or Mouse.cpp I've get a lot of errors !! If u need more details just ask me please. Tnx
|
|
|
|
|
Please tell me what the errors are and what the #includes are for each .cpp file, and also any #includes added to your stdafx.h
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
The includes:
In Html2View.h
#include "Mouse.h"
in Html2View.cpp
#include "stdafx.h"
#include "Html2.h"
#include "Html2Doc.h"
#include "Html2View.h"
in Mouse.cpp
#include "stdafx.h"
#include "Hml2.h"
#include "Mouse.h"
in stdafx.h:
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxdisp.h> // MFC Automation classes
#include <afxdtctl.h>
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
#include <afxhtml.h>
if I put an #include "Html2View.h" in Mouse.h or Mouse.cpp I get the following errors:
G:\John\Software\Visual C\Html\Hml2View.h(22) : error C2143: syntax error : missing ';' before '*'
G:\John\Software\Visual C\Html\Hml2View.h(22) : error C2501: 'CHml2Doc' : missing storage-class or type specifiers
G:\John\Software\Visual C\Html\Hml2View.h(22) : error C2501: 'GetDocument' : missing storage-class or type specifiers
G:\John\Software\Visual C\Html\Hml2View.h(59) : error C2143: syntax error : missing ';' before '*'
G:\John\Software\Visual C\Html\Hml2View.h(59) : error C2433: 'CHml2Doc' : 'inline' not permitted on data declarations
G:\John\Software\Visual C\Html\Hml2View.h(59) : error C2501: 'CHml2Doc' : missing storage-class or type specifiers
G:\John\Software\Visual C\Html\Hml2View.h(60) : error C2501: 'GetDocument' : missing storage-class or type specifiers
|
|
|
|
|
Ah, it's a view. In order to #include a view class, you need to #include the doc class first, as the view class contains a pointer to the doc, but does not include it. Try #include "Html2Doc.h", THEN include the view. Do it in the .cpp, because in the .h creates a circular reference. Put a dummy class declaration for Chtmlview in the mouse class header, as in 'class CHtmlView{};', so you can make a pointer to it a member variable.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
Nop less errors but anyway it doesn't compile!! Where exactly should the dummy definition be placed? My View class it's called CHtml2View.
In Mouse.h i've got:
class CMouse : public CWnd
{
// Construction
public:
CMouse();
/ Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMouse)
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CMouse();
// Generated message map functions
protected:
//{{AFX_MSG(CMouse)
afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
|
|
|
|
|
What were the errors ?
class CHtml2View{};
class CMouse : public CWnd
{
public:
CMouse();
CHtml2View * m_View;
/ Operations
public:
public:
virtual ~CMouse();
protected:
afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
DECLARE_MESSAGE_MAP()
};
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
Hi all,
What is return value in this code:
&(_variant_t("Hadi"))
I mean, return value is what kind of data types ?
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
surely a pointer to a variant with a char * in it ? If you want a WCHAR, then you'd do this
&(_variant_t(L"Hadi"))
Doing this would make me nervous - I don't know what would happen because you're returning the address of a variable which you're creating in the same line and is about to go out of scope. If I have to return a pointer, I create it first and don't delete it ( obviously ), so the returning function has responsibility for clearing the memory.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
It is all the source code:
long lArray = 0;
COleSafeArray ole_array;
ole_array.CreateOneDim(VT_VARIANT, 1);
ole_array.PutElement(&lArray, &(_variant_t("NAME")));
I read MSDN, i must pass void * value to second parameter in PutElement, but in this example he wrote: &(_variant_t("NAME")) !!!
I can't understand
help me ...
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Yes, but it's not in a return statement, like your first example, and therefore is not deleted because it is still in scope during the call.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|