Thank you Claudio. You gave good lesons and more features than I needed.
- I saw event release is also sizing.
- Adding a flag to switch when is minimize, was good idea.
- Using BT_DrawSetPixel OnPaint event, keeps grid permanently as part of form.
In FMG_Editor, I would like to switch by user option when to use grids or not.
But now I learned that making OnPaint event is the best practice to keep grids without without being harmed by the events OnMaximize, OnMinimize and OnRestore.
So, I see now that was not even necessary to control the OnRestore event.
Sorry if I gave work to you, but for me is worth as learning.
I made my final test, now knowing the best way to implement Grid on forms:
Code: Select all
#include "hmg.ch"
Function Main()
PUBLIC flag_Restore := .F.
DEFINE WINDOW Form_1 ;
AT 0,0 ;
WIDTH 200 ;
HEIGHT 200 ;
ON PAINT OnPaint();
MAIN
@ 60,50 BUTTON Button_1 CAPTION "ON" ACTION (flag_Restore:=.T.,OnPaint())
@ 90,50 BUTTON Button_2 CAPTION "OFF" ACTION (flag_Restore:=.F.,RedrawWindow(GetFormHandle("Form_1")))
END WINDOW
// CREATE EVENT PROCNAME OnRestore HWND Form_1.HANDLE
CENTER WINDOW Form_1
ACTIVATE WINDOW Form_1
Return
#define WM_SYSCOMMAND 274
#define SC_RESTORE 0xF120
FUNCTION OnRestore
IF EventMSG() == WM_SYSCOMMAND .AND. EventWPARAM() == SC_RESTORE
flag_Restore := .T.
ENDIF
RETURN NIL
PROCEDURE OnPaint (nPx)
LOCAL Width := BT_ClientAreaWidth ("Form_1")
LOCAL Height := BT_ClientAreaHeight ("Form_1")
LOCAL hDC, BTstruct
Default nPx := 10
IF flag_Restore == .T.
hDC := BT_CreateDC ("Form_1", BT_HDC_ALLCLIENTAREA, @BTstruct)
For i := nPx TO Width STEP nPx
For j := nPx TO Height STEP nPx
BT_DrawSetPixel (hDC, j, i, BLACK)
Next
Next
BT_DeleteDC (BTstruct)
ENDIF
// flag_Restore := .F.
Return Nil
Perhaps the misunderstanding that happened was because I have not used our native language and the lack of greater expertise from me.
Thank you again Claudio.