Flickering Buttons: How Do I Get Rid Of Them?-VBForums
Page 1 of 10 1234 ... LastLast
Results 1 to 40 of 366

Thread: Flickering Buttons: How Do I Get Rid Of Them?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2008
    Location
    St. John's, Newfoundland, Canada
    Posts
    934

    Flickering Buttons: How Do I Get Rid Of Them?

    I have noticed flickering of buttons on the Info form upon running the form. The same flickering prevails on the "Show Question" button (Command1?) on the Q2 form.

    Also, when I run the forms, after opening the Info form, I am unable to close out of the form. Every time I try to close the Info form, a new Info form comes up. Thankfully, I can close out by minimizing the MDI form, and clicking the button to stop the run.

    Here are the files I have thus far:

    Link removed by user.

    Please let me know if you cannot access them. Hopefully this problem can be fixed soon enough.

    If you can discover what needs to be fixed, please let me know on this thread.
    Last edited by JonSea31; Dec 6th, 2009 at 06:01 PM.

  2. #2
    Addicted Member Xiphias3's Avatar
    Join Date
    Jan 2009
    Location
    Clarendon, Jamaica
    Posts
    188

    Re: Flickering Buttons: How Do I Get Rid Of Them?

    wow, huge file.
    I'll look.

    EDIT:
    Well, CSForm.frm is missing, but I'll try to scratch out those lines and try to get to the prob.

    EDIT2:
    If flicker is a problem, then you need to double-buffer.
    Too many bugs. Missing x, y and z. Check the upload that it runs properly.

    The Start game button doesn't even have an impl.
    Code:
    Private Sub Launch_Click()
    
    End Sub
    Last edited by Xiphias3; Dec 6th, 2009 at 07:54 AM.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2008
    Location
    St. John's, Newfoundland, Canada
    Posts
    934

    Re: Flickering Buttons: How Do I Get Rid Of Them?

    Quote Originally Posted by Xiphias3
    Well, CSForm.frm is missing
    CSForm.frm is now attached.
    Attached Files Attached Files

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2008
    Location
    St. John's, Newfoundland, Canada
    Posts
    934

    Re: Flickering Buttons: How Do I Get Rid Of Them?

    Quote Originally Posted by Xiphias3 View Post
    If flicker is a problem, then you need to double-buffer.
    Too many bugs. Missing x, y and z. Check the upload that it runs properly.
    How do I double-buffer?

    And where would I be missing x, y, and z?

    Also, I clicked the launch button on the test run, but the sound from the Info form carries over to the next form. How do I stop playing the sound after clicking the Launch button?

  5. #5
    VBaholic & Loving It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    GetWindowRect()
    Posts
    12,644

    Re: Flickering Buttons: How Do I Get Rid Of Them?

    You removed your project from post #1, so can you answer this question?

    Are your buttons standard VB command buttons?
    :: if so, are you using subclassing?
    :: if not, you may need the source code to track down the flickering. What type of control is it? What's its name when you hover over its icon in the toolbox?
    Insomnia is just a byproduct of, "It can't be done"

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {GDI+ Classes/Samples} {Unicode Open/Save Dialog} {Icon Organizer/Extractor}
    {VBA Control Arrays} {XP/Vista Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2008
    Location
    St. John's, Newfoundland, Canada
    Posts
    934

    Re: Flickering Buttons: How Do I Get Rid Of Them?

    Quote Originally Posted by LaVolpe View Post
    Are your buttons standard VB command buttons?
    :: if so, are you using subclassing?
    :: if not, you may need the source code to track down the flickering. What type of control is it? What's its name when you hover over its icon in the toolbox?
    Yes, they are standard command buttons. At least, that's what I think.

    I create a button on the form - is that a standard command button?

    And what is subclassing? I'm still in the learning stages.

    BTW, someone is trying to figure out my problem and hopefully he can get back to me later on.

  7. #7
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    32,878

    Re: Flickering Buttons: How Do I Get Rid Of Them?

    Quote Originally Posted by JonSea31 View Post
    ...Also, when I run the forms, after opening the Info form, I am unable to close out of the form. Every time I try to close the Info form, a new Info form comes up.....
    It doesn't happen when I do it. What are the exact steps necessary to reproduce the problem?

  8. #8
    VBaholic & Loving It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    GetWindowRect()
    Posts
    12,644

    Re: Flickering Buttons: How Do I Get Rid Of Them?

    Quote Originally Posted by JonSea31 View Post
    And what is subclassing? I'm still in the learning stages.
    Subclassing is an advanced technique that allows one to take complete control over a window/control. They can change how it behaves and how it looks.

    I've never seen a command button flicker without someone doing something to it... Unless your code is rapidly changing the buttons' appearance properties (font, caption, backcolor, etc), I thought maybe subclassing might be involved. Since you aren't familiar with subclassing, guess we can assume that it is not involved if you wrote each line of code.
    Insomnia is just a byproduct of, "It can't be done"

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {GDI+ Classes/Samples} {Unicode Open/Save Dialog} {Icon Organizer/Extractor}
    {VBA Control Arrays} {XP/Vista Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2008
    Location
    St. John's, Newfoundland, Canada
    Posts
    934

    Re: Flickering Buttons: How Do I Get Rid Of Them?

    Quote Originally Posted by MartinLiss View Post
    It doesn't happen when I do it. What are the exact steps necessary to reproduce the problem?
    That's because I figured it out myself afterwards. Gotta love trial and error.

    But Marty, the only quagmire I am faced with is the flickering of the Command1 button when the Q2 form is open. When I click the Command1 button on Q2.frm, the button does endless flickering. Can you try to locate the error?

  10. #10
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    32,878

    Re: Flickering Buttons: How Do I Get Rid Of Them?

    If you are talking about the Show Question button then, again, when I do it it doesn't happen. Perhaps we don't have the same project files any more. BTW I know you have a lot of work to do yet on your project but you should really start using more self-documenting names like cmdShowQuestion rather than the default Command1.

  11. #11

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2008
    Location
    St. John's, Newfoundland, Canada
    Posts
    934

    Re: Flickering Buttons: How Do I Get Rid Of Them?

    Maybe it's possible that, where I used the Command1 name on one form, I cannot use the same Command1 name again on other forms. That may be what was to blame for the flickering problem on the Info form, which I corrected eventually, and the flickering on that button didn't prevail afterwards on the Info form.

    But then again, it may not be a problem on your side because you may not have set each form as an MDI child. The files may have been sent to you and not originally set as MDI children.

    EDIT: Nope, flickering still prevails.
    Last edited by JonSea31; Dec 7th, 2009 at 05:43 PM.

  12. #12

  13. #13

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2008
    Location
    St. John's, Newfoundland, Canada
    Posts
    934

    Re: Flickering Buttons: How Do I Get Rid Of Them?

    Maybe it is possible that yesterday, for some reason, I got an error message regarding the file "Q2.log" when I tried to resave the Q2 form - which such error message should not have been prevalent. I may have gotten the same problem with regards to saving the Info form as well. I may not have had any problems with it on Saturday (though I don't know for sure), but I may have as of yesterday.

    I will deliver the updated folder (as the folder) later this evening.

    If there's no problems with the "Show Question" button on your side, maybe my computer doesn't have the appropriate MDI features, or some other kind of problem on my side that is unknown.
    Last edited by JonSea31; Dec 7th, 2009 at 06:09 PM.

  14. #14
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    32,878

    Re: Flickering Buttons: How Do I Get Rid Of Them?

    Do you still have a flickering button problem? Using your new files I start the app, click on "Start Game!" and after the host stops talking I click the form's "X" control and the app closes. What are you doing differently that gives you a problem. BTW there are no "MDI features" to worry about.

  15. #15

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2008
    Location
    St. John's, Newfoundland, Canada
    Posts
    934

    Re: Flickering Buttons: How Do I Get Rid Of Them?

    And by clicking the "X" control, yes, the entire application closes. That's due to the setting of all the forms inside the MDI form (a.k.a. CSForm) as MDI children. It means that when the forms are not set as MDI children within an MDI form, each subsequent form (especially the cards form) will not close and a new form of the same kind appears.

    And yes, on my side, the flickering problem still prevails. Not sure what it is on my side, but did you click "Start Game!" and play the Q1 form. Click "Show Question" and answer the question, then reveal the answer, then click "Go To The Cards", play the cards until you get to the Q2 form. I suggest you play the cards form until you get to Q2, if you haven't already. Then see if the flickering problem in the Q2 form exists on your side.

    Unless it has to do with content in the GameLogic module or something.

    EDIT: Is it possible that, where I originally saved the Q1.frm as Q2.frm, edited the code, and imported the Q1 form again, that may have caused problems with flickering? If so, I will probably have to create a new Q2 form from scratch tomorrow.
    Last edited by JonSea31; Dec 7th, 2009 at 08:06 PM.

  16. #16
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    32,878

    Re: Flickering Buttons: How Do I Get Rid Of Them?

    Here are the steps I took.

    1. Start Game
    2. Show Question
    3. Answered 0
    4. Chose "Higher" (of course)
    5. Go to the cards
    6. Got a 5
    7. Chose play it
    8. Got a 7 and froze

    Q2 form is then loaded and I see no flickering. What did I do differently from you?

    BTW there's nothing that you can do as far as form creation that would cause flickering.

  17. #17
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    32,878

    Re: Flickering Buttons: How Do I Get Rid Of Them?

    If you want the Q2 form to stop reappearing after you close it you can do this in the form.

    Code:
    Private Sub Form_Unload(Cancel As Integer)
    'Marty
    Cards1.Timer1.Enabled = False
    
    playing = False
    Set DSBuffer = Nothing
    
    End Sub
    The timer in the Cards1 form was continually Showing the form because the token equals "NewForm". If you don't change the token then you'll need also to do something in addition because you wind up with a blank screen.

    When you wind up in situations like the form reappearing do you use Debug to try to find out why?

  18. #18
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    32,878

    Re: Flickering Buttons: How Do I Get Rid Of Them?

    Oh and BTW when you are referring to things in form Q2 that are a part of the form you don't need to say things like Q2.contBkgd(1) = .... VB assumes you are talking about something in that form so contBkgd(1) = ... will do.

  19. #19

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2008
    Location
    St. John's, Newfoundland, Canada
    Posts
    934

    Re: Flickering Buttons: How Do I Get Rid Of Them?

    Quote Originally Posted by MartinLiss View Post
    When you wind up in situations like the form reappearing do you use Debug to try to find out why?
    No, because even though I am in the learning stages, I still have a hard time understanding the full concept, even when I do debug. There is more to VB than meets the eye, it seems.

    But the flickering still prevails.

    Though the forms did run smoothly with no flickering when it is not in an MDI parent form. The problem only prevails when it is in an MDI form.

    BTW, is there a way to run the forms smoothly without an MDI form, and the forms remain in the center of the screen or in one place on the screen? This is why I was testing with the MDI form this past weekend - to see if the forms remain in place. I'm pretty sure all the forms can remain in place (unless moved by the mouse) without an MDI form. How do I allow the forms to remain in the center or in one place of the screen without an MDI form?

    And BTW, thanks for the advice on the setting the Cards1.frm to false in the Form_Unload section.
    Last edited by JonSea31; Dec 8th, 2009 at 07:06 AM.

  20. #20
    Super Moderator Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,335

    Re: Flickering Buttons: How Do I Get Rid Of Them?

    Set their "StartUpPosition" to 2 - Center Screen
    Please use [Code]your code goes in here[/Code] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum section.

    Creating A Wizard In VB.NET
    Paging A Recordset
    What is wrong with using On Error Resume Next
    Good Article: Language Enhancements In Visual Basic 2010
    Upgrading VB6 Code To VB.NET
    Microsoft MVP 2005/2006/2007/2008/2009/2010/2011/2012/Defrocked

  21. #21

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2008
    Location
    St. John's, Newfoundland, Canada
    Posts
    934

    Re: Flickering Buttons: How Do I Get Rid Of Them?

    I tried it, but instead of appearing in the center of the screen, it takes up the entire screen.

    My form is 13515 X 9360, btw. What do I do to keep that same width X height and remain centered on my screen?

  22. #22
    Super Moderator Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,335

    Re: Flickering Buttons: How Do I Get Rid Of Them?

    It would take up my entire screen as well, and then some.

    What screen resolution are you running?

    If it takes up the entire screen, then there really isn't anything against which to center it.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum section.

    Creating A Wizard In VB.NET
    Paging A Recordset
    What is wrong with using On Error Resume Next
    Good Article: Language Enhancements In Visual Basic 2010
    Upgrading VB6 Code To VB.NET
    Microsoft MVP 2005/2006/2007/2008/2009/2010/2011/2012/Defrocked

  23. #23

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2008
    Location
    St. John's, Newfoundland, Canada
    Posts
    934

    Re: Flickering Buttons: How Do I Get Rid Of Them?

    what screen resolution are you running?
    1024 x 768

  24. #24
    PowerPoster
    Join Date
    Dec 2007
    Location
    Take The PCI Bus Across To The CPU!!
    Posts
    3,246

    Re: Flickering Buttons: How Do I Get Rid Of Them?

    Quote Originally Posted by JonSea31 View Post
    I tried it, but instead of appearing in the center of the screen, it takes up the entire screen.

    My form is 13515 X 9360, btw. What do I do to keep that same width X height and remain centered on my screen?
    Change the Form's Maximize button to False. Then set the Form Border to Fixed Single. That way the Form won't be recieveing any resize events to it, at all. No matter what kind of size event you are running. Except when you run the code: Form1.Height ... and Form1.Width ...
    I have a huge free products range, of computer software in which you can download using any kind of 32-Bit Web Browser. Also there is coming a Social Networking section that I am making on my Website...
    Main Page: Click Here | Blog Page: Click Here | Products Page: Click Here | News Page: Click Here | Horoscopes Page: Click Here | My Games Section: Click Here | CodeBank Page: Coming Really Soon...

    Do you wish to do unpaid work for me??? If so, the PM me on this Forum, and then we can get to work, programming for the future of computers go by the name of ThEiMp. This is my ghost writers name. Also my nickname, means that I am: The Imperial of the Technology Industry, so then to make it really short, I just then wrote: The Imp, which is where I get the nickname from...

  25. #25
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    32,878

    Re: Flickering Buttons: How Do I Get Rid Of Them?

    Quote Originally Posted by JonSea31 View Post
    No, because even though I am in the learning stages, I still have a hard time understanding the full concept, even when I do debug. There is more to VB than meets the eye, it seems.

    But the flickering still prevails.

    Though the forms did run smoothly with no flickering when it is not in an MDI parent form. The problem only prevails when it is in an MDI form.

    BTW, is there a way to run the forms smoothly without an MDI form, and the forms remain in the center of the screen or in one place on the screen? This is why I was testing with the MDI form this past weekend - to see if the forms remain in place. I'm pretty sure all the forms can remain in place (unless moved by the mouse) without an MDI form. How do I allow the forms to remain in the center or in one place of the screen without an MDI form?

    And BTW, thanks for the advice on the setting the Cards1.frm to false in the Form_Unload section.
    It's hard for me to help you unless you cooperate, so please answer my question in post #16. Also if you have questions about Debug please ask because in a fairly complex program like yours you will need to understand how to use it.

  26. #26
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    32,878

    Re: Flickering Buttons: How Do I Get Rid Of Them?

    Also about your MDI forms. Do I understand correctly that you went that route just because you want to keep certain forms always in the same place? If that's true then that's totally unnecessary.

  27. #27
    PowerPoster
    Join Date
    Dec 2007
    Location
    Take The PCI Bus Across To The CPU!!
    Posts
    3,246

    Re: Flickering Buttons: How Do I Get Rid Of Them?

    Quote Originally Posted by JonSea31 View Post
    1024 x 768
    With a twips resoultion, like the one that was mentioned in the posts before, this one. It sounds like, he is running twenty-two inch widescreen. But that means that in pixels: It becomes over 1400 x 900 (19 inch widescreen).
    I have a huge free products range, of computer software in which you can download using any kind of 32-Bit Web Browser. Also there is coming a Social Networking section that I am making on my Website...
    Main Page: Click Here | Blog Page: Click Here | Products Page: Click Here | News Page: Click Here | Horoscopes Page: Click Here | My Games Section: Click Here | CodeBank Page: Coming Really Soon...

    Do you wish to do unpaid work for me??? If so, the PM me on this Forum, and then we can get to work, programming for the future of computers go by the name of ThEiMp. This is my ghost writers name. Also my nickname, means that I am: The Imperial of the Technology Industry, so then to make it really short, I just then wrote: The Imp, which is where I get the nickname from...

  28. #28

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2008
    Location
    St. John's, Newfoundland, Canada
    Posts
    934

    Re: Flickering Buttons: How Do I Get Rid Of Them?

    Quote Originally Posted by MartinLiss View Post
    Q2 form is then loaded and I see no flickering. What did I do differently from you?
    Apologies for not answering. I presume you ran the form as an MDI form?

    Maybe the flickering problem that prevails on my side is an unsolved mystery, but after some helpful advice maybe I don't even need an MDI form at all. I can just set the Cards1.frm as a parent form (not an MDI parent) and link the Q#.frms as its child forms.

    I did post a thread over a week ago (it was titled "Parent vs. Child"), and user LaVolpe did suggest what to do, but it didn't seem clear enough. I used the code, but it didn't seem to get me anywhere. What do you suggest with regards to linking the Q# forms as the children and the Cards1 form as a parent to those children forms?

    Quote Originally Posted by MartinLiss View Post
    Also about your MDI forms. Do I understand correctly that you went that route just because you want to keep certain forms always in the same place? If that's true then that's totally unnecessary.
    Thanks, I realized that after ThEiMp offered a suggestion, and the MDI form truly is unnecessary. I probably did that out of overanalyzing on my part. I did a test run without the MDI form and MDI children, and the flickering doesn't prevail.
    Last edited by JonSea31; Dec 8th, 2009 at 12:43 PM.

  29. #29
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    32,878

    Re: Flickering Buttons: How Do I Get Rid Of Them?

    Quote Originally Posted by JonSea31 View Post
    Apologies for not answering. I presume you ran the form as an MDI form?

    Maybe the flickering problem that prevails on my side is an unsolved mystery, but after some helpful advice maybe I don't even need an MDI form at all. I can just set the Cards1.frm as a parent form (not an MDI parent) and link the Q#.frms as its child forms.

    I did post a thread over a week ago (it was titled "Parent vs. Child"), and user LaVolpe did suggest what to do, but it didn't seem clear enough. I used the code, but it didn't seem to get me anywhere. What do you suggest with regards to linking the Q# forms as the children and the Cards1 form as a parent to those children forms?


    Thanks, I realized that after ThEiMp offered a suggestion, and the MDI form truly is unnecessary. I probably did that out of overanalyzing on my part. I did a test run without the MDI form and MDI children, and the flickering doesn't prevail.
    I ran the project just as you provided it to me and that was a MDI application. If you plan to keep the MDI forms then I still need an answer to my question.

    Why do you need to use SetParent? If that works for you then don't change anything but if you just want to place forms in the same position each time then that shouldn't be a problem.

  30. #30

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2008
    Location
    St. John's, Newfoundland, Canada
    Posts
    934

    Re: Flickering Buttons: How Do I Get Rid Of Them?

    Quote Originally Posted by MartinLiss View Post
    Why do you need to use SetParent?
    You mean to say SetParent isn't necessary in an MDI form?

    And is it possible to go to the following forms in order (with some backtracking involved)?

    Q1
    Cards1
    Q2
    Cards1 (backtracking from Q2)
    Q3
    Cards1 (backtracking from Q3)
    Q4
    Cards1 (backtracking from Q4)

    BTW, the flickering doesn't occur on my side when it's not in an MDI form, but the only downside is, when not set as MDI children, all forms after Q1.frm will not close immediately after clicking the "X" on the top right hand corner of those particular forms.

    Maybe I might not need the MDI form as much as I realized earlier. It's a good idea for me to pass on the MDI form for the time being, as long as flickering doesn't prevail.

    Guess I figured out the flickering problem (as per purpose of this thread) and I may have to mark this thread resolved.
    Last edited by JonSea31; Dec 8th, 2009 at 01:49 PM.

  31. #31
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    32,878

    Re: Flickering Buttons: How Do I Get Rid Of Them?

    Quote Originally Posted by JonSea31 View Post
    You mean to say SetParent isn't necessary in an MDI form?...
    That's correct.

    Quote Originally Posted by JonSea31 View Post
    ...And is it possible to go to the following forms in order (with some backtracking involved)?

    Q1
    Cards1
    Q2
    Cards1 (backtracking from Q2)
    Q3
    Cards1 (backtracking from Q3)
    Q4
    Cards1 (backtracking from Q4)....
    I'm not sure what that means.

    Quote Originally Posted by JonSea31 View Post
    ...BTW, the flickering doesn't occur on my side when it's not in an MDI form, but the only downside is, when not set as MDI children, all forms after Q1.frm will not close immediately after clicking the "X" on the top right hand corner of those particular forms....
    If you want to close all forms when a particular form is closed then do this in that form.

    Code:
    Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    
    Dim frm As Form
    
    For Each frm In Forms
        Unload frm
        Set frm = Nothing
    Next
    
    End Sub

  32. #32
    PowerPoster
    Join Date
    Dec 2007
    Location
    Take The PCI Bus Across To The CPU!!
    Posts
    3,246

    Re: Flickering Buttons: How Do I Get Rid Of Them?

    This is the code for Form1:
    Code:
    Public Sub Form_Load()
    Form2.Show
    
    End Sub
    And then so on. Until all of the Forms, have been covered as what you are asking for!!
    I have a huge free products range, of computer software in which you can download using any kind of 32-Bit Web Browser. Also there is coming a Social Networking section that I am making on my Website...
    Main Page: Click Here | Blog Page: Click Here | Products Page: Click Here | News Page: Click Here | Horoscopes Page: Click Here | My Games Section: Click Here | CodeBank Page: Coming Really Soon...

    Do you wish to do unpaid work for me??? If so, the PM me on this Forum, and then we can get to work, programming for the future of computers go by the name of ThEiMp. This is my ghost writers name. Also my nickname, means that I am: The Imperial of the Technology Industry, so then to make it really short, I just then wrote: The Imp, which is where I get the nickname from...

  33. #33

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2008
    Location
    St. John's, Newfoundland, Canada
    Posts
    934

    Re: Flickering Buttons: How Do I Get Rid Of Them?

    Quote Originally Posted by ThEiMp View Post
    This is the code for Form1:
    Code:
    Public Sub Form_Load()
    Form2.Show
    
    End Sub
    And then so on. Until all of the Forms, have been covered as what you are asking for!!
    Nope. Didn't work. All I got was two forms playing at the same time. I know because the audio for 2 of the forms played simultaneously.

    Though despite all that, I cannot go back to the Cards1.frm. Maybe there's some code in the Cards1.frm that probably causes the Cards1.frm not to display after the second question (Q2.frm). Though I do have news that may be a good omen - the Cards1.frm did display for a split second, but then quickly disappeared afterwards. I will examine it, and see what happens. I will provide feedback later on.

  34. #34

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2008
    Location
    St. John's, Newfoundland, Canada
    Posts
    934

    Re: Flickering Buttons: How Do I Get Rid Of Them?

    I still experience problems with the reinstating of the Cards1.frm. I am not sure if it has to do with some code or if the problem has to do with content in the GameLogic module (a module to determine the order of the forms to appear).

    This is some code from the GameLogic module:

    Code:
    Do While GameToken <> EndGame
        Select Case GameToken
            Case Startup
                Info.Show
    
            Case Ques1
                GameToken = idle
                PlaySound vbNullString, 0&, SND_PURGE
                Unload Info
                Set Info = Nothing
                DoEvents
                Q1.Show
            Case R1Cards1Red
                GameToken = idle
                PlaySound vbNullString, 0&, SND_PURGE
                Unload Q1
                Set Q1 = Nothing
                DoEvents
                Cards1.Show
            Case Ques2
                GameToken = idle
                PlaySound vbNullString, 0&, SND_PURGE
                Unload Cards1
                Set Cards1 = Nothing
                DoEvents
                Q2.Show
            Case R1Cards2
                GameToken = idle
                PlaySound vbNullString, 0&, SND_PURGE
                Unload Q2
                Set Q2 = Nothing
                DoEvents
                Cards1.Show
            Case idle
                DoEvents
        End Select
        If Forms.Count = 1 Then GameToken = EndGame
        DoEvents
    In the Form_Unload section of the Q2.frm:

    Code:
    Private Sub Form_Unload(Cancel As Integer)
    Cards1.Timer1.Enabled = False
    playing = False
    Set DSBuffer = Nothing
    Unload Q2
    End Sub
    And the area where I click the GoToCards button control and it is supposed to direct me back to the cards form and continue the cards where the player left off:

    Code:
    Private Sub cmdGoToCards_Click()
    Cards1.Show
    Q2.Hide
    End Sub
    I have still to successfully get back to the Cards1.frm after Q2. Is it possible I may have to do another Cards form (like Cards2) and carry over the card values that are visible with the same card sequence using some sort of module?

  35. #35

  36. #36
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    32,878

    Re: Flickering Buttons: How Do I Get Rid Of Them?

    I can't pin down the exact reason but I believe the problem has to do with most (or perhaps all) of the code you have in your timer code. You are using the timer improperly. Timers are used mainly to do certain tasks rapidly over and over like incrementing some value or moving some control or form and in rare cases to catch user input. I guess you put in the timer to do the latter but you don't need to and it's wasteful of CPU time. In your case you know when you want to show a question so here's what you should do in form Q1. Instead of having this

    Code:
    Private Sub Command1_Click()
        token = ShowQuestion
    End Sub
    and this in the timer

    Code:
        Case ShowQuestion
            token = 0
            QuesCount(0).Caption = "A"
            For i = 0 To 1
                Label2(i).Visible = False
            Next
            CurrentQ = CurrentQ + 1
            If CurrentQ > 36 Then CurrentQ = 1
            For i = 0 To 1
                Label1(i).Caption = Question(CurrentQ)
            Next
            cmdShowQ2.Enabled = False
            Command2.Enabled = True
            Command2.Visible = True
            Text1.Enabled = True
    Do this instead.

    Code:
    Private Sub Command1_Click()
        ShowAQuestion 
    End Sub
    And create this in form Q1.

    Code:
    Private Sub ShowAQuestion()
    
        Dim i As Integer
            
            QuesCount(0).Caption = "A"
            For i = 0 To 1
                Label2(i).Visible = False
            Next
            CurrentQ = CurrentQ + 1
            If CurrentQ > 36 Then CurrentQ = 1
            For i = 0 To 1
                Label1(i).Caption = Question(CurrentQ)
            Next
            Command1.Enabled = False
            Command2.Enabled = True
            Command2.Visible = True
            Text1.Enabled = True
    
    End Sub
    You should do the same in form Q2.

    And similar for all the other token values.

  37. #37

  38. #38

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2008
    Location
    St. John's, Newfoundland, Canada
    Posts
    934

    Re: Flickering Buttons: How Do I Get Rid Of Them?

    So, if I plan to use different question forms, is it recommended that I use "ShowBQuestion" for Q2 form, and "ShowCQuestion" for Q3, and so forth?

    I did try it with the same code I had backed up, and the flickering does not prevail.

    However, the WhosTurn = BluePlayer for Q2.frm and when I enter a number, it displays on the red side instead of the blue side.

    Quote Originally Posted by MartinLiss View Post
    Why did you create two forms, Q1 and Q2? They seem almost identical and your app would be much simpler if you only had one.
    Because I wanted to use 3 question types for the entire game:

    Q1: Audience Poll questions (Out of 10 People)
    Q2-Q4: Survey Out of 100
    Q5: Educated Guess (general knowledge questions with numeric answers)
    Q6-Q8: Survey Out of 100
    Q9 (Tiebreaker): Audience Poll Questions (Out of 10 People)

    Is there a way to allow the ability to use 3 question text files for certain question types?
    Last edited by JonSea31; Dec 8th, 2009 at 07:41 PM.

  39. #39
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    32,878

    Re: Flickering Buttons: How Do I Get Rid Of Them?

    Quote Originally Posted by JonSea31 View Post
    So, if I plan to use different question forms, is it recommended that I use "ShowBQuestion" for Q2 form, and "ShowCQuestion" for Q3, and so forth?...
    No. While that would work let me explain something about what is called "scope". The scope of a variable or procedure is where it will be recognized by VB. Here are some examples.

    If you use Dim in a Sub or procedure that variable will have a scope limited to that procedure. In other words as I'm sure you are aware, if you try to refer to that variable outside of that procedure you'll get an error. The good thing about that is that you can have for example Dim i As Integer in many procedures without a problem. To go further...

    Dim MyVar at the top of a form or Private (use this rather than Dim) at the top of a form gives the variable form-wide scope. In other words you can refer to that variable anyplace in that form without a problem.

    You can also do Public MyVar at the top of a form and give the variable form-wide scope. It also allows other forms to use the variable as long as they prefix the variable name with the name of the form that it's on. In other words if you do Public MyVar in Form1 you can use it in Form2 by doing Form1.MyVar =. However you really shouldn't use Public in a form since code modules are made for that.

    Private My Var at the top of a code module gives module-wide scope to the variable and Public at the top of a code module gives program-wide scope.

    The same Public/Private rules apply to procedure names so as long as your procedures are Private (which they are by default) you can have ShowAQuestion procedure in every form and VB will know which one you mean. BTW I called my example ShowAQuestion only because ShowQuestion is already a form-scope variable in the form and so I can not also have a procedure called ShowQuestion.

    Lastly let me say that I believe that you will be making a BIG mistake if you have 4 very similar Q forms. So again let me ask, why do you have Q1 and Q2 when it looks to me that they are almost exactly the same?

  40. #40
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    32,878

    Re: Flickering Buttons: How Do I Get Rid Of Them?

    I see you gave an answer to my question as I was answering yours. I still think however that you could reduce the planned number of forms to a maximum of 4 without a lot of work if you did this.

    Q1: Audience Poll questions (Out of 10 People)
    Q2: All Survey Out of 100
    Q3: Educated Guess (general knowledge questions with numeric answers)
    Q4: (Tiebreaker): Audience Poll Questions (Out of 10 People)

    I don't know the game that well but I wouldn't be surprised of you could do all of the above in one form which would be much easier to maintain.

Page 1 of 10 1234 ... LastLast

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.