代码名称:更解Mapinfow标题

作者/收集者:hbzh

开发环境:MapBasic

代码:

Include "MENU.DEF"
Include "MAPBASIC.DEF"

Declare Sub Main()
Declare Sub EndApp
Declare SUb SetMIWinText

Declare Function GetActiveWindow32 Lib "user32" Alias "GetActiveWindow" () As Integer
Declare Function GetActiveWindow Lib "User" () as SmallInt
Declare Function GetWindowText32 Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Integer, lpString As String, ByVal cch As Integer) As Integer
Declare Function GetWindowText Lib "User" (ByVal hWnd As SmallInt, lpString As String, ByVal aInt As SmallInt) As SmallInt
Declare Function SetWindowText32 Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Integer, ByVal lpString As String) As Integer
Declare Sub      SetWindowText Lib "User" (ByVal hWnd As SmallInt, ByVal Str As String)

Sub Main()
 Create Menu "&API Calls" As
  "Set MapInfo Window Text..."    Calling SetMIWinText,
      "&Remove API Calls"             Calling EndApp
 Alter Menu Bar Add "API Calls"
End Sub

Sub EndApp
 Alter Menu Bar Remove "API Calls"
 Terminate Application "AAAAAAA.mbx"
End Sub

Sub SetMIWinText
  Dim sWinText As String
  Dim n, nWin, nRes As Integer

  If SystemInfo(SYS_INFO_MIPLATFORM) = MIPLATFORM_WIN32 Then
    nWin = GetActiveWindow32()
  ElseIf SystemInfo(SYS_INFO_MIPLATFORM) = MIPLATFORM_WIN16 Then
    nWin = GetActiveWindow()
  End If
 
 Dialog Title "Enter Text"
    Control EditText  Position 8,12  value sWinText Into sWinText Width 100
    Control OKButton
    Control CancelButton
  If CommandInfo(CMD_INFO_DLG_OK) Then
    If SystemInfo(SYS_INFO_MIPLATFORM) = MIPLATFORM_WIN32 Then
      n = SetWindowText32(nWin, sWinText)
    ElseIf SystemInfo(SYS_INFO_MIPLATFORM) = MIPLATFORM_WIN16 Then
      Call SetWindowText(nWin, sWinText)
    End If
  End If
End Sub