GetWindowTextA Win32 API call is returning garbage using PowerBuilder 10.5...

Well, this one's got me whipped. Time to turn to you folks for help.

I am launching MS-Word, and some of my user's computers are slower than 
others, so I am needing to delay the PowerBuilder script an undetermined 
amount of time while MS-Word opens up.
I have looked at and tried tons of methods, and it all seems to be 
boiling down to a failure of the Win32 API function GetWindowTextA (it 
returns garbage characters instead of the window's title bar text).
I have it declared as a Global External Functions as follows:
FUNCTION LONG GetWindowTextA( long hWnd, Ref String lpString, long 
nMaxCount ) LIBRARY "user32"

And I'm calling it, as follows:
LONG ll_Size
ll_Size = 255
TitleTmp = SPACE(ll_Size) + CHAR(0)
nRet = GetWindowTextA(hWndTmp, TitleTmp, ll_Size)

It seems to be returning a valid length in the return value (varies upon 
each call to the routine), but garbage characters (boxes) are being 
returned in the TitleTmp variable.

Any help would be greatly appreciated!
					=Steve=
0
Steve
9/4/2007 5:59:42 PM
sybase.powerbuilder.general 62418 articles. 17 followers. Follow

5 Replies
1039 Views

Similar Articles

[PageSpeed] 13

been awhile but I think because your now unicode you have to end all 
declarations with ....alias for "<functionname>;Ansi"

Greg
"Steve McKenna" <nospam@nospam.com> wrote in message 
news:46dd9d0e$1@forums-1-dub...
> Well, this one's got me whipped. Time to turn to you folks for help.
>
> I am launching MS-Word, and some of my user's computers are slower than 
> others, so I am needing to delay the PowerBuilder script an undetermined 
> amount of time while MS-Word opens up.
> I have looked at and tried tons of methods, and it all seems to be boiling 
> down to a failure of the Win32 API function GetWindowTextA (it returns 
> garbage characters instead of the window's title bar text).
> I have it declared as a Global External Functions as follows:
> FUNCTION LONG GetWindowTextA( long hWnd, Ref String lpString, long 
> nMaxCount ) LIBRARY "user32"
>
> And I'm calling it, as follows:
> LONG ll_Size
> ll_Size = 255
> TitleTmp = SPACE(ll_Size) + CHAR(0)
> nRet = GetWindowTextA(hWndTmp, TitleTmp, ll_Size)
>
> It seems to be returning a valid length in the return value (varies upon 
> each call to the routine), but garbage characters (boxes) are being 
> returned in the TitleTmp variable.
>
> Any help would be greatly appreciated!
> =Steve= 


0
GW
9/4/2007 6:05:23 PM
Steve,

PB 10.5 is Unicode so you should use the W version of all API functions - 
GetWindowTextW for example.

I have an example of 'Run and Wait' if that would work better.

http://www.topwizprogramming.com/freecode_runandwait.html

Roland


"Steve McKenna" <nospam@nospam.com> wrote in message 
news:46dd9d0e$1@forums-1-dub...
> Well, this one's got me whipped. Time to turn to you folks for help.
>
> I am launching MS-Word, and some of my user's computers are slower than 
> others, so I am needing to delay the PowerBuilder script an undetermined 
> amount of time while MS-Word opens up.
> I have looked at and tried tons of methods, and it all seems to be boiling 
> down to a failure of the Win32 API function GetWindowTextA (it returns 
> garbage characters instead of the window's title bar text).
> I have it declared as a Global External Functions as follows:
> FUNCTION LONG GetWindowTextA( long hWnd, Ref String lpString, long 
> nMaxCount ) LIBRARY "user32"
>
> And I'm calling it, as follows:
> LONG ll_Size
> ll_Size = 255
> TitleTmp = SPACE(ll_Size) + CHAR(0)
> nRet = GetWindowTextA(hWndTmp, TitleTmp, ll_Size)
>
> It seems to be returning a valid length in the return value (varies upon 
> each call to the routine), but garbage characters (boxes) are being 
> returned in the TitleTmp variable.
>
> Any help would be greatly appreciated!
> =Steve= 


0
Roland
9/4/2007 6:16:00 PM
Sir, you are a life-saver!!
That marks the 3rd time I've been stung by this "unicode" bee. Is there 
a document that I can refer to that has a list of all the stuff that 
Unicode impacts?
					=Steve=

GW wrote:
> been awhile but I think because your now unicode you have to end all 
> declarations with ....alias for "<functionname>;Ansi"
> 
> Greg
> "Steve McKenna" <nospam@nospam.com> wrote in message 
> news:46dd9d0e$1@forums-1-dub...
>> Well, this one's got me whipped. Time to turn to you folks for help.
>>
>> I am launching MS-Word, and some of my user's computers are slower than 
>> others, so I am needing to delay the PowerBuilder script an undetermined 
>> amount of time while MS-Word opens up.
>> I have looked at and tried tons of methods, and it all seems to be boiling 
>> down to a failure of the Win32 API function GetWindowTextA (it returns 
>> garbage characters instead of the window's title bar text).
>> I have it declared as a Global External Functions as follows:
>> FUNCTION LONG GetWindowTextA( long hWnd, Ref String lpString, long 
>> nMaxCount ) LIBRARY "user32"
>>
>> And I'm calling it, as follows:
>> LONG ll_Size
>> ll_Size = 255
>> TitleTmp = SPACE(ll_Size) + CHAR(0)
>> nRet = GetWindowTextA(hWndTmp, TitleTmp, ll_Size)
>>
>> It seems to be returning a valid length in the return value (varies upon 
>> each call to the routine), but garbage characters (boxes) are being 
>> returned in the TitleTmp variable.
>>
>> Any help would be greatly appreciated!
>> =Steve= 
> 
> 
0
Steve
9/4/2007 6:24:04 PM
Thanks Roland, this is great stuff!
                                       =Steve=
Roland Smith [TeamSybase] wrote:
> Steve,
> 
> PB 10.5 is Unicode so you should use the W version of all API functions - 
> GetWindowTextW for example.
> 
> I have an example of 'Run and Wait' if that would work better.
> 
> http://www.topwizprogramming.com/freecode_runandwait.html
> 
> Roland
> 
> 
> "Steve McKenna" <nospam@nospam.com> wrote in message 
> news:46dd9d0e$1@forums-1-dub...
>> Well, this one's got me whipped. Time to turn to you folks for help.
>>
>> I am launching MS-Word, and some of my user's computers are slower than 
>> others, so I am needing to delay the PowerBuilder script an undetermined 
>> amount of time while MS-Word opens up.
>> I have looked at and tried tons of methods, and it all seems to be boiling 
>> down to a failure of the Win32 API function GetWindowTextA (it returns 
>> garbage characters instead of the window's title bar text).
>> I have it declared as a Global External Functions as follows:
>> FUNCTION LONG GetWindowTextA( long hWnd, Ref String lpString, long 
>> nMaxCount ) LIBRARY "user32"
>>
>> And I'm calling it, as follows:
>> LONG ll_Size
>> ll_Size = 255
>> TitleTmp = SPACE(ll_Size) + CHAR(0)
>> nRet = GetWindowTextA(hWndTmp, TitleTmp, ll_Size)
>>
>> It seems to be returning a valid length in the return value (varies upon 
>> each call to the routine), but garbage characters (boxes) are being 
>> returned in the TitleTmp variable.
>>
>> Any help would be greatly appreciated!
>> =Steve= 
> 
> 
0
Steve
9/4/2007 6:35:16 PM
This is in the Application techniques manual:

http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.dc37774_1100/html/apptech/apptech509.htm

Marilyn

"Steve McKenna" <nospam@nospam.com> wrote in message 
news:46DDA2C5.80103@nospam.com...
> Sir, you are a life-saver!!
> That marks the 3rd time I've been stung by this "unicode" bee. Is there a 
> document that I can refer to that has a list of all the stuff that Unicode 
> impacts?
> =Steve=
>
> GW wrote:
>> been awhile but I think because your now unicode you have to end all 
>> declarations with ....alias for "<functionname>;Ansi"
>>
>> Greg
>> "Steve McKenna" <nospam@nospam.com> wrote in message 
>> news:46dd9d0e$1@forums-1-dub...
>>> Well, this one's got me whipped. Time to turn to you folks for help.
>>>
>>> I am launching MS-Word, and some of my user's computers are slower than 
>>> others, so I am needing to delay the PowerBuilder script an undetermined 
>>> amount of time while MS-Word opens up.
>>> I have looked at and tried tons of methods, and it all seems to be 
>>> boiling down to a failure of the Win32 API function GetWindowTextA (it 
>>> returns garbage characters instead of the window's title bar text).
>>> I have it declared as a Global External Functions as follows:
>>> FUNCTION LONG GetWindowTextA( long hWnd, Ref String lpString, long 
>>> nMaxCount ) LIBRARY "user32"
>>>
>>> And I'm calling it, as follows:
>>> LONG ll_Size
>>> ll_Size = 255
>>> TitleTmp = SPACE(ll_Size) + CHAR(0)
>>> nRet = GetWindowTextA(hWndTmp, TitleTmp, ll_Size)
>>>
>>> It seems to be returning a valid length in the return value (varies upon 
>>> each call to the routine), but garbage characters (boxes) are being 
>>> returned in the TitleTmp variable.
>>>
>>> Any help would be greatly appreciated!
>>> =Steve=
>> 

0
Marilyn
9/5/2007 7:44:48 PM
Reply:

Similar Artilces:

Powerbuilder 5 to Powerbuilder 10
Hi all We have migrated our application from powerbuilder 5 to powerbuilder 10. after migration to version 10, alignment in most of reports disturbed. please advice me some solution. On Fri, 29 Feb 2008 12:45:01 +0100, Adnan Jamil <adnanjamil@nji.com.pk> wrote: > Hi all > > We have migrated our application from powerbuilder 5 to powerbuilder 10. > after migration to version 10, alignment in most of reports disturbed. > please advice me some solution. Adnan, Is this a SQL Anywhere question? If not, you have posted to the wrong forum. If yes,...

update powerbuilder 10.0 to powerbuilder 10.5
hi, I need update powerbuilder ver 10.0 to powerbuilder 10.5. by the way, my company already buy pb ver 10.00 and need to update to ver 10.5. the question : if update pb from ver 10.00 to ver 10.5, is it free of charge ? if no, How I found the price ? best regards, alim 10.5 is considered a major release, you would need to purchase an upgrade. This is what I found on Sybase's own eshop: http://eshop.sybase.com/eshop/buy_detail?id=92023&prodId=9281&bid=17856 You may find better through an online merchant, partner or local retailer. This is also the Ent...

Better to use API fn call/Powerbuilder fn call ...
I have a rather elementary question. Is there any difference in application performance if I use an API call rather than a PowerBuilder function call ? eg Suppose there is PowerBuilder function 'X' which will bring a window to the foreground. An API function 'Y' does the same. Assuming that I need not prepare/initialize any structure etc to be passed to the API function 'Y', does it make any difference to the app performance if I make an API call instead of the PowerBuilder function call 'X' ? Thx Ganesh The difference would be virtually i...

Moving from PowerBuilder 6.5 to PowerBuilder 10
Hi, I have an application developed in PB6.5 and due to changing requirements application has to be switched to PB10. There when I am trying to regenerate the contents of my PBL, it is giving error stating: C0042 : cannot compile without valid database signon. This error is coming for few windows but not for the functions I have made in my pbl. It is working perfectly fine for pb6.5. Can you please help me on this. Thanks in advance. Manich First you must to connect to the database by a profile, continue migrate your app. Karla <Manich Tripathi> escribi...

PowerBuilder 10.5.2 Build 7826 differs from PowerBuilder 11.5.1 Build 4675
Apparently there's some data conversion issues that differ from PowerBuilder 10.5.2 and 11.5.1 (builds listed in subject). The following mini scrip results in different returned values: Byte lb_test Decimal ld_test lb_test = 48 ld_test = Dec(lb_test) MessageBox("Test", String(ld_test)) In PowerBuilder 10.5.2, the messagebox displays the value "48". In PowerBuilder 11.5.1 the messagebox displays the value "0.48". It appears that in PB 11.5.1, it's dividing the result by 100 for some reason. It appears to be a bug, just wanted to ve...

how to use the registration number for powerbuilder 10.5
Hi. I recently installed powerbuilder 10.5 at my work place. It has the cd key/registration number on the cd's. But I didn't find a place to plug in that key during the installation process. can you guys help me in validation my installation. Do I need to do it online ? You don't have to provide it. -- Terry Dykstra (TeamSybase) http://powerbuilder.codeXchange.sybase.com/ http://casexpress.sybase.com product enhancement requests: http://my.isug.com/cgi-bin/1/c/submit_enhancement <kunal> wrote in message news:4b4b3ce4.232b.1681692777@sybase.com... > Hi...

Use PowerBuilder DLL in PowerBuilder
We use PB6.5. We would want to use a DLL create from PB in a PB application. We compiled an a PBL as DLL. After we tried to use DLL in a user object external, but without success. How can we do to use DLL create from PB or use in a new PB application some object (visual and no) before compiled with PB? Any help will be appreciated. Saul.Convalle@mail.cec.it Thanks When you create a DLL from a PB library it is not really a standard Windows DLL. I'm not sure what the difference is. If you are making calls from PB then just use the standard PB calling syntax the ...

PowerBuilder 10.5 Save as PDF using PDF995
Hi, I have been trying to use PDF995 to create PDFs using the SaveAs funtion. I have run into the following problem that I am hoping someone can help me with. When I install PDF995 it creates a printer named PDF995 that cannot be changed and as I understand it PowerBuilder requires the printer to be named "Sybase DataWindow PS" is there a way around this problem? Thanks Terry Hannon PDF995 is a PDF printer. Meaning, when you print to it you get a PDF document. This would not work with the datawindows SaveAs function (unless they changed something since I last ...

Remote Debugging in EAS 5.5 and Powerbuilder 10.5.1
I just wanted the thank the user group for its help and input on remote debugging. The comments were helpful and ogt me finally going on debugging remote objects on EAS. i might add that I still had deployment problems in Powerbuilder 10.5.1. The properties for the deployed compent would be selectable in the but the debug property in the property file would be false. Strangely enough, it would show up in the component to debug list as selectable. I had event delete the component, made sure the remote debugging checkbox was not selected, and the component would still deploy as thou...

Error calling GetUserNameA win API from PowerBuilder 11.5
I have declared a global external function GetUserNameA for advapi32.dll in powerbuilder 11.5. Then i am trying to call this function from application open event. When cintrol comes to calling GetUserNameA, application fails with null object reference. Why is my pb aplication not able to recognise this win wrapper function? Pls help with ur suggestions. Is there any settings are code that I am missing? You want to use the unicode version; GetUserNameW On 23/11/2010 1:00 PM, sapna wrote: > I have declared a global external function GetUserNameA for > advapi32.dll in powe...

How can I get PowerBuilder to use the UNICODE API calls to an ODBC?
How can I get PowerBuilder to use the UNICODE API calls to an ODBC? I am connecting to a DB2 database and when running a trace and reviewing the file the calls are to ANSI API's. example below pb80 db-157 EXIT SQLDescribeCol with return code 0 (SQL_SUCCESS) HSTMT 032F2528 UWORD 2 UCHAR * 0x0012E2D0 [ 14] "FIRST_DIST_DTE" SWORD 129 SWORD * 0x0012E2AC (14) SWORD * 0x0012E29C (9) SQLLEN * 0x0012E298 (10) SWORD * 0x00...

How do I call a com dll written in c++ using PowerBuilder 6.5???
Environment : Win Nt Wks 4.0 SP4 PowerBuilder 6.5 hi, I have written a com dll using c++ (ATL dev studio 6.0) and I now have to call the dll form a powerbuilder app. How do I call my com dll from my powerbuilder app??? Thanks Sunit On Tue, 9 Feb 1999 20:37:50 -0600, "Senna" <puto@execpc.com> wrote: I believe you use the ConnectToNewRemoteObject function to do this. You will have to make sure your COM object is registered, however. HTH Jon Credit[TeamPS] CPD Professional PB6 JCredit@Sprynet.com http://home.sprynet.com/sprynet/jcredit >E...

include/call (.net)-methods from own classlibrary in PowerBuilder 10.5 application
Hello i have a classlibrary written in .net-framework - and now i must include or call some methodes in my powerbuilder-10.5 -application. how could i simple include this dll and his funtions ?? have anyone a clue for my problem? many thanks in advance & best regards Michael Hi Michael; The easiest would be to migrate to PB 11.2 or higher that allows .NET based WinForm applications built from the PB IDE to include .NET assemblies. Regards ... Chris President: OSUG / STD Inc. Blog: http://chrispollach.blogspot.com PBDJ: http://chrispollach.sys-con.com Sour...

Upgrade from powerbuilder 10.5 to 11.5
Hi, were are investigating the process of upgrading powerbuilder 105 to powerbuilder 11.5. are there any steps to watch out for. my initial plan is to backup the current source. Copy the source to a temp location. Perform an upgrade of PB10.5 to 11.5 and 'upgrade' the source. Does this sound about right at all? Many Thanks Anish, although I'm not a [TeamSybase] member, we have converted over 25 applications (most very large) from PB 10.5 to PB 11.5 without any problems (no additional steps or changes to objects or code was required, for us at least). The only cav...

Web resources about - GetWindowTextA Win32 API call is returning garbage using PowerBuilder 10.5... - sybase.powerbuilder.general

Malwr - Malware Analysis by Cuckoo Sandbox
Submit malware for free analysis with Cuckoo Sandbox

forums.sandboxie.com • View topic - Block Process Access
sbiextra ====== I've created a DLL to block sandboxed processes from accessing information about processes running outside the sandbox, and to ...

Blizzard Entertainment Uses Spyware to Verify EULA Compliance
I recently performed a rather long reversing session on a piece of software written by Blizzard Entertainment, yes the ones who made Warcraft, ...

Resources last updated: 11/29/2015 8:51:58 PM