Major unsolvable problem

Status
Not open for further replies.

Winston

Junior Contributor
Joined
Jan 25, 2003
Messages
266
Location
Sydney, Australia
i have a form

it hasa button
click on it a font dialog appears
user selects it

then the font is applied to be preivewd in a label

and then the font name displayed

once the user clicks on apply

the font is applied to the main form

i.e. mainform.font = fontdialog.font


this is what i put in the appply button


dim mainform as new frmmain

mainform.font = fntdlg.font




what happens is it keeps creating new main forms and loading and my system tray has like 20 billion of the app opened

i have no way of doing it

any way u guys?
 
Because on this line:

dim mainform as new frmmain

You are creating a new instance of your main form. You don't want to do this, you want to refer to the instance which is already there. There are many ways to do this, the most common of which is to pass it in the constructor of your options form:

Visual Basic:
Dim f As New frmOptions(Me)

Then your options form can retain that object to refer to the already open form.
 
In your first form, when you create the instance of the options form. I suggest you go and read about constructors in the help system.
 
sorry im really bad with programming im just trying to implement most of the features
its for my major assignment
i have no idea wat im reading so yea
 
ok the mainform opens the font dialog from a menu item


the code as is..


PHP:
Private Sub mnuFormatAppBaseFont_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFormatAppBaseFont.Click
        Dim appbasefont As New frmAppBaseFont()
        appbasefont.ShowDialog()

    End Sub

where appbasefont is the font form



now the font form has a button , once u click on it out comes a font dialog box, user selects a font, and then they get a preview of it in a label and the name of the selected font in a text box, this is the code for the browse button which opens a font dialog



PHP:
  fntAppBase.ShowDialog()
        lblPreviewBox.Font = fntAppBase.Font
        txtFontSel.Text = fntAppBase.Font.Name
        btnApply.Enabled = True


ok now when the user clicks apply the selected font the user has

chosen is changes the main forms font
 
Ok:

First put
Imports Microsoft.Win32
on top of the code

Visual Basic:
Dim key As RegistryKey
Dim subkey As RegistryKey
key = Registry.LocalMachine
subkey = key.CreateSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run\")
subkey.SetValue("ProgramName", "ProgramPath")
Call subkey.Close()
Call key.Close()
 
By checkbox?
You mean that if user checks the check box and presses a button the program will start with windows?
 
yea its within my options

should i just do a select case on the ok button

and case true


then add blah blah



or case false


delete key


how do i remove the key?
 
Change the previous code to:
Visual Basic:
Dim key As RegistryKey
Dim subkey As RegistryKey
key = Registry.LocalMachine
subkey = key.CreateSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run\ProgramName")
subkey.SetValue("ProgramName", "ProgramPath")
Call subkey.Close()
Call key.Close()

And here is one that will delete it:

Visual Basic:
Dim key As RegistryKey
key = Registry.LocalMachine
key.DeleteSubKeyTree("SOFTWARE\Microsoft\Windows\CurrentVersion\Run\ProgramName\")
Call key.Close()
 
Try this:

Visual Basic:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim f As New Form2()
Timer1.Enabled = False
f.Show()
End Sub
 
ok currently

the splash form is set as the start up object


the form has a timer

once the form loads the timer gets executed


and the timer has the following code



Visual Basic:
dim counter as integer


counter +=1

if counter =3 then

me.close
dim mainform as new frmmain

mainform.show

end if
 
Last edited by a moderator:
Is that in the timer event?
If it is just use what i said before and set interval to 3000.
Also i think that you program ends before you get the main form showed because you closed the only form of app before you open new one.
 
Status
Not open for further replies.
Back
Top