locked
Strange behavior after changing the main window of a Windows Form application RRS feed

  • Question

  • Good morning all,

    I have a windows form application. (Vb Express 2010 - .NET Framework 4 Client Profile, OS : Windows 10 version 1909)!
    At first, I had a main form that I was using.

    In order to refresh the application, I created a new main form. This is where the strange problems started to appear (the code is identically the same):
    1) After starting, some areas do not refresh! (Toolstrip, Menustrip, etc.) you must move the mouse over it to see the buttons and menu appear or to resize the window!
    2) At the end of startup, I trigger a Timer to save every X minutes. The timer does not start! even by forcing x times timer1.start
    3) The biggest problem, if I bring up a Messagebox, this messagebox remains in the background behind the main window, thus blocking the application! because it waits until I click OK but it is not accessible!
    4) I created a custom popup using another form, to display temporary messages for X seconds. If I run this popup (using the ShowWindow, and SetWindowPos APIs), nothing happens unless I minimize the main window (even after 1 minute).
    It looks like the main window is blocking some Thread! I checked, double-checked my code.
    (and it's the same as the previous one, I don't have an error message! I use Datatables with XmlSerializer, etc.)

    Whether I define the startup object "Sub Main" or "Form", it doesn't change anything.
    I even recreated a 3rd main form and I have the same problem!
    In short, it is not usable.

    If I restart with the old main form I no longer have its problems!

    I would have put the start code but the code is complex and calls subroutines (it is a program with more than 10,000 thousand lines of code) (70 forms, 50 classes, 30 modules, ...)

    I have already done a lot of applications and have never encountered this problem, thanks for your help.

    PS: sorry for my english

    Cordially.

    Steeve.


    Steeve

    Monday, February 10, 2020 10:35 AM

Answers

  • Hello,

    Usually when a form does not refresh like this and something is blocking the updates the form would not be responsive yet it sounds like this is not the case as you can hover over controls and they refresh so this would rule out not having time to paint.

    Jumping to the original form not having any issues your choice is to create a new form as the main form without any code other than a button with Close in the Click event. See if this works, if yes add small segments of code and try do this until there is a failure to function properly. 

    If the above does not yield anything to assist it's time to use the debugger e.g.

    If in Sub Main you are using 

    Dim SomeForm As New Form2

    ShowForm.ShowDialog

    Then set a breakpoint on Dim SomeForm As New Form2 and step through the code without the Timer enabled. 


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Monday, February 10, 2020 11:03 AM

All replies

  • Hello,

    Usually when a form does not refresh like this and something is blocking the updates the form would not be responsive yet it sounds like this is not the case as you can hover over controls and they refresh so this would rule out not having time to paint.

    Jumping to the original form not having any issues your choice is to create a new form as the main form without any code other than a button with Close in the Click event. See if this works, if yes add small segments of code and try do this until there is a failure to function properly. 

    If the above does not yield anything to assist it's time to use the debugger e.g.

    If in Sub Main you are using 

    Dim SomeForm As New Form2

    ShowForm.ShowDialog

    Then set a breakpoint on Dim SomeForm As New Form2 and step through the code without the Timer enabled. 


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Monday, February 10, 2020 11:03 AM
  • Long shots:

    You know that when you paste code into a form, or if you delete a control, the handles code at the end of the sub statement sometimes gets deleted by the VS IDE. Then if you run the project there is no error and there is a sub routine but the event for that control no longer exists.

    Other things like renaming can blow a hole in things you dont expect.

    How did you make the new form or whatever? Always copy or add the controls first and then paste the code.

    Check your control events and see if the event handles are right.

    Make sure the project has menu debug - windows - exceptions dialog set with break on all CLR errors set. Sometimes you can be skipping errors.

    Monday, February 10, 2020 11:51 AM
  • Hi,

    I have the same idea. Did you copy the code before adding the control to the form?

    How is your problem solved now?

    If you have anything else about this issue, please feel free to contact us.

    Best Regards,

    Julie


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, February 17, 2020 2:05 AM
  • Hello everyone,

    And thank you all for your solutions, after several hours of research, I was able to identify the problem.
    As Tommy suggested, I turned on all CLR errors but I had no errors.
    I then isolated line by line to finally find!
    It seems that the problem is related to the SelectValueChanged event of several combobox that I had previously linked using databindings.

    Steeve

    Tuesday, February 18, 2020 2:05 PM