Results 1 to 12 of 12

Thread: TopMost

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    617
    Guys/Gals

    I am invoking a stored procedure from within VB which
    takes a long time to run

    However, my main VB form will blank out during that time
    if any one does anything else like opening up a new
    task... The items would be no longer visible until such
    time that I return from the stored procedure call

    How can I fix this... keep my form on top not just on top
    all my vb forms within this program but on top of
    everything else

    Your help will be appreciated

    Thanks

  2. #2
    Guest

    Red face

    Your computer is "too busy" with your function or procedure to redraw the form after something has overlapped. You are probably doign stuff in a loop like this:

    Code:
    While Cont = True
      If A_One_in_a_zillion_chance=5 then Cont=false
    Wend
    This "pseudo-code" will keep the computer very busy...
    Now try this:

    Code:
    While Cont = True
      If A_One_in_a_zillion_chance=5 then Cont=false
      DoEvents  ' It's this one that I've added
    Wend
    It gives your computer some time to breathe in the loop befor starting another loop again.. and again... and again... and again... and again... and again... and again...


    Hope it helped ya...

  3. #3
    Guest
    So what I forgot to mention is that you probably don't need an "on-top" function or anything...

    A quote from the help-files:

    Yields execution so that the operating system can process other events.

    Syntax

    DoEvents( )

    Remarks

    The DoEvents function returns anInteger representing the number of open forms in stand-alone versions of Visual Basic, such as Visual Basic, Professional Edition. DoEvents returns zero in all other applications.

    DoEvents passes control to the operating system. Control is returned after the operating system has finished processing the events in its queue and all keys in the SendKeys queue have been sent.

    DoEvents is most useful for simple things like allowing a user to cancel a process after it has started, for example a search for a file. For long-running processes, yielding the processor is better accomplished by using a Timer or delegating the task to an ActiveX EXE component.. In the latter case, the task can continue completely independent of your application, and the operating system takes case of multitasking and time slicing.

    Caution Any time you temporarily yield the processor within an event procedure, make sure theprocedure is not executed again from a different part of your code before the first call returns; this could cause unpredictable results. In addition, do not use DoEvents if other applications could possibly interact with your procedure in unforeseen ways during the time you have yielded control.

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    617

    Thanks, But...

    The DOEVENTS would normally work
    Except that once the stored procedure is invoked...
    It's like another process has it completely until
    completed... It is in its world and My application can only wait... then do a DOEVENTS but...

    It's like I would need the DOEVENTS as the stored proc is
    running in its own world (thread)

    Am I clear enough?

    Thanks in advance

  5. #5
    Guest
    Can't you make it process the data in bits instead of all of the data at once?

    So instead of ProcessData(1 to a million_or_so) do it like

    Code:
    ChunkSize=1000
    For T=1 to a million_or_so-ChunkSize Step ChunkSize
      ProcessData(T to T+ChunkSize)
      DoEvents
    Next T

  6. #6
    Fanatic Member crispin's Avatar
    Join Date
    Aug 2000
    Location
    2 clicks west of a Quirkafleeg...Cornwall, England
    Posts
    754
    Can you give us a bit more info Lafor,

    What sort of stored procedure do you mean?

    Is it an SQL server stored procedure, what Data Access Technology are you using?

    You may need to subclass the form, and trap windows messages, so if it loses focus, then you can disable this event, so it stays on top.

    [Edited by crispin on 09-21-2000 at 06:49 AM]
    Crispin
    VB6 ENT SP5
    VB.NET
    W2K ADV SVR SP3
    WWW.BLOCKSOFT.CO.UK

    [Microsoft Basic: 1976-2001, RIP]

  7. #7
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    Lightbulb

    Have you considered executing your stored procedure asynchronously? Use an event to trap when the stored procedure has finished processing.

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    617

    hmm

    Hi!

    So many great ideas u guys have...

    Rob -- I think I am somewhat doing that already... In that
    the stored procedure is already nroken down into
    3 smaller stored procs...

    crisp -- SQL SERVER stored proc and ADO

    "You may need to subclass the form, and trap windows messages, so if it loses focus, then you can disable this event, so it stays on top."

    Would appreciate your help on implementing the above statement...

    simonm -- Yes, I did consider that... but could not get it to work

    Any help would be appreciated

    Thanks


  9. #9
    Fanatic Member crispin's Avatar
    Join Date
    Aug 2000
    Location
    2 clicks west of a Quirkafleeg...Cornwall, England
    Posts
    754
    Try this code for keeping your form on top ala Matt Hart

    http://blackbeltvb.com/free/ontop.htm

    Crispin
    VB6 ENT SP5
    VB.NET
    W2K ADV SVR SP3
    WWW.BLOCKSOFT.CO.UK

    [Microsoft Basic: 1976-2001, RIP]

  10. #10

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    617

    hmm (onTop)

    crisp - That would be good but I don't really want to compile my pgm into an active Exe to force it to stay on top

  11. #11
    Fanatic Member crispin's Avatar
    Join Date
    Aug 2000
    Location
    2 clicks west of a Quirkafleeg...Cornwall, England
    Posts
    754
    so you run your app from the VB development environment, and you don't compile an EXE?

    ..Just clarifying
    Crispin
    VB6 ENT SP5
    VB.NET
    W2K ADV SVR SP3
    WWW.BLOCKSOFT.CO.UK

    [Microsoft Basic: 1976-2001, RIP]

  12. #12

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    617

    ok


    crisp-
    The reference with not willing to compile into .exe was
    due to the fact the link you pointed made the following remark:

    "When run from VB, this window will ONLY be on top of VB windows. You must compile it to an EXE file and run it before putting it on top will make it stay above ALL running programs."

    Just clarifying...

    Thanks again

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