Page 2 of 2
Re: Add some text in the exe file
Posted: Wed Mar 17, 2021 6:21 am
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
Re: Add some text in the exe file
Posted: Wed Mar 17, 2021 8:01 am
by serge_girard
TXT and as save as name.INI
Re: Add some text in the exe file
Posted: Wed Mar 17, 2021 11:37 am
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
Re: Add some text in the exe file
Posted: Wed Mar 17, 2021 2:27 pm
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
Re: Add some text in the exe file
Posted: Wed Mar 17, 2021 11:58 pm
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
Re: Add some text in the exe file
Posted: Thu Mar 18, 2021 2:25 am
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 (1.62 KiB) Viewed 2782 times