?
Solved

get the text of other program!

Posted on 2003-02-21
7
Medium Priority
?
159 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

801 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