Add some text in the exe file

Moderator: Rathinagiri

User avatar
hmgchang
Posts: 273
Joined: Tue Aug 13, 2013 4:46 am
Location: Indonesia

Re: Add some text in the exe file

Post by hmgchang »

Ok Mol...
Good suggestion and make sense to have an .ini file instead of modifying the
running .exe file.
Any suggestion for the .ini file type ? text file ?


Thks n Rgds
Chang
Just Hmg It !
User avatar
serge_girard
Posts: 3161
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Add some text in the exe file

Post by serge_girard »

TXT and as save as name.INI
There's nothing you can do that can't be done...
User avatar
Claudio Ricardo
Posts: 367
Joined: Tue Oct 27, 2020 3:38 am
DBs Used: DBF, MySQL, MariaDB
Location: Bs. As. - Argentina

Re: Add some text in the exe file

Post by Claudio Ricardo »

Any suggestion for the .ini file type ? text file ?
Hi...
Example Config.ini file... if not exist, is created for Write_Ini function

Code: Select all

#include <hmg.ch>

Function Main

PUBLIC pcFileIni := GetCurrentFolder () + "\Config.ini"
PUBLIC pnMainRowIni := 10	// First init value
PUBLIC pnMainColIni := 10	// First init value

Set Language To Spanish
Set CodePage To Unicode

Set Multiple Off
Set Century On
Set Date French
Set Decimals To 2
Set BrowseSync On
Set TooltipStyle Balloon

	If File (pcFileIni)
	
		Read_Ini ()
		
	Else
	
		Write_Ini ()
		
	EndIf

        Load Window Main

			SetProperty ("Main" , "Col" , pnMainColIni)
			SetProperty ("Main" , "Row" , pnMainRowIni)

        Main. Activate

Return Nil
//------------------------------------------------------------------------//
Function Read_Ini
	
	BEGIN INI FILE pcFileIni
	
		GET pnMainColIni SECTION "MAIN" ENTRY "ColIni"
		GET pnMainRowIni SECTION "MAIN" ENTRY "RowIni"

	END INI
	
Return Nil
//------------------------------------------------------------------------//
Function Write_Ini

	BEGIN INI FILE  pcFileIni
	
		SET SECTION "MAIN" ENTRY "ColIni" TO pnMainColIni
		SET SECTION "MAIN" ENTRY "RowIni" TO pnMainRowIni

	END INI

Return Nil
//------------------------------------------------------------------------//
Function Main_Button_Exit

	pnMainColIni := GetProperty ( "Main" , "Col" )
	pnMainRowIni := GetProperty ( "Main" , "Row" )

	Write_Ini ()	
	
	Main. Release

Return Nil
This save in Config.ini Row and Col main window position stored in public var's for remember at init the last window position
but can save much more information.
This is the content of the example .ini file:

[MAIN]
ColIni=96
RowIni=18

Pd. Sorry for my bad english :oops:
Corrige al sabio y lo harás más sabio, Corrige al necio y lo harás tu enemigo.
WhatsApp / Telegram: +54 911-63016162
edk
Posts: 909
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: Add some text in the exe file

Post by edk »

hmgchang wrote: Wed Mar 17, 2021 6:21 am Ok Mol...
Good suggestion and make sense to have an .ini file instead of modifying the
running .exe file.
Any suggestion for the .ini file type ? text file ?


Thks n Rgds
Chang
hmgchang wrote: Wed Mar 17, 2021 4:04 am Hola Masters,

i can use ON SIZE event when i size a window,
but how about moving a window... any ON MOVE ?

or how can i catch the move event ?
windowsEvents.JPG

Thks n rgds
Chang
See this example, but according to your goal, you don't need to read window parameters on the fly, just handle it when closing the window.

Code: Select all

#include "hmg.ch"
#define WM_MOVE            		0x0003
#define WM_SIZE                         0x0005


Function Main
Local nFRow:=0, nFCol:=0, nFWidth:=400, nFHeight:=600, lCenter:=.T.

IF File("Config.ini")
   Begin ini file ("Config.ini")
      Get nFRow    Section "FORM_1" ENTRY "Row"
      Get nFCol    Section "FORM_1" ENTRY "Col"
      Get nFWidth  Section "FORM_1" ENTRY "Width"
      Get nFHeight Section "FORM_1" ENTRY "Height"
   End Ini
   lCenter:=.F.
EndIf

DEFINE WINDOW Form_1 AT nFRow, nFCol WIDTH nFWidth HEIGHT nFHeight TITLE 'Hello World!' MAIN ;
	ON RELEASE SaveIni()
   
  ON KEY ESCAPE ACTION ThisWindow.Release
  
  DEFINE STATUSBAR
     STATUSITEM "Try moving or resizing this window"
  END STATUSBAR
END WINDOW

IF lCenter
    CENTER WINDOW Form_1
ENDIF
CREATE EVENT PROCNAME MoveAndSizeForm_1() HWND Form_1.HANDLE 	
ACTIVATE WINDOW Form_1
Return Nil

***************************************************
Function SaveIni()
Begin ini file ("Config.ini")
      Set Section "FORM_1" ENTRY "Row" To Form_1.Row
      Set Section "FORM_1" ENTRY "Col" To Form_1.Col
      Set Section "FORM_1" ENTRY "Width" To Form_1.Width
      Set Section "FORM_1" ENTRY "Height" To Form_1.Height
End Ini
RETURN
***************************************************

Function MoveAndSizeForm_1()
Local nMSG := EventMSG ()
Local xPos, yPos, nWidth, nHeight, nRow, nCol

IF nMSG == WM_MOVE .OR. nMSG == WM_SIZE
	xPos := LOWORD(EventlParam())
	yPos := HIWORD(EventlParam())
	nWidth := Form_1.Width
	nHeight := Form_1.Height
	nRow := Form_1.Row
	nCol := Form_1.Col

	Form_1.StatusBar.Item(1):="Form_1  Row: "+StrZero(nRow,5,0)+" / Col: "+StrZero(nCol,5,0)+" | Width: "+StrZero(nWidth,5,0)+" / Height: "+StrZero(nHeight,5,0)+" | xPos: "+StrZero(xPos,5,0)+" / yPos: "+StrZero(yPos,5,0)

ENDIF
Return Nil

User avatar
hmgchang
Posts: 273
Joined: Tue Aug 13, 2013 4:46 am
Location: Indonesia

Re: Add some text in the exe file

Post by hmgchang »

Hola and thousand thanks to Mr. Claudio Ricardo and Mr. edk
for the very useful code.

It solved my problem effectively.
But still i wonder :
1. why the ON MOVE event not build in the hmg ?
2. any documentation on the BEGIN INI statement ? or any others un-documented statements ?
3.

Code: Select all

These users thanked the author edk for the post (total 2):
danielmaximiliano (Thu Mar 18, 2021 12:38 am) • andyglezl (Thu Mar 18, 2021 2:12 am)
. How can i make this ?

Thks n Rgds
Chang
Just Hmg It !
User avatar
Claudio Ricardo
Posts: 367
Joined: Tue Oct 27, 2020 3:38 am
DBs Used: DBF, MySQL, MariaDB
Location: Bs. As. - Argentina

Re: Add some text in the exe file

Post by Claudio Ricardo »

Hi...
1. why the ON MOVE event not build in the hmg ?
Maybe no one needed to start an event when moving a window.
How can i make this ?
With this button:
Screenshot_20210317_230137.png
Screenshot_20210317_230137.png (1.62 KiB) Viewed 2649 times
Corrige al sabio y lo harás más sabio, Corrige al necio y lo harás tu enemigo.
WhatsApp / Telegram: +54 911-63016162
Post Reply