Author Topic: ModalForm Flickering while Selecting...  (Read 9090 times)

0 Members and 1 Guest are viewing this topic.

LE

  • Guest
ModalForm Flickering while Selecting...
« on: April 29, 2007, 09:46:17 PM »
ModalForm Flickering while Selecting... no good..

Any idea if this got solved in AutoCAD 2008 ?  or is there a workaround (using AutoCAD 2007)

If I start a solution using the autocad managed wizard I get what I am showing in the image below, and also if I have other forms open not autocad related, it becomes a mess, then if I start a library class solution and add a window form, then a simple button with the click event, I get the flickering but is minor (not too noticeably like the one in the image).


Thanks!

Glenn R

  • Guest
Re: ModalForm Flickering while Selecting...
« Reply #1 on: April 29, 2007, 09:53:46 PM »
Got a sample project you can post Luis and I will have a look at it.

Cheers,
Glenn.

LE

  • Guest
Re: ModalForm Flickering while Selecting...
« Reply #2 on: April 29, 2007, 10:33:33 PM »
Here is a sample project, I just did... using the AutoCAD Managed wizard.

Open AutoCAD (I have 2007) and open other applications like explorer etc... then use the command: TESTFORM

Edit: I uploaded again the zip, including just the needed files for the SLN, it was included the 'bin' and 'obj' folders, created when you do the compile.
« Last Edit: April 30, 2007, 10:00:32 AM by LE »

LE

  • Guest
Re: ModalForm Flickering while Selecting...
« Reply #3 on: April 29, 2007, 10:48:23 PM »
OK... while doing some research I found this thread, and looks like, it is the same issue...

http://discussion.autodesk.com/thread.jspa?messageID=5061101

Glenn R

  • Guest
Re: ModalForm Flickering while Selecting...
« Reply #4 on: April 29, 2007, 10:50:57 PM »
Luis,

No flickering here on 2007 after I did the following:

In the form's propert window, set ShowInTaskbar = false.
Whilst you're at it, set minimizebox and maximizebox = false as well.

Cheers,
Glenn.

LE

  • Guest
Re: ModalForm Flickering while Selecting...
« Reply #5 on: April 29, 2007, 10:56:54 PM »
Luis,

No flickering here on 2007 after I did the following:

In the form's propert window, set ShowInTaskbar = false.
Whilst you're at it, set minimizebox and maximizebox = false as well.

Cheers,
Glenn.

Tried that.... and no, still the same


Thanks!

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: ModalForm Flickering while Selecting...
« Reply #6 on: April 30, 2007, 12:48:32 AM »
Luis,
For me  in AC2008 :
The form does not flicker as shown in your piccy .. instead the outline of the application behind flashes briefly as the form is hiding. It appears to ONLY be affected by SOME applications being open behind AutoCAD, not all.

added: there is no flickering when the user selects, as appears to happen on your piccy.

 
Note [irrelevant for this], I changed the CopyLocal to False for the AutoCAD dll's 
« Last Edit: April 30, 2007, 12:53:30 AM by Kerry Brown »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Glenn R

  • Guest
Re: ModalForm Flickering while Selecting...
« Reply #7 on: April 30, 2007, 01:03:16 AM »
Kerry,

I asked Luis to send his project to me and whilst he's sleeping now, I can let the cat out of bag to what caused it.
His project posted above and the one sent to me are quite different. The one above doesn't exhibit the flickering at all for me either.

What was causing it, is that he had inadvertently added 2 event handler delegates to his "Install button", so whenever it was clicked, it would hide, do it's mojo, show, then be called AGAIN!. Hence the flickering  :evil:

Cheers,
Glenn.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: ModalForm Flickering while Selecting...
« Reply #8 on: April 30, 2007, 01:07:13 AM »
I thought it may be because running in debug mode ... but Release Mode is no better.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: ModalForm Flickering while Selecting...
« Reply #9 on: April 30, 2007, 01:09:18 AM »
............

What was causing it, is that he had inadvertently added 2 event handler delegates to his "Install button", so whenever it was clicked, it would hide, do it's mojo, show, then be called AGAIN!. Hence the flickering  :evil:

Cheers,
Glenn.

That was going to be my next question .." What did you take out of the code posted"   :D
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

MaksimS

  • Guest
Re: ModalForm Flickering while Selecting...
« Reply #10 on: April 30, 2007, 05:01:43 AM »
Take a look at the following thread:

http://discussion.autodesk.com/thread.jspa?messageID=5061101

The cause may be (?) the same...

Regards,
Maksim Sestic

ModalForm Flickering while Selecting... no good..

Any idea if this got solved in AutoCAD 2008 ?  or is there a workaround (using AutoCAD 2007)
« Last Edit: April 30, 2007, 05:04:34 AM by MaksimS »

LE

  • Guest
Re: ModalForm Flickering while Selecting...
« Reply #11 on: April 30, 2007, 09:43:52 AM »
Take a look at the following thread:

http://discussion.autodesk.com/thread.jspa?messageID=5061101

The cause may be (?) the same...

Yes, I found that yesterday and appears to be the same issue...

Still I see the little flickering after doing the selection (and after following all the advices on how to solved, so far).


Thanks!

LE

  • Guest
Re: ModalForm Flickering while Selecting...
« Reply #12 on: April 30, 2007, 11:35:12 AM »
Well;

I was following one of the samples on the 'autocad_2007_.net_training.zip' LAB7 in the DOC 'AutoCAD 2007 Managed C#.NET Training.3.doc' and where reads:

Quote
Before we can test the code, we need to remember that this code is running from a modal dialog, which means that user interactivity is blocked while the dialog is visible.  Before we can actually pick an Employee to list, we need to hide the form to allow picking.  Then when all is done, we can show the form again (e.g. in the Finally block of the function).

Add code to hide before picking (e.g. before the try block), ‘this.Hide’  and code to show the form when complete (e.g. in the Finally block) , ‘this.Show’. 

Build, Load and run the MODALFORM command in AutoCAD to see the dialog work.  Try picking an entity and populating the form’s values.

So in one of my button's event I was using:
Code: [Select]
private void onClick_InstallDoor(object sender, EventArgs e)
{
    Database db = HostApplicationServices.WorkingDatabase;
    Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
    this.Hide();
    try
    {
        using (Transaction trans = db.TransactionManager.StartTransaction())
        {
            //////PromptEntityOptions prEnt = new PromptEntityOptions("Select an Entity");
            //////PromptEntityResult prEntRes = ed.GetEntity(prEnt);
            //////if (prEntRes.Status != PromptStatus.OK)
            //////    throw new System.Exception("Error or User Cancelled");
           
            doorInstaller();

        }
    }
    catch (System.Exception ex)
    {
        MessageBox.Show("Error: " + ex.Message);
    }
    finally
    {
        this.Show();
    }
}

Then, I simple remove some parts of the code and all works just fine!
Code: [Select]
private void onClick_InstallDoor(object sender, EventArgs e)
{
    Database db = HostApplicationServices.WorkingDatabase;
    Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
    //////this.Hide(); THIS ONE OUT!
    try
    {
        using (Transaction trans = db.TransactionManager.StartTransaction())
        {
            //////PromptEntityOptions prEnt = new PromptEntityOptions("Select an Entity");
            //////PromptEntityResult prEntRes = ed.GetEntity(prEnt);
            //////if (prEntRes.Status != PromptStatus.OK)
            //////    throw new System.Exception("Error or User Cancelled");
           
            doorInstaller();

        }
    }
    catch (System.Exception ex)
    {
        MessageBox.Show("Error: " + ex.Message);
    }
    //////finally // THIS ONE OUT!
    //////{
    //////    this.Show();
    //////}
}

I think I was doing better, before reading those training samples...  :roll:

almost forgot to add their code event sample it is in the ModalForm.cs file:
Quote
      private void SelectEmployeeButton_Click(object sender, System.EventArgs e)
      {
            Database db = HostApplicationServices.WorkingDatabase;
            Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
            this.Hide();
            try
            {
                using (Transaction trans = db.TransactionManager.StartTransaction())
                {
                    PromptEntityOptions prEnt = new PromptEntityOptions("Select an Employee");
                    PromptEntityResult prEntRes = ed.GetEntity(prEnt);
                    if (prEntRes.Status != PromptStatus.OK)
                        throw new System.Exception("Error or User Cancelled");

                    ArrayList saEmployeeList = new ArrayList();

                    AsdkClass1.ListEmployee(prEntRes.ObjectId, saEmployeeList);
                    if (saEmployeeList.Count == 4)
                    {
                        tb_Name.Text = saEmployeeList[0].ToString();
                        tb_Salary.Text = saEmployeeList[1].ToString();
                        tb_Division.Text = saEmployeeList[2].ToString();
                    }
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("Error Creating Employee: " + ex.Message);
            }
            finally
            {
                this.Show();
            }
        }
« Last Edit: April 30, 2007, 11:39:48 AM by LE »

LE

  • Guest
Re: ModalForm Flickering while Selecting...
« Reply #13 on: April 30, 2007, 02:22:12 PM »
It must be me... I added the Close(); in the button, like if it was an OK to close the form, and let do the process... and got the flickering again....  :cry:

LE

  • Guest
Re: ModalForm Flickering while Selecting...
« Reply #14 on: April 30, 2007, 03:46:22 PM »
For now, I will be using the FormClosed Event

LE

  • Guest
Re: ModalForm Flickering while Selecting...
« Reply #15 on: May 01, 2007, 01:06:33 AM »
After all the hoops... it was an human error or a.k.a = le = me

Thank you, now I have the command running normally, and continue practicing.


Have fun.

MickD

  • King Gator
  • Posts: 3636
  • (x-in)->[process]->(y-out) ... simples!
Re: ModalForm Flickering while Selecting...
« Reply #16 on: May 01, 2007, 01:13:06 AM »
After all the hoops... it was an human error or a.k.a = le = me
...

ahh, they are sometimes the best errors, you learn so much more on the way even though you want to kick yourself for missing something simple. :D
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

LE

  • Guest
Re: ModalForm Flickering while Selecting...
« Reply #17 on: May 01, 2007, 01:19:24 AM »
ahh, they are sometimes the best errors, you learn so much more on the way even though you want to kick yourself for missing something simple. :D

Yes.... very true.

I changed to modeless dialog and now I can Hide the dialog while installing the door(s)..... YES !


Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: ModalForm Flickering while Selecting...
« Reply #18 on: May 01, 2007, 02:19:35 AM »
Luis, good to hear it's resolved, even if it had to be a workaround.

Can you post a copy of the current working solution so anyone following along later can compare the alternative code.

... something like 'TestModeless.zip'  just for clarity.
« Last Edit: May 01, 2007, 02:20:50 AM by Kerry Brown »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

LE

  • Guest
Re: ModalForm Flickering while Selecting...
« Reply #19 on: May 03, 2007, 01:09:30 PM »
Just want it to say... that the porting and coding is getting so well, that this particular routine that was original done in autolisp and dcl, it is looking good!, it has not been that difficult at all.

Here is an animation preview of my work in progress... it might encourage some to jump into C#...

Glenn R

  • Guest
Re: ModalForm Flickering while Selecting...
« Reply #20 on: May 03, 2007, 07:20:37 PM »
Good to see you resisted the urge to get too colourfull with your interface Luis. Looking good.
A rule of thumb all should follow is to make your UI look and feel like AutoCAD as much as possible.

Cheers,
Glenn.

LE

  • Guest
Re: ModalForm Flickering while Selecting...
« Reply #21 on: May 03, 2007, 10:37:11 PM »
Good to see you resisted the urge to get too colourfull with your interface Luis. Looking good.
A rule of thumb all should follow is to make your UI look and feel like AutoCAD as much as possible.

Cheers,
Glenn.

Thank you Glenn;

It end up like this:


edit: last changes
« Last Edit: May 03, 2007, 11:43:11 PM by LE »

Glenn R

  • Guest
Re: ModalForm Flickering while Selecting...
« Reply #22 on: May 03, 2007, 10:47:57 PM »
Just one thing Luis. If it was me, I would ditch the blue background and "Door Installer Not/Ready.." stuff at the bottom and simply enable or disable the "Install Button" appropriately. Looks great.

Cheers,
Glenn.

LE

  • Guest
Re: ModalForm Flickering while Selecting...
« Reply #23 on: May 03, 2007, 10:59:16 PM »
Just one thing Luis. If it was me, I would ditch the blue background and "Door Installer Not/Ready.." stuff at the bottom and simply enable or disable the "Install Button" appropriately. Looks great.

Cheers,
Glenn.

10-4

:)

LE

  • Guest
Re: ModalForm Flickering while Selecting...
« Reply #24 on: May 04, 2007, 09:31:13 PM »
Note:
Since there is no way to make a custom object... I end up making a Door class and saved in dictionaries the door properties and redoing the door with anonymous blocks - it works for what I need.

I know, there is no code, but have a look of my work in progress:

Glenn R

  • Guest
Re: ModalForm Flickering while Selecting...
« Reply #25 on: May 05, 2007, 06:29:42 AM »
Nicely done Luis. The UI looks good too :)