PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: Martin Francom on January 25, 2010, 01:42:49 PM

Title: FireSplitter
Post by: Martin Francom on January 25, 2010, 01:42:49 PM
Paul for what it is worth, I thought I would report an odd behavior that may only happen when using the FireSplitter control.  I was able to find a work  arround that seems to solve the problem, and the problem may very well be some odd coding that I am using.

Problem:  I am using a a FireSplitter control.  There are 12 forms that get "Shown" and "Hidden" on the FireSplitter control.    In one area of the code I am using the following code to switch from one form to another.  The problem is that the wrong form gets loaded.  This is the original code:


Function  GetRecForRx (TblName As String) As Long

       Local sTxt  As String
       Local sFld  As String     
             

      Select Case TblName
         Case "Patient"
             sTxt = FF_Control_GetText (HWND_FORMRX_TXTRXPATNAME)
             sTxt = Remove$(sTxt, " ")
             Replace Any "," With "~" In sTxt
             gCurPtSKey = sTxt
             SendMessage HWND_FRMMAIN_FIRESPLITTER1, %FF_SPLITTER_SETCHILD, 2, HWND_FORMPatInfo
             ShowWindow HWND_FORMPatInfo, %SW_SHOW
             PtSearchRecord()

         Case "Doctor"
             sTxt = FF_Control_GetText (HWND_FORMRX_TXTRXDOCNAME)
             sTxt = Remove$(sTxt, " ")
             Replace Any "," With "~" In sTxt
             gCurDrSKey = sTxt
             SendMessage HWND_FRMMAIN_FIRESPLITTER1, %FF_SPLITTER_SETCHILD, 2, HWND_FORMDocInfo
             ShowWindow HWND_FORMDocInfo, %SW_SHOW 
             DrSearchRecord()
         
         Case "Drug"
             sTxt = FF_Control_GetText (HWND_FORMRX_TXTRXDRUGNAME)
             sTxt = Remove$(sTxt, " ")
             Replace Any "," With "~" In sTxt
             gCurDgSKey = sTxt
             SendMessage HWND_FRMMAIN_FIRESPLITTER1, %FF_SPLITTER_SETCHILD, 2, HWND_FORMDRUGInfo
             ShowWindow HWND_FORMDrugInfo, %SW_SHOW 
             DgSearchRecord()
         
         Case "Sig"
             sTxt = FF_Control_GetText (HWND_FORMRX_txtRxSIGcode)
             sTxt = Remove$(sTxt, " ")
             Replace Any "," With "~" In sTxt
             gCurSgSKey = sTxt
             SendMessage HWND_FRMMAIN_FIRESPLITTER1, %FF_SPLITTER_SETCHILD, 2, HWND_FORMSigInfo
             ShowWindow HWND_FORMPatInfo, %SW_SHOW 
             SgSearchRecord()
     
      End Select

End Function


When I called the Case Patient  the form for the Doctor would be loaded.  I check all the obvious possible coding errors and did not find one.   Then I remarked out the doctor section and compile and ran the program then the correct Patient form would show.  (yes, I know this doesn't make any sense.) 
After much trial and error,  I found that if I place a SetFocus to a field on the Form I want to be loaded then the problem went away.  Note that  this function is being called from a  EN_KILLFOCUS  function. 

This is the corrected function that now works.

Function  GetRecForRx (TblName As String) As Long

       Local sTxt  As String
       Local sFld  As String     
             

      Select Case TblName
         Case "Patient"
             sTxt = FF_Control_GetText (HWND_FORMRX_TXTRXPATNAME)
             sTxt = Remove$(sTxt, " ")
             Replace Any "," With "~" In sTxt
             gCurPtSKey = sTxt
             FF_Control_SetFocus(HWND_FormPatInfo_txtPatSearch)    ' <-------
             SendMessage HWND_FRMMAIN_FIRESPLITTER1, %FF_SPLITTER_SETCHILD, 2, HWND_FORMPatInfo
             ShowWindow HWND_FORMPatInfo, %SW_SHOW
             PtSearchRecord()
         
         Case "Doctor"
             sTxt = FF_Control_GetText (HWND_FORMRX_TXTRXDOCNAME)
             sTxt = Remove$(sTxt, " ")
             Replace Any "," With "~" In sTxt
             gCurDrSKey = sTxt
             FF_Control_SetFocus(HWND_FormDocInfo_txtDocSearch)   '<------------             SendMessage HWND_FRMMAIN_FIRESPLITTER1, %FF_SPLITTER_SETCHILD, 2, HWND_FORMDocInfo
             ShowWindow HWND_FORMDocInfo, %SW_SHOW 
             DrSearchRecord()
         
         Case "Drug"
             sTxt = FF_Control_GetText (HWND_FORMRX_TXTRXDRUGNAME)
             sTxt = Remove$(sTxt, " ")
             Replace Any "," With "~" In sTxt
             gCurDgSKey = sTxt
             FF_Control_SetFocus(HWND_FormDrugInfo_txtDrugSearch)  '<-----------
             SendMessage HWND_FRMMAIN_FIRESPLITTER1, %FF_SPLITTER_SETCHILD, 2, HWND_FORMDRUGInfo
             ShowWindow HWND_FORMDrugInfo, %SW_SHOW 
             DgSearchRecord()
         
         Case "Sig"
             sTxt = FF_Control_GetText (HWND_FORMRX_txtRxSIGcode)
             sTxt = Remove$(sTxt, " ")
             Replace Any "," With "~" In sTxt
             gCurSgSKey = sTxt
             FF_Control_SetFocus(HWND_FormSigInfo_txtSigSearch)   <------------
             SendMessage HWND_FRMMAIN_FIRESPLITTER1, %FF_SPLITTER_SETCHILD, 2, HWND_FORMSigInfo
             ShowWindow HWND_FORMPatInfo, %SW_SHOW 
             SgSearchRecord()
     
      End Select

End Function



Do you have any ideas as to why this would occur and why adding a SetFocus would resolve the problem?     Oh, I also tried putting the SetFocus after the ShowWindow and that did not help.  It needed to be before the SendMessage.

This problem is reproducable by simply commenting out the SetFocus statements.