Table or Field Name New or Edit

This popup makes "add / edit" dialog less "messy". File ./bBaseW_Text_IDs.inc, and the language DLL change daily (I hope). If somebody wants to run this code's demo, ask for the files.
Code section by section description later.


%test_dialog = -1 'change to 0 to use this file as a #INCLUDE

#if %test_dialog '

#compile exe

#dim all

%UNICODE = 1

#resource icon, 101, "./../IconStor/bBaseW32.ico"



#include once "Win32API.inc"

#include "./bBaseW_Text_IDs.inc"

global gpGetLText as dword

function pbmain () as long

  local hLangText, hStdFont as dword

  local TName as wstringz * 32

  import addr "GetCtlText","xBaseW_EN.dll" to gpGetLText, hLangText

  dialog default font "Microsoft Sans Serif", 12, 0, 1

  TName = "Dick" '

  TableFieldName 0, TName, %TblNmDlgTtl '%TblNmDlgTtl %FldNmDlgTtl set caption

 ? Tname

    ' %TblNmDlgTtl %FldNmDlgTtl

  import close hLangText

end function

declare function GetLText (byval W_ID as long) as wstring

#endif



'============================================================================  ===

%dym_pStr = %wm_user + 501

%ID_ExitBtn = 1000

%ID_NameTxtBx = 1001

%ID_AcceptBtn  = 1002

%ID_AbandonBtn = 1003

%ID_TblFldNmLbl = 1020



callback function TblFldNmDlgCB() as long

  static pStr as wstringz pointer * 32

  local TmpStr, TmpStr2 as wstring

  local TmpLg as long

  if cb.msg = %wm_command then

    if (cb.ctl = %ID_AcceptBtn) and (cb.ctlmsg = %bn_clicked) then

      control get text cb.hndl, %ID_NameTxtBx to TmpStr

      TmpLg = len(TmpStr)

      if TmpLg > 31 then

        call dword gpGetLText using GetLText(%NmTooLgMBmsg) to TmpStr

        TmpStr += dec$(TmpLg - 31)

        call dword gpGetLText using GetLText(%ErrorMBTtl) to TmpStr2

        beep

        msgbox TmpStr, %mb_ok or %mb_iconerror or %mb_taskmodal, TmpStr2

      else

        @pStr = TmpStr

        dialog end cb.hndl

      end if

    elseif (cb.ctl = %ID_AbandonBtn) and (cb.ctlmsg = %bn_clicked) then

        dialog end cb.hndl

    end if

  elseif cb.msg = %dym_pStr then

    pStr = cb.wparam

  end if

end function

'-------------------------------------------------------------------------------

function TableFieldName(byval hParent as dword, _

                        byref wNamez as wstringz * 32, _

                        byval TextIsFor as long) as long

  local hTblFldNmDlg as dword

  local CtlText as wstring

  local Parent_X, Parent_Y as long

  ' - dialog -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -

  dialog get loc hParent to Parent_X, Parent_Y

  call dword gpGetLText using GetLText(TextIsFor) to CtlText

  dialog new hParent,  CtlText, Parent_X + 10, Parent_Y + 10, 160, 52, _

                                                                   to hTblFldNmDlg

  ' - instruction label  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -

  call dword gpGetLText using GetLText(%TblFldNmLbl) to CtlText

  control add label, hTblFldNmDlg, %ID_TblFldNmLbl, CtlText, 5, 5, 150, 10

  ' - name textbox -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -

  CtlText = wNamez

  Parent_X = len(CtlText)

  control add textbox, hTblFldNmDlg, %ID_NameTxtBx, CtlText, 5, 15, 150, 12

  ' - accept button   -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -

  call dword gpGetLText using GetLText(%AcceptBtnTop) to CtlText

  control add button, hTblFldNmDlg, %ID_AcceptBtn, CtlText, 11 ,32, 60, 15

  if Parent_X then

    control set focus hTblFldNmDlg, %ID_AcceptBtn

  else

    control set focus hTblFldNmDlg, %ID_NameTxtBx

  end if

  ' - abandon button  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -

  call dword gpGetLText using GetLText(%AbandonBtnTop) to CtlText

  control add button, hTblFldNmDlg, %ID_AbandonBtn, CtlText, 92, 32, 58, 11

  ' - pointer for result to callback and show the dialog   -  -  -  -  -  -  -  -  -  -

  dialog post hTblFldNmDlg, %dym_pStr, varptr(wNamez), 0

  dialog show modal hTblFldNmDlg call TblFldNmDlgCB

end function


Created on August 31, 2023