Author Topic: ModalForm Flickering while Selecting...  (Read 9091 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