I'm trying to do an update to the
Edit library but I'm having a problem with the GetCueBanner routine. If you have
Windows Vista or Windows 7 and ~3 minutes, please run this script and let me know if see the cue banner text in the MsgBox windows that popup when you press the GB* buttons. Here's the test script:
Code:
#NoEnv
#SingleInstance Force
;;;;;ListLines Off
gui -MinimizeBox
gui Margin,0,0
gui Add,Edit,xm w300 hWndhEdit1
Edit_SetCueBanner(hEdit1,"Name",True)
gui Add,Edit,xm w300 hWndhEdit2
Edit_SetCueBanner(hEdit2,"Address 1",False)
gui Add,Edit,xm w300 hWndhEdit3
Edit_SetCueBanner(hEdit3,"Address 2",False)
gui Add,Edit,xm w170 hWndhEdit4
Edit_SetCueBanner(hEdit4,"City",False)
gui Add,Edit,x+0 w50 hWndhEdit5
Edit_SetCueBanner(hEdit5,"State",False)
gui Add,Edit,x+0 w80 hWndhEdit6
Edit_SetCueBanner(hEdit6,"Zip",False)
gui Add,Edit,xm w300 hWndhEdit7 +Password
Edit_SetCueBanner(hEdit7,"Password",True)
Gui Add,Button,xm y+100 gGCB1,GCB1
Gui Add,Button,x+0 wp gGCB2,GCB2
Gui Add,Button,x+0 wp gGCB3,GCB3
Gui Add,Button,x+0 wp gGCB4,GCB4
Gui Add,Button,x+0 wp gGCB5,GCB5
Gui Add,Button,x+0 wp gGCB6,GCB6
Gui Add,Button,x+0 wp gGCB7,GCB7
gui Add,StatusBar
gui Show
MsgBox 64,Info,
(ltrim join`s
This script does not return cue banner text on Windows XP. I'm not sure if
this is something that only occurs on Windows XP or if it's a problem that
occurs on all versions of Windows.
`n`nTo test, click on one or more of the GB* buttons. If the GetCueBanner
stuff works, you'll see the cue banner text in the MsgBox windows that pop
up. If it doesn't, you'll just see blank stuff after the prompt in the
MsgBox. Thanks for your help.
`n`nPress OK to continue.
)
return
GUIEscape:
GUIClose:
ExitApp
GCB1:
GCB2:
GCB3:
GCB4:
GCB5:
GCB6:
GCB7:
ControlNbr:=SubStr(A_ThisLabel,0)
hEdit:=hEdit%ControlNbr%
;;;;;MsgBox hEdit=%hEdit%
MsgBox % "Cue banner text for control " . ControlNbr . ":`n" . Edit_GetCueBanner(hEdit)
return
;-- Functions
Edit_ANSI2Unicode(ByRef sString,ByRef wString)
{
Static CP_ACP:=0 ;-- The system default Windows ANSI code page.
;-- Workaround for AutoHotkey Basic
PtrType:=A_PtrSize ? "Ptr":"UInt"
;-- Collect size, in characters
nSize:=DllCall("MultiByteToWideChar"
,"UInt",CP_ACP ;-- CodePage
,"UInt",0 ;-- dwFlags
,PtrType,&sString
;-- lpMultiByteStr. Pointer to the character string to convert.
,"Int",-1
;-- cbMultiByte. Size, in bytes, of the string indicated by the
; lpMultiByteStr parameter. -1=Process the entire string,
; including terminating null.
,PtrType,0
;-- lpWideCharStr. Pointer to a buffer that receives the
; converted string. Not used here.
,"Int",0)
;-- cchWideChar. Size, in characters, of the buffer indicated
; by lpWideCharStr. If this value is 0, the function returns
; the required buffer size, in characters, including any
; terminating null character.
;-- Convert
VarSetCapacity(wString,nSize*2,0) ;-- Size in bytes
DllCall("MultiByteToWideChar"
,"UInt",CP_ACP ;-- CodePage
,"UInt",0 ;-- dwFlags
,PtrType,&sString
;-- lpMultiByteStr. Pointer to the character string to convert.
,"Int",nSize
;-- cbMultiByte. Size, in bytes, of the string indicated by the
; lpMultiByteStr parameter.
,PtrType,&wString
;-- lpWideCharStr. Pointer to a buffer that receives the
; converted string.
,"Int",nSize)
;-- cchWideChar. Size, in characters, of the buffer indicated
; by lpWideCharStr.
Return &wString
}
Edit_GetCueBanner(hEdit,p_MaxSize=2048)
{
Static EM_GETCUEBANNER:=0x1502 ;-- (ECM_FIRST+2)
VarSetCapacity(wText,p_MaxSize,0)
SendMessage EM_GETCUEBANNER,&wText,p_MaxSize,,ahk_id %hEdit%
if not A_IsUnicode
Edit_Unicode2ANSI(wText,aText)
MsgBox l_RC=%l_RC%`nErrorLevel=%ErrorLevel%`nwText=%wText%`naText=%aText%
Return A_IsUnicode ? wText:aText
}
Edit_SetCueBanner(hEdit,p_Text,p_ShowWhenFocused=False)
{
Static EM_SETCUEBANNER:=0x1501 ;-- (ECM_FIRST+1)
if A_IsUnicode
wText:=p_Text
else
Edit_ANSI2Unicode(p_Text,wText)
SendMessage EM_SETCUEBANNER,p_ShowWhenFocused,&wText,,ahk_id %hEdit%
Return ErrorLevel
}
Edit_Unicode2ANSI(ByRef wString,ByRef sString)
{
Static CP_ACP:=0 ;-- The system default Windows ANSI code page.
;-- Workaround for AutoHotkey Basic
PtrType:=A_PtrSize ? "Ptr":"UInt"
;-- Collect size
nSize:=DllCall("WideCharToMultiByte"
,"UInt",CP_ACP ;-- CodePage
,"UInt",0 ;-- dwFlags
,"UInt",&wString ;-- lpWideCharStr. Pointer to Unicode string.
,"Int",-1
;-- cchWideChar. -1=Process the entire string, including
; terminating null.
,PtrType,0
;-- lpMultiByteStr. Pointer to a buffer that receives the
; converted string. Not specified here.
,"Int",0
;-- cbMultiByte. Size, in bytes, of the buffer indicated by
; lpMultiByteStr. When set to 0, the function returns the
; required buffer size for lpMultiByteStr.
,"UInt",0 ;-- lpDefaultChar
,"UInt",0) ;-- lpUsedDefaultChar
;-- Convert to ANSI
VarSetCapacity(sString,nSize,0) ;-- Size includes terminating null
DllCall("WideCharToMultiByte"
,"UInt",CP_ACP ;-- CodePage
,"UInt",0 ;-- dwFlags
,PtrType,&wString ;-- lpWideCharStr. Pointer to Unicode string.
,"Int",nSize
;-- cchWideChar. Size, in characters, of the string indicated
; by lpWideCharStr. For this function, nSize includes the
; terminating null if found.
,"Str",sString
;-- lpMultiByteStr. Pointer to a buffer that receives the
; converted string.
,"Int",nSize
;-- cbMultiByte. Size, in bytes, of the buffer indicated by
; lpMultiByteStr.
,"UInt",0 ;-- lpDefaultChar
,"UInt",0) ;-- lpUsedDefaultChar
Return &sString
}
Thanks for your help.