Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.databases.paradox    |    To crash or not to crash, asks Borland    |    9,834 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 9,303 of 9,834    |
|    Robert Wiltshire to Rick Rans    |
|    Re: Preventing a form from opening a sec    |
|    27 Jul 08 03:37:35    |
   
   From: nomail@nospam.com   
      
   Ok, solved good enough for me.   
      
   The pita issue on this ended up being that   
      
   >the issue to get pdox form handle is difficult   
   >because both instances have the same exact title.   
      
   Originall, my second solution from the first post,   
   was to change title after form was open,   
   so that when 2nd instance tried to open,   
   I had different titles to work with ,   
   and therefore could stay totally with pdox methods   
   of attach and bringToTop.   
      
      
   Using that approach,   
   plus reading suggestions leads me to   
   a slightly more efficient approach to that technique.   
   Instead of modifying the title after it opens,   
   I modify the form title of the second instance of the form,   
   which is about to be closed anyways.   
      
   The steps are like this   
      
   get handle of form opening for second time   
    fThis.attach()   
   gettitle for form   
    stTitle = fThis.getTitle()   
   get all form names into array   
    enumFormnames(arForms)   
   cycle through array and see how many times stTitle exists in arForms   
    used a for loop and test to see if arForms[x]=stTitle   
      
   if arForms contains stTitle 2 times, then change title of opening form   
    fThis.setTitle(stTitle+"2")   
   Since we will be closing this 2nd instance of the form,   
   it does not matter if we change the title.   
      
   That will leave us with only one form with stTitle as its title,   
   and it is simple matter to attach and then bringToTop.   
    fOrig.attach(stTitle)   
    fOrig.bringToTop()   
      
   Thank you all for taking time to read this and offer suggestions.   
   It was much appreciated and helped with the brainstorming process.   
      
   Robert Wiltshire   
      
      
      
   ****Final code below ***************   
      
   Code in the init section now looks like this   
      
   method init(var eventInfo Event)   
      
   if isFormOpeningAlreadyOpen() then   
    eventInfo.setErrorCode(canNotArrive)   
    close()   
    return   
    endif   
      
   endMethod   
      
      
   and code in custom method looks like   
      
   method isFormOpeningAlreadyOpen() logical   
      
   var   
    fThis,fOrig form   
    stTitleThisForm string   
    arForms array[] string   
    liEach,liMatches longint   
   endvar   
      
   attach to current form, and get its title   
   fThis.attach()   
   stTitleThisForm = fThis.getTitle()   
      
   use opal enum method to populate array,   
   and then count number of times current title is in array   
   enumFormnames(arForms)   
   liMatches = 0   
   for liEach from 1 to arForms.size()   
    if arForms[liEach] = stTitleThisForm then   
    liMatches = liMatches + 1   
    endif   
   endfor   
      
   if found zero or one time, then not already open   
   if liMatches <= 1 then   
    return(false)   
    endif   
      
   since we will be closing this form   
   modify its title, so that attach gets other form   
   fThis.setTitle(stTitleThisForm+"2")   
      
   if fOrig.attach(stTitleThisForm)   
    then fOrig.bringToTop()   
    else msgStop("Error","Did not find 2nd instance of form")   
   endif   
      
   return(true)   
      
   endMethod   
      
      
      
      
      
      
      
      
      
      
      
      
      
      
   "Rick Rans"
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca