PureBasic Forum
https://www.purebasic.fr/english/

IVirtualDesktopManager (Windows 10)
https://www.purebasic.fr/english/viewtopic.php?f=5&t=73309
Page 1 of 1

Author:  Rinzwind [ Sat Aug 03, 2019 6:57 am ]
Post subject:  IVirtualDesktopManager (Windows 10)

Any way to use this interface from PB?

https://docs.microsoft.com/en-us/window ... topmanager

The IVirtualDesktopManager interface has these methods.

Method Description
IVirtualDesktopManager::GetWindowDesktopId Gets the identifier for the virtual desktop hosting the provided top-level window.
IVirtualDesktopManager::IsWindowOnCurrentVirtualDesktop Indicates whether the provided window is on the currently active virtual desktop.
IVirtualDesktopManager::MoveWindowToDesktop Moves a window to the specified virtual desktop.

The API is incomplete IMHO (missing enumeration for example). You wonder why MS started from scratch instead of improving the existing flat win32 virtual desktop API... but whatever.

Author:  Mijikai [ Sun Aug 18, 2019 9:02 pm ]
Post subject:  Re: IVirtualDesktopManager (Windows 10)

I came up with this:
Code:
EnableExplicit

Interface IVirtualDesktopManager
  IsWindowOnCurrentVirtualDesktop.i(*topLevelWindow)
  GetWindowDesktopId.i(*topLevelWindow)
  MoveWindowToDesktop.i(*topLevelWindow,*desktopId)
EndInterface

Procedure.i GetIVirtualDesktopManager()
  Protected cid.CLSID
  Protected iid.CLSID
  Protected vtable.i
  If CoInitialize_(#Null) = #S_OK
    If CLSIDFromString_("{AA509086-5CA9-4C25-8F95-589D3C07B48A}",@cid) = #S_OK
      If IIDFromString_("{A5CD92FF-29BE-454C-8D04-D82879FB3F1B}",@iid) = #S_OK
        If CoCreateInstance_(@cid,#Null,#CLSCTX_INPROC_SERVER,@iid,@vtable) = #S_OK
          ProcedureReturn vtable 
        EndIf
      EndIf
    EndIf
    CoUninitialize_()
  EndIf
  ProcedureReturn #Null
EndProcedure

Global *VirtualDesktopManager.IVirtualDesktopManager

*VirtualDesktopManager = GetIVirtualDesktopManager()

If *VirtualDesktopManager
  Debug "Interface is ready!" 
Else
  Debug "Error!"
EndIf

End

Not sure if it works (i have no Windows 10 right now)

Author:  Mijikai [ Mon Aug 19, 2019 10:17 am ]
Post subject:  Re: IVirtualDesktopManager (Windows 10)

Ok now i was able to run it on Windows 10

The interface gets created but it may look different:
Code:
Interface IVirtualDesktopManager
  IsWindowOnCurrentVirtualDesktop.i(topLevelWindow.i,*onCurrentDesktop.b)
  GetWindowDesktopId.i(topLevelWindow.i,*desktopId)
  MoveWindowToDesktop.i(topLevelWindow.i,*desktopId)
EndInterface


Does this work?

Author:  Kwai chang caine [ Fri Aug 23, 2019 3:32 pm ]
Post subject:  Re: IVirtualDesktopManager (Windows 10)

In the two case the debugger say "Interface is ready!" with W10 X64 / v5.70 X86 :wink:

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/