Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords:
Here are some UDFs.
In the following examples, you can choose: inifile or registry.
When the parameter savelocation is numeric: registry otherwise it is an inifile
#definefunction SaveWinPosXY(thisdlg, savelocation) ; usage: ButtonPushed = Dialog('MyDialog') ; SaveWinPosXY('MyDialog', savelocation) ; !! do not use buttonvalue 0 for &Cancel.... ; !! use another value and do the handling yourself %thisdlg%X = IntControl(75, 1, 0, 0, 0) %thisdlg%Y = IntControl(75, 2, 0, 0, 0) if isnumber(savelocation) ;---- savelocation is a registry key key = RegCreateKey(savelocation,'position') rtv = RegSetValue(key,'[%thisdlg%X]', %thisdlg%X) rtv = RegSetValue(key,'[%thisdlg%Y]', %thisdlg%Y) else ;---- savelocation is an inifile IniWritePvt('position','%thisdlg%X' ,%thisdlg%X,savelocation) IniWritePvt('position','%thisdlg%Y' ,%thisdlg%Y,savelocation) endif #endfunction #definefunction GetWinPosX(thisdlg, savelocation) ; usage: MyDialogX = GetWinPosX('MyDialog',savelocation) ; default value: -1 (centered) ; if isnumber(savelocation) ;---- savelocation is a registry key key = RegCreateKey(savelocation,'position') if RegExistValue(key,'[%thisdlg%X]') retvalue = RegQueryValue(key, '[%thisdlg%X]') else retvalue = -1 endif else ;---- savelocation is an inifile retvalue = IniReadPvt('position','%thisdlg%X',-1,savelocation) endif return retvalue #endfunction #definefunction GetWinPosY(thisdlg, savelocation) ; usage: MyDialogY = GetWinPosY('MyDialog',savelocation) ; default value: -1 (centered) ; if isnumber(savelocation) ;---- savelocation is a registry key key = RegCreateKey(savelocation,'position') if RegExistValue(key,'[%thisdlg%Y]') retvalue = RegQueryValue(key, '[%thisdlg%Y]') else retvalue = -1 endif else ;---- savelocation is an inifile retvalue = IniReadPvt('position','%thisdlg%Y',-1,savelocation) endif return retvalue #endfunction #definefunction ExeIniFile() ; returns an inifile with the path and root of the exefile ; exepath = IntControl(1004,0,0,0,0) return strCat(FilePath(exepath),FileRoot(exepath),'.ini') #endfunction ;savelocation = ExeIniFile() ;-- savelocation is an inifile savelocation = RegCreateKey(@REGCURRENT,'Software\WinBatch\winpos_udf') ;-- savelocation is a registry key ;--- testing....... MyDialogFormat=`WWWDLGED,5.0` MyDialogCaption=`WIL Dialog` MyDialogWidth=178 MyDialogHeight=78 MyDialogNumControls=6 MyDialog01=`82,52,64,DEFAULT,PUSHBUTTON,DEFAULT,"&Cancel",99` MyDialog02=`48,12,64,DEFAULT,VARYTEXT,MyDialogX,""` MyDialog03=`10,12,36,DEFAULT,STATICTEXT,DEFAULT,"MyDialogX ="` MyDialog04=`10,26,36,DEFAULT,STATICTEXT,DEFAULT,"MyDialogY = "` MyDialog05=`48,26,64,DEFAULT,VARYTEXT,MyDialogY,""` MyDialog06=`8,52,64,DEFAULT,PUSHBUTTON,DEFAULT,"&Try again",1` while 1 MyDialogX= GetWinPosX('MyDialog',savelocation) MyDialogY= GetWinPosY('MyDialog',savelocation) ButtonPushed=Dialog("MyDialog") SaveWinPosXY('MyDialog', savelocation) if buttonpushed==99 then exit endwhile exit
Article ID: W14991
File Created: 2001:11:08:12:41:18
Last Updated: 2001:11:08:12:41:18