closing window

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
franco
Posts: 818
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

closing window

Post by franco »

Hello all in new forum design.
New problem that should be simple
At the start of a function I would like to say (window closable := .F.) to stop being able to close window with X.
At the end of the function I could say (window closable := .T.)
I want to do the this because I am using temporary files and if I am working with file and click the close button my
program crashes because (onrelease) goes to a function that closes the temp file but the program goes back to where it was and
there is no temporary file. I have tried (oninteractiveclose) but it does not do what .
I go from this window to another. I have not tried to make it so I can not leave the other window without closing it.
I think there is a way to do this with window type. do you think this is the way to do what I want and what window type
makes it so you can not leave it. I just thought of this while I was creating this topic.
Still it would be nice to say window closable := .f.
Thanks in advance .............Franco ;)

FOUND SOLUTION CHECK IF TEMP FILE HAS NOT BEEN RELEASED WITH
if alltrim(upper(alias())) = TEMPFILENAME
THEN CARRY ON
thanks to all ................... Franco ;)
Last edited by franco on Fri Oct 31, 2014 9:47 am, edited 1 time in total.
All The Best,
Franco
Canada
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: closing window

Post by esgici »

franco wrote:Hello all in new forum design.
New problem that should be simple
At the start of a function I would like to say (window closable := .F.) to stop being able to close window with X.
At the end of the function I could say (window closable := .T.)
I want to do the this because I am using temporary files and if I am working with file and click the close button my
program crashes because (onrelease) goes to a function that closes the temp file but the program goes back to where it was and
there is no temporary file. I have tried (oninteractiveclose) but it does not do what .
I go from this window to another. I have not tried to make it so I can not leave the other window without closing it.
I think there is a way to do this with window type. do you think this is the way to do what I want and what window type
makes it so you can not leave it. I just thought of this while I was creating this topic.
Still it would be nice to say window closable := .f.
Thanks in advance .............Franco ;)
Did you tried a separate (always un-cloaseable) window dedicated that function ?

For example a wait window saying something "Please wait; working on temporary file(s)".
Viva INTERNATIONAL HMG :D
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: closing window

Post by esgici »

esgici wrote:...
a separate (always un-cloaseable) window dedicated that function ?
...
Tried, WaitWindow() interrupts interventions on caller window :o

So, not necessary a separate ( dedicated ) window :arrow:

I'm about something like this :
dontclose.jpg
dontclose.jpg (36.53 KiB) Viewed 2491 times
dontclose.zip
(595 Bytes) Downloaded 164 times
Happy HMG'ing :D
Viva INTERNATIONAL HMG :D
franco
Posts: 818
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: closing window

Post by franco »

Here is a sample of my problem. I found if I make my search window modal the first window can not close which is what I wanted.
now I can not release the second window.
My real brcr is a complete other program. I made it a function for this demo.
I use brcr to browse 2 fields from anywhere in my program. This works GREAT if no errors.
If you try this demo The error is can not release top modal window, but i want to release because it is a different program in main system.
Any thoughts ?

Code: Select all

* -._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.
#include <hmg.ch>

* Temporary Table Test by Grigory Filatov
* Slightly modified by Roberto Lopez

Function Main

CreateTemp()
   
   define window winMain ;
      at 0, 0 ;
      width 640 height 480 main ;
      title "Temporary Table" 
      
      DEFINE GRID brwTemp
         COL 0
         ROW 0
         WIDTH 600
         HEIGHT 340
         HEADERS {"Item Code", "Item Description", "Rate"}
         WIDTHS {125, 300, 100}
         ROWSOURCE "curItem"
         COLUMNFIELDS {"itemcd", "itemnm", "rate"}
      END GRID
		DEFINE BUTTON Btr3New 
            ROW 350
            COL 10
            WIDTH 60 
            HEIGHT 60
            FONTBOLD .T.
			CAPTION "V"
            ACTION  BRcr(135,746, 100, 100, 390, 'Item', 'Name', 'curitem', 'curitem->itemcd', 'curitem->itemnm')  
          
            TOOLTIP 'Enter New Invoice'
            END BUTTON
   end window
   
   winMain.center
   winMain.activate

Return

function CreateTemp()
   local aDbf := {}
   aadd(adbf,   {"itemcd", "c",   10, 0})
   aadd(adbf,   {"itemnm", "c",   40,   0})
   aadd(adbf,   {"rate",   "n",    8, 2})
   
   if !hb_dbcreatetemp("curItem", adbf)
      msgbox("Cannot create temporary table: Item")
      RELEASE WINDOW ALL
      return nil
   endif
   
   if select("curItem") = 0
      use curItem new
   endif
   select curItem
   append blank
   curItem->itemcd := "CD1"
   curItem->itemnm := "Compact Disc"
   curItem->rate := 10.00
   unlock
    append blank
   curItem->itemcd := "AD2"
   curItem->itemnm := "Compact Disc"
   curItem->rate := 10.00
   unlock
   index on itemcd to curitem
return nil

function brcr
LOCAL WID1
PARAMETERS R1, C1, W1, W2, H1, H2, H3, T1, FC1, FC2      // TA, W1, W2, C1, R1, H1, I1, D1, FC1, FC2
go top
IF W2 = 0
   WID1 := 'FC1'
ELSE 
   WID1 := 'FC1 , FC2'
ENDIF   
DEFINE WINDOW frmQSMain ;
AT  R1+80, C1+10 ;
WIDTH W1+W2+40 ;      //GetDesktopWidth() * 0.75 ;
HEIGHT H1+20 ;  // GetDesktopHeight() * 0.75 ;
WINDOWTYPE modal 

 // ON KEY ESCAPE ACTION frmQSMain.Release
 // ON KEY ESCAPE ACTION ''


DEFINE BROWSE brwItems
ROW 25    //133
COL 0     //211
WIDTH W1 + W2+25  // 400
HEIGHT H1  //290
BACKCOLOR    { 255, 255, 255}
FONTCOLOR { 0, 0, 0 }
HEADERS  {H2 , H3}
WIDTHS   {W1, W2}
WORKAREA  &T1  //inv
FIELDS { &WID1}
ONDBLCLICK { || dbgoto(this.value),  thiswindow.Release }
ONLOSTFOCUS { || dbgoto(this.value),  thiswindow.Release } 
ONCHANGE { || dbgoto(this.value) }
NOLINES .F.
END BROWSE // brwItems

DEFINE TEXTBOX textSearch
ROW 0 //R1
COL 0  //232
WIDTH 200 // 200 can make 0 so you cannot see
HEIGHT 24
TOOLTIP 'START TO TYPE SEARCH ITEM'
ONCHANGE { || DBSEEK( UPPER( this.Value ), .T. ), frmQSMain.brwItems.value := curitem->(RECNO() ) }
ONENTER { || frmQSMain.brwItems.SETFOCUS }
ONLOSTFOCUS { || frmQSMain.brwItems.SETFOCUS}
END TEXTBOX // tbxSearch



END WINDOW // frmQSMain   
frmQSMain.textSEARCH.VISIBLE := .T.
frmQSMain.brwItems.VISIBLE := .T.
frmQSMain.textSEARCH.SETFOCUS
frmQSMain.Activate
return
// HMG_HELP Main()

* -._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.

Thanks Franco
All The Best,
Franco
Canada
franco
Posts: 818
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: closing window

Post by franco »

FOUND SOLUTION CHECK IF TEMP FILE HAS NOT BEEN RELEASED WITH
if alltrim(upper(alias())) = TEMPFILENAME
THEN CARRY ON
thanks to all ................... Franco ;)
PS the above program works well as a 2 field table lookup you can sen parameters to
All The Best,
Franco
Canada
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: closing window

Post by esgici »

franco wrote:FOUND SOLUTION CHECK IF TEMP FILE HAS NOT BEEN RELEASED WITH
if alltrim(upper(alias())) = TEMPFILENAME
THEN CARRY ON
thanks to all ................... Franco ;)
PS the above program works well as a 2 field table lookup you can sen parameters to
Good news, congrats :)

Happy HMG'ing :)
Viva INTERNATIONAL HMG :D
Post Reply