473,804 Members | 3,094 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Form.Show() Error

13 New Member
Hi All,

If I type this code (VB.net 2003):

Expand|Select|Wrap|Line Numbers
  1. Dim myDialog As frmTestDialog
  2.  
  3. myDialog = New frmTestDialog
  4.  
  5. myDialog.Show()
you'd expect some dialog window to appear in a non-modal state. For some reason, this isn't the case with a program I am working on. Most of the dialogs use ShowDialog() to open them, and one uses Show(). The second I try to show another non-modal dialog, the dialog appears in a modal state. Another strange thing is, before I show the dialog, there is code to shift the dialog location to centre it on the main form - this isn't executed either: the dialog appears at 0,0.

My usual trend is to blame myself for errors (usually the case), then I blame the software; I have checked every single line of code (including the generated code), and it all checks out - the dialog should be non-modal. But ... it's not. I've come across other errors in VB.net 2003; is this another instance?

I'll try creating a new dialog and displaying this non-modal, and see what happens. If it works, I can just transplant the code ... but ... this shouldn't be happening, just like if I go to a shop, ask for a cola, I expect a cola not a Chinese panda; more annoying, I return the panda, ask for a cola, and they give me the panda back ... do loop until I give up ...

The system does using threading, but none of that code connects to the display dialog routines - all dialogs are opened with more-or-less the above code (a few have simple validation routines).

Any help would be appreciated here. I've been coding with VB.net solidly for years, and I've never encountered this before.
Apr 19 '09 #1
5 3607
Enij
13 New Member
Yep, for some reason when I add a new form to the solution, try to show it as non-modal, it appears in a non-modal state...

Okay, hold the phone ... as part of the validation routine that precedes the dialog.Show(), a ListView control is tested for an item count > 0 -- this listview is part of a threaded routine. The second I comment all the listview code, the dialog shows in a non-modal state (and the dialog is centred on the main form). It's like any connection whatsoever to the listview control is making the dialog become modal (the validation pseudo-code is: check listview for 0 items / if > 0, iterate listview items, creating a comma-delimited string based on listview item text / place the string in the dialog's tag / show dialog non-modal). By adding this string to the dialog tag property, the dialog becomes modal ...

This happens regardless to the String's scope.

I can work around this, but I would love to know what is going on here.
Apr 19 '09 #2
Enij
13 New Member
Wrote quite a few workarounds, even tried a 'cheat' by creating a dialog in thread, and they all failed.

I'm fairly positive this is a threading issue now. It is strange that my first non-modal dialog works perfectly.

I have a collection of routines that are run in a separate thread, which access the aforementioned listview control - directly access it, no invoking to the main UI thread, or anything like that (there are some visual glitches that happen when this is done, but by refreshing the control, the glitches vanish). I have a feeling this tardiness of mine is responsible for the error(s).

I did once invoke to the main UI thread, as there is some old code still commented on the system; not sure why I reverted the code. I'll run through my notes, and retry the invoking technique, see if this cures the problem...
Apr 19 '09 #3
Enij
13 New Member
Okay ... I'm at a dead-end here.

Tried using a delegate and invoking to the main UI thread, which failed, as in everything went smoothly, but the dialog is still modal and in the upper-left corner.

To see if this is a threading issue, I removed all the threading code and called the routine directly. The UI hung as I expected it to, the routine completed, showing results in the listview control, but ... still the dialog opens as modal, and it's in the upper-left corner. So, now I don't think it is a threading issue.

Before I start this routine, the dialog opens normally. It is after the routine has been called and ends, that is when the dialog goes nuts.

I've exhausted my VB.net knowledge, and I can't find anything with Google that mentions this type of error. I am loathed to blame VB.net; this is most likely something I've done, but I cannot find what it is.

Move on a few minutes into new tests ...

Now this is where things get a little strange. To see if the problem lay with something in the dialog code, I created a new, empty dialog, and hooked it up to display on a button click, commenting the old code out. In my understanding of the universe, when the button is clicked, the new dialog would appear, and for every click, a new dialog. This is what happened.

Then I ran my listview control routine. The routine completes, and ... this doesn't make any sense. Code that had been commented out is running -- I click the button to load the new, empty dialog, and the old dialog appears (modal, upper-left corner).

When I worked as a computer engineer, I saw errors (crazy errors) like this when the computer's memory modules were corrupted (one minute a DVD-ROM would read 50 files, then next, it'd read 23 files, etc).

Anyway, I'm out of ideas. Any help here would be great.
Apr 19 '09 #4
Plater
7,872 Recognized Expert Expert
As for your latest problem:
If you set breakpoints and run in debug, do your breakpoint circles become empty red circle (instead of filled in ones)?
It sort of sounds like something is happening at compile time, like maybe something is not being cleaned/built correctly?
I've had it happen where I didn't pay close enough attention to the build output to see things like "project not selected for build" (vs went crazy and took all of my projects out of the build list) and couldn't figure out why my code wasn't running.
Apr 20 '09 #5
Enij
13 New Member
Hi Plater,

Thanks for your quick reply. Things are a tad strange at this end.

My build list is good -- everything is where it should be. I deleted all the .exes, .pdbs, Release and Debug folders, letting VB recreate them - the error still happens.

Then, I tried your breakpoints idea, and regardless of what I did or where the breakpoints were set, they were never triggered. Then, I thought maybe another routine had accidentally been told to handle the control's click event (I'm using a label control to act as a button), but the routine handling the click was the only one.

Then, I commented out the entire click event code, ran the application, and the dialog still appeared in its modal state (X-Files eat your heart out!!) ... there's no code to do anything, yet something happens... Dumbfounded, I placed a button control on the form and rigged it to show the dialog, and it works -- the dialog is being shown as non-modal, doing everything the code tells it to.

My computer's hard-disk started making some strange, whining noises a few days back (it is 6 years old after all), so I ran the usual checks on all system elements, and they all came back clean. But, just on the off-chance, I put the VB solution on to my new laptop, ran the application, and the same fault happens, letting my old machine and the VB installation off the hook.

Label controls have a click event, so I'm assuming it's fine to use them as buttons (I use label controls as simple, flat menu icons). Though, saying that, I have bundle of 24x24 labels acting as buttons, and they're all doing their job nicely.

My breakpoints are displayed as solid red circles.

I'll try creating another label control, configure it as the other, and transplant the code across, see what happens ...

EDIT: (after the above test)

Deleted the old label control, created a new one, and hooked it up to show a dialog in a non-modal state ...

It works ... it ... WORKS!!!!!! ha hahahahahhahaha aaaa!!!

... ahem ...

Guess the solution was obvious -- if a control stops working correctly, delete it and replace it, before going over-board, tearing your application apart, searching for a problem that isn't there.

I've been meaning to have a look at the express edition of VB2008, perhaps it's time I did. Does anybody know if VB2008 can be purchased alone, or if it is only available as part of Visual Studio 2008?
Apr 22 '09 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

10
2788
by: Norman Bird | last post by:
I have a form i will use to register new people and when I click the submit button, the form just shows itself. It is supposed to show a message showing field errors if you leave fields blank etc. so submitting the empty form should show error message in red , then show form, but all it does is show form. I checked the variable to make shore they ere ok and they are fine. i believe it is a logical error with my if else.... I eved...
13
74145
by: genetic.error | last post by:
I'm moving from Vb6 to VB.Net. I have a feeling this has come up before... The VS.Net MSDN file seems to state that the following should work: Form1.Show Form1.Visible = True Form1.Hide Form1.Visible = False Load (Form1)
4
1852
by: Ahmet | last post by:
Hi all; I have one application in which I read form names from database to be opened. I open form with the code below, and call its show method for form to be shown but before this, I must set MdiChild property to true to make this form child I can call functions as you can see like (show), how can i set.MdiParent = this property of dynamically loaded form ? Or I can call a form function dynamically with parameter ?...
6
1437
by: Shane Saunders | last post by:
I have a menu option that loads a form and displays infomation. if you go to main form and try to load something else from that same menu, it does a check to see if the form in exist and then reloads it has to or does messagebox. the problem i have is that i want to set the module instance varible to nothing when i exit the form that is being check. The code i am use is If frmWeatherMap Is Nothing Then
5
3934
by: ortaias | last post by:
I have a form which calls up a second form for purposes of data entry. When closing the data entry form and returning to the main form, things don't work as expected. When I return to the main form, I trigger the on acitvate event to run a macro. I can use the Dlookup function to update my fields, which is OK. However, I intitially tried to use the Repaint Object command to repaint the form. That did not work. Though I solved the...
20
4817
by: vitorjol | last post by:
Hello. I have 2 forms (Form1 and Form2). When i call the Sub placed in form1 from form2, i get the error "object reference not set to an instance of an object" ! What can i do to solve the problem? Thanks
11
3002
by: Rik | last post by:
Hello guys, now that I'm that I'm working on my first major 'open' forms (with uncontrolled users I mean, not a secure backend-interface), I'd like to add a lot of possibilities to check wether certain fields match certain criteria, and inform the user in different ways when the data is wrong (offcourse, this will be checked on posting the data again, but that's something I've got a lot of experience with). Now, offcourse it's...
9
2434
by: timnels | last post by:
I have an issue where I have a user control that is launched into a floating form. At some point later, I allow the user to "unfloat" the user control by reparenting it on a split container in another form. Problem is if I wake a tooltip when the window is floated, and then try the same thing when it is reparented, the app crashes with " Cannot access a disposed object.Object name: 'Form'. Presumably, this is a result of the tooltips...
10
15335
by: sara | last post by:
Hi - I have been struggling with solution ideas for this now for almost 2 weeks, and have not been able to figure this out. I have a user who creates a Purchase Order (tblPOData). In some circumstances, this or another user must create an invoice to go with the PO (I know - that makes no sense, but this is the business case). I have the user go to a form to create the invoice:
4
3480
by: zufie | last post by:
I have a main form containing a command SEND button that prompts an email form to pop up. The email address(es) that are supposed to appear on the email form are those corresponding to the respective agency record appearing on the main form at the current time. Instead, what I get is the email form without the appropriate information in the textboxes of the email form.
0
9569
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10558
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10318
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10302
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10069
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9130
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5636
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3802
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2975
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.