c++ HIMAGELIST return XBROWSE ?

c++ HIMAGELIST return XBROWSE ?

Postby yunbg1 » Sat Dec 05, 2009 2:54 am

Hi all.

How can i get return 'HIMAGELIST' ?

Will do how and the possibility which will receive this 'hImageList' is?

ico := ICON_EXEREAD("test.exe")

DEFINE ICON oIcon RESOURCE ico

DEFINE WINDOW oWnd FROM 0, 0 TO 10, 10 TITLE "Test" ICON oIcon
ACTIVATE WINDOW oWnd

Code: Select all  Expand view  RUN

HB_FUNC( ICON_EXEREAD )
{

   HIMAGELIST hImageList;
   SHFILEINFO sfi;

   ZeroMemory(&sfi, sizeof(SHFILEINFO));

   hImageList = (HIMAGELIST)SHGetFileInfo(hb_parc(1), 0, &sfi, sizeof(SHFILEINFO), SHGFI_SYSICONINDEX | SHGFI_LARGEICON );

   if(hImageList) {
      ///////////////////////////////////////////////////
      ? How can i get (return  hImageList)
      ///////////////////////////////////////////////////
   }
}
 
Last edited by yunbg1 on Sun Dec 06, 2009 1:31 am, edited 1 time in total.
FWH User
FWPPC User
FWLinux User
yunbg1
 
Posts: 107
Joined: Sun Nov 13, 2005 12:40 am
Location: Winnipeg Canada

Re: c++ HIMAGELIST return parameter ?

Postby Daniel Garcia-Gil » Sat Dec 05, 2009 4:21 am

Hello yunbg1

SHGetFileInfo no return HIMAGELIST

http://msdn.microsoft.com/en-us/library/bb762179(VS.85).aspx

you can get the info from:
Code: Select all  Expand view  RUN


SHFILEINFO *psfi

DWORD_PTR SHGetFileInfo(      
    LPCTSTR pszPath,
    DWORD dwFileAttributes,
    SHFILEINFO *psfi,
    UINT cbFileInfo,
    UINT uFlags
);


if you want get icon from exe file try
Code: Select all  Expand view  RUN

#include "fivewin.ch"



Function Main()
local ico, oIcon, oWnd

ico := ICON_EXEREAD("Filename.exe")

DEFINE ICON oIcon

oIcon:hIcon := ico

DEFINE WINDOW oWnd FROM 0, 0 TO 10, 10 TITLE "Test" ICON oIcon
ACTIVATE WINDOW oWnd


return nil

#pragma BEGINDUMP

#include <hbapi.h>
#include <windows.h>

HB_FUNC( ICON_EXEREAD )
{
   SHFILEINFO sfi;
   
   ZeroMemory(&sfi, sizeof(SHFILEINFO));

   SHGetFileInfo(hb_parc(1), 0, &sfi, sizeof(SHFILEINFO), SHGFI_ICON );
   
   hb_retnl( ( LONG ) sfi.hIcon );

}

#pragma ENDDUMP
 
 
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: c++ HIMAGELIST return parameter ?

Postby yunbg1 » Sat Dec 05, 2009 9:32 am

Mr. Daniel Garcia-Gil

Thanks gives too in quick answer back.
FWH User
FWPPC User
FWLinux User
yunbg1
 
Posts: 107
Joined: Sun Nov 13, 2005 12:40 am
Location: Winnipeg Canada

Re: c++ HIMAGELIST return parameter ?

Postby yunbg1 » Sun Dec 06, 2009 1:29 am

How can i accept ICON handle ..... xBrowse class use ?.

xBrowse -> oBrw:aCols[ 1 ]:bStrImage := {|oCol, oBrw| oBrw:aRow[ 2 ] } <----- C return (ico)
?
?
?

Code: Select all  Expand view  RUN

//---------------------------------------------
#include "fivewin.ch"

Function Main()
local ico, oIcon, oWnd

aArr_g := {}

for nI := 1 to 5
    aadd( aArr_g, { "", space( 255 ) } )
next

DEFINE WINDOW oWnd FROM 0, 0 TO 10, 10 TITLE "Test"

   @ 0,0 XBROWSE oBrw OF oDlgi columns {1,2};
      Array aArr_g sizes {50, 50} LINES CELL autocols fastedit

   oBrw:nMarqueeStyle              := 1
   oBrw:nRowHeight                 := 33

   oBrw:aCols[ 1 ]:nEditType       := TYPE_IMAGE
   oBrw:aCols[ 1 ]:lBmpStretch     := .t.
   oBrw:aCols[ 1 ]:lBmpTransparent := .t.
   oBrw:aCols[ 1 ]:bStrImage       := {|oCol, oBrw| oBrw:aRow[ 2 ] }
   oBrw:aCols[ 1 ]:nDataBmpAlign   := AL_CENTER

   oBrw:aCols[ 2 ]:nEditType       := EDIT_BUTTON
   oBrw:aCols[ 2 ]:bEditBlock      := {|nRow, nCol, oCol| file_load() ) }

   oDlgi:oClient                    := oBrw

   oBrw:CreateFromCode()

ACTIVATE WINDOW oWnd

return nil

/*------------------------------------------------------------------------*/
FUNC file_load()
loca cname

cname := cGetFile( "*.*", "Select file" )

if cname != NIL
   ico := ICON_EXEREAD(cname)
   msginfo(ico)

  [b]This Code ..... INSERT (METHOD ?)  Refresh

   /*
   oBrw:aCols[ 1 ]:bStrImage       := {|oCol, oBrw| oBrw:aRow[ 2 ] }
   oBrw:aCols[ 1 ]:bStrImage := ico
  */
[/b]

endi

RETU NIL

#pragma BEGINDUMP

#include <hbapi.h>
#include <windows.h>

HB_FUNC( ICON_EXEREAD )
{
   SHFILEINFO sfi;
   
   ZeroMemory(&sfi, sizeof(SHFILEINFO));

   SHGetFileInfo(hb_parc(1), 0, &sfi, sizeof(SHFILEINFO), SHGFI_ICON );
   
   hb_retnl( ( LONG ) sfi.hIcon );

}

#pragma ENDDUMP
 
FWH User
FWPPC User
FWLinux User
yunbg1
 
Posts: 107
Joined: Sun Nov 13, 2005 12:40 am
Location: Winnipeg Canada

Re: c++ HIMAGELIST return XBROWSE ?

Postby Daniel Garcia-Gil » Sun Dec 06, 2009 5:28 am

Hello yunbg1.

you first should convert Icon to Bitmap,
i dont remember, but i think you can not use TYPE_IMAGE for this
you can use the converted handle ( hicon to hbitmap ) and add in aBitmaps ( Column Bitmaps array ) with AddBmpHandle

i show a sample... (include BmpFromIcon function )
Code: Select all  Expand view  RUN

#include "fivewin.ch"
#include "xbrowse.ch"

Function Main()
local ico, oIcon, oWnd, aRet

aArr_g := {}

for nI := 1 to 5
    aadd( aArr_g, { "", Space( 50 ), 0 } )
next


DEFINE WINDOW oWnd FROM 0, 0 TO 30, 60 TITLE "Test"

   @ 0,0 XBROWSE oBrw OF oWnd columns {1, 2, 3};
      Array aArr_g sizes {100, 250, 1} LINES CELL autocols fastedit

   oBrw:nMarqueeStyle              := 1
   oBrw:nRowHeight                 := 33

//   oBrw:aCols[ 1 ]:lBmpStretch     := .t.
   oBrw:aCols[ 1 ]:lBmpTransparent := .t.
   oBrw:aCols[ 1 ]:nDataBmpAlign   := AL_CENTER
   oBrw:aCols[ 1 ]:bStrData        := {|| NIL }
   oBrw:aCols[ 1 ]:bBmpData        := {| | oBrw:aRow[ 3 ] }

   oBrw:aCols[ 2 ]:nEditType       := EDIT_BUTTON
   oBrw:aCols[ 2 ]:bEditBlock      := {|nRow, nCol, oCol| aRet := file_load( oCol ), ;
                                                          oBrw:aRow[ 3 ] := aRet[ 1 ],;
                                                          oBrw:aRow[ 2 ] := aRet[ 2 ] }

   oBrw:aCols[ 3 ]:lHide           := .T.

   oWnd:oClient                    := oBrw

   oBrw:CreateFromCode()

ACTIVATE WINDOW oWnd //on paint( PalBmpDraw( hDC, 0, 0, hBmp ) )

return nil

/*------------------------------------------------------------------------*/
FUNC file_load( oCol )
loca cname
local hBmp
local aRet
cname := cGetFile( "*.*", "Select file" )

if cname != NIL
   ico  := ICON_EXEREAD(cname)
   hBmp := BmpFromIcon( ico )
   
   oCol:oBrw:aCols[ 1 ]:AddBmpHandle( hBmp )
   
   aRet := { Len( oCol:oBrw:aCols[ 1 ]:aBitmaps ), cName }


endi

RETU aRet

#pragma BEGINDUMP

#include <hbapi.h>
#include <windows.h>

HB_FUNC( ICON_EXEREAD )
{
   SHFILEINFO sfi;
   
   ZeroMemory(&sfi, sizeof(SHFILEINFO));

   SHGetFileInfo(hb_parc(1), 0, &sfi, sizeof(SHFILEINFO), SHGFI_ICON );
   
   hb_retnl( ( LONG ) sfi.hIcon );

}

HB_FUNC( BMPFROMICON )
{
     HICON hIcon = ( HICON ) hb_parnl( 1 );
     HDC HDCMem  = GetDC( GetDesktopWindow() );
   HDC hDC = CreateCompatibleDC( HDCMem );
   HBITMAP hBitmap = CreateCompatibleBitmap(HDCMem, GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON));
   HBITMAP hOldBitmap = (HBITMAP)SelectObject(hDC, hBitmap);
   DrawIcon(hDC, 0, 0, hIcon);
   SelectObject(hDC, hOldBitmap);
   DeleteDC(hDC);

   hb_retnl( ( LONG ) hBitmap );
}

#pragma ENDDUMP
 
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: c++ HIMAGELIST return XBROWSE ?

Postby yunbg1 » Sun Dec 06, 2009 10:29 am

Thank you so much !
I was working for 2~3 days because of that problem
I did what you told me and it is really working well now
Thank you for the answer!

regards

Yunbg1.
FWH User
FWPPC User
FWLinux User
yunbg1
 
Posts: 107
Joined: Sun Nov 13, 2005 12:40 am
Location: Winnipeg Canada


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 51 guests