If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Corel Paradox > Prevent Open Form

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-26-04, 10:15
Air Air is offline
Registered User
 
Join Date: May 2004
Posts: 3
Question Prevent Open Form

hi all,
i need to prevent open of a paradox form from windows explorer. When users double click a form file it open in paradox runtime and bypass any application control. Thx for answer and sorry for bad english
Reply With Quote
  #2 (permalink)  
Old 05-26-04, 10:42
lmckelvy lmckelvy is offline
Registered User
 
Join Date: Oct 2003
Posts: 107
Place this code in the init method of each form you don't want them to open:

Code:
var
  openForms Array[] String
endVar

enumFormNames(openForms)
;openForms.view()

if not openForms.contains("the TITLE of your main menu form goes here")
	then  msgStop("Security Violation:","You cannot open this form without going through the Main Menu system")
   		eventinfo.setErrorCode(canNotArrive)
			close()
         return
endif
This will prevent any form from opening unless the control form (like a main application form) is actually open. It's not perfect as they could technically open the main application form and then browse to one of the others, but it keeps casual power users from messing around.

It's important that you put the TITLE value of the form, not the form name. I included the commented-out line openForms.view() as a debugging tool to use if the code doesn't see your main form as really being OPEN. This will list all open forms by TITLE so you can check to make sure you are referencing the right TITLE.

Hope this helps

Last edited by lmckelvy; 05-26-04 at 10:51.
Reply With Quote
  #3 (permalink)  
Old 05-26-04, 10:49
Air Air is offline
Registered User
 
Join Date: May 2004
Posts: 3
Thx for help but that don't resolve any issues of my problem because i need to stopping form opening from windows explorer even if my main form is open. This because main form could request some authentication before a form is opening. I need also resolve this problem with code in main form only if is possible. Thx for any other helps.
Reply With Quote
  #4 (permalink)  
Old 05-26-04, 11:13
lmckelvy lmckelvy is offline
Registered User
 
Join Date: Oct 2003
Posts: 107
Then the only other thing I can think of is to not allow the form to open unless an environment variable is properly set.

For example, in your main form when a support form is called you set an environment variable to a value. When the support form opens, it should check the environment variable. If the variable value is right, the form should reset the variable to a bs value and open normally.

Example:

On the main Form, say from a pushButton event:

Code:
var
 myForm     Form
endvar

writeEnvironmentString("FormStat", "OkayToOpen")

myForm.open(":myAlias:theform.fdl")
In the init method of each form:

Code:
var
 secretCode    string
endvar

;get current string value
secretCode = readEnvironmentString("FormStat")

;reset environment variable
writeEnvironmentString("FormStat", "DoNotOpen")

if secretCode <> "OkayToOpen"
	then  msgStop("Security Violation:","You cannot open this form without going through the Main Menu system")
   		eventinfo.setErrorCode(canNotArrive)
			close()
         return
endif
Reply With Quote
  #5 (permalink)  
Old 05-26-04, 11:37
Air Air is offline
Registered User
 
Join Date: May 2004
Posts: 3
That's good. I think same mode... only other questions. There is a method for intercept open of a form from main form and get handler of that form? In this case i've a possibility to write control code for opening in main form only... thank you very much for attention
Reply With Quote
  #6 (permalink)  
Old 05-26-04, 12:55
lmckelvy lmckelvy is offline
Registered User
 
Join Date: Oct 2003
Posts: 107
I don't know for certain as I've never tried anything like that. I would guess that you would need to check for open forms on a regular interval (maybe using a timer) and if any are opened, close them.

You would probably need to grab an array of open forms and if the size is greater than 1 (meaning more than just the main form is open), then you would do a while/endwhile loop to step through each open form, attach to it by title and close it if it's not your main form.
Reply With Quote
  #7 (permalink)  
Old 05-27-04, 06:24
Shores Shores is offline
Registered User
 
Join Date: Aug 2003
Location: Bologna - Italy
Posts: 209
Don't try to close opened forms, that would always be error prone.

You should PREVENT opening of forms with the trick that lmckelvy has told you, and then be sure they can't open at all, instead of trying to close them after they've been opened.

Bye!
__________________
The only failure is not trying to do it.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On