Home > Archive > Visual Basic > July 2006 > UserControls disable (diag lines) when pasting a control to form
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
UserControls disable (diag lines) when pasting a control to form
|
|
| DRBarkley 2006-07-02, 6:55 pm |
| Hello all,
VB6/SP5/Win2K
I added some usercontrols I created to a form (as control arrays).
The usercontrol code was later modified; user controls were updated and
saved.
The program runs as expected, but there is a problem when adding more
controls to the form.
When any control is added, all of my usercontrols look like I have opened
the designer.
(i.e. They have the diagonal lines across them).
Also--if the control is being pasted--it does not get added to the form.
I put breakpoints in the UserControl_Initialize event, but it never hits
when adding another control.
Any ideas?
Dave
| |
| Michael C 2006-07-02, 9:55 pm |
| "DRBarkley" <David.NOSPAMBarkley@L-3NOSPAMCom.com> wrote in message
news:Og%23iQJgnGHA.3772@TK2MSFTNGP04.phx.gbl...
> Hello all,
>
> VB6/SP5/Win2K
>
> I added some usercontrols I created to a form (as control arrays).
> The usercontrol code was later modified; user controls were updated and
> saved.
>
> The program runs as expected, but there is a problem when adding more
> controls to the form.
> When any control is added, all of my usercontrols look like I have opened
> the designer.
> (i.e. They have the diagonal lines across them).
> Also--if the control is being pasted--it does not get added to the form.
>
> I put breakpoints in the UserControl_Initialize event, but it never hits
> when adding another control.
Put your controls into a seperate project and compile that project. Having
controls in the same project as the exe is not the best approach.
>
> Any ideas?
>
> Dave
>
>
>
>
>
| |
| Jan Hyde 2006-07-03, 3:55 am |
| "DRBarkley" <David.NOSPAMBarkley@L-3NOSPAMCom.com>'s wild
thoughts were released on Sun, 2 Jul 2006 14:06:59 -0400
bearing the following fruit:
>Hello all,
>
>VB6/SP5/Win2K
>
>I added some usercontrols I created to a form (as control arrays).
>The usercontrol code was later modified; user controls were updated and
>saved.
>
>The program runs as expected, but there is a problem when adding more
>controls to the form.
>When any control is added, all of my usercontrols look like I have opened
>the designer.
> (i.e. They have the diagonal lines across them).
>Also--if the control is being pasted--it does not get added to the form.
>
>I put breakpoints in the UserControl_Initialize event, but it never hits
>when adding another control.
>
>Any ideas?
>
>Dave
Michael has already given you the best advice and I strongly
suggest you follow it. However, in you current situation,
you need to right click on the form and select 'Update
Usercontrols'
Jan Hyde (VB MVP)
--
”On the first day of Christmas, my tulip gave to me” (Richard Lederer)
| |
| DRBarkley 2006-07-03, 7:55 am |
|
"Jan Hyde" <StellaDrinker@REMOVE.ME.uboot.com> wrote in message
news:qfjha2dod33tp2ubivv4tj078jktud41v5@
4ax.com...
> "DRBarkley" <David.NOSPAMBarkley@L-3NOSPAMCom.com>'s wild
> thoughts were released on Sun, 2 Jul 2006 14:06:59 -0400
> bearing the following fruit:
>
>
> Michael has already given you the best advice and I strongly
> suggest you follow it. However, in you current situation,
> you need to right click on the form and select 'Update
> Usercontrols'
>
>
>
> Jan Hyde (VB MVP)
>
> --
> "On the first day of Christmas, my tulip gave to me" (Richard Lederer)
>
Thanks Jan and Michael,
I did Update Usercontrols and it returned them to normal, but they are
disabled again on any paste.
I will give the separate projects a try.
Many Thanks,
Dave
| |
| Michael C 2006-07-03, 7:55 am |
| "DRBarkley" <David.NOSPAMBarkley@L-3NOSPAMCom.com> wrote in message
news:%230XZZBqnGHA.1076@TK2MSFTNGP03.phx.gbl...
> Thanks Jan and Michael,
>
> I did Update Usercontrols and it returned them to normal, but they are
> disabled again on any paste.
This is normal behaviour. The reason it does this is because the control is
in run mode but the form is in design mode, so part of your project is being
designed and part is being run!! (only in vb could you do something like
this :-) Anyway, any changes to the project that would require the project
to be stopped will cause the controls to do as you described. Things get
weird when you have controls that gpf when stopped due to subclassing. It
took me a while to work that one out the first time I encounted it :-)
Michael
| |
| Jan Hyde 2006-07-03, 6:56 pm |
| "DRBarkley" <David.NOSPAMBarkley@L-3NOSPAMCom.com>'s wild
thoughts were released on Mon, 3 Jul 2006 08:58:13 -0400
bearing the following fruit:
>
>"Jan Hyde" <StellaDrinker@REMOVE.ME.uboot.com> wrote in message
> news:qfjha2dod33tp2ubivv4tj078jktud41v5@
4ax.com...
>
>
>Thanks Jan and Michael,
>
>I did Update Usercontrols and it returned them to normal, but they are
>disabled again on any paste.
And it will continue to do this until you go the compiles
ocx route.
>I will give the separate projects a try.
Not seperate projects, but a compiled ocx.
Jan Hyde (VB MVP)
--
A friend of mine just had her 11th baby. Everyone says she's overbearing
(Megan Waves)
| |
| DRBarkley 2006-07-03, 6:56 pm |
| <snip>
>
> Not seperate projects, but a compiled ocx.
>
>
>
> Jan Hyde (VB MVP)
>
> --
> A friend of mine just had her 11th baby. Everyone says she's overbearing
> (Megan Waves)
>
Thanks again to you both.
I left the code as usercontrols while they were being tested, and planned to
eventually create the OCXes.
I'm still wondering why the control could be pasted without a problem for a
while, then started this weirdness.
Not sure when it began; maybe after saving and reloading the project, or
modifying the usercontrols.
Anyway, I appreciate the help.
Dave
| |
| Dmitriy Antonov 2006-07-03, 6:56 pm |
|
"Michael C" <nospam@nospam.com> wrote in message
news:e%23OAeZqnGHA.1204@TK2MSFTNGP04.phx.gbl...
> "DRBarkley" <David.NOSPAMBarkley@L-3NOSPAMCom.com> wrote in message
> news:%230XZZBqnGHA.1076@TK2MSFTNGP03.phx.gbl...
>
> This is normal behaviour. The reason it does this is because the control
> is in run mode but the form is in design mode, so part of your project is
> being designed and part is being run!! (only in vb could you do something
> like this :-) Anyway, any changes to the project that would require the
> project to be stopped will cause the controls to do as you described.
> Things get weird when you have controls that gpf when stopped due to
> subclassing. It took me a while to work that one out the first time I
> encounted it :-)
>
> Michael
>
Simple solution is just to close UC window in IDE (I prefer to close both -
Designer and code, but I think, closing of Designer would suffice - don't
remember) after you make any changes in it. This should update it on each
form, where it exists. If not - close and re-open the form's designer.
Dmitriy.
| |
| DRBarkley 2006-07-03, 6:56 pm |
|
"Dmitriy Antonov" <antonovdima@netzero.net_NOT_FOR_SPAM> wrote in message
news:%23vV0HZrnGHA.4716@TK2MSFTNGP02.phx.gbl...
>
> "Michael C" <nospam@nospam.com> wrote in message
> news:e%23OAeZqnGHA.1204@TK2MSFTNGP04.phx.gbl...
is[color=darkred]
something[color=darkred]
>
> Simple solution is just to close UC window in IDE (I prefer to close
both -
> Designer and code, but I think, closing of Designer would suffice - don't
> remember) after you make any changes in it. This should update it on each
> form, where it exists. If not - close and re-open the form's designer.
>
> Dmitriy.
>
>
For the record,
This has never happened on this form before--and it has been undergoing
changes for many years.
It originally had one user control, and has recently received several newer
ones.
When the new controls were being added, they did not display this behavior.
Some mods were made to the user controls later, and--at some point--began to
act this way.
I can open and close the UC designer, and the diagonal lines disappear.
But, they re-appear when any control--even intrinsic ones--are pasted to the
screen.
I still think something is phishy in Philadelphia, but have solved it for
now.
All usercontrols are now part of one OCX and working beautifully!
That's another thing I researched and found little useful:
How to create an OCX that, when selected in Components, would add multiple
items to the toolbox (like comctl32).
It turned out to be as simple as adding all of the user controls to another
user control project,
and setting each control's Public property to True.
Thanks to all for your suggestions,
Dave
| |
| Michael C 2006-07-03, 6:56 pm |
| "DRBarkley" <David.NOSPAMBarkley@L-3NOSPAMCom.com> wrote in message
news:OyMU%
> For the record,
>
> This has never happened on this form before--and it has been undergoing
> changes for many years.
> It originally had one user control, and has recently received several
> newer
> ones.
> When the new controls were being added, they did not display this
> behavior.
> Some mods were made to the user controls later, and--at some point--began
> to
> act this way.
>
> I can open and close the UC designer, and the diagonal lines disappear.
> But, they re-appear when any control--even intrinsic ones--are pasted to
> the
> screen.
>
> I still think something is phishy in Philadelphia, but have solved it for
> now.
There's nothing fishy about this, this is quite normal, although I'm not
sure what triggers it.
> That's another thing I researched and found little useful:
> How to create an OCX that, when selected in Components, would add multiple
> items to the toolbox (like comctl32).
> It turned out to be as simple as adding all of the user controls to
> another
> user control project,
> and setting each control's Public property to True.
You actually researched this? :-)
Michael
| |
| Michael C 2006-07-03, 6:56 pm |
| "DRBarkley" <David.NOSPAMBarkley@L-3NOSPAMCom.com> wrote in message
news:ea6%
> I'm still wondering why the control could be pasted without a problem for
> a
> while, then started this weirdness.
I'm curious about this myself. I was under the impression this always
happened but I've just tested and this is not the case. I know it happens
when the project needs to be stopped, similar to when you make a change to
the code in debug mode and it comes up with that dialog saying that it has
to stop to make the change.
Michael
| |
| DRBarkley 2006-07-03, 6:56 pm |
|
"Michael C" <nospam@nospam.com> wrote in message
news:%236vgPqvnGHA.5056@TK2MSFTNGP02.phx.gbl...
> "DRBarkley" <David.NOSPAMBarkley@L-3NOSPAMCom.com> wrote in message
> news:ea6%
>
> I'm curious about this myself. I was under the impression this always
> happened but I've just tested and this is not the case. I know it happens
> when the project needs to be stopped, similar to when you make a change to
> the code in debug mode and it comes up with that dialog saying that it has
> to stop to make the change.
>
> Michael
>
Michael,
As I mentioned in another post, this program is several years old, and it
has been modified--often daily, yet this has never occurred.
Of course, it isn't a problem, but I would sure like to know what triggers
it.
Also, when it started, I noticed a couple of other oddities.
If I deleted one of the controls, the form would not show again.
A line that referenced the deleted control (not my usercontrol) would be
highlighted, and an error would occur.
That would have been normal had I been trying to run the program, but, it
wouldn't even let me leave the erroneous code to show the form--to undo the
deletion.
Also, I could draw one of the UCs to the screen, but a copy/paste was
unsuccessful.
The drawn control had a different name, but I could rename it and it would
become one of the control arrays.
Phishy, I say!
If you come up anything, I'll be happy to hear about it.
Thanks for the comments,
Dave
| |
| Michael C 2006-07-03, 6:56 pm |
| "DRBarkley" <cab_rn@worldnet.att.net> wrote in message
news:OuEF9HwnGHA.1668@TK2MSFTNGP05.phx.gbl...
> Also, when it started, I noticed a couple of other oddities.
> If I deleted one of the controls, the form would not show again.
> A line that referenced the deleted control (not my usercontrol) would be
> highlighted, and an error would occur.
That sounds like code in your control is triggering code on the form to run.
This can happen if your control references a form. The solution to that is
to put an "If Ambient.UserMode" around the offending code so it doesn't run
in designer mode.
> That would have been normal had I been trying to run the program, but, it
> wouldn't even let me leave the erroneous code to show the form--to undo
> the deletion.
I think you need to push the stop button in these cases.
> Also, I could draw one of the UCs to the screen, but a copy/paste was
> unsuccessful.
> The drawn control had a different name, but I could rename it and it would
> become one of the control arrays.
That's normal, if a control array exists and you rename a control to the
name of the control array then it will becomes part of the array without
prompting.
Michael
| |
| Jan Hyde 2006-07-04, 3:55 am |
| "DRBarkley" <David.NOSPAMBarkley@L-3NOSPAMCom.com>'s wild
thoughts were released on Mon, 3 Jul 2006 10:52:33 -0400
bearing the following fruit:
><snip>
>
>
>Thanks again to you both.
>
>I left the code as usercontrols while they were being tested, and planned to
>eventually create the OCXes.
>
>I'm still wondering why the control could be pasted without a problem for a
>while, then started this weirdness.
>Not sure when it began; maybe after saving and reloading the project, or
>modifying the usercontrols.
>
>Anyway, I appreciate the help.
>
>Dave
>
I think it's odd that you haven't experienced this problem
before.
Jan Hyde (VB MVP)
--
"You must be my host" Tom guessed. (Kegel Archives)
| |
| DRBarkley 2006-07-04, 7:55 am |
|
"Michael C" <nospam@nospam.com> wrote in message
news:uEGB4MwnGHA.4868@TK2MSFTNGP02.phx.gbl...
> "DRBarkley" <cab_rn@worldnet.att.net> wrote in message
> news:OuEF9HwnGHA.1668@TK2MSFTNGP05.phx.gbl...
>
> That sounds like code in your control is triggering code on the form to
run.
> This can happen if your control references a form. The solution to that is
> to put an "If Ambient.UserMode" around the offending code so it doesn't
run
> in designer mode.
>
That's the first thing I thought, too, but I double-checked the control and
found nothing referencing the form.
As we all know, that doesn't mean I haven't overlooked something--thanks for
the thought.
I do use Ambient.UserMode to stop the Enable property from disabling the
usercontrol during development.
it[color=darkred]
>
> I think you need to push the stop button in these cases.
>
But, form code should not be running at that time; right?
I realize that usercontrol code runs at various times, but the code that
stops the form from showing is Form code.
And when I do press stop, when I try to display the form, it goes
immediately back to the form code.
I know; I know; that sounds like code in my control is triggering code on
the form to run....
would[color=darkred]
>
> That's normal, if a control array exists and you rename a control to the
> name of the control array then it will becomes part of the array without
> prompting.
Yes, I was only explaining that there IS a way to place a control on the
form, only, never by pasting.
>
> Michael
>
>
At least, as an OCX, all works well.
Thanks again for the input,
Dave
| |
| DRBarkley 2006-07-04, 7:55 am |
|
"Jan Hyde" <StellaDrinker@REMOVE.ME.uboot.com> wrote in message
news:0o8ka2tja3bhj1hdk7tbesgrepbjd1csvf@
4ax.com...
> "DRBarkley" <David.NOSPAMBarkley@L-3NOSPAMCom.com>'s wild
> thoughts were released on Mon, 3 Jul 2006 10:52:33 -0400
> bearing the following fruit:
>
overbearing[color=darkred]
to[color=darkred]
a[color=darkred]
>
> I think it's odd that you haven't experienced this problem
> before.
>
> Jan Hyde (VB MVP)
>
> --
> "You must be my host" Tom guessed. (Kegel Archives)
>
Hi Jan,
I don't create OCXes often, so that may explain why I haven't.
But, I have added, modified, deleted, and re-added my UCs many times without
seeing this.
You do realize that I'm not talking about the "normal" diagonal lines that
come up when the UC editor is open, right?
Same lines, but an unexpected time for them to appear.
Of course, maybe to you, and others who build UCs often, it is normal.
But then, how do you paste UCs on a form if it is normal? In this case, you
can't--anymore.
Thanks again,
Dave
| |
| Jan Hyde 2006-07-04, 7:55 am |
| "DRBarkley" <David.NOSPAMBarkley@L-3NOSPAMCom.com>'s wild
thoughts were released on Tue, 4 Jul 2006 06:40:14 -0400
bearing the following fruit:
>
>"Jan Hyde" <StellaDrinker@REMOVE.ME.uboot.com> wrote in message
> news:0o8ka2tja3bhj1hdk7tbesgrepbjd1csvf@
4ax.com...
>overbearing
>to
>a
>
>Hi Jan,
>
>I don't create OCXes often, so that may explain why I haven't.
>But, I have added, modified, deleted, and re-added my UCs many times without
>seeing this.
>
>You do realize that I'm not talking about the "normal" diagonal lines that
>come up when the UC editor is open, right?
>Same lines, but an unexpected time for them to appear.
>
>Of course, maybe to you, and others who build UCs often, it is normal.
>But then, how do you paste UCs on a form if it is normal? In this case, you
>can't--anymore.
>
>Thanks again,
>
LOL, all I can say is that dealing with compiled ocxs
eliminates these issues.
Jan Hyde (VB MVP)
--
With everything you read about spray cans and the ozone layer it's
enough to scareosol to death. (Mike Bull)
| |
| Michael C 2006-07-04, 7:55 am |
| "DRBarkley" <David.NOSPAMBarkley@L-3NOSPAMCom.com> wrote in message
news:%23dgyhR1nGHA.4572@TK2MSFTNGP05.phx.gbl...
> But, form code should not be running at that time; right?
> I realize that usercontrol code runs at various times, but the code that
> stops the form from showing is Form code.
> And when I do press stop, when I try to display the form, it goes
> immediately back to the form code.
> I know; I know; that sounds like code in my control is triggering code on
> the form to run....
What does the stack look like at that point? (assuming you can look at the
stack)
| |
| DRBarkley 2006-07-04, 7:55 am |
|
"Michael C" <nospam@nospam.com> wrote in message
news:%23%23bvka2nGHA.512@TK2MSFTNGP05.phx.gbl...
> "DRBarkley" <David.NOSPAMBarkley@L-3NOSPAMCom.com> wrote in message
> news:%23dgyhR1nGHA.4572@TK2MSFTNGP05.phx.gbl...
on[color=darkred]
>
> What does the stack look like at that point? (assuming you can look at the
> stack)
>
>
Michael,
Went back to the old code, and now I can't get it to do the same thing.
Still disabling the usercontrols, but no code errors.
I may have changed something.
I may try to reproduce it again and check the stack when I get time--will
report back.
Worked all w end, and the holiday.
Happy Independence Day!
Thanks for the idea; it makes sense to check it.
Dave
| |
| DRBarkley 2006-07-04, 7:55 am |
|
"Jan Hyde" <StellaDrinker@REMOVE.ME.uboot.com> wrote in message
news:smmka25gjrs3p720g6ts35ruqpcvsgq3kl@
4ax.com...
> "DRBarkley" <David.NOSPAMBarkley@L-3NOSPAMCom.com>'s wild
> thoughts were released on Tue, 4 Jul 2006 06:40:14 -0400
> bearing the following fruit:
>
planned[color=darkred]
for[color=darkred]
or[color=darkred]
without[color=darkred]
that[color=darkred]
you[color=darkred]
>
> LOL, all I can say is that dealing with compiled ocxs
> eliminates these issues.
>
>
>
> Jan Hyde (VB MVP)
>
> --
> With everything you read about spray cans and the ozone layer it's
> enough to scareosol to death. (Mike Bull)
>
Jan,
Yeah, thanks for suggesting it; all is well now!
Happy Fourth,
Dave
|
|
|
|
|