Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: Displaying file icons in datawindow

259 views
Skip to first unread message

Brad Wery[TeamSybase]

unread,
Mar 23, 2007, 5:22:55 PM3/23/07
to
I'm not sure how you would get the images so they can be used in the
datawindow.

Take a look at this sample for an alternative:

http://www.wideopenwest.com/~rsizer/powerbuilder/source/imagelist.htm

It shows you how to extract icons and display them in a listview control.

You may also want to take a look at this API function:

ExtractAssociatedIcon

The imagelist example used ExtractIconEx to extract an pointer to an
icon from an executable file. I think ExtractAssociatedIcon may be a
better fit, you'll have to try it.


Good Luck,

Brad

Mark Pare wrote:
> Hi all, does anyone know of any code that can get the icon
> of a file and display it next to a filename in a datawindow
> (similar to Windows Explorer in the attachment) Or any code
> that mimics Windows Explorer in general?
>
> Let me know. Thanks
>
> PB 10.5.1 (6021)
>
>
> ------------------------------------------------------------------------
>


--

Join the Advanced GUI Development project on CodeXchange
https://advanced-gui-development.codexchange.sybase.com/

Mark Pare

unread,
Mar 24, 2007, 8:40:36 AM3/24/07
to
I really need the datawindow aspect of things since I'm doing a lot with
filters, etc. and listviews simply don't offer that kind of functionality.
Is there a way perhaps that I can extract the icon and save it as a disk
file? That way I could use the BitMap function in the datawindow.

"Brad Wery[TeamSybase]" <bradweryatagricoreunited.com> wrote in message
news:4604452f$1@forums-1-dub...

Paul Horan[TeamSybase]

unread,
Mar 24, 2007, 11:49:19 AM3/24/07
to
It's really easy...

You just retrieve a char() column containing the bitmap name i.e.,
'fileicon.bmp', then you select the "display as bitmap" attribute for the
column.

Actually, I prefer relative pathing - much more flexible.
'..\icons\fileicon.bmp'. See why below...

Here's the handy-dandy guide to external resources in PB apps:

1. NO PATHING references. 'fileicon.bmp'
If you use this style for attribute and code references, then the .bmp file
HAS to be in the same physical folder as the PBL containing the object
that's referencing it at COMPILE time. If you have two different objects,
in two different PBLs, in two different folders, referencing the same .BMP,
you need two copies... Ugly and inflexible.

2. ABSOLUTE PATHING references.
'c:\myProject\myPBSource\icons\fileicon.bmp'
The .bmp file HAS to be in THIS VERY folder at compile time. We have
developers that liked to use their D: partition, and they always got the
"red X'. This is the default style that PB gives you... Ugly and
inflexible.

3. RELATIVE PATHING references. '..\icons\fileicon.bmp'
The .bmp file must be located in the \icons folder, which (in this example)
is a sibling of the folder containing the PBL with the object that's
referencing it. The code references (dw_1.dragicon =
'..\icons\dragicon.bmp') and property attributes must be specified this way,
and it's NOT the default. This style provides the BEST flexibility. I can
work from my C: drive, and have 4 different build workspaces in progress,
and Susie can work from her D: drive, and it all works perfectly.

In any of the three styles, you have to create a .PBR file that contains all
these external resource references - and they must match the code/property
references character-for-character. Then associate the .PBR file with the
build in the Project object. If you do this - you will compile the
bitmaps/icons/cursors directly into the EXE (or PBD) and you DON'T need to
deploy the resource files themselves with the build.

Paul Horan[TeamSybase]

<Mark Pare> wrote in message news:46041b50.46b...@sybase.com...

Mark Pare

unread,
Mar 25, 2007, 4:53:00 PM3/25/07
to
OK, but how does this link to what Brad said about extracting icons from
files at run time? In order to make a dw look like the right-side of Windows
Explorer, I need show icons based on the type of files that are in the
folder that a user has selected.

Let me know. Thanks

"Paul Horan[TeamSybase]" <phoran AT sybase DOT com> wrote in message
news:4605487f$1@forums-1-dub...

Philip Salgannik

unread,
Mar 25, 2007, 5:58:25 PM3/25/07
to
Any reason why you want to replace Explorer when the user has it :-)?

"Mark Pare" <mark...@videotron.ca> wrote in message
news:4606e12c$1@forums-1-dub...

Mark Pare

unread,
Mar 25, 2007, 6:44:21 PM3/25/07
to
Because the app I'm working on is pretty much an "extension" of what Windows
Explorer is. I want to re-create the entire interface but be able to do
completely different things with the files than you can do in Windows
Explorer.

"Philip Salgannik" <philema...@comcast.net> wrote in message
news:4606f081@forums-1-dub...

Paul Horan[TeamSybase]

unread,
Mar 25, 2007, 9:14:35 PM3/25/07
to
"Mark Pare" <mark...@videotron.ca> wrote in message
news:4606e12c$1@forums-1-dub...
> OK, but how does this link to what Brad said about extracting icons from
> files at run time? In order to make a dw look like the right-side of
> Windows Explorer, I need show icons based on the type of files that are in
> the folder that a user has selected.
>
> Let me know. Thanks
>

Extract them ahead of time into BMPs, and compile them into your
application. How many can there be? A dozen?

Then write an SQL statement something like this:

Select
fileName,
fileType,
CASE fileType
WHEN 'musicfile' THEN '..\icons\itunes.bmp'
WHEN 'worddoc' THEN '..\icons\word.bmp'
WHEN 'excelxls' THEN '..\icons\excel.bmp'
...
ELSE '..\icons\somethingelse.bmp' END
from
myTable ;

Paul Horan[TeamSybase]

markpare

unread,
Mar 26, 2007, 9:30:33 AM3/26/07
to
Hi Paul, I'm really not sure what you're getting at here.
Why would I hard-code anything? I can think of more than a
dozen file types off the top of my head. And there's no
guarantee that the user has the normally known icon
associated with it.

I'm basically looking for the functionality described for
the listview available for a datawindow, but the only way to
do that is to extract that icon from a file (text, exe,
etc.) and put it in a column in a grid dw.

This seems like a tall order. It's too bad that PB doesn't
have the ability to have a grid dw that mimics a listview.

Any other ideas? Thanks

Brad Wery[TeamSybase]

unread,
Mar 26, 2007, 10:12:45 AM3/26/07
to
I'm not sure how to get an image list to the hard drive. I did a quick
search on Google and found some VB examples. It's possible to execute VB
code in PB so this may be an option for you.

You should also take a look at u_lv and u_lvs in the PFC. I've never
used these object before so I'm not exactly sure if they will help you.
If they work anything like the PFC treeview you should be able to link a
datastore to the listview control.

Brad

Paul Horan[TeamSybase]

unread,
Mar 26, 2007, 10:54:16 AM3/26/07
to
From your posting earlier in the thread:

>>Is there a way perhaps that I can extract the icon and save it as a disk
file? That way I could use the BitMap function in the datawindow.<<

That's along the lines of what I'm suggesting. My suggestion is just to do
it at development/compile time, rather than runtime.

There are API calls (as Brad pointed out) where you can ask a file "what
icon are you using", but I know of no way to take that string and render the
actual icon unless you already have the image extracted.

Paul Horan[TeamSybase]

<Mark Pare> wrote in message news:4607caf9.456...@sybase.com...

markpare

unread,
Mar 26, 2007, 11:43:10 AM3/26/07
to
Would you be able to tell me which searches you did so I can
translate the VB code? Thanks for your help with this.

Brad Wery[TeamSybase]

unread,
Mar 26, 2007, 12:03:38 PM3/26/07
to
I searched for "save imagelist to disk" and came up with these samples:

http://www.devx.com/vb2themax/Tip/18931
http://forums.devx.com/archive/index.php/t-36814.html

One other thing I would suggest is that you go to kodigo.sourceforge.net
and checkout the Kodigo framework. I know that Yeyi has done some image
list stuff (I'm not sure he every put the images in a datawindow). There
is a forum on that site that may be of better help.

This is an interesting problem. Please let us know if you find a solution.

Brad

Mark Pare wrote:
> Would you be able to tell me which searches you did so I can
> translate the VB code? Thanks for your help with this.
>
>

0 new messages