Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

ignore show desktop

  • 09-06-2008 6:04pm
    #1
    Registered Users, Registered Users 2 Posts: 21,611 ✭✭✭✭


    i'm making a program in vb6 and i never want it to minimise, even when show desktop is pressed

    i've put code in the form_resize function that sets the form back to normal windowstate when it's minimised but when you click show desktop the function isn't called.

    when show desktop is pressed, the forms location is set to some big negative number so i put in a timer that checks for that and shows the form in that case but it just does that thing where the taskbar button flashes blue until you click it.

    then i tried disabling the showintaskbar option and it just doesn't do anything with the timer fires.

    lots and lots of googling has come to nothing. can anyone help?


Comments

  • Registered Users, Registered Users 2 Posts: 2,931 ✭✭✭Ginger


    You could try

    Me.WindowState = vbMaximized when the OnMinimized event is fired...

    Its been a while since I have done VB6.. and I dont have the compiler in front of me to try it

    You could do on your timer

    If Me.WindowState <> vbMaximized
    Me.WindowState = vbMaximized
    End If

    Or use the Form_Resize event to check.. I dont know if that will help tho


  • Registered Users, Registered Users 2 Posts: 21,611 ✭✭✭✭Sam Vimes


    ah you see the problem is that the form_resize event isn't fired when you press show desktop. I don't think there is an onminimize event. I'll have a look but i don't think that would be fired either since form_resize isn't


  • Registered Users, Registered Users 2 Posts: 515 ✭✭✭NeverSayDie


    Re resizing, I think the problem is that the "show desktop" functionality isn't the same as a "minimise all". From what I've noticed of its behaviour, it doesn't minimise windows, it just brings the desktop "window"/client area to the foreground - ie, puts it in front of all other windows.

    Re the flashing taskbar entry, that usually means that a window is trying to bring itself to the foreground, but Windows won't let it (only foreground process is allowed to do that, it's meant to stop windows popping up and disrupting the user, I think).

    Can't recall all the details off the top of my head, but I've done stuff like this before in C++ and C#, API is roughly the same. What you need to do is attach to the foreground process, and then you can move your window to the top. Sorry I can't remember the exact process, but if you google along those lines it should turn up, it's a common enough trick to do.

    Edit; this isn't VB, but hopefully it'll help:
    http://nibuthomas.wordpress.com/2008/05/24/move-a-window-to-foreground/


  • Registered Users, Registered Users 2 Posts: 2,152 ✭✭✭dazberry


    I took a look at some messages that were received by a blank application (albeit a Delphi application - not a VB one) when the "Show the Desktop" item is selected. The issue with Delphi applications is there is an invisible application window (referred to below as "Project1") - and the visible window is "Form1".

    What's interesting is that it is doing a number of things, including a WM_MOVE that looks like it goes off screen -32000, -32000. I'll leave you figure out what exactly is needed here - but I reckon you'll have to intercept some of these messages to either stop the "hiding" or detect it and then restore you application.
    +01059.500 000073:000900D4 "Form1"  wm_syncpaint (8804X) Sent   wp=00000004  lp=00000000
    01059.516 000074:000900D4 "Form1"  WM_ERASEBKGND (1404X) Sent   wp=01010054  lp=00000000  hdc 01010054
    01059.516 000075:000900D4 "Form1"  WM_PAINT (f04X) Dispatched   wp=00000000  lp=00000000  (0,75)-(185,316)
    01059.766 000076:000900D4 "Form1"  WM_SHOWWINDOW (1804X) Sent   wp=00000000  lp=00000001  Hide  ParentClosing
    01059.766 000077:000900D4 "Form1"  WM_SHOWWINDOW (1804X) Sent   wp=00000000  lp=00000000  Hide  Normal
    01059.766 000078:000900D4 "Form1"  WM_WINDOWPOSCHANGING (4604X) Sent   wp=00000000  lp=0012F9EC  (0,0)-(0,0)    Z-Order Top
    01059.766 000079:000900D4 "Form1"  WM_WINDOWPOSCHANGED (4704X) Sent   wp=00000000  lp=0012F9EC  (1140,67)-(1608,412)    NoSize,  NoMove,  NoZOrder,  NoActivate,  HideWindow  Z-Order Unchanged
    01059.766 000080:000900D4 "Form1"  WM_WINDOWPOSCHANGING (4604X) Sent   wp=00000000  lp=0012FEB4  (0,0)-(0,0)    Z-Order Top
    01059.766 000081:00070130 "Project1"  WM_WINDOWPOSCHANGING (4604X) Sent   wp=00000000  lp=0012FEB4  (0,0)-(0,0)    Z-Order Top
    01059.766 000082:000900D4 "Form1"  WM_WINDOWPOSCHANGED (4704X) Sent   wp=00000000  lp=0012FEB4  (1140,67)-(1608,412)    NoSize,  NoMove,  NoRedraw,  NoActivate  Z-Order After hwnd 00090144h
    01059.766 000083:00070130 "Project1"  WM_WINDOWPOSCHANGED (4704X) Sent   wp=00000000  lp=0012FEB4  (-32000,-32000)-(-31840,-31974)    NoActivate,  FrameChanged,  NoCopybits  Z-Order After hwnd 000900D4h
    01059.782 000084:00070130 "Project1"  WM_MOVE (304X) Sent   wp=00000000  lp=83008300  (-32000,-32000) 
    01059.782 000085:00070130 "Project1"  WM_SIZE (504X) Sent   wp=00000001  lp=00000000  Minimized  (0,0)
    01059.797 000086:00070130 "Project1"  WM_WINDOWPOSCHANGING (4604X) Sent   wp=00000000  lp=0012FB14  (0,0)-(0,0)    Z-Order Top
    01059.828 000087:00070130 "Project1"  WM_WINDOWPOSCHANGED (4704X) Sent   wp=00000000  lp=0012FB14  (-32000,-32000)-(-31840,-31974)    NoSize,  NoMove,  NoZOrder,  NoActivate,  FrameChanged  Z-Order Unchanged
    

    D.


  • Registered Users, Registered Users 2 Posts: 7,468 ✭✭✭Evil Phil


    I think you'll have to use the Windows API for this, afaik VB6 doesn't have that find of functionality built in.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 2,781 ✭✭✭amen


    i'm intrigued as to why you would want to do this?


  • Registered Users, Registered Users 2 Posts: 1,456 ✭✭✭FSL


    Use the Windows APi function SetWindowPos the declaration is below along with the constant values needed

    Declare the function in a module. As one line or use concatenation characters

    Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long

    in the form declare the constants below

    Const conHwndTopmost = -1
    Const SWP_NOSIZE = &h1
    Const SWP_NOMOVE = &h2



    In the form activate event set the window position to be always on top as detailed below. The four zero parameters
    are the x,y start position and the width and height of the window.
    Using the SWP_NOSIZE and SWP_NOMOVE flags ignores the start, height and width parameters and leaves the window where it is and the size it is.

    The SetWindowPos on one line or using concatenation characters
    SetWindowPos {formname}.hWnd, conHwndTopmost, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE


  • Registered Users, Registered Users 2 Posts: 21,611 ✭✭✭✭Sam Vimes


    Re resizing, I think the problem is that the "show desktop" functionality isn't the same as a "minimise all". From what I've noticed of its behaviour, it doesn't minimise windows, it just brings the desktop "window"/client area to the foreground - ie, puts it in front of all other windows.
    that does seem to be what's happening
    Re the flashing taskbar entry, that usually means that a window is trying to bring itself to the foreground, but Windows won't let it (only foreground process is allowed to do that, it's meant to stop windows popping up and disrupting the user, I think).

    Can't recall all the details off the top of my head, but I've done stuff like this before in C++ and C#, API is roughly the same. What you need to do is attach to the foreground process, and then you can move your window to the top. Sorry I can't remember the exact process, but if you google along those lines it should turn up, it's a common enough trick to do.

    Edit; this isn't VB, but hopefully it'll help:
    http://nibuthomas.wordpress.com/2008/05/24/move-a-window-to-foreground/

    that helped thanks. i managed to get it to attach to the foreground process and display but i'm still experiencing a problem.

    i have a timer that monitors the left and top parameters of the form and when i click show desktop, the form is moved to a negative position and i can bring it back. so that works fine. the problem is that i don't want the application to be in the task bar and if the showintaskbar property is set to false, the form doesn't receive the move message from windows.

    so i've figured out how to get it to bring itself to the front but i'm stuck on a way to detect the event.
    dazberry wrote: »
    I took a look at some messages that were received by a blank application (albeit a Delphi application - not a VB one) when the "Show the Desktop" item is selected. The issue with Delphi applications is there is an invisible application window (referred to below as "Project1") - and the visible window is "Form1".

    What's interesting is that it is doing a number of things, including a WM_MOVE that looks like it goes off screen -32000, -32000. I'll leave you figure out what exactly is needed here - but I reckon you'll have to intercept some of these messages to either stop the "hiding" or detect it and then restore you application.
    +01059.500 000073:000900D4 "Form1"  wm_syncpaint (8804X) Sent   wp=00000004  lp=00000000
    01059.516 000074:000900D4 "Form1"  WM_ERASEBKGND (1404X) Sent   wp=01010054  lp=00000000  hdc 01010054
    01059.516 000075:000900D4 "Form1"  WM_PAINT (f04X) Dispatched   wp=00000000  lp=00000000  (0,75)-(185,316)
    01059.766 000076:000900D4 "Form1"  WM_SHOWWINDOW (1804X) Sent   wp=00000000  lp=00000001  Hide  ParentClosing
    01059.766 000077:000900D4 "Form1"  WM_SHOWWINDOW (1804X) Sent   wp=00000000  lp=00000000  Hide  Normal
    01059.766 000078:000900D4 "Form1"  WM_WINDOWPOSCHANGING (4604X) Sent   wp=00000000  lp=0012F9EC  (0,0)-(0,0)    Z-Order Top
    01059.766 000079:000900D4 "Form1"  WM_WINDOWPOSCHANGED (4704X) Sent   wp=00000000  lp=0012F9EC  (1140,67)-(1608,412)    NoSize,  NoMove,  NoZOrder,  NoActivate,  HideWindow  Z-Order Unchanged
    01059.766 000080:000900D4 "Form1"  WM_WINDOWPOSCHANGING (4604X) Sent   wp=00000000  lp=0012FEB4  (0,0)-(0,0)    Z-Order Top
    01059.766 000081:00070130 "Project1"  WM_WINDOWPOSCHANGING (4604X) Sent   wp=00000000  lp=0012FEB4  (0,0)-(0,0)    Z-Order Top
    01059.766 000082:000900D4 "Form1"  WM_WINDOWPOSCHANGED (4704X) Sent   wp=00000000  lp=0012FEB4  (1140,67)-(1608,412)    NoSize,  NoMove,  NoRedraw,  NoActivate  Z-Order After hwnd 00090144h
    01059.766 000083:00070130 "Project1"  WM_WINDOWPOSCHANGED (4704X) Sent   wp=00000000  lp=0012FEB4  (-32000,-32000)-(-31840,-31974)    NoActivate,  FrameChanged,  NoCopybits  Z-Order After hwnd 000900D4h
    01059.782 000084:00070130 "Project1"  WM_MOVE (304X) Sent   wp=00000000  lp=83008300  (-32000,-32000) 
    01059.782 000085:00070130 "Project1"  WM_SIZE (504X) Sent   wp=00000001  lp=00000000  Minimized  (0,0)
    01059.797 000086:00070130 "Project1"  WM_WINDOWPOSCHANGING (4604X) Sent   wp=00000000  lp=0012FB14  (0,0)-(0,0)    Z-Order Top
    01059.828 000087:00070130 "Project1"  WM_WINDOWPOSCHANGED (4704X) Sent   wp=00000000  lp=0012FB14  (-32000,-32000)-(-31840,-31974)    NoSize,  NoMove,  NoZOrder,  NoActivate,  FrameChanged  Z-Order Unchanged
    

    D.
    this helped too. i've managed to capture these messages but i'm having trouble differentiating them. the WM_WINDOWPOSCHANGED message is received whenever the form loses focus but i can't figure out how to make it only bring itself to the front if the window that took the focus was the desktop.

    there's a function called getDesktopWindow which you would think would work but when i click show destkop and call the getforegroundwindow function, the window numbers are different.

    does anyone know how to find the correct window id for the desktop in advance so that i can do a command like this:

    if getForeGroundWindow=getDesktopWindow
    call pSetForeGroundWindow(.....)
    end if

    amen wrote: »
    i'm intrigued as to why you would want to do this?

    i want the app to be below all others and not in the taskbar so that when the user clicks show desktop it's still there and he can use it.

    it's for this app:
    http://boards.ie/vbulletin/showthread.php?t=2055165333

    take a look at cormie's request
    http://boards.ie/vbulletin/showpost.php?p=56071317&postcount=598


  • Registered Users, Registered Users 2 Posts: 21,611 ✭✭✭✭Sam Vimes


    FSL wrote: »
    Use the Windows APi function SetWindowPos the declaration is below along with the constant values needed

    Declare the function in a module. As one line or use concatenation characters

    Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long

    in the form declare the constants below

    Const conHwndTopmost = -1
    Const SWP_NOSIZE = &h1
    Const SWP_NOMOVE = &h2



    In the form activate event set the window position to be always on top as detailed below. The four zero parameters
    are the x,y start position and the width and height of the window.
    Using the SWP_NOSIZE and SWP_NOMOVE flags ignores the start, height and width parameters and leaves the window where it is and the size it is.

    The SetWindowPos on one line or using concatenation characters
    SetWindowPos {formname}.hWnd, conHwndTopmost, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE
    this didn't work i'm afraid. clicking show desktop minimised it as normal


  • Registered Users, Registered Users 2 Posts: 7,468 ✭✭✭Evil Phil


    Hmm. Maybe you need to trap the message telling you window your window to minimize.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 515 ✭✭✭NeverSayDie


    Re detecting it, don't really have any ideas for that, though some googling suggests that the Show Desktop functionality calls the ToggleDesktop() method in the shell API. Maybe you could look into using Win32 hooks to catch that, though I gather they're tricky to work with.


  • Registered Users, Registered Users 2 Posts: 21,611 ✭✭✭✭Sam Vimes


    Evil Phil wrote: »
    Hmm. Maybe you need to trap the message telling you window your window to minimize.

    unfortunately the show desktop command doesn't minimise the form. if the form is in the taskbar it moves it to a large negative number that depends on your resolution i think, something like -32000,-32000 and changes the z-order of the desktop.

    i can detect the form moving but if it's not in the taskbar it doesn't get that message so i can't detect it
    Re detecting it, don't really have any ideas for that, though some googling suggests that the Show Desktop functionality calls the ToggleDesktop() method in the shell API. Maybe you could look into using Win32 hooks to catch that, though I gather they're tricky to work with.

    yeah i saw something about that but the site said they were tricky to work with so i stopped investigating. i think i might have to


  • Registered Users, Registered Users 2 Posts: 2,152 ✭✭✭dazberry


    Sam Vimes wrote: »

    Take a look at this Shell API function:
    WINSHELLAPI UINT APIENTRY SHAppBarMessage(
        DWORD dwMessage, 	
        PAPPBARDATA pData	
       );
    

    This allows you to register a form as a dockable toolbar on the desktop. I *think* this will both ignore "Show The Desktop" and will allow you to dock the form to whatever side of the screen you want.

    D.


  • Registered Users, Registered Users 2 Posts: 21,611 ✭✭✭✭Sam Vimes


    dazberry wrote: »
    Take a look at this Shell API function:
    WINSHELLAPI UINT APIENTRY SHAppBarMessage(
        DWORD dwMessage, 	
        PAPPBARDATA pData	
       );
    

    This allows you to register a form as a dockable toolbar on the desktop. I *think* this will both ignore "Show The Desktop" and will allow you to dock the form to whatever side of the screen you want.

    D.

    that looks promising. i'll look into that. thanks everyone for your help


  • Registered Users, Registered Users 2 Posts: 1,456 ✭✭✭FSL


    I created a simple application one form no border or control box just a command button to exit it. It stayed on top when I hit show desk top or ran any other application and only disappeared when I exited it. Just the same as Task Manager will always sit on top.


  • Registered Users, Registered Users 2 Posts: 21,611 ✭✭✭✭Sam Vimes


    that's close to what i'm looking for but i don't want it to always be on top. i want it as if it's embedded in the desktop so you only see it when you click show desktop


  • Registered Users, Registered Users 2 Posts: 21,611 ✭✭✭✭Sam Vimes


    i found code to do it \o/

    i got it here:
    http://www.vbforums.com/showthread.php?p=2597245

    i finally found the right thing to google: "stick window to the desktop visual basic" :pac:

    coupled with the code to remove it from the taskbar it does exactly what i needed


Advertisement