Watch, Follow, &
Connect with Us

Welcome, Guest
Guest Settings
Help

Thread: Implementation of interface in TForm descendant



Permlink Replies: 2 - Last Post: Jun 23, 2017 11:09 PM Last Post By: Remy Lebeau (Te... Threads: [ Previous | Next ]
khanh hoa

Posts: 1
Registered: 7/17/17
Implementation of interface in TForm descendant
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 17, 2017 8:46 AM
Indie stardom was feasible for Jason Lee. But could be the onetime skateboard tricks for beginners ead?

The amount of actors will easily notice skateboarding sent them zooming around the track to stardom?

Jason Lee glided into acting a few years after winning a nationwide skateboard championship within the teens. Since 1995, when author-director Kevin Cruz cast him in Mallrats, the Oc native has switched in certain 15 movies. He's now balancing two worlds, the indies as well as the majors, as rapidly while he used to the 360 switch, moving he earned famous back round the skateboarding scene.

"Jason's performed plenty of 'dude' roles, and the man clearly is a touch a dude," states Cruz, who's cast him in four films. "However I usually have seen him just like a good guy. I'm glad all individuals other customers are finally creating ground.Inch

Lee will get to Canteen in SoHo fresh within the number of Vanilla Sky, his second movie for Cameron Crowe. (He performed second fiddle to Billy Crudup in Almost Famous.) Snow is falling, and he's wearing just an easy parka. Though he's in desperate will require a smoke which is pissed off at New You'll be able to cabs, he's still maintaining that positive L.A. mindset: "The snow rocks !, man."

Whatever the unself-conscious elan he fidgets along with his hair and illuminates a cigarette, he insists he's little curiosity about cultivating a awesome-guy image. "That whole James Dean revival factor--searching mysterious, cigarette smoking along with your shirt somewhat open--that's so outdated already," according to him.

Still, Lee will have his debut just like a romantic good guy, opposite Jennifer Love Hewitt inside the neo-screwball comedy Heartbreaker. "My movies have become bigger and bigger,Inch he admits. "However almost didn't take Heartbreakers. The person made an appearance somewhat straight--a sweet, nice guy that ladies would love. However, you cannot just play in the weirdo in every single movie to head off being the dark."

Really, although his Heartbreakers character, a bartenders, falls challenging for Hewitt's tough disadvantage artist, he is not an entire sap, which explains why author-director David Mirkin chose Lee. "I didn't want an actress who'd play him totally straight," states Mirkin. "I authored the spend someone off-kilter in your thoughts. I really like a enjoyable edge, though heart. Jason has that. They can be emotional, but he is not mushy."

A few several days later, Lee is at La wrapping Vanilla Sky, from time to time shooting Smith's Jay and Silent Bob Strike Back (that literally brings back his character from Chasing Amy and Mallrats, along with Film Clip, Joey Lauren Adams, Matt Damon plus a cast of hundreds), prepping Stealing Stanford (the initial movie from Bruce McCulloch of "The Kids inside the Hall") and doing promotion for just about any comedy referred to as Big Trouble which will come within the fall. He's also recording a couple of from the experimental ambient music he's been noodling around with for any lengthy time, getting involved in and sponsoring vintage-vehicle races and beginning a specialist-driving instructor, Road One Racing, getting a buddy. https://www.linkedin.com/pulse/what-size-skateboard-should-i-get-skates-zone

Basically, he's busy. In addition to focused. One reason for Lee's eclectic success is always that he doesn't drink, doesn't party and, within the ripe ages of 30, remains married for five years, to his longtime sweetheart, L.A. professional professional photographer Carmen Llywellyn.

"The primary reason I put within the towel partying? Already been through it, done that," Lee states. "I obtained from my system. I don't even drink coffee now."

"You don't see many youthful actors who're that settled lower," states 20-year-old Zooey Deschanel, who labored with Lee on Mumford, Almost Famous and enormous Trouble. "It's nice to get along with Jason, because he's so family-minded, and he's so crazy about his wife. And therefore funny."

Clearly, he is not all funny in Vanilla Sky the show Crowe is directing around the secretive set with Tom Cruise, Cameron Diaz and Penelope Cruz. "It's dark," Lee admits. "Then when I signed on to make it happen, that's all I understood relating to this. We're not allowed to discuss it, but everyone knows it's a remake from the Spanish film from 1997 referred to as Abre los Ojos "And you also know what's weird?" he asks. "Tom Cruise is regarded as the normal guy connected having a guy actor I've met. He loves sports, and he's a guy who can look to college reunions and become buddies using the uncles."

But is he ... awesome? how to assemble skateboard

"What exactly?In . Lee laughs. "I used to be awesome. Awesome was all I figured about. But awesome is kind of overrated. In my opinion Tom Cruise would explain how. And do you know what?In . He stubs out half of his third smoke. "Many of us are just trying to pretend we're cooler than we really are. Making me think I oughta quit smoking. If Sean Penn are capable of doing it, I am in a position to.In .

Edited by: khanh hoa on Jun 23, 2017 11:05 PM
Antonio Estevez

Posts: 503
Registered: 4/12/00
Re: Implementation of interface in TForm descendant [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 17, 2017 9:30 AM   in response to: khanh hoa in response to: khanh hoa
El 17/06/2017 a las 17:52, khanh hoa escribió:
In example bellow compilation is without error, but in runtime Error: 'Pure virtual function called' is raised

File interface.h

//---------------------------------------------------------------------------
#ifndef InterfaceH
#define InterfaceH

__interface INTERFACE_UUID("{9EB5933E-7556-46FD-A3EB-85163E462809}") ITest : public IInterface
{
private:
protected:
public:
virtual void __fastcall SetTest(int Scale) = 0; // Pure virtual
virtual int __fastcall GetTest(void) = 0; // Pure virtual
__property int Test = { read = GetTest, write = SetTest };
};
typedef System::DelphiInterface<ITest> _di_Test;
#endif
//---------------------------------------------------------------------------

File Unit1.h
//---------------------------------------------------------------------------

#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <System.Classes.hpp>
#include <Vcl.Controls.hpp>
#include <Vcl.StdCtrls.hpp>
#include <Vcl.Forms.hpp>
#include "Interface.h"
//---------------------------------------------------------------------------
class TForm1 : public TForm, public ITest
{
__published: // IDE-managed Components
private: // User declarations
void __fastcall SetTest(int Scale) { }; // Override
int __fastcall GetTest(void) {return 1;}; // Override
public: // User declarations
__fastcall TForm1(TComponent* Owner);

};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif

File Unit1.cpp
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
_di_Test i1;

if (this->GetInterface(i1)) // <====== Error: Pure virtual function called (Win32),
{
i1->Test = 1;

int x = i1->Test;
}
}
//---------------------------------------------------------------------------

Where is mistake? Thanks

You must implement both AddRef() and Release() methods of the IUnknown interface:

class TForm1 : public TForm, public ITest
{
__published:	// IDE-managed Components
private:	// User declarations
    // IUnknown
    virtual ULONG STDMETHODCALLTYPE AddRef(void);
    virtual ULONG STDMETHODCALLTYPE Release(void);
    // ITest
    void __fastcall SetTest(int Scale) { }; // Override
    int __fastcall GetTest(void) {return 1;}; // Override
public:		// User declarations
    __fastcall TForm1(TComponent* Owner);
};


ULONG STDMETHODCALLTYPE TForm1::AddRef( void)
{
    return _AddRef();
}
 
ULONG STDMETHODCALLTYPE TForm1::Release( void)
{
    return _Release();
}
Remy Lebeau (Te...


Posts: 8,201
Registered: 12/23/01
Re: Implementation of interface in TForm descendant [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 19, 2017 10:20 AM   in response to: Antonio Estevez in response to: Antonio Estevez
Antonio Estevez wrote:

You must implement both AddRef() and Release() methods of the
IUnknown interface

And QueryInterface() as well.

These 3 methods are already implemented by TComponent for you. And
while your code example is correct (for AddRef() and Release(), but you
are missing QueryInterface()), you did not explain why you wrote the
code the way you did. This is actually documented on Embarcadero's
DocWiki:

http://docwiki.embarcadero.com/RADStudio/en/Inheritance_and_Interfaces#IUnknown_and_IInterface

The root issue is that "the Delphi definition of IUnknown, however,
does not correspond to the definition of IUnknown that is used in
C++Builder." Because of that, you have to implement the C++ version of
IUnknown and delegate it to the Delphi implementation of IIinterface:

class TForm1 : public TForm, public ITest
{
__published:	// IDE-managed Components
    //...
private:	// User declarations
public:		// User declarations
    __fastcall TForm1(TComponent* Owner);
 
    // IUnknown
    virtual HRESULT STDMETHODCALLTYPE QueryInterface(const GUID &IID,
void **Obj);
    virtual ULONG STDMETHODCALLTYPE AddRef(void);
    virtual ULONG STDMETHODCALLTYPE Release(void);
 
    // ITest
    void __fastcall SetTest(int Scale);
    int __fastcall GetTest(void);
};
 
HRESULT STDMETHODCALLTYPE TForm1::QueryInterface(const GUID &IID, void
**Obj)
{
    return TForm::QueryInterface(IID, (void*)Obj); 
}
 
ULONG STDMETHODCALLTYPE TForm1::AddRef( void)
{
    return TForm::_AddRef();
}
 
ULONG STDMETHODCALLTYPE TForm1::Release( void)
{
    return TForm::_Release();
}
 
void __fastcall TForm1::SetTest(int Scale)
{
    //...
}
 
int __fastcall TForm1::GetTest(void)
{
    return ...;
}


You can simplify this by using the INTFOBJECT_IMPL_IUNKNOWN() macro,
which implements and delegates the IUnknown methods for you:

class TForm1 : public TForm, public ITest
{
__published:	// IDE-managed Components
    //...
private:	// User declarations
public:		// User declarations
    __fastcall TForm1(TComponent* Owner);
 
    // IUnknown
    INTFOBJECT_IMPL_IUNKNOWN(TForm);
 
    // ITest
    void __fastcall SetTest(int Scale);
    int __fastcall GetTest(void);
};
 
void __fastcall TForm1::SetTest(int Scale)
{
    //...
}
 
int __fastcall TForm1::GetTest(void)
{
    return ...;
}


--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02