PC Review


Reply
Thread Tools Rate Thread

Code translation

 
 
O-('' Q)
Guest
Posts: n/a
 
      21st Nov 2005
Hello and sorry if this is the wrong group for this.

I am looking to translate some delphi code to .Net/C++ style code. I've
tried, but it is simply a mess as I am still learning. I got it to
compile once, but it never worked as intended and it would sometimes
crash on me.

Here is the code:
[code]
function HWndGet(partialTitle: string): hWnd;
var
hWndTemp: hWnd;
iLenText: Integer;
cTitletemp: array [0..254] of Char;
sTitleTemp: string;
begin
//find first window and loop through all subsequent windows in the
master window list
hWndTemp := FindWindow(nil, nil);

while hWndTemp <> 0 do
begin //retrieve caption text from current window
iLenText := GetWindowText(hWndTemp, cTitletemp, 255);
sTitleTemp := cTitletemp;

//clean up the return string, preparing for case insensitive
comparison
sTitleTemp := UpperCase(copy( sTitleTemp, 1, iLenText));

//use appropriate method to determine if the current window's
caption
//either starts with or contains passed string
partialTitle := UpperCase( partialTitle );
if pos( partialTitle, sTitleTemp ) <> 0 then
break;
//get next window in master window list and continue
hWndTemp := GetWindow(hWndTemp, GW_HWNDNEXT);
end;
result := hWndTemp;
end;
[code]

This basically goes through all open windows to find any window which
contains the word passed to partialTitle. It then returns the hWnd of
the window it finds to the calling function.

I am lost with this one, hehe. It may be too much for someone just
learning, but I have gone too far in this application to stop now I
guess. So, any help on this would be greatly appreciated.

Thanks in advance.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Code translation please =?Utf-8?B?Ti5G?= Microsoft Excel Misc 0 6th Jul 2007 12:42 AM
Code translation Just For Fun... Microsoft Excel Misc 2 1st Oct 2004 11:32 PM
VBA Code Translation Q Microsoft Excel Programming 3 18th Mar 2004 03:56 AM
Re: Translation of code Wayne Morgan Microsoft Access VBA Modules 3 3rd Sep 2003 09:29 PM
Re: Translation of code Tom Microsoft Access VBA Modules 2 3rd Sep 2003 06:16 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:27 AM.