Results 1 to 17 of 17

Thread: Help with Project (Saving and Updating)

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2012
    Posts
    61

    Help with Project (Saving and Updating)

    Hi.
    This is my Project:

    https://sourceforge.net/p/xtrmstpwtch

    I'd like to add new features to it.

    ->One of which is Saving Settings

    I've added a Theme for the app, and would like the App to be able to remember the Theme that was selected before Exiting, so that it can be loaded as the initial one next time.
    For this I've got a Combo box which lists the Theme Name and a Check box which the user can select to remember the selected theme.
    Without the Saving settings option, the theme works.. but I wasn't able to figure out how to get the Saving Settings of a Check box to work

    I did take a look at a few links, but most of them were about saving Strings and Text


    -> Secondly, I'd like to add an Option to Check for Updates to the app.
    Is this possible If I'm uploading my Projects/Apps to Sourceforge? If Yes then I'd appreciate a few ti

    or do I need a Personal Website/FTP Server?


    Thanks..

  2. #2
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,531

    Re: Help with Project (Saving and Updating)

    Add a new User level setting... make it a boolean type... bind it to your checkbox...
    select the checkbox, go to the properties... under the Data grouping, there's an "(ApplicationSettings)" entry... expand it... select the Checked entry... and in the drop down, select the Setting you just created... done... now your checkbox is linked to the setting... so when the user turns it on, the value will be saved in the setting... then when the app loads, it checks the setting to see if it should load the theme, and then load it if it has been set...

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Member
    Join Date
    Oct 2012
    Posts
    61

    Re: Help with Project (Saving and Updating)

    Thanks for the Reply..
    I tried doing as you said, but couldn't complete.. I got an error in the process.

    This is what I did..
    I created Setting called ThemeSettings, Boolean Type, User Scope

    Name:  Project-settings.png
Views: 209
Size:  22.0 KB

    Name:  settingsdialog.png
Views: 205
Size:  8.0 KB

    Binding:
    Selected Check box, Application Settings, Property Binding.
    I selected the Drop down where it says Checked, and it didn't show the settings (ThemeSettings) that I created.
    I tried clicking on New
    and it gives me an error...

    Name:  error.png
Views: 205
Size:  24.0 KB

    I am really not that much good at VB.NET and am still learning.. Sorry if the mistake is silly..

  4. #4
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,531

    Re: Help with Project (Saving and Updating)

    I followed my steps, it worked fine, I followed your steps, it worked fine for me too... so I'm not sure what to tell you.


    do this... go back to the settings page... and remove it... save everything... go back to the checkbox, and try to re-create the setting from that end like you did... I wonder if not savign the new setting is what caused it to not show and so when you then created the secondone, it got an error because of two settings with one name...

    Or... after creating the setting, SAVE every thing Ctrl+Shift+S ... then try the binding again.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5

    Thread Starter
    Member
    Join Date
    Oct 2012
    Posts
    61

    Re: Help with Project (Saving and Updating)

    Quote Originally Posted by techgnome View Post
    do this... go back to the settings page... and remove it... save everything... go back to the checkbox, and try to re-create the setting from that end like you did... I wonder if not savign the new setting is what caused it to not show and so when you then created the secondone, it got an error because of two settings with one name...

    Or... after creating the setting, SAVE every thing Ctrl+Shift+S ... then try the binding again.
    -tg
    I Deleted the Setting that I created Manually and hit Ctrl+Shift+S, This fixed the error that was being thrown.


    I have left the Check box to be Unchecked by default.
    I had to do some research about Settings as I've never used them before..
    This is the code that I then wrote..


    Code:
        Private Sub BtnApply_Click(sender As System.Object, e As System.EventArgs) Handles btnApply.Click
            If cbothemes.SelectedItem = "Misty Rose" Then
                Stopwatch.MistyRose()
            End If
    
            If chbYes.Checked = True Then
                My.Settings.ThemeRem = True
                My.Settings.Save()
            End If
        End Sub

    BtnApply = Button to Apply the Theme
    cbothemes = Combo box that lists the Themes
    chbYes = Check box that says Yes. If checked the Settings should be saved and loaded next time the Form is loaded.



    I tried this way too..

    Code:
        Private Sub BtnApply_Click(sender As System.Object, e As System.EventArgs) Handles btnApply.Click
            If cbothemes.SelectedItem = "Misty Rose" Then
                Stopwatch.MistyRose()
            End If
    
            If chbYes.Checked = True Then
                My.Settings.ThemeRem = Me.chbYes.Checked
                My.Settings.Save()
            Else
                My.Settings.Save()
            End If
        End Sub

    Unfortunately both methods didn't work out..

    What I did notice this does is that it Saves the State of the Check box i.e: Checked/Unchecked..

  6. #6
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,531

    Re: Help with Project (Saving and Updating)

    Ummm.... yes... I though that's what you wanted... what is it that you want to save?
    you said "I wasn't able to figure out how to get the Saving Settings of a Check box to work" ... now it does... what is it you're looking for?

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  7. #7

    Thread Starter
    Member
    Join Date
    Oct 2012
    Posts
    61

    Re: Help with Project (Saving and Updating)

    Actually what I wanted was the Theme to be Remembered when the Check box is Checked..
    For example: If the user selects "Misty Rose" theme and checks the check box, next time the form is loaded, the Theme "Misty Rose" should be loaded and not the Default..

  8. #8
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,531

    Re: Help with Project (Saving and Updating)

    See... whren you said "I did take a look at a few links, but most of them were about saving Strings and Text" and "I wasn't able to figure out how to get the Saving Settings of a Check box to work" I took that to mean you wanted to save the checkbox to a setting... you implied that you already had the setting for the theme name (as it's a string, and you pointed out, you found examples of that)... You didn't say you wanted to save the theme... Even still, you now know how to create a setting, assign something to it and save it... if you want to save what's in the combobox... it's a string... so.......



    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  9. #9

    Thread Starter
    Member
    Join Date
    Oct 2012
    Posts
    61

    Re: Help with Project (Saving and Updating)

    Alright, so this is what I did..

    I chose to work with Boolean rather than String in the settings, as I'm new to it.. it seemed difficult..
    Perhaps once I'm used to working with Settings, I'll think about changing.

    So, I replaced the Combo box with two Radio buttons.
    One named: Default and the Other: Misty Rose

    When the user Checks the Radio Button, the Respective theme is applied.

    I did the same, I went on to bind the Radio buttons with settings. Each with its own..

    Now... When the Theme is selected, then the form is closed..
    Next time it opens up.. the Theme is still unchanged (default).... no changes.
    But... when I open up the Settings Form the Theme that was last selected is applied.

    I thought I needed to command the Start-up form to load the settings..

    So I put this code in the Event Handler for the Start-up form:

    Code:
            If My.Settings.MistyRoseTheme.Equals(True) Then
                MistyRose()
            ElseIf My.Settings.InitialTheme.Equals(True) Then
                Initial()
            End If

    and this is the Error thrown:


    Code:
    System.InvalidOperationException was unhandled
      Message=Cross-thread operation not valid: Control 'Stopwatch' accessed from a thread other than the thread it was created on.
      Source=System.Windows.Forms
      StackTrace:
           at System.Windows.Forms.Control.get_Handle()
           at System.Windows.Forms.Control.Invalidate(Boolean invalidateChildren)
           at DevComponents.DotNetBar.StyleManager.<>c__DisplayClass4.<OnColorTintChanged>b__1()
           at System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme)
           at System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj)
           at System.Threading.ExecutionContext.runTryCode(Object userData)
           at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
           at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme)
           at System.Windows.Forms.Control.InvokeMarshaledCallbacks()
           at System.Windows.Forms.Control.WndProc(Message& m)
           at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
           at System.Windows.Forms.Form.WndProc(Message& m)
           at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
           at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
           at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
           at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
           at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
           at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
           at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
           at System.Windows.Forms.Application.Run(Form mainForm)
           at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DisplaySplash()
           at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
           at System.Threading.ExecutionContext.runTryCode(Object userData)
           at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
           at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Threading.ThreadHelper.ThreadStart()
      InnerException:

  10. #10
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Help with Project (Saving and Updating)

    I'm lost. Is MistyRose() a sub which applies the theme? If so where does it reside and how is it called in the actual program when (presumably) a user chooses it? Is the start up form part of the usual interface or does it just initialise some stuff and then pass control on to another form? Are you using the VB.Net stopwatch to do the grunt work (which would explain the cross threading problem)?
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  11. #11

    Thread Starter
    Member
    Join Date
    Oct 2012
    Posts
    61

    Re: Help with Project (Saving and Updating)

    Quote Originally Posted by dunfiddlin View Post
    I'm lost. Is MistyRose() a sub which applies the theme? If so where does it reside and how is it called in the actual program when (presumably) a user chooses it? Is the start up form part of the usual interface or does it just initialise some stuff and then pass control on to another form? Are you using the VB.Net stopwatch to do the grunt work (which would explain the cross threading problem)?
    Yes, MistyRose() is a sub which applies the theme. It resides in the Main Form which is also the Start-up form.
    The user selects the Theme in the Settings form. Which calls the MistyRose() sub from the Main Form.

    The Start-up form is the Main form, i.e: Contains the Stopwatch and Features.

    Nope, I ain't using VB.Net Stopwatch.
    The Stopwatch works solely based upon Timers.

    In short... My app has only 2 forms. The Main form which contains the timers etc and the Settings Form

    You can understand the Program much better if you download and install it..
    https://sourceforge.net/projects/xtrmstpwtch/

  12. #12
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Help with Project (Saving and Updating)

    The Stopwatch works solely based upon Timers.
    Timer controls or system timers?

    You can understand the Program much better if you download and install it..
    Er yeah, I did that if you remember; it crashed. I've just downloaded and installed again. It crashed. So not much understanding gained there then!
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  13. #13

    Thread Starter
    Member
    Join Date
    Oct 2012
    Posts
    61

    Re: Help with Project (Saving and Updating)

    Timer controls..

    I can't understand why it crashes for you..
    It works fine for me and on most of my friends' pc.

    What Windows 7 are you running? 32 or 64 bit?

    I am developing the app in Windows 7 64bit.
    Do I have to change the Active Solution Patform to Any CPU ?
    It is currently x86

    <:> EDIT <:>

    Alright.. I tried it on a Windows XP PC and it gave an error right after the splash screen.
    After hours of searching and tweaking.. I think I got it working..

    I'd appreciate if you could download and try it out. It should most probably work now..
    Download link: https://sourceforge.net/projects/xtr...atest/download

    Project Link: https://sourceforge.net/projects/xtrmstpwtch/

    Please let me know how it goes..

    Thanks alot for the help so far
    Last edited by TheThinker; Nov 17th, 2012 at 08:19 AM.

  14. #14

    Thread Starter
    Member
    Join Date
    Oct 2012
    Posts
    61

    Re: Help with Project (Saving and Updating)

    I've now tested it on both Windows 7 32/64 bit and Windows xp as well..
    Its working.. no errors..

    The problem is still the same:
    Now... When the Theme is selected, then the form is closed..
    Next time it opens up.. the Theme is still unchanged (default).... no changes.
    But... when I open up the Settings Form the Theme that was last selected is applied.

  15. #15

    Thread Starter
    Member
    Join Date
    Oct 2012
    Posts
    61

    Re: Help with Project (Saving and Updating)

    How would I go about to appropriate call the Settings to be checked prior to loading the form without it giving me errors?

  16. #16

    Thread Starter
    Member
    Join Date
    Oct 2012
    Posts
    61

    Re: Help with Project (Saving and Updating)

    Switched to using the Stopwatch Class successfully.. Thanks to the Valuable Help from this Thread:

    http://www.vbforums.com/showthread.p...59#post4288059


    Now back to the Saving & Recalling the saved Theme

  17. #17

    Thread Starter
    Member
    Join Date
    Oct 2012
    Posts
    61

    Re: Help with Project (Saving and Updating)

    This is what I've got so far:

    Settings Form:

    Code:
        Private Sub rbMistyRose_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles rbMistyRose.CheckedChanged
            If rbMistyRose.Checked = True Then
                StopwatchMain.MistyRose()
                My.Settings.Save()
            End If
        End Sub

    Code:
        Private Sub Settings_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
            My.Settings.Save()
        End Sub

    Main/Startup Form:

    Code:
        Private Sub StopwatchMain_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
            If My.Settings.MistyRoseTheme.Equals(True) Then
                'My.Settings.Reload()
                MistyRose()
            ElseIf My.Settings.InitialTheme.Equals(True) Then
                Initial()
                'My.Settings.Reload()
            End If
    End Sub
    Last edited by TheThinker; Nov 27th, 2012 at 11:24 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width