Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

get the text of other program!

Posted on 2003-02-21
7
Medium Priority
?
162 Views
Last Modified: 2010-04-04
like this:
 
i open a program and selected a item from its combobox,when i click a "OK" button,the form will hide and a other form show.i want to get the last selected text of the item from the combobox, before i click the "OK" button.

sorry,my points only left 25,but...i need your help!!!
0
Comment
Question by:yunbo
  • 3
  • 3
7 Comments
 

Expert Comment

by:luisseixas
ID: 7997573
This Label is located in FORM2 and gets the selected value of Combobox1, located in FORM1.

procedure TForm2.FormShow(Sender: TObject);
begin

Label1.Caption:=Form1.Combobox1.Text;

end;
0
 

Author Comment

by:yunbo
ID: 7998055
oh,no.The combobox in another program!
0
 
LVL 6

Accepted Solution

by:
DaFox earned 75 total points
ID: 7998450
Hi!

Try this function (you have to know the handle of the combobox):

function GetWndText(AHandle: THandle): String;
var
 Len: Integer;
 Str: String;
begin
 Len := SendMessage(AHandle, WM_GETTEXTLENGTH, 0, 0);
 SetString(Str, PChar(nil), Len);
 if (Len <> 0) then SendMessage(AHandle, WM_GETTEXT, Len + 1, Longint(Pointer(Str)));
 Result := Str;
end;

Markus
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:yunbo
ID: 8002219
Thanks,DaFox! I have a problem with a other program have many same comboBox,how can i get each text of them?
0
 
LVL 6

Expert Comment

by:DaFox
ID: 8002770
Hi,

try to get each handle of the comboboxes using FindWindow(), FindWindowEx().

Markus
0
 

Author Comment

by:yunbo
ID: 8007050
could u give a example code?im still have a little problem with it,Thanks!
0
 
LVL 6

Expert Comment

by:DaFox
ID: 8007169
procedure TForm1.Button1Click(Sender: TObject);
var
  hWndIE,
  hWndRebar,
  hWndAdrBar,
  hWndCombo   : HWND;
begin
  //look for the Internet Explorer main window
  hWndIE := FindWindow('IEFrame', nil);
  if (hWndIE > 0) then
  begin
    //try to get a handle to IE's toolbar container
    hWndRebar := FindWindowEx(hWndIE, 0, {'SizableRebar'}'WorkerW', nil);
    if (hWndRebar > 0) then
    begin
      //get a handle to address bar
      hWndAdrBar := FindWindowEx(hWndRebar, 0, 'ReBarWindow32', nil);
      if (hWndAdrBar > 0) then
      begin
        //finally, locate combo box
        hWndCombo := FindWindowEx(hWndAdrBar, 0, 'ComboBoxEx32', nil);
        if (hWndCombo > 0) then
        begin
          ShowMessage(GetWndText(hWndCombo));
        end else ShowMessage('IE address combo not found!');
      end else ShowMessage('IE Address bar not found!');
    end else ShowMessage('IE toolbars not found!');
  end else ShowMessage('Interner Explorer not running!');
end;

Markus
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
Suggested Courses
Course of the Month10 days, 23 hours left to enroll

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question