Page 1 of 3

Hard coding picture on a button

Posted: Thu Dec 07, 2017 7:12 pm
by RPC
Hi
Is there a way to hard code a picture on a button in the code.
For eg if in a button control we include PICTURE "HP_PRINT" we will get PRINTER icon on the button, without icon actually being in the folder
similarly if in a button control we include PICTURE "HP_CLOSE" we will get EXIT icon on the button, without icon actually being in the folder
Is it possible to do this for any icon which is used as a picture in button control ?

Re: Hard coding picture on a button

Posted: Thu Dec 07, 2017 7:22 pm
by esgici
RPC wrote: Thu Dec 07, 2017 7:12 pm Hi
Is there a way to hard code a picture on a button in the code.
For eg if in a button control we include PICTURE "HP_PRINT" we will get PRINTER icon on the button, without icon actually being in the folder
similarly if in a button control we include PICTURE "HP_CLOSE" we will get EXIT icon on the button, without icon actually being in the folder
Is it possible to do this for any icon which is used as a picture in button control ?

Code: Select all

IF I understand right: 
    Did you tried hard code path include the icon ?

    fe

    PICTURE "C:\IMAGES\ICONS\ExitIcon.ico"
ELSE
    Would you supply a SSW ( Short, Simple and Working) example
ENDIF
Viva HMG

Re: Hard coding picture on a button

Posted: Fri Dec 08, 2017 4:15 am
by Rathinagiri
I think you are talking about embedding the icon and other application pictures inside EXE files. You have to just add to resource file. You can find many samples in the samples folder.

Re: Hard coding picture on a button

Posted: Fri Dec 08, 2017 7:38 am
by RPC
Hi Esgici
The solution you provided will work well if the exe is run on a particular computer from any folder or sub-folder.
I think it will not work, ie icons will not be ported along with exe file, if exe is run on a different computer.
What I want is the icon/image should get embedded in the exe file so icons/images are not required to sent along with exe file.

Re: Hard coding picture on a button

Posted: Fri Dec 08, 2017 7:47 am
by RPC
Rathinagiri wrote: Fri Dec 08, 2017 4:15 am I think you are talking about embedding the icon and other application pictures inside EXE files. You have to just add to resource file. You can find many samples in the samples folder.
Yes Rathinagiri I talking about embedding the icon/image.
I tried looking in samples folder but could not find any example. I tried entering the details of icon in *.rc file but icons didn't get embedded.
For eg I entered following line in *.rc file
open BITMAP open.bmp
the open icon did not get embedded in resultant exe file.
Thanks

Re: Hard coding picture on a button

Posted: Fri Dec 08, 2017 9:30 am
by Rathinagiri
Can you give a sample project?

The files shall have .ico file for Icons.

Re: Hard coding picture on a button

Posted: Fri Dec 08, 2017 10:29 am
by edk
It seems to me that the icon files (ico) included in resources are not supported by the PICTURE property for the BUTTON control.
Bez tytułu.png
Bez tytułu.png (3.01 KiB) Viewed 4591 times
b0.7z
(1.09 MiB) Downloaded 217 times

Re: Hard coding picture on a button

Posted: Fri Dec 08, 2017 12:54 pm
by Rathinagiri
Yes. For picture property I think we need bitmap?

Re: Hard coding picture on a button

Posted: Fri Dec 08, 2017 1:52 pm
by edk
Works fine with bitmap, png, gif, jpg, tif

Re: Hard coding picture on a button

Posted: Fri Dec 08, 2017 7:08 pm
by gfilatov
edk wrote: Fri Dec 08, 2017 10:29 am It seems to me that the icon files (ico) included in resources are not supported by the PICTURE property for the BUTTON control.
Bez tytułu.pngb0.7z
Hi Edward,

Your sample works fine in MiniGUi Extended (with a minor modification).

The updated source is below :arrow:

Code: Select all

#include "hmg.ch"

Function Main()

   DEFINE WINDOW Form_1 ;
      AT 0,0 ;
      WIDTH 430 ;
      HEIGHT 270 ;
      ICON "B3" ;
      MAIN ;
      TITLE 'Button Test'

      @ 50,20 BUTTONEX B_1 CAPTION "B1" PICTURE "B1" WIDTH 110 HEIGHT 100 VERTICAL ACTION Nil
      @ 50,155 BUTTONEX B_2 CAPTION "B2" PICTURE "B2" WIDTH 110 HEIGHT 100 VERTICAL ACTION Nil
      @ 50,290 BUTTONEX B_3 CAPTION "B3" ICON "B3" WIDTH 110 HEIGHT 100 VERTICAL ACTION Nil

   END WINDOW

   CENTER WINDOW Form_1

   ACTIVATE WINDOW Form_1

Return Nil