Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / General 2 / January 2004



Tip: Looking for answers? Try searching our database.

Use it or Lose it

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mike Williams - 29 Jan 2004 22:00 GMT
I've just started playing with User Controls (ActiveX Controls actually, is
that the same thing?). I don't usually mess about with new stuff until I
write code that actually requires it, but most people here seem to think
that User Controls are the best thing since sliced bread, and who am I to
argue! So I'm looking into them even though I don't really need them ;-)

The first thing I tried to do was to print one of the little buggers. Now
there are probably a number of different ways of doing this, but for the
method I had in mind I needed to get its hDC, and I wanted to get the hDC of
the User Control from code within the Form on which it lives.  It seems daft
to me, but from what I can see so far code within the User Control itself
can get hold if its hDC, but code within the Form on which the User Control
sits can't get hold of it! For example, I can put code in the User Control
that references its hDC property, but if in the Form which contains it I put
something like "myhandle = UserControl1.hDC" I get an error. Is this the way
it is supposed to be?

Mike
Frank Adam - 29 Jan 2004 22:32 GMT
>I've just started playing with User Controls (ActiveX Controls actually, is
>that the same thing?). I don't usually mess about with new stuff until I
>write code that actually requires it, but most people here seem to think
>that User Controls are the best thing since sliced bread, and who am I to
>argue! So I'm looking into them even though I don't really need them ;-)

They're useful enough for reusable stuff.

>The first thing I tried to do was to print one of the little buggers. Now
>there are probably a number of different ways of doing this, but for the
[quoted text clipped - 6 lines]
>something like "myhandle = UserControl1.hDC" I get an error. Is this the way
>it is supposed to be?

Some things are hidden from the caller. Don't forget, the idea of
class libraries and usercontrols (which are simply glorified classes)
is data hiding. The stuff that you don't want the caller to know about
or doesn't need to know about can be hidden away as private stuff.

However, you can provide it via a Property Get()

Property Get TheHdc() as long
    TheHdc = usercontrol.hdc
End Property

Then in the form : hdc = usercontrol1.thehdc

Signature

Regards, Frank

Mike Williams - 29 Jan 2004 22:41 GMT
> However, you can provide it via a Property Get()
> Property Get TheHdc() as long
> TheHdc = usercontrol.hdc
> End Property
> Then in the form : hdc = usercontrol1.thehdc

Thank you, Frank. Nice one. I'll look into it as soon as I sober up ;-)

Mike
Frank Adam - 29 Jan 2004 22:46 GMT
>> However, you can provide it via a Property Get()
>> Property Get TheHdc() as long
[quoted text clipped - 3 lines]
>
>Thank you, Frank. Nice one. I'll look into it as soon as I sober up ;-)

Oh, i'm not sure if it works when you're sober. ;-)

Signature

Regards, Frank

QuickHare - 30 Jan 2004 00:14 GMT
> >Thank you, Frank. Nice one. I'll look into it as soon as I sober up ;-)
> Oh, i'm not sure if it works when you're sober. ;-)
I found that when I'm sober, my dual-screen computer loses a monitor. So that
technology doesn't work when I'm sober...

--
QuickHare
QuickHare @ Hotmail. com
Trousle Undrhil - 30 Jan 2004 06:20 GMT
> > >Thank you, Frank. Nice one. I'll look into it as soon as I sober up ;-)
> > Oh, i'm not sure if it works when you're sober. ;-)
> I found that when I'm sober, my dual-screen computer loses a monitor. So that
> technology doesn't work when I'm sober...

Heck.  Sober or not, if I see two monitors on my desk, I'm going to think
I'm in the wrong house.  :)

Kena
undrhil@hotmail.nospam.com

> --
> QuickHare
> QuickHare @ Hotmail. com
QuickHare - 30 Jan 2004 21:17 GMT
> Heck.  Sober or not, if I see two monitors on my desk, I'm going to think
> I'm in the wrong house.  :)
Actually, if I see two monitors on my desk, it'd be a miracle. You can't fit two
monitors on my desk! There's only just enough space for one amongst the clutter.

--
QuickHare
QuickHare @ Hotmail. com
J French - 30 Jan 2004 07:53 GMT
>I've just started playing with User Controls (ActiveX Controls actually, is
>that the same thing?).

User controls can be converted into OCXes
- I strongly recommend not doing so

>I don't usually mess about with new stuff until I
>write code that actually requires it, but most people here seem to think
>that User Controls are the best thing since sliced bread, and who am I to
>argue!

They are truly wonderful

>So I'm looking into them even though I don't really need them ;-)

You will find yourself using them all over the place
(or should I say re-using them - because that is their beauty)

>The first thing I tried to do was to print one of the little buggers. Now
>there are probably a number of different ways of doing this, but for the
>method I had in mind I needed to get its hDC, and I wanted to get the hDC of
>the User Control from code within the Form on which it lives.  

You'll have the same problem with the hWnd
- it is not a problem, you just expose it as a property of the
UserControl

>It seems daft
>to me, but from what I can see so far code within the User Control itself
>can get hold if its hDC, but code within the Form on which the User Control
>sits can't get hold of it!

In a way it is daft, but in a way it makes rather good sense
- /you/ can expose it if you want, but you don't have to
 sort of 'need to know' design

>For example, I can put code in the User Control
>that references its hDC property, but if in the Form which contains it I put
>something like "myhandle = UserControl1.hDC" I get an error. Is this the way
>it is supposed to be?

Yes - but it is no problem

I think you'll get to like UserControls
- they tidy up ones main code beautifully
- and even more importantly, they allow you to build your own toolkit
of extended visual controls

Good Luck
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.