CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 4 of 4

Thread: Who does change?

  1. #1
    Join Date
    Jan 2013

    Who does change?

    I have forms with multiple controls. Most Controls when their property (for text box it's Text, for CheckBox it is Value etc.) is changed set the flag named blnDataChanged controlling the changes to TRUE. Based on that some other processes go different way (If blnDataChanged = True Then...). When form is loading and loads data to controls all controls set blnDataChanged = True and after loading blnDataChanged = False.
    I'd like to run some process when any data in controls is changed by user, not by program. If I select using Key_Up, Key_Press or some other events I will need to write huge amount of code.
    Is there any way to know who changes data in controls, user or program?

    Thank you.

  2. #2
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008

    Re: Who does change?

    A simple method
    1: Create a flag var
    2: Set it to false at the top of form load
    3: In each change event check the flag and if false then ignore. If true then process
    4: At the end of form load or wherever needed to activate the change events set the flag to true
    Dim ChangesActive as Boolean
    Private Sub Form_Load()
        ' other stuff
    End Sub
    Private Sub Text1_Change()
       If ChangesActive Then
           'Do stuff, set var or whatever
       End IF
    End Sub
    Always use [code][/code] tags when posting code.

  3. #3
    Join Date
    Jan 2013

    Re: Who does change?

    Thank you. I was thinking about this method. It was the first idea I came to. But it requires me to write a lot of changes due to big number of controls plus their often repopulation invoking by different processes. I was hoping to find the way to distinguish who makes changes, the user or the program.

  4. #4
    Join Date
    Jun 2010

    Re: Who does change?

    Well, if you could really distinguish somehow between code or the user making the change, wouldn't you need to check that as well in each and every event handler, just like the flag suggested by DataMiser?
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

Posting Permissions

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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)