|
You'll probably need to fix the errors in the UML posted before anyone can really answer this. the '.' operator doesn't work on intrinsic pointers, tb1 needs declaring etc. Some idea of why you want to compare the two pointer values, i.e. what's the goal beyond understanding inheritance would also be useful.
In the end I suspect you're just comparing two different pointers, possibly even by looking at the consecutive addresses where they are stored rather than their values. What you've done isn't really clear enough to be certain though.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
I have corrected the diagram where tmp pointer is used and used actual C++ code now.
Please help me
|
|
|
|
|
Ok there's still an issue with if(tmp==b1) rather than if(tmp==obj_b1) but assuming that is just a typo my bet would be on the multiple inheritance causing an offset between what a2 thinks the value of this is and what a b1 pointer would be pointing at. A couple of things to try, instead of passing a void pointer to update try a a2, try making this a single inheritance hierarchy by deriving a1 form a2 or otherwise.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Hi thank you very much for replying.
I have corrected the problem. (Just inverted the triangles)
What I gave in the UML Diagram is just a kinda semi-pseudocode...
The program compiles and excecuted with no errors...
I am trying to develop a CAD Application with some complex relationships between the shapes
with GOF Observer - Notify pattern for maintaining the relationships
What I gave there is only the class structure where i have problems.
Please tell me why those two pointers are not holding the same address?
|
|
|
|
|
Firstly just a small correction:
In the program section the first line is as follows
c1 *myc1 = new myc1();
That certainly did not compile.
c1 *myc1 = new c1();
will.
In the method update you have the line:
if(tmp==b1)
did you mean:
if(tmp==obj)
Also why the use of the word function if this is C++?
When you instantiate Rel you cast a c1 pointer to a b1 pointer.
When you call f1();
you pass in a this pointer from within a2 in to the update method in the Rel class.
You then cast that pointer to a b1 pointer and compare to see if they are the same pointer.
If they are you call the success method.
So basically you're casting a c1* to a b1*, no problem there.
and casting an a1* to a b1*
I'm curious, how are you maintaining a pointer to Rel in a2 when Rel contains a pointer to a b1, a subclass of a2?
Cheers
Tom
Philosophy: The art of never getting beyond the concept of life.
Religion: Morality taking credit for the work of luck.
"The object of life is not to be on the side of the majority, but to escape finding oneself in the ranks of the insane."
- Marcus Aurelius
|
|
|
|
|
Ah a multiple inheritance problem. Unless only one of the base classes has data members ( so the others are all interfaces ), it should not be done unless as a last resort.
Together with your Rel method update(void*) you appear to have a design problem. void* is untyped and therefore indicative of design flaws.
No doubt there are one or more bugs that could be fixed, but poor design can manufacture complexity and increase the risk of bugs, difficult bugs.
|
|
|
|
|
Hi All,
I m not getting process details (process name, process path) for some processes. for example, I m not getting process details for 3 svchost.exe out 5 svchost.exe. I m getting proper details for 2 svchost.exe.
Thanx,
Subhash
|
|
|
|
|
Subhash Karemore wrote: I m not getting process details...
Using what? Do you have the Debug privilege (i.e., SeDebugPrivilege ) enabled?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hello to all,
i am creating one modeless dialog box whose id is "IDD_DIALOG_TEST" and i have placed some static text "Hello codeproject" on that dialog box. I am invoking that dialog box through "Create" method and showing it through "ShowWindow(SW_SHOWNORMAL)" method, after some time when i will call "DestroyWindow()" method the dialog box will get destroyed, now the problem is that dialog box is getting invoked and displayed properly but the static text on it is not getting displayed means i can see only dialog box but not the static text on it, what can be the reason, can anybody help me plz?
Thanks and Regards,
Anay
|
|
|
|
|
is this[^] article of any help ?
|
|
|
|
|
AnayKulkarni wrote: have placed some static text "Hello codeproject" on that dialog box.
how are you placing the Static text on the dialog. i.e. are you using SetWindowText or included that in Resource file or giving value to any variable to display the static text at startup
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
How are you calling this update function on the dialog? Are you in a UI thread? If not, you can run into problems...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</A>
|
|
|
|
|
Hi all,
how to add pictures to the mainframe as my mainframe is opening with nothing in it.can any one plz tell me clearly about this,,,
thanks in advance,
Saravana...
|
|
|
|
|
saravana001 wrote: how to add pictures to the mainframe as my mainframe is opening with nothing in it.can any one plz tell me clearly about this,,,
how are putting you image in MainFrame Window, i.e. View Window. have you overidden the OnDraw function for drawing image on View Window. you can use this class for display variety of image format on windows http://www.codeproject.com/bitmap/extendedbitmap2.asp[^]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
I have an MDI app - and I wanted a less boring backdrop. The trick is to subclass the MDI Frame window - and then override WM_ERASEBKGND.
The below code uses CSubclassWnd by Paul DiLascia - you should be able to search for in from an old MSJ article on the web.
Good luck,
Iain.
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
m_Backdrop.Install (m_hWndMDIClient, IDB_MIDAS, 32);
....
return 0;
}
class CUIMDIBackdrop : public CSubclassWnd
{
public:
CUIMDIBackdrop ();
~CUIMDIBackdrop ();
BOOL Install (HWND hWndMDIClient, UINT idBitmap, int nMargin);
protected:
virtual LRESULT WindowProc(UINT msg, WPARAM wp, LPARAM lp);
};
CUIMDIBackdrop::CUIMDIBackdrop ()
{
}
CUIMDIBackdrop::~CUIMDIBackdrop ()
{
}
BOOL CUIMDIBackdrop::Install (HWND hWndMDIClient, UINT idBitmap, int nMargin)
{
return HookWindow (hWndMDIClient);
}
LRESULT CUIMDIBackdrop::WindowProc(UINT msg, WPARAM wp, LPARAM lp)
{
if (msg != WM_ERASEBKGND)
return CSubclassWnd::WindowProc(msg, wp, lp);
HDC hDC = (HDC) wp;
CDC *pDC = CDC::FromHandle (hDC);
CRect rc;
::GetClientRect (m_hWnd, &rc);
return TRUE;
}
|
|
|
|
|
Hi all,
I have an application that create a process in suspend mode:
CreateProcess(filePath, 0, 0, 0, TRUE, CREATE_SUSPENDED, 0, 0, &startup, &procinfo);
and then later in code, we will run the program... so do a resume
ResumeThread(procinfo.hThread);
the problem I have is that the windows of the launched program does not appear. For example, if the create process is notepad.exe, when I resume the thread, the window of notepad does not appear and even not in the taskbar.
What is wrong with my approach?
thanks
InovaH
|
|
|
|
|
send it a WM_RESTORE or WM_MAXIMIZE...
BTW, what are you trying to achieve here ?
|
|
|
|
|
How do I send it?
Trought the SendMessage() ? (If so, how to get hwnd)
or with startup.wShowWindow = SW_MINIMIZE; ?
I try to create a process of user's choice in suspend mode to analyse program and inject a monitor DLL. Then process is resumed so that program is used by user.
InovaH
|
|
|
|
|
How are you initializing the startup structure?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Here is the initialization:
STARTUPINFO startup;
GetStartupInfo(&startup);
memset (&procinfo, 0, sizeof (PROCESS_INFORMATION));
memset (&startup, 0, sizeof (STARTUPINFO));
startup.cb = sizeof(&startup);
//start process in SUSPEND mode
CreateProcess(filePath, 0, 0, 0, TRUE, CREATE_SUSPENDED, 0, 0, &startup, &procinfo);
CU
|
|
|
|
|
Shouldn't you be assigning a value, other than 0 , to the wShowWindow member?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
What is the difference between the following two statements?
1. if ((nID & 0xFFF0) == IDM_ABOUTBOX)
2. if ( nID == IDM_ABOUTBOX)
|
|
|
|
|
by doing nID & 0xFFF0 , you're forcing the lower significant bytes to 0.
read this article[^] to understand the & operator better.
|
|
|
|
|
Sakthi_Vel wrote: 1. if ((nID & 0xFFF0) == IDM_ABOUTBOX)
This only looks at the three most significant (upper) bytes, and then compares the result to IDM_ABOUTBOX .
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
DavidCrow wrote: This only looks at the three most significant (upper) bytes
Have to disagree, 0xFFF0 only represents 2 bytes or 16 bits, how can the expression look at three bytes? The expression nID & 0xFFF0 ignores only the lower 4 bits of nID.
|
|
|
|