Get the contents of Listbox and ComboBox in other processes

zhaozj2021-02-16  45

(* //

Title: Get the contents of Listbox and ComboBox in other processes

Description: WINDOW2000 Delphi6 debugging

Design: zswang

Support: wjhu111@21cn.com

Date: 2004-03-25

// *)

Function getListboxText (Mhandle: Thandle; Mstrings: Tstrings): Boolean;

VAR

Vitemcount: Integer;

I: integer;

String;

Begin

Result: = FALSE;

IF NOT ASSIGNED (MSTRINGS).

Mstrings.beginupdate;

Try

Mstrings.clear;

Vitemcount: = sendMessage (Mhaldle, LB_Getcount, 0, 0);

For i: = 0 to vitemcount - 1 do begin

SETLENGTH (S, SendMessage (Mhandle, LB_Gettextlen, i, 0));

SendMessage (Mhaldle, LB_Gettext, I, Integer (@S [1]));

MStrings.Add (s);

END;

SETLENGTH (S, 0);

Finally

Mstrings.endupdate;

END;

RESULT: = TRUE;

End; {getListboxText}

Function GetcomboBoxtext (Mhandle: Thandle; Mstrings: Tstrings): Boolean;

VAR

Vitemcount: Integer;

I: integer;

String;

Begin

Result: = FALSE;

IF NOT ASSIGNED (MSTRINGS).

Mstrings.beginupdate;

Try

Mstrings.clear;

Vitemcount: = SendMessage (Mhandle, Cb_getcount, 0, 0);

For i: = 0 to vitemcount - 1 do begin

SETLENGTH (S, SendMessage (Mhandle, CB_GetlbTextlen, i, 0));

SendMessage (Mhandle, CB_Getlbtext, I, Integer (@S [1]));

MStrings.Add (s);

END;

SETLENGTH (S, 0);

Finally

Mstrings.endupdate;

END;

RESULT: = TRUE;

End; {getcomboBOxText}

// esample

Procedure TFORM1.FormCreate (Sender: TOBJECT);

Begin

RegisterhotKey (Handle, 1, MOD_WIN, VK_F2);

RegisterhotKey (Handle, 2, Mod_win, VK_F3);

END;

Procedure TFORM1.FORMDESTROY (Sender: TOBJECT);

Begin

UnregisterhotKey (Handle, 1);

UnregisterhotKey (Handle, 2);

END;

Procedure TFORM1.WMHOTKEY (VAR MSG: TWMHOTKEY);

Begin

Case msg.hotKey of

1:

GetListboxText (

WindowFromPoint (Point (mouse.cursorpos.x, mouse.cursorpos.y),

Memotext.Lines);

2:

GetcomboBoxText

WindowFromPoint (Point (mouse.cursorpos.x, mouse.cursorpos.y),

Memotext.Lines);

END;

END;

转载请注明原文地址:https://www.9cbs.com/read-27895.html

New Post(0)