Get the Window Handle

Is there a way to get the Window Handle (Hwnd) of Modules and DBs?
I am after the Hwnd as given by (for example) WinSpy on MicroSoft Windows Operating Systems.
SystemAdmin - Thu Oct 06 09:32:05 EDT 2011

Re: Get the Window Handle
OurGuest - Thu Oct 06 14:14:15 EDT 2011

Can't be done with dxl -- you will have to use another application for this.

Re: Get the Window Handle
Mathias Mamsch - Fri Oct 07 16:27:01 EDT 2011

OurGuest - Thu Oct 06 14:14:15 EDT 2011
Can't be done with dxl -- you will have to use another application for this.

Can't be done is not entirely correct. The HWND handles are stored in the DBE, DB and Module structures, but using those is always risky regarding updates. Every new DOORS version, even a patch could potentially change the offsets and therefore break the code. Therefore I would think about if you really want to use code like this.

What are you trying to do? Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Re: Get the Window Handle
llandale - Sun Oct 09 15:01:29 EDT 2011

Mathias Mamsch - Fri Oct 07 16:27:01 EDT 2011
Can't be done is not entirely correct. The HWND handles are stored in the DBE, DB and Module structures, but using those is always risky regarding updates. Every new DOORS version, even a patch could potentially change the offsets and therefore break the code. Therefore I would think about if you really want to use code like this.

What are you trying to do? Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

If you did go this route perhaps the following sample code would make things easier.

// sample code, HWND offsets are unknown to this author
string c_Vers = doorsInfo(infoVersion)
int    c_HWND_Window_Offset = 0
 
elseif(c_Vers[0]   == '7')          c_HWND_Window_Offset = 4
elseif(c_Vers[0]   == '8')              c_HWND_Window_Offset = 4
elseif(c_Vers[0:2] == "9.0")          c_HWND_Window_Offset = 4
elseif(c_Vers[0:2] == "9.1")          c_HWND_Window_Offset = 5
elseif(c_Vers      == "9.2.0.1")      c_HWND_Window_Offset = 5
elseif(c_Vers      == "9.2.0.2")      c_HWND_Window_Offset = 5
elseif(c_Vers      == "9.2.0.3")      c_HWND_Window_Offset = 6
elseif(c_Vers      == "9.2.0.4")      c_HWND_Window_Offset = 6
elseif(c_Vers[0:2] == "9.3")          c_HWND_Window_Offset = 6
else                                    c_HWND_Window_Offset = 6   // future offsets?
 
int  GetHwndHandle(DB in_db)
{  get addr_, extract addr_ + c_HWND_Window_Offset 
   return(whatever)
}

Re: Get the Window Handle
SystemAdmin - Mon Oct 10 05:08:53 EDT 2011

Mathias Mamsch - Fri Oct 07 16:27:01 EDT 2011
Can't be done is not entirely correct. The HWND handles are stored in the DBE, DB and Module structures, but using those is always risky regarding updates. Every new DOORS version, even a patch could potentially change the offsets and therefore break the code. Therefore I would think about if you really want to use code like this.

What are you trying to do? Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

The reason is because I am doing OLE Automation, launched from a "Topmost" DB. The new window opens behind the DB, so I was hoping to just pass it a parent HWnd rather than a default value of 0 (the desktop) to make it a child of the DB.

I guess another way would be to somehow make my new window "Always on top" too, but no luck on doing that yet.

Re: Get the Window Handle
SystemAdmin - Mon Oct 10 10:15:49 EDT 2011

SystemAdmin - Mon Oct 10 05:08:53 EDT 2011
The reason is because I am doing OLE Automation, launched from a "Topmost" DB. The new window opens behind the DB, so I was hoping to just pass it a parent HWnd rather than a default value of 0 (the desktop) to make it a child of the DB.

I guess another way would be to somehow make my new window "Always on top" too, but no luck on doing that yet.

If you just want to bring the window to the front you could try the following: -
 

OleAutoObj shell = oleCreateAutoObject("WScript.shell")
OleAutoArgs shellArgs = create
put(shellArgs, "Window Title (only need first part of it)")
oleMethod(shell, "AppActivate", shellArgs)
clear(shellArgs)
oleCloseAutoObject(shell)
shell=null

 


Regards,

Richard