|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to make this call from form to controlI'm making a control project. This usercontrol connects to internet and downloads some infos. So it shows a plain form showing the progress of downloads. The form doesn't have any code inside. The progress bar on the form is controlled by the WinSock inside my usercontrol. Now I want to put a Cancel button on the form. This cancel button should call a sub (called CancelOperation) in the usercontrol, which will disconnect the WinSock and unload the Form. Problem is: How do I call a subroutine from a Form to a usercontrol? If it was a different form/module, I would write Form2.CancelOperation. But since the usercontrol is not a class, Im confused on how to call a sub from the usercontrol. Secondly, even if there was some way of calling the sub... I'll have to make that sub as Public (I think). Now this will reveal my CancelOperation sub to the users of the control. I don't want that to happen. So how should I handle this coding situation? "Faraz Azhar" <itzfa***@gmail.com> wrote Please excuse the obvious, but why isn't the progress bar and> The form doesn't have any code inside. The progress bar on the form is > controlled by the WinSock inside my usercontrol. Cancel button on the User Control? LFS On Mar 16, 7:27 pm, "Larry Serflaten" <serfla***@usinternet.com> Because the usercontrol is supposed to be a hidden control. Itswrote: > "Faraz Azhar" <itzfa***@gmail.com> wrote > > > The form doesn't have any code inside. The progress bar on the form is > > controlled by the WinSock inside my usercontrol. > > Please excuse the obvious, but why isn't the progress bar and > Cancel button on the User Control? > > LFS supposed to show various popup windows (dialog forms) asking users about stuff. Just one popup window shows the progress bar of downloading content from website. > Because the usercontrol is supposed to be a hidden control. Itssupposed to show various popup windows (dialog forms) asking users about stuff. Just one popup window shows the progress bar of downloading content from website. > Are you aware that you don't have to compileyour control as an OCX? It actually makes much more sense not to, when that's feasible. It can be faster and doesn't need to be registered. Just compile it into your EXE. In your case it sounds like there wouldn't be any reason to do otherwise, since you want the control to be hidden and unusable from the outside.
Show quote
Hide quote
On Mar 16, 9:11 pm, "mayayana" <mayayaX***@rcXXn.com> wrote: My plan is to make an ActiveX OCX which can be installed once on the> Because the usercontrol is supposed to be a hidden control. Its > supposed to show various popup windows (dialog forms) asking users > about stuff. Just one popup window shows the progress bar of > downloading content from website. > > > > Are you aware that you don't have to compile > your control as an OCX? It actually makes much more > sense not to, when that's feasible. It can be faster > and doesn't need to be registered. Just compile it into > your EXE. > In your case it sounds like there wouldn't > be any reason to do otherwise, since you want the > control to be hidden and unusable from the outside. user's system and many applications can use it. @Dave O. yes that would be a very tacky way of doing it. I'm wondering how others do it.. ? My activeX is supposed to be a invisible control. The applications will call the Connect function and it will show a popup window that shows a downloading progressbar. Thats it. simple! What Im asking is that is there a way I can code in the Cancel button that: usercontrol.CancelOperation ? but the 'usercontrol' is a control so it cannot be used this way. Is there any other way of calling the CancelOperation sub, without revealing it to other applications? "Faraz Azhar" <itzfa***@gmail.com> wrote I was never fond of 'kitchen sink' applications (or controls). I rather> My plan is to make an ActiveX OCX which can be installed once on the > user's system and many applications can use it. prefer focused applications that do one job well... Thus, the idea that the UC would make the connection and show its progress, etc... > What Im asking is that is there a way I can code in the Cancel button That's a bit like saying you want to put text in a textbox by using> that: usercontrol.CancelOperation ? but the 'usercontrol' is a > control so it cannot be used this way. Text1.Text, but its a control and can't be used that way. Controls can have properties, functions, and methods. Why not add the CancelOperation method, if that is what it needs ??? If you mean you want to create a control that only your applications can use, that is also possible. In that case, create a type library that has the UserControl interface you want supported, and implement that in the UserControl. Then in your UC, add code only to methods of that interface. With the Type Library on your system (An ActiveX Dll with one class defining the interface) you can reference it in your projects but as long as you don't give it out, no one else will even know it is there. Your applications talk to your user control through that interface, just like it was a normal control... Dim MyUC As IHiddenInterface Set MyUC = UserControl11.Object ' Now use MyUC to access the UC MyUC.CancelOperation But be careful, once you define your hidden interface, and implement it in your UserControl, tuck it away and don't change anything. If you break compatibility by adding something to the interface, you won't be able to talk to your usercontol. (It will be expecting the old version and will show type mismatch for anything else.) LFS
Show quote
Hide quote
On Mar 17, 12:20 am, "Larry Serflaten" <serfla***@usinternet.com> Hmm.. very interesting! I'll look into the possibilities of rewritingwrote: > "Faraz Azhar" <itzfa***@gmail.com> wrote > > > My plan is to make an ActiveX OCX which can be installed once on the > > user's system and many applications can use it. > > I was never fond of 'kitchen sink' applications (or controls). I rather > prefer focused applications that do one job well... Thus, the idea > that the UC would make the connection and show its progress, etc... > > > What Im asking is that is there a way I can code in the Cancel button > > that: usercontrol.CancelOperation ? but the 'usercontrol' is a > > control so it cannot be used this way. > > That's a bit like saying you want to put text in a textbox by using > Text1.Text, but its a control and can't be used that way. > > Controls can have properties, functions, and methods. Why not > add the CancelOperation method, if that is what it needs ??? > > If you mean you want to create a control that only your applications > can use, that is also possible. > > In that case, create a type library that has the UserControl interface > you want supported, and implement that in the UserControl. Then > in your UC, add code only to methods of that interface. > > With the Type Library on your system (An ActiveX Dll with one > class defining the interface) you can reference it in your projects > but as long as you don't give it out, no one else will even know > it is there. Your applications talk to your user control through that > interface, just like it was a normal control... > > Dim MyUC As IHiddenInterface > Set MyUC = UserControl11.Object > ' Now use MyUC to access the UC > MyUC.CancelOperation > > But be careful, once you define your hidden interface, and implement > it in your UserControl, tuck it away and don't change anything. If you > break compatibility by adding something to the interface, you won't be > able to talk to your usercontol. (It will be expecting the old version and > will show type mismatch for anything else.) > > LFS my code or using type libs, whichever turns out to be best. thanks all for your advises! "Faraz Azhar" <itzfa***@gmail.com> wrote in message Seems odd you'd want to hide such a function, but if you really must the news:e8334d95-6cd5-4e02-bf96-8ab1c7eec1ba@o2g2000prl.googlegroups.com... > Hello > Secondly, even if there was some way of calling the sub... I'll have > to make that sub as Public (I think). Now this will reveal my > CancelOperation sub to the users of the control. I don't want that to > happen. easiest way and the worst (from a programming perspective) would be to add it to an existing function but only with very specific parameter(s), something like: Public Sub InitDownload(DownURL as string) If DownURL = "XX_RESET_XX" then CancelOperation Else ' Normal Init code end if Truly tacky but it would work and does what you want. You'll may also need the control to release processor cycles to allow the button to be pressed, if so just add a DoEvents in the main loop somewhere ensuring it is hit at least twice a second but no more than about 15 times a second. Dave O. Could you explain better what you are trying to do?
What I think I understood or misunderstood is: You are writing an usercontrol to do something. It is invisible. You'll ask your usercontrol's users to add a progressbar to the same form that you will control it from the usercontrol (how?) Now you also will ask them to add a cancel button, and you want to get the click event of that cancel button from inside your usercontrol. Is that right? How do you bind the progress bar and the cancel button to the usercontrol? Show quoteHide quote "Faraz Azhar" <itzfa***@gmail.com> escribió en el mensaje news:e8334d95-6cd5-4e02-bf96-8ab1c7eec1ba@o2g2000prl.googlegroups.com... > Hello > > I'm making a control project. This usercontrol connects to internet > and downloads some infos. So it shows a plain form showing the > progress of downloads. > > The form doesn't have any code inside. The progress bar on the form is > controlled by the WinSock inside my usercontrol. > > Now I want to put a Cancel button on the form. This cancel button > should call a sub (called CancelOperation) in the usercontrol, which > will disconnect the WinSock and unload the Form. > > Problem is: How do I call a subroutine from a Form to a usercontrol? > If it was a different form/module, I would write > Form2.CancelOperation. But since the usercontrol is not a class, Im > confused on how to call a sub from the usercontrol. > > Secondly, even if there was some way of calling the sub... I'll have > to make that sub as Public (I think). Now this will reveal my > CancelOperation sub to the users of the control. I don't want that to > happen. > > So how should I handle this coding situation? I re read and now I think I got it.
The form is yours, it's a form of your ActiveX project. OK, if you want to add a method that is visible for inside your activex project but not from the outside, then just define it as "Friend". ' Inside your usercontrol code: Friend Sub Cancel () 'do something to perform the cancel operation End Sub 'Let's suppose the name of your form is frmShowProgess, then prior to show it: set frmShowProgess.pUC = Me ' then show it frmShowProgess.Show 'In the code of the form: Public pUC as YourUserControlTypeName ' if the cancel button's name is cmdCancel the code is: Private Sub cmdCancel_Click() pUC.Cancel End Sub Show quoteHide quote "Eduardo" <m*@mm.com> escribió en el mensaje news:gpmeta$41j$1@aioe.org... > Could you explain better what you are trying to do? > > What I think I understood or misunderstood is: > > You are writing an usercontrol to do something. > It is invisible. > You'll ask your usercontrol's users to add a progressbar to the same form > that you will control it from the usercontrol (how?) > Now you also will ask them to add a cancel button, and you want to get the > click event of that cancel button from inside your usercontrol. Is that > right? > > How do you bind the progress bar and the cancel button to the usercontrol? > > > "Faraz Azhar" <itzfa***@gmail.com> escribió en el mensaje > news:e8334d95-6cd5-4e02-bf96-8ab1c7eec1ba@o2g2000prl.googlegroups.com... >> Hello >> >> I'm making a control project. This usercontrol connects to internet >> and downloads some infos. So it shows a plain form showing the >> progress of downloads. >> >> The form doesn't have any code inside. The progress bar on the form is >> controlled by the WinSock inside my usercontrol. >> >> Now I want to put a Cancel button on the form. This cancel button >> should call a sub (called CancelOperation) in the usercontrol, which >> will disconnect the WinSock and unload the Form. >> >> Problem is: How do I call a subroutine from a Form to a usercontrol? >> If it was a different form/module, I would write >> Form2.CancelOperation. But since the usercontrol is not a class, Im >> confused on how to call a sub from the usercontrol. >> >> Secondly, even if there was some way of calling the sub... I'll have >> to make that sub as Public (I think). Now this will reveal my >> CancelOperation sub to the users of the control. I don't want that to >> happen. >> >> So how should I handle this coding situation? > > PS: procedures defined as Friend are public from within the ActiveX project
but not visible from the outside. Show quoteHide quote "Eduardo" <m*@mm.com> escribió en el mensaje news:gpmhh9$73t$1@aioe.org... Faraz Azhar wrote:
Show quoteHide quote > I'm making a control project. This usercontrol connects to internet Here, it's done for you: http://vb.mvps.org/samples/NetGrab> and downloads some infos. So it shows a plain form showing the > progress of downloads. > > The form doesn't have any code inside. The progress bar on the form is > controlled by the WinSock inside my usercontrol. > > Now I want to put a Cancel button on the form. This cancel button > should call a sub (called CancelOperation) in the usercontrol, which > will disconnect the WinSock and unload the Form. > > Problem is: How do I call a subroutine from a Form to a usercontrol? > If it was a different form/module, I would write > Form2.CancelOperation. But since the usercontrol is not a class, Im > confused on how to call a sub from the usercontrol. > > Secondly, even if there was some way of calling the sub... I'll have > to make that sub as Public (I think). Now this will reveal my > CancelOperation sub to the users of the control. I don't want that to > happen. > > So how should I handle this coding situation? Yes yes thats exactly what I've been trying to do; thank you both
Eduardo and Karl. > Does the NetGrab work behind proxy?> Here, it's done for you:http://vb.mvps.org/samples/NetGrab > -- > .NET: It's About Trust! > http://vfred.mvps.org On Mar 21, 12:33 pm, Faraz Azhar <itzfa***@gmail.com> wrote:
> > Here, it's done for you:http://vb.mvps.org/samples/NetGrab yea i experimented, it works. But it uses the IE's built-in settings> > -- > > .NET: It's About Trust! > > http://vfred.mvps.org > > Does the NetGrab work behind proxy? for proxy. If proxy is turned on by IE, the usercontrol's asyncread method will use it too. Anyways thanks a million everyone!
Differences between VB amd VBA and VBA Education
Application.Quit but Word remains open in Task Manager VB App fails when log reaches 65536 HOW IS Memory Used by a VB App vb.net executing on Help with Binary Compatibility Fonts Internal String Visibility NET Required ??? Is it possible to remove 3rd party app icon from systray? |
|||||||||||||||||||||||