Re: get text from listbox

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



RB Smissaert <bartsmissaert@xxxxxxxxxxxxxxxx> schrieb im Beitrag
<uROL3f49FHA.1332@xxxxxxxxxxxxxxxxxxxx>...
> Well, it is drug data and you would it recognize directy if you had found

> it.
> The first column holds an icon, then a date, then the drug name, then the
> dosage, then some issue related data, such as 10/20 (10 issues out of 20
> authorisations)
> then an attachement column that isn't used and then finally a string or
> maybe a number
> indicating the person who authorised that drug.
> So for example:
> 01/02/05
> FRUSEMIDE 40 mg tablets
> two each morning, 100 tablets
> 10/20
>
> What I got now is an entirely different bit of memory, so as you say I
need
> some further manipulations
> of those numbers before it points to the right bits.

Oh, such kind of data!
Here's my new bet: The data displayed is stored in a database hold in
memory by the application. The item data is an >identifier< identifying the
database entry displayed by the respective list entry. Maybe the identifier
is the ID of the person whose data is displayed maybe it is a database
record ID. Check if the application uses a file with a common database file
extension (*.mdb, *.dbf, *.dbx, or the like; but a proprietary database
format of course can't be excluded).
And: IMHO there is >no chance< for you to get to the data in memory unless
there is a function exported for this.

I rather doubt that the strings displayed do exist in memory for each list
entry individually. Instead they presumably are string constants drawn
according to values of the respective database record entries.
At least this is the way >I< would code such listbox...

So, what is left is IMHO only optical character recognition. In general it
shouldn't be very difficult if you know the font properties used to display
the list entries. After creating a font with the respective font properties
and selecting it into a device context the properties of which are the same
as that of the device context of the listbox the Windows API function
GetGlyphOutline() provides you with bitmaps of the font's glyphs which
should be the same as used for the text displayed in the listbox, i.e. a
comparison bit by bit should be successfull. Things are a bit more
difficult if the list items are displayed only partially because then you
would have to scroll the list also horizontally by code.

O.k., here is a very dirty other solution of which I don't know if it
really is a solution - it is just an 'online idea':
- Subclass the ListBox; unfortunately AFAIK it is not possible to subclass
a control of a different process in VB; I don't know if it is possible at
all.
- Capture the WM_OWNERDRAW message sent to the ListBox and replace the hDC
member of the DRAWITEMSTRUCT by a handle of of an enhanced meta file.
- After the WM_OWNERDRAW message has been processed by the owner of the
ListBox enumerate the objects of the enhanced meta file with
EnumEnhMetaFile(). If the owner of the ListBox draws the text with
TextOut() or ExtTextOut() you EnumEnhMetaFile() will list a META_TEXTOUT/
META_EXTTEXTOUT object for each of them holding the string that has been
drawn.
- Last and least send the WM_OWNERDRAW message once again to the process
but know with the original device context handle so that it will be drawn
into the device context of the ListBox (and thereby will be displayed).

And: No, I can't provide you with a code snippet for this, simply because I
have never done it...

--
----------------------------------------------------------------------
THORSTEN ALBERS Universität Freiburg
albers@
uni-freiburg.de
----------------------------------------------------------------------

.



Relevant Pages

  • Re: get text from listbox
    ... if the numbers were database id numbers that would be fine as I know the database and have ... The database is Interbase and there only could be 2 tables involved for the bit of the listbox I am interested in. ... and selecting it into a device context the properties of which are the ...
    (microsoft.public.vb.winapi)
  • Re: Using ADO to populate a List Box
    ... you do not want to see by using the ColumnWidths attribute of the Listbox. ... Dim myDataBase As Database ... Doug Robbins - Word MVP ... > How would you code this if you only wanted tthe Listbox to display one ...
    (microsoft.public.word.vba.beginners)
  • Multiple Instances of Same Listbox
    ... be entered for each of the customers. ... with the names I'm getting from my database via MS Query. ... My plan is to display a listbox above each of the displayed product ... For n products imported from the other spreadsheet, how can I display n ...
    (microsoft.public.excel.programming)
  • From ListBox to Excel to TextBox
    ... using VBA to organize my database, but I came up with a big problem. ... display it as a listbox. ... Now, I have in Excel, on the same row for each number on ListBox ...
    (microsoft.public.word.vba.beginners)
  • RE: Userform to add and update a table
    ... One of the most common scenarios in application development is to display ... the walkthrough illustrates many of the basic ... Access to a server with the Pubs SQL Server sample database. ... Creating the Windows Form. ...
    (microsoft.public.sqlserver.programming)