1
votes

I have problem about close() or dispose() fucntion with my barcode reader (Windoes Embeded Compact 7). In this case I can only hide() form.

I tried to show Form2 as dialogue but after I clicked the close button (to hide this form and go back to Form1) It made all of my application close

In Form1 (Main):

Public Sub showForm2()

Dim secForm As New Form2

secForm.ShowDialog()

End Sub

In Form2:

'close button

Private Sub closebt_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles closebt.Click

Me.Hide()

End Sub

3
no reason why it would close.SSpoke
@SSpoke It cause message received from Windows Message amount increase every time I enter the "scan form". Ex. First time I enter the form and scan, I recieve only one barcode message (from batch by WndProc) then I press back or change form then re-enter the scan form again I will received 2 messages per one scan, next time It will be 3, 4, 5 . . . messages. about this problem I don't know whyPalm

3 Answers

1
votes

Form can't be hidden if it is shown as Dialog. If you want to hide the form then use form.show() rather than form.ShowDialog(). Also here is a link

    http://www.vbforums.com/showthread.php?759061-How-can-i-hide-my-second-form-dialog-without-bliking-form-not-closing-my-first-form
1
votes

Go to properties page of the project. In the Application tab, there is a setting:

  • Shutdown mode
    • When startup form closes
    • When last form closes

Choose "When last form closes" to prevent closing the application when your main form closes.

-1
votes

in the index form add in form closing the fallow code:

Form1.Dispose()