Results 1 to 11 of 11

Thread: Windowstate problem

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    Windowstate problem

    hi there

    i cant figure this one:

    i have a program i made. in the main form, it eventually gets to the code where it has to execute a 3rd party program.

    it minmized this window and shows a splash form i made in vb to tell the user that the program is loading

    it then calls another form up but this form isnt shown as it has other code in it.

    so in this nonshown form it has a code which says many other stuff along with the command to keep the splash screen on focus so its windowstate is vbnormal

    when the 3rd party program is closed, i told it to close the splash form and in the splash form on the unload query i have said to set the windowstate of the main form to vbnormal - since it was minimized.

    it used to do it - but not now

    actually - it only ever works at home but not at university and i don know why. please help

    the window stays on the taskbar and no matter what u try and do to get the focus to vbnormal on the mainform - it wont do it. it just sticks at the taskbar.

    help!

    code on main form:

    Code:
    ..
    ..
    completerun = temppath + "\setenvironment.bat"
    
    
    Me.WindowState = vbMinimized
    
    frmExecuteRomeStatus.Show
    DoEvents
    frmExecuteRomeStatus.WindowState = vbNormal
    frmExecuteOperation.runrome (completerun)
    romestatus is the splash form and has this code:

    Code:
    Private Sub Form_Load()
    
    Me.WindowState = vbNormal
    
    End Sub
    
    Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    
    frmMain.WindowState = vbNormal
    
    End Sub
    
    Private Sub Form_Unload(Cancel As Integer)
    
    frmMain.WindowState = vbNormal
    
    
    End Sub
    execute rome operation form has this code:

    Code:
    Const SYNCHRONIZE = &H100000
      
     
    Const INFINITE = &HFFFF
     'Wait forever
     
    Const WAIT_OBJECT_0 = 0
     'The state of the specified object is signaled
     
    Const WAIT_TIMEOUT = &H102
     'The time-out interval elapsed & the object’s state
    'is nonsignaled.
     
    
    Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, _
                ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
    
    Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, _
                ByVal dwMilliseconds As Long) As Long
    
    Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
    
    Sub runrome(ByVal runrome As String)
    
    Dim lPid As Long
    Dim lHnd As Long
    Dim lRet As Long
    
    
    lPid = Shell(runrome, vbMinimizedFocus)
    
    If lPid <> 0 Then
            frmExecuteRomeStatus.WindowState = vbNormal
            DoEvents
            
            'Get a handle to the shelled process.
            lHnd = OpenProcess(SYNCHRONIZE, 0, lPid)
            
    
            If lHnd <> 0 Then
                    lRet = WaitForSingleObject(lHnd, INFINITE)
                    CloseHandle (lHnd)
            End If
            frmMain.WindowState = vbNormal
            
            Unload frmExecuteRomeStatus
            
            Unload Me
    End If
    
    End Sub
    
    Private Sub Form_Load()
    
    frmExecuteRomeStatus.WindowState = vbNormal
    DoEvents
    
    End Sub
    help! i appreciate any help and advice.

    thanks

  2. #2

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773
    no one knows? come on!

  3. #3
    Fanatic Member
    Join Date
    Jun 2003
    Location
    IL
    Posts
    739
    Can't you use a module instead of putting that code in the main form? So then you would call the code from the module in the splash screen and after you are done just load the main form. You won't have to worry about window state.
    Motto: Anything for a laugh.

    Getting second place only means you are the first loser to cross the finish line.

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773
    Thanks

    but how would i use a module?

    and it would take some time doing this any other way for a temp cure now?

  5. #5
    Fanatic Member
    Join Date
    Jun 2003
    Location
    IL
    Posts
    739
    Just got to project->Add Module. Then you can put the code inside of it like you would on a form.
    Motto: Anything for a laugh.

    Getting second place only means you are the first loser to cross the finish line.

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773
    Thanks - will try it

    one more thing - what does object required 424 mean? im adding more code but keep getting this error and dont know at what line since it doesnt break at that line.

    [edit] found the problem but how can i resolve?

    Code:
    Public Sub ExecCmdconfig(cmdline$)
             Dim proc2 As PROCESS_INFORMATION
             Dim start2 As STARTUPINFO
             Dim ReturnValue2 As Integer
    
             ' Initialize the STARTUPINFO structure:
             start2.cb = Len(start2)
             
    
            frmCopyHDDWait.Show
            frmCopyHDDWait.WindowState = vbNormal
             
             'On Error GoTo executeerror
             ' Start the shelled application:
             ReturnValue2 = CreateProcessA(0&, cmdline$, 0&, 0&, 1&, _
                NORMAL_PRIORITY_CLASS, 0&, 0&, start2, proc2)
    
             ' Wait for the shelled application to finish:
             Do
                ReturnValue = WaitForSingleObject(proc2.hProcess, 0)
                DoEvents
                frmCopyHDDWait.Show
             Loop Until ReturnValue2 <> 258
                
             ReturnValue2 = CloseHandle(proc.hProcess2) 'ERROR IS HERE!!!!!
    
    end sub
    [/edit]

  7. #7
    Fanatic Member
    Join Date
    Jun 2003
    Location
    IL
    Posts
    739
    You can always put a break point in the program of where you want to stop your code. Then you can run your code line by line by hitting F8. YOu can put a break point in your code by moving your cursor to a line of code and then hit F9. After that you can run your program and the minute it gets to that line of code it will stop and let you debug your code line by line. then you can find out at what point you get the error. Just make sure you figure out what screen and what you are doing that this error happens. So you can put your break point close to where you think the error is occuring.
    Motto: Anything for a laugh.

    Getting second place only means you are the first loser to cross the finish line.

  8. #8
    Hyperactive Member squakMix's Avatar
    Join Date
    Oct 2003
    Location
    Washington
    Posts
    342
    I think I might Know why it doesnt work at university. Try setting: vbRestoredFocus instead of vbNormal.
    -squaK

  9. #9

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773
    Thanks - problem sorted!

  10. #10

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773
    ok squak - i will try - ta!

  11. #11

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773
    the vbrestoredfocus doesnt work...help...

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