473,324 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

How to hide access window killing my popup menus?

374 256MB
Hi all,

I am using the following article code to minimize the access container window when my application starts because it looks really professional without the grey background being there.

However I have found my shortcut menu's no longer work. I have tried even executing code such as:

Expand|Select|Wrap|Line Numbers
  1. CommandBars("mymenu").showpopup
This fails with an error saying method popup of command bar failed (runtime error).

Is there another method which can be used to hide the access window so only my popup form shows cleanly? or some form of shortcut way to get past this issue.

I have also found this method also stops the default menu popups working also.
Jan 31 '11 #1
6 5941
Stewart Ross
2,545 Expert Mod 2GB
Could you post the specific code for hiding the Access DB window you are referring to? You mention it but have not posted it.

Thanks

Stewart
Jan 31 '11 #2
munkee
374 256MB
In my splash screens on load even I call a routine as follows:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Open(Cancel As Integer)
  2. 'Start open ended error handler
  3. On Error GoTo tagError
  4.  
  5. Call AccessMinimize
  6.  
  7. DoCmd.OpenForm "frmHidden", acNormal, , , , acHidden
  8.  
  9. 'End of successful code
  10. ExitMe:
  11. Exit Sub
  12.  
  13. 'Handle the error type code
  14. tagError:
  15.     MsgBox Err.Description
  16.     Resume ExitMe
  17. End Sub
This is then running the following code:

Expand|Select|Wrap|Line Numbers
  1.   Option Explicit
  2.  
  3. Declare Function apiGetActiveWindow Lib "user32" Alias _
  4.          "GetActiveWindow" () As Long
  5. Declare Function apiGetParent Lib "user32" Alias "GetParent" _
  6.          (ByVal hwnd As Long) As Long
  7. Declare Function apiShowWindow Lib "user32" Alias "ShowWindow" _
  8.          (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
  9. Declare Function apiIsIconic Lib "user32" Alias "IsIconic" (ByVal _
  10.          hwnd As Long) As Long
  11. Declare Function apiIsZoomed Lib "user32" Alias "IsZoomed" (ByVal _
  12.          hwnd As Long) As Long
  13.  
  14. Global Const SW_MAXIMIZE = 3
  15. Global Const SW_SHOWNORMAL = 1
  16. Global Const SW_SHOWMINIMIZED = 2
  17.  
  18. Function GetAccesshWnd()
  19. Dim hwnd As Long
  20. Dim hWndAccess As Long
  21.  
  22. ' Get the handle to the currently active window.
  23. hwnd = apiGetActiveWindow()
  24. hWndAccess = hwnd
  25.  
  26. ' Find the top window without a parent window.
  27. While hwnd <> 0
  28.     hWndAccess = hwnd
  29.     hwnd = apiGetParent(hwnd)
  30. Wend
  31.  
  32. GetAccesshWnd = hWndAccess
  33.  
  34. End Function
  35.  
  36. Function AccessMinimize()
  37.     AccessMinimize = apiShowWindow(GetAccesshWnd(), SW_SHOWMINIMIZED)
  38. End Function
  39.  
  40. Function AccessMaximize()
  41.     AccessMaximize = apiShowWindow(GetAccesshWnd(), SW_MAXIMIZE)
  42. End Function
  43.  
  44. Function AccessRestore()
  45.     AccessRestore = apiShowWindow(GetAccesshWnd(), SW_SHOWNORMAL)
  46. End Function
  47.  
  48.  
  49.  
  50. Function IsAccessMaximized()
  51. If apiIsZoomed(GetAccesshWnd()) = 0 Then
  52.     IsAccessMaximized = False
  53. Else
  54.     IsAccessMaximized = True
  55. End If
  56. End Function
  57.  
  58. Function IsAccessMinimized()
  59. If apiIsIconic(GetAccesshWnd()) = 0 Then
  60.     IsAccessMinimized = False
  61. Else
  62.     IsAccessMinimized = True
  63. End If
  64. End Function
  65.  
  66. Function IsAccessRestored()
  67. If IsAccessMaximized() = False And IsAccessMinimized() = False Then
  68.     IsAccessRestored = True
  69. Else
  70.     IsAccessRestored = False
  71. End If
  72. End Function
  73.  
  74.  
  75.  
Feb 1 '11 #3
Stewart Ross
2,545 Expert Mod 2GB
I suspect the problem is that the application is not hidden at all; it's window is minimised, in which case Access itself is no longer the active window as far as Windows is concerned. In my tests (in Access 2007 rather than 2003) with a dummy popup switchboard the switchboard functions, but as the results are minimised within the application window they are not visible unless the application is restored manually.

If you wish the splash screen to be visible without the normal Access background you can use the minimise function as at present to keep the splash screen visible with the application minimised, then (say) call the restore function from the splash screen form's On Close event to allow the other forms to behave normally.

-Stewart
Feb 1 '11 #4
munkee
374 256MB
Scott

that is how I run one of my databases. minimise on load and restore when I work with reports. But for my new database I wanted the same professional look but needed custom short cut menus. Looks like I will have to deal with the ugly background being there. I'm also wondering if the access windows opacity could be changed so it isnt minimised but its invisible.... More research to be done into that though



Also forgot to add you need to use popup forms for this code to work correctly. Access minimises but the forms stay visible. You can see your desktop and the form floating on top. Hence the professional look
Feb 1 '11 #5
munkee
374 256MB
I've managed to crack this using some apis.

I have dropped the minimisation of the application window because to be honest it is full of drawbacks.

I have mixed a couple of apis together to produce code which firstly grabs the current screen resolution. Divides this by half to get the theoretical centre of the screen. The access window is then resized to be at a minimum footprint of 0 by 0.

I then position this to the centre of my screen with all of my forms within access being set to popups.

I execute the code via my autoexec macro by calling the function "SizeAccess"

Expand|Select|Wrap|Line Numbers
  1.        Option Compare Database
  2.        Option Explicit
  3.  
  4.        Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
  5.        Declare Sub SetWindowPos Lib "user32" (ByVal hwnd&, ByVal hWndInsertAfter&, ByVal x&, ByVal y&, ByVal cx&, ByVal cy&, ByVal wFlags&)
  6.        Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
  7.        Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
  8.  
  9.        'PUBLIC Constants
  10.        Public Const SM_CXSCREEN = 0
  11.        Public Const SM_CYSCREEN = 1
  12.  
  13.        'Moves MS Access window to top of Z-order.
  14.        Global Const HWND_TOP = 0
  15.        'Creates a window with a maximize box
  16.        Global Const WS_MINIMIZEBOX = &H20000
  17.        'Creates a window with a minimize box
  18.        Global Const WS_MAXIMIZEBOX = &H10000
  19.        Global Const GWL_STYLE = (-16)
  20.        'Values for wFlags.
  21.        Global Const SWP_NOZORDER = &H4      'Ignores the hWndInsertAfter.
  22.  
  23.        Function SizeAccess()
  24.         Dim cx As Long
  25.         Dim cy As Long
  26.         Dim h As Long
  27.         Dim L As Long
  28.         Dim cHeight As Long
  29.         Dim cWidth As Long
  30.  
  31.         'Size to set app window height/width
  32.         cHeight = 0
  33.         cWidth = 0
  34.  
  35.         'Get handle to Microsoft Access.
  36.         h = Application.hWndAccessApp
  37.  
  38.         'Set the position for the app to be centred to (50 and 100 refer to offsetting due to application titlebar size)
  39.         cx = (GetSystemMetrics(SM_CXSCREEN) / 2) - 50
  40.         cy = (GetSystemMetrics(SM_CYSCREEN) / 2) - 100
  41.  
  42.         'Position the access window
  43.         SetWindowPos h, HWND_TOP, cx, cy, cWidth, cHeight, SWP_NOZORDER
  44.  
  45.          'Get the current style.
  46.          L = GetWindowLong(h, GWL_STYLE)
  47.  
  48.          'Get rid of the Minimize Button
  49.          L = L And Not (WS_MINIMIZEBOX)
  50.  
  51.          'Get rid of the maximise button
  52.          L = L And Not (WS_MAXIMIZEBOX)
  53.  
  54.          L = SetWindowLong(h, GWL_STYLE, L)
  55.  
  56.         End Function
The reason this works is basically by ensuring my application window is always small and "hidden" behind my popup forms. The application will continue to have focus so now shortcut menus will work correctly.
Feb 3 '11 #6
TheSmileyCoder
2,322 Expert Mod 2GB
Could you post a screenshot of your application (or parts of it)? Im a bit curious about the "professional" look you get from using such code.
Feb 3 '11 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: dfg | last post by:
Hi...Just a quick question about popup menus. I have a menu popup using the code below: Private Sub fraAccBal_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button...
2
by: Aaron | last post by:
Is it possible to create popup menus without using absolute positioning that take up no space in the flow of the document and appear with an onMouseOver() ? Thanks, Aaron
3
by: MEM | last post by:
Hello, I'd like to refresh the main or top most browser window from a child window. Specifically, child popup A is opened by a main browser window then child popup B is opened from within child...
0
by: Lauren Quantrell | last post by:
Ok, here's a strange one... I'm using a lot of Followhyperlink code in my MS Access2000 application to launch various websites. All my forms are popup, so they run outside the MS Access window...
9
by: Mark | last post by:
Hi All, I am trying to use the function found on the MVP site http://www.mvps.org/access/api/api0019.htm to hide the Access window. I must be missing something as I keep getting an error message:...
7
by: Lauren Quantrell | last post by:
Is there a way in code to freeze the size of the MS Access window or to prevent it from being sized? Thanks. lq
1
by: Roger Withnell | last post by:
My navbar is in a frame down the left hand side of the window. The frame is 150px wide and the navbar buttons are 100px wide. Hovering over the buttons displays popup menus to the right of the...
2
by: Rich Churcher | last post by:
Is there a way using any of the Python UI toolkits to generate popup menus outside the context of an application? For example, middle-clicking on the desktop shows a list of shortcuts to choose...
5
by: BA | last post by:
Hi there I am trying to write an "application" in Access 2000, that displays a front end and allows the user to interact with the database without seeing Access loaded, in the background, nor on...
5
by: clincoln | last post by:
I have run into the problem of MS seemingly dropping support for custom popup menus in Access 2007. My app heavily uses popup menus and suddenly I can not even change a typeo in a popup menu or add...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.