AutoHotkey Community

It is currently May 27th, 2012, 8:26 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: February 8th, 2012, 12:59 am 
Offline

Joined: October 1st, 2005, 9:55 pm
Posts: 775
Location: Texas, USA
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 8th, 2012, 1:29 am 
Offline

Joined: July 20th, 2009, 6:01 am
Posts: 166
Location: Amsterdam
Tried it on Wind 7 in a virtual machine:

Image

I suspect that what I filled in into the text boxes is supposed to come up in the messageboxes (it did not: just the titles of the boxes, as you can see)? Good luck!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 8th, 2012, 1:37 am 
Offline

Joined: October 1st, 2005, 9:55 pm
Posts: 775
Location: Texas, USA
Cerberus wrote:
Tried it on Wind 7 in a virtual machine:

[snip]

I suspect that what I filled in into the text boxes is supposed to come up in the messageboxes (it did not: just the titles of the boxes, as you can see)? Good luck!

No, it works exactly how it is supposed to work. Thank you for taking the time to test it.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 8th, 2012, 1:40 am 
Offline

Joined: October 1st, 2005, 9:55 pm
Posts: 775
Location: Texas, USA
Cerberus tested it on Win 7 and the cue banner text shows like it is supposed to (i.e. it works!). Just to be thorough, any with Vista get a chance to test it?

Thanks.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 8th, 2012, 1:55 am 
Offline

Joined: January 20th, 2012, 2:04 pm
Posts: 42
Windows Vista:
Image

After pressing OK I get what Cerberus shows in his screenshot above.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 8th, 2012, 2:13 am 
Offline

Joined: October 1st, 2005, 9:55 pm
Posts: 775
Location: Texas, USA
Thanks Xei. That is the info I needed. Thanks for taking the time to test it.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 8th, 2012, 2:32 am 
Offline

Joined: July 20th, 2009, 6:01 am
Posts: 166
Location: Amsterdam
Oh, perhaps I forgot to mention that I get two message boxes when I press one of those buttons; first I get one, then I press OK, then I get the box like the ones in my screenshot.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], BrandonHotkey, Google Feedfetcher, immunity, sjc1000 and 76 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group