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
Add some text in the exe file
Moderator: Rathinagiri
Re: Add some text in the exe file
Just Hmg It !
- serge_girard
- Posts: 3167
- 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
TXT and as save as name.INI
There's nothing you can do that can't be done...
- 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
Hi...Any suggestion for the .ini file type ? text file ?
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
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
Corrige al sabio y lo harás más sabio, Corrige al necio y lo harás tu enemigo.
WhatsApp / Telegram: +54 911-63016162
WhatsApp / Telegram: +54 911-63016162
Re: Add some text in the exe file
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
Re: Add some text in the exe file
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.. How can i make this ?
Thks n Rgds
Chang
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)
Thks n Rgds
Chang
Just Hmg It !
- 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
Hi...
Maybe no one needed to start an event when moving a window.1. why the ON MOVE event not build in the hmg ?
With this button:How can i make this ?
Corrige al sabio y lo harás más sabio, Corrige al necio y lo harás tu enemigo.
WhatsApp / Telegram: +54 911-63016162
WhatsApp / Telegram: +54 911-63016162