Hard coding picture on a button

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

RPC
Posts: 119
Joined: Fri Feb 10, 2017 4:12 am
Has thanked: 28 times
Been thanked: 6 times

Hard coding picture on a button

Post by RPC » 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 ?

User avatar
esgici
Posts: 4363
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Has thanked: 247 times
Been thanked: 91 times
Contact:

Post by esgici » Thu Dec 07, 2017 7:22 pm

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: 5181
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 142 times
Been thanked: 131 times
Contact:

Post by Rathinagiri » 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.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.

RPC
Posts: 119
Joined: Fri Feb 10, 2017 4:12 am
Has thanked: 28 times
Been thanked: 6 times

Post by RPC » Fri Dec 08, 2017 7:38 am

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: 119
Joined: Fri Feb 10, 2017 4:12 am
Has thanked: 28 times
Been thanked: 6 times

Post by RPC » Fri Dec 08, 2017 7:47 am

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: 5181
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 142 times
Been thanked: 131 times
Contact:

Post by Rathinagiri » Fri Dec 08, 2017 9:30 am

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: 200
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland
Has thanked: 58 times
Been thanked: 136 times

Post by edk » 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.png
Bez tytułu.png (3.01 KiB) Viewed 155 times
b0.7z
(1.09 MiB) Downloaded 14 times

User avatar
Rathinagiri
Posts: 5181
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 142 times
Been thanked: 131 times
Contact:

Post by Rathinagiri » Fri Dec 08, 2017 12:54 pm

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: 200
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland
Has thanked: 58 times
Been thanked: 136 times

Post by edk » Fri Dec 08, 2017 1:52 pm

Works fine with bitmap, png, gif, jpg, tif

User avatar
gfilatov
Posts: 519
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Has thanked: 8 times
Been thanked: 72 times
Contact:

Post by gfilatov » Fri Dec 08, 2017 7:08 pm

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

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

Post Reply