Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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?

  • *Gurus*
Posted

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:

 

Dim f As New frmOptions(Me)

 

Then your options form can retain that object to refer to the already open form.

MVP, Visual Developer - .NET

 

Now you see why evil will always triumph - because good is dumb.

 

My free .NET Windows Forms Controls and Articles

Posted

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

Posted
Show me the code that calls the form with dialog please.
Posted

ok the mainform opens the font dialog from a menu item

 

 

the code as is..

 

 

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

 

 

 

  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

Posted
Sorry but i ran out of ideas everything i try doesnt work.
Posted
Ill get you a sample of creating a registry key in one sec :)
Posted

Ok:

 

First put

Imports Microsoft.Win32

on top of the code

 

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()

Posted

By checkbox?

You mean that if user checks the check box and presses a button the program will start with windows?

Posted

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?

Posted

Change the previous code to:

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:

 

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

Posted

Try this:

 

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

Posted (edited)

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

 

 

 

dim counter as integer


counter +=1

if counter =3 then

me.close
dim mainform as new frmmain

mainform.show

end if

Edited by divil
Posted

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.

Posted

When you drag the timer into your form, set the interval of timer to 3000 cause you 3 seconds right,set enabled to true.

In the code: when timer reaches 3 seconds you have to turn it off by putting enabled = false so it wont continue, otherwise you would get a new form shown every 3 seconds instead of once.

Posted
Oh, now when i reread your post i think i get what you ask and how would it tick. The tick event will be executed when timer reaches the interval. So when it ticks after reaching the interval you have to disable it so it wont tick again and show another form.
Posted

cywizz it isnt how i wanted it

 

 

i got a mainform

 

 

and a font form

 

 

 

mainform has a menu

user clicks on it

and it opens up the font form

 

 

 

on the font form

 

 

theres a browse button

 

 

once the user selects the font from the browse button whcih opens a font dialog

 

 

then they get a preview and the fonts name in a label on the font form

 

 

then they can click apply

 

 

and the mainforms font will be changed to wateva they desire

Guest
This topic is now closed to further replies.
×
×
  • Create New...