|
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.
|
|
|
|
|
That creates a new _variant_t object and returns its address. However that is a temporary object, and gets destroyed at the end of whatever statement it's in, so you can't use that as a function return value, because the pointer will be invalid back in the calling code (it won't point at a valid object).
--Mike--
http://home.inreach.com/mdunn/
"....." -- Silent Bob
your with and
|
|
|
|
|
I see your website, that is nice !!!
By the way, 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
|
|
|
|
|
As I said already, that makes a new temporary _variant_t object and takes its address. That address is passed to the PutElement() function. Since by C++ rules, any pointer can be implicitly converted to void*, no cast is needed.
--Mike--
http://home.inreach.com/mdunn/
"....." -- Silent Bob
your with and
|
|
|
|
|
Does anyone know how to throw an exception across threads?
Is this possible at all given the stack unwinding issues? Is there perhaps some other mechanism for interrupting the logic of one thread from another without Waits or SleepEx or other sync functions. Callbacks - from timers etc. - are in the calling thread so they are no good to me.
I need to protect a block of code as follows,
Start timer
-------------
Code Block
normal exit
-------------
Timeout
timeout exit
The try/catch block is ideal but the timers run in their own threads so I don't catch nothing.
Thanks to all!
|
|
|
|
|
AFAIK throwing an exception from a thread will cause the exception to be propogated down the stack of the thread only - if it were to be caught by another thread then the operating being performed by that thread would have to be interrupted etc and it would just be a disaster as well as being unimplentable (practially at least).
A better solution is to return an error value from the thread.
--
Andrew.
|
|
|
|
|
I think you are correct and a thread can't be interrupted. I don't see any great technical difficulty in doing it (that's really what the scheduler does after all) but the system is designed not to do it, so that's that.
I looked at APCs but they only work when the thread is sleeping or waiting so that's no good to me either. I need to have functions (node/action functions for a state machine written by others) running by themselves and being timed out in the state engine which I wrote.
What do you mean "return an error value from the thread"? Do you mean the value in the terminating "return int" or some other mechanism I don't know about. I know you can get the terminating value when a thread exits is this what you mean?
Thanks for your thoughts anyway.
Joe M.
|
|
|
|
|
I think you are correct and a thread can't be interrupted. I don't see any great technical difficulty in doing it...
Yes, it is easy for threads to be suspended. However, to change the path of execution for a thread is unthinkable - I mean, if your program is carrying out a task and half way through writing to a file the control gets shifted to a code handler you've had it.
Yes, I did mena the terminating return int statement.
--
Andrew.
|
|
|
|