Hard coding picture on a button

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

RPC
Posts: 281
Joined: Fri Feb 10, 2017 4:12 am
DBs Used: DBF

Hard coding picture on a button

Post 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 ?
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Hard coding picture on a button

Post 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
Viva INTERNATIONAL HMG :D
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Hard coding picture on a button

Post 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.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
RPC
Posts: 281
Joined: Fri Feb 10, 2017 4:12 am
DBs Used: DBF

Re: Hard coding picture on a button

Post 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.
RPC
Posts: 281
Joined: Fri Feb 10, 2017 4:12 am
DBs Used: DBF

Re: Hard coding picture on a button

Post 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
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Hard coding picture on a button

Post by Rathinagiri »

Can you give a sample project?

The files shall have .ico file for Icons.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
edk
Posts: 909
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: Hard coding picture on a button

Post 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 4527 times
b0.7z
(1.09 MiB) Downloaded 213 times
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Hard coding picture on a button

Post by Rathinagiri »

Yes. For picture property I think we need bitmap?
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
edk
Posts: 909
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: Hard coding picture on a button

Post by edk »

Works fine with bitmap, png, gif, jpg, tif
User avatar
gfilatov
Posts: 1060
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: Hard coding picture on a button

Post 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
Attachments
Scrrensot of a sample
Scrrensot of a sample
screen.png (12.71 KiB) Viewed 4468 times
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
Post Reply