jorge Posted July 30, 2003 Posted July 30, 2003 (edited) Sub main + Howto Execute code when app is closed Ok, How do i use sub main to do: Check to see if a valeu in the reg is 1 or 0 If it is 0, show a form, if it is 1 then show a notifyicon. btw: the notify icon is on the form :s I have a temp fix, but it us irritating that the form flashesa few times befor it disapears :confused: :eek: btw: you can look at the latest stabel code here: http://users.skynet.be/jorge/apachemon/apachemon-src.zip Thanx in advance Edited July 30, 2003 by jorge Quote Jorge - http://www.blackdot.be/?page=apache.htm
GT500Shlby Posted July 30, 2003 Posted July 30, 2003 http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcn7/html/vatskreadingwritingtoregistryusingvisualbasic.asp That may help you. Its the msdn library article on reading and writing the Windows Registry. I also have some sample code I derived from that. Dim regConfig As RegistryKey regConfig = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Merck\\MRL LADI\\WPPDR", True) If regConfig Is Nothing Then Registry.LocalMachine.CreateSubKey("SOFTWARE\\Merck\\MRL LADI\\WPPDR") regConfig.CreateSubKey("Config") GoTo nofile End If strConfigFile = regConfig.GetValue("Config") NoFile: With OpenFileDialog1 .InitialDirectory = "..\Config" .Filter = "PD Rating Configuration (*.ini)|*.ini" .ShowDialog() strConfigFile = .FileName() End With regConfig.SetValue("Config", strConfigFile) Quote
jorge Posted July 30, 2003 Author Posted July 30, 2003 thax, but i can read, but don't know how to load the form from sub main or the notifyicon :s thanx anywhay Quote Jorge - http://www.blackdot.be/?page=apache.htm
GT500Shlby Posted July 30, 2003 Posted July 30, 2003 Okay I was misunderstanding what you wanted. If someRegValue = 0 Then Dim you as new frmSomeForm you.show() ElseIf someRegValue = 1 Then someicon.visible = True End If This is all I can think of. If its a taskbar icon I never used those, and don't know how to show/hide it. but the form part works. Quote
jorge Posted July 30, 2003 Author Posted July 30, 2003 ok, I can see the form for a few sec, when sub main end so does my programm :s And it says, trayicon.shoc() gives a error, maby becouse it on the form :s Quote Jorge - http://www.blackdot.be/?page=apache.htm
Administrators PlausiblyDamp Posted July 30, 2003 Administrators Posted July 30, 2003 try something like Dim you As New frmSomeForm If someRegValue = 0 Then you.show() ElseIf someRegValue = 1 Then someicon.visible = True End If application.run(you) not near a compiler so I haven't tested it though... Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
jorge Posted July 30, 2003 Author Posted July 30, 2003 (edited) After some playing i found application.run(fomr) works :D But still can't get the tray to work :( btw anyid on howto execute code when a form is closed? Edited July 30, 2003 by jorge Quote Jorge - http://www.blackdot.be/?page=apache.htm
Administrators PlausiblyDamp Posted July 30, 2003 Administrators Posted July 30, 2003 (edited) Just had a quick look (with a compiler handy yipee!!!) Application.Run(you) does indeed display the form. the following may be of some help though... Dim you As New frmSomeForm If someRegValue = 0 Then you.show() ElseIf someRegValue = 1 Then you.someicon.visible = True 'with someicon being a notifyicon component of form1 declared public End If application.run() the only problem is that the app doesn't exit when you close the form - either add a handler for the Form close event or deal with it in you're exit routine. Edited July 30, 2003 by PlausiblyDamp Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
jorge Posted July 30, 2003 Author Posted July 30, 2003 (edited) you.someicon.visible = True Will show the form too! btw: How kan i work around it? it only seems to stay in memery when clsoe via the [X] not when usding END in the code, that bring me back, how can i detect that [X] is pushed? Edited July 30, 2003 by jorge Quote Jorge - http://www.blackdot.be/?page=apache.htm
jorge Posted July 30, 2003 Author Posted July 30, 2003 Found it :p Sub main() Dim frmMain As New main() If sAM_tray_start = 0 Then frmMain.Show() ElseIf sAM_tray_start = 1 Then frmMain.systray.Visible = True End If Application.Run() End Sub Thanx a lot :p And for the closing problem: Private Sub main_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing End End Sub Quote Jorge - http://www.blackdot.be/?page=apache.htm
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.