Results 1 to 7 of 7

Thread: SHELLING and TOPMOST question

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2002
    Location
    AUSTRALIA
    Posts
    603

    SHELLING and TOPMOST question

    Is it possible to make a Shelled pgm TopMost, when I am Shelling via a JPEG file ?

    I show all my forms VBModal.
    I have a wide form with a grid, listing lots of job records (the Job Register).
    If user clicks on a row they get a form showing the details for that job record.
    The detail form is similar in size to an A4 sheet of paper, in the sense that it -
    - occupies the full height of the screen, but not the full width.
    - when printed, it exactly matches the dimensions of the A4 sheet.

    The user would like the ability to call up a view of scanned images which are also A4 dimension.
    I can do that with this code -

    VB Code:
    1. Private Sub ShowScans()
    2.  Dim sPathAndFile As String
    3.   sPathAndFile = App.path & "\" & "Scan01.jpg"
    4.   LaunchFile sPathAndFile
    5. End Sub
    6.  
    7. 'IN BAS FILE
    8. Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
    9.     (ByVal hwnd As Long, _
    10.     ByVal lpOperation As String, _
    11.     ByVal lpFile As String, _
    12.     ByVal lpParameters As String, _
    13.     ByVal lpDirectory As String, _
    14.     ByVal nShowCmd As Long) As Long
    15.  
    16. 'Constant declarations
    17. Public Const SW_SHOWNORMAL = 1
    18. Public Const SW_SHOWMINIMIZED = 2
    19. Public Const SW_SHOWMAXIMIZED = 3
    20.  
    21.  
    22. Function LaunchFile(Filename As String, Optional WindowState As Integer, Optional Action As Integer) As Long
    23.  Dim retVal As Long
    24.  Dim LAction As String
    25.     'If window state is not specified, set to normal
    26.     If WindowState = 0 Then WindowState = SW_SHOWNORMAL
    27.     'Assign action
    28.     'If Action = 0 Then
    29.         LAction = "Open"
    30.     'Else
    31.     '    LAction = "Print"
    32.     'End If
    33.     'Call the function
    34.     retVal = ShellExecute(0&, _
    35.         LAction, _
    36.         Filename, _
    37.         vbNullString, _
    38.         vbNullString, _
    39.         WindowState)
    40.        
    41.     LaunchFile = retVal
    42. End Function

    This works, and the user can redimension the XP Windows Picture and Fax viewer so that it is occupying the left half of the screen. They can have my Job Form on the right.
    The problem is
    Somehow they should be able to have both visible at the same time.
    At the moment, they can get that 'view', but the minute they click in my Job Form, the Win XP Picture viewer goes behind the other forms that my pgm has showing (the wider Job register grid, that the user used to get to the job Form).
    I could make my Job Form TopMost(API call), but that does not prevent the Win XP Picture viewer going behind other forms.
    I believe the best solution would be for me to make the Win XP Picture viewer, TopMost
    If I had 'shelled' the Win XP Picture viewer direct, no doubt I could get the handle and make it TopMost.
    With my approach above, I tried TopMosting the returned value, but that did not work (I didn't think it would).
    I like my current approach, which just Shells the JPEG, as it just simply opens up the image in the user's default viewer (clean, simple, 'idiot proof' for this humble programmer).
    Is it possible for me to make the default viewer topmost when I am opening it with my code above ?
    Last edited by RobCrombie; Mar 28th, 2005 at 10:26 PM.
    Rob C

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: SHELLING and TOPMOST question

    You can make just about any window TopMost. You can use the FindWindow API to get the windows handle.
    Then you can use SetWindowLong to change the window style to TopMost.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2002
    Location
    AUSTRALIA
    Posts
    603

    Re: SHELLING and TOPMOST question

    I am now 'Googling' to find FindWindow examples.

    Thanks,
    Rob C

  4. #4
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: SHELLING and TOPMOST question

    You'll find an excellent reference at http://www.mentalis.org/apilist/apilist.php
    All API List

  5. #5
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: SHELLING and TOPMOST question

    Forget Google, there are many examples on the Forums.

    FindWindow

    FindWindow 2

    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  6. #6
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Brooklyn NY USA
    Posts
    1,258

    Re: SHELLING and TOPMOST question

    try using appactivate

  7. #7
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: SHELLING and TOPMOST question

    AppActivate will not make both windows visible at the same time.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

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