Closed dynamicboy closed 3 months ago
Moreover, when the child form is first displayed, the Me.ShowChildForm method fails to execute code, and the child form's background is black, with a blank title. However, when I invoke Me.ShowChildForm for the second time and onwards, the code executes normally.
It's worth noting that on the child form, I only use code to dynamically add UI controls.
This issue did not arise when I tested it in a simple project.
In contrast, in my actual project, which consists of over 3000 lines of code, this problem persists consistently.
Interestingly, the child forms that I created using the XAML form designer to place controls do not exhibit this issue.
Therefore, I plan to redesign the child form using the designer to resolve this issue.
Forms.LoadForm only creates the form from the Form.xaml file that contains its design, but it doesn’t execute any code or define variable. This is why it is called from the Form.sb.gen file that defines variable for controls, and create their event handlers that are added by the form designer. When you run the project, the compiler adds this code at the start of the code you write in the Form.sb file, so that the form is initialized correctly, before the code you write in the global area is executed. To get the same effect, you can use any of the following methods: Forms.ShowForm Forms.ShowDialog Form.ShowChildForm The sVB notepad project in the samples folder is a good example on using those methods. The Form.ShowChildForm works fine in this large project, and in all my samples. I need to see how do you use it in your project to fine out what is the problem.
From: dynamicboy @.> Sent: Monday, August 12, 2024 5:54 PM To: VBAndCs/sVB-Small-Visual-Basic @.> Cc: Subscribed @.***> Subject: [VBAndCs/sVB-Small-Visual-Basic] Form added vis LoadForm won't excute code! (Issue #79)
a0.png (view on web)https://github.com/user-attachments/assets/33c9749d-222c-4fe1-8024-492ebe66c83d a1.png (view on web)https://github.com/user-attachments/assets/c6c3f2ae-7364-4d00-b6e2-c2b19856fbfe a2.png (view on web)https://github.com/user-attachments/assets/67e40504-be8c-4475-9577-0016701dc0df
— Reply to this email directly, view it on GitHubhttps://github.com/VBAndCs/sVB-Small-Visual-Basic/issues/79, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ALQ5MVW235T75MVPBZQ2MPDZRDZFFAVCNFSM6AAAAABMMU2SCOVHI2DSMVQWIX3LMV43ASLTON2WKOZSGQ3DCNJYGQZDINY. You are receiving this because you are subscribed to this thread.Message ID: @.***>
Forms.LoadForm only creates the form from the Form.xaml file that contains its design, but it doesn’t execute any code or define variable. This is why it is called from the Form.sb.gen file that defines variable for controls, and create their event handlers that are added by the form designer. When you run the project, the compiler adds this code at the start of the code you write in the Form.sb file, so that the form is initialized correctly, before the code you write in the global area is executed. To get the same effect, you can use any of the following methods: Forms.ShowForm Forms.ShowDialog Form.ShowChildForm The sVB notepad project in the samples folder is a good example on using those methods. The Form.ShowChildForm works fine in this large project, and in all my samples. I need to see how do you use it in your project to fine out what is the problem. … ____ From: dynamicboy @.> Sent: Monday, August 12, 2024 5:54 PM To: VBAndCs/sVB-Small-Visual-Basic @.> Cc: Subscribed @.> Subject: [VBAndCs/sVB-Small-Visual-Basic] Form added vis LoadForm won't excute code! (Issue #79) a0.png (view on web)https://github.com/user-attachments/assets/33c9749d-222c-4fe1-8024-492ebe66c83d a1.png (view on web)https://github.com/user-attachments/assets/c6c3f2ae-7364-4d00-b6e2-c2b19856fbfe a2.png (view on web)https://github.com/user-attachments/assets/67e40504-be8c-4475-9577-0016701dc0df — Reply to this email directly, view it on GitHub<#79>, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ALQ5MVW235T75MVPBZQ2MPDZRDZFFAVCNFSM6AAAAABMMU2SCOVHI2DSMVQWIX3LMV43ASLTON2WKOZSGQ3DCNJYGQZDINY. You are receiving this because you are subscribed to this thread.Message ID: @.>
I created a new form and copied the code from the child form to the new form's code file, and everything went smoothly! I might have inadvertently made that child form vulnerable in the process.
version: sVB 3.0.8.3 details: Forms added via LoadForm do not execute code when shown using the show() method.
screenshot: