Foreground window handle

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.

If I run the following code and then click on the Desktop, why are
both values different? I thought they should be the same?

Code: Select all

Repeat
  Sleep_(500)
  Debug "Foreground = "+Str(GetForegroundWindow_())
  Debug "Fake Desktop = "+Str(GetDesktopWindow_())
  Debug "Real Desktop = "+Str(FindWindow_(0,"Program Manager"))
  Debug ""
ForEver
Basically, I need to set the focus to the Desktop in my app, but it's
hard to know what the handle of the Desktop is because using the
GetDesktopWindow API doesn't seem to actually be the Desktop...?

UPDATE: Never mind, I worked out that I can get the Desktop handle
by using: dt=FindWindow_(0,"Program Manager"). :)


PB - Registered PureBasic Coder