sancarn / Extended_MapBasic

This is an Open Source project. We are developing a powerful extension for the MapBasic Window in Pitney Bowes' MapInfo. The extension will give users the ability to compile on demand from the MapBasic Window. Further extensions may include custom MapBasic functions to accomplish common tasks. This project is still very much WIP
MIT License
1 stars 0 forks source link

Detecting when MapBasic window is active and a word on the Message window #2

Open sancarn opened 8 years ago

sancarn commented 8 years ago

I was hoping we would be able to grab the hWND from MapInfo using the WindowInfo() function. The MapInfo window ID for the MapBasic window is 1002.

If I do the following: print WindowInfo(1002,12) '[or WindowInfo(WIN_MAPBASIC,WIN_INFO_WND) ]

I get 0 in the Message Window, regardless of whether the window is bound to MapInfo or not.

Unfortunately also there is no specific info that we can target from AHK that would indicate the current window being the MapBasic Window. However there is the active window's text which we can get with WinGetText statement. That contains this:

<<
>>
 List 

If the MapBasic window is not docked to the main application however the title of the window is indicated as "MapBasic". Therefore we can say:

WinGetTitle, TITLE, A
MapBasicWindowActive(){
    If winexist("MapBasic"){
        return TITLE = "MapBasic"
    } else {
        ;...
    }
}

The question really comes down to what we do in that ...


On a more positive note the Message window is much easier to access: When docked:

ClassNN: RICHEDIT1 WindowInfo(1003,12) returns 1117068 (at least it returns something!) again if not docked wintitle = "Message"

sancarn commented 8 years ago

Another potential method for detecting MapBasic Window is with WindowInfo(,4-7), but it's not a good way.

It may also be possible to use the "WinFocusChangedHandler" but still we need a way of returning some information about the active control in MapInfo.

WindowInfo(ID,8) does not detect the MapBasic Window either.

sancarn commented 8 years ago

From a Discussion with the MapInfo team: "12.5.1 is MapInfoPro 64 bit, therefore the MapBasic window is a WPF user control and does not have HWND. Wpf user control can only have HWNDSOURCE which can't be used as an HWND."

To get whether a WPF User Control is active, we may be able to use the following functions: System.Windows.Input.FocusManager.GetFocusedElement() and System.Windows.Input.Keyboard.FocusedElement()