The function appendfromdocx appends data from an Word 2007+ file (docx) into an open DBF or cursor
Version 1.3
- bug fixed when text in cell is broken in more pieces
Append from docx 1.3
Version 1.2
- better detection of the content of cells
Append from docx 1.2
Version 1.1
- appends the data from the docx document into an already existing and opened cursor or table.
- the field type and name are the ones from the cursor / table (no validations are performed)
- SET DATE must be set properly, to import the date and datetime fields
- a logical field is replaced with .T., if the cell contains "true", and with .F., otherwise
* 1) append all columns into the current alias
= appendfromdocx('MyWordFile.docx')
* 2) append all columns into MyTable
* MyTable must be open
= appendfromdocx('MyWordFile.docx', 'MyTable')
* 3) append only into some fields
= appendfromdocx('MyWordFile.docx' , , 'Field1,Field2')
* 4) Skip first row, and start the import with the second one
= appendfromdocx('MyWordFile.docx' , , , 2)
* 5) Import the second table form the docx document
= appendfromdocx('MyWordFile.docx' , , , , 2)
The function with some test data and prg can be downloaded from here
Append from docx 1.1
Related posts
http://praisachion.blogspot.com/2016/06/inspectpptx-10.html
http://praisachion.blogspot.com/2016/06/inspectdocx-10.html
MSOffice -> DBF
http://praisachion.blogspot.com/2017/08/importfromxlsx-40.html
http://praisachion.blogspot.com/2017/06/append-from-xlsx-30.html
http://praisachion.blogspot.com/2016/08/importfromxlsx-34.html
http://praisachion.blogspot.com/2016/08/importfromxlsx-33.html
http://praisachion.blogspot.com/2016/06/importfromxlsx-32-appendfromxlsx-21.html
http://praisachion.blogspot.com/2016/06/appendfrompptx-10.html
http://praisachion.blogspot.com/2016/06/appendfromdocx-21.html
http://praisachion.blogspot.com/2016/06/importfromdocx-31.html
http://praisachion.blogspot.com/2016/06/importfrompptx-11.html
http://praisachion.blogspot.com/2016/06/importfromxlsx-31.html
http://praisachion.blogspot.com/2016/06/importfrompptx-10.html
http://praisachion.blogspot.com/2016/06/importfromdocx-30.html
http://praisachion.blogspot.com/2016/05/importfromxlsx-22.html
http://praisachion.blogspot.com/2016/02/import-dbf-from-msoffice-2007-xlsx-docx.html
http://praisachion.blogspot.com/2016/01/importfromdocx-20.html
http://praisachion.blogspot.com/2016/01/appendfromdocx-20.html
http://praisachion.blogspot.com/2016/01/importfromxlsx-13.html
http://praisachion.blogspot.com/2016/01/appendfromxlsx-20.html
http://praisachion.blogspot.com/2015/12/appendfromxlsx-15.html
http://praisachion.blogspot.com/2015/11/importfromxlsx-13.html
http://praisachion.blogspot.com/2015/09/importfromxlsx-12.html
http://praisachion.blogspot.com/2015/09/appendfromxlsx-14.html
http://praisachion.blogspot.com/2015/09/appendfromnxlsx-13.html
http://praisachion.blogspot.com/2015/08/importfromxlsx-11.html
http://praisachion.blogspot.com/2015/07/import-from-xlsx.html
http://praisachion.blogspot.com/2015/07/insert-from-focx.html
http://praisachion.blogspot.com/2015/06/append-from-docx.html
DBF -> MSOffice
Dbf2Xlsx6 4.2 (VFP6)
http://praisachion.blogspot.com/2017/04/export-dbf-to-excel-2007.html
http://praisachion.blogspot.com/2017/01/export-dbf-to-msexcel-xlsx.html
http://praisachion.blogspot.com/2017/01/export-dbf-to-mspowerpoin-pptx.html
http://praisachion.blogspot.com/2017/01/export-dbf-to-msword-docx.html
http://praisachion.blogspot.com/2016/11/export-to-xlsx.html
http://praisachion.blogspot.com/2016/11/export-to-pptx.html
http://praisachion.blogspot.com/2016/11/export-to-docx.html
http://praisachion.blogspot.com/2016/11/export-from-vfp6-to-msoffice-docx-pptx.html
http://praisachion.blogspot.com/2016/09/copytoxlsx6-10.html
http://praisachion.blogspot.com/2016/01/export-dbf-to-msoffice-2007-xlsx-docx_24.html
http://praisachion.blogspot.com/2016/01/export-dbf-to-msoffice-2007-xlsx-docx.html
http://praisachion.blogspot.com/2016/01/exporttopptx-20.html
http://praisachion.blogspot.com/2016/01/exporttodocx-20.html
http://praisachion.blogspot.com/2016/01/copytopptx-20.html
http://praisachion.blogspot.com/2016/01/exporttoxlsx-20.html
http://praisachion.blogspot.com/2016/01/copytoxlsx-30.html
http://praisachion.blogspot.com/2015/12/exporttoxlsx-19-class.html
http://praisachion.blogspot.com/2015/12/copytoxlsx-210-procedure.html
http://praisachion.blogspot.com/2015/12/exporttoxlsx-18-class.html
http://praisachion.blogspot.com/2015/12/copytoxlsx-29.html
http://praisachion.blogspot.com/2015/02/export-pptx-13.html
http://praisachion.blogspot.com/2015/01/copytodocx-12.html
http://praisachion.blogspot.com/2015/01/exportdocx-1.html
OOffice -> DBF
http://praisachion.blogspot.com/2016/11/import-from-openoffice-libreoffice-for.html
http://praisachion.blogspot.com/2016/09/importfromoowrtext-10.html
http://praisachion.blogspot.com/2016/09/importfromooffice-1o.html
http://praisachion.blogspot.com/2016/08/importfromoocalc.html
DBF -> OOffice
http://praisachion.blogspot.com/2016/09/export-dbf-to-openoffice-libreoffice_52.html
http://praisachion.blogspot.com/2016/09/export-dbf-to-openoffice-libreoffice_16.html
http://praisachion.blogspot.com/2016/09/copy-to-ods-10-openoffice-calc.html
http://praisachion.blogspot.com/2016/09/export-dbf-to-openoffice-libreoffice.html
http://praisachion.blogspot.com/2016/09/copy-to-odt-10.html
Faceți căutări pe acest blog
marți, 30 iunie 2015
marți, 23 iunie 2015
Append from xlsx
Version 1.2
- appends the data from the xlsx document into one already existing and opened cursor or table.
- the field type and name are the ones from the cursor / table (no validations are performed)
The function appendfromxlsx appends data from an Excel 2007+ file (xlsx)
* 1) append all columns into the current alias
= appendfromxlsx('MyExcelFile.xlsx')
* 2) append all columns into MyTable
* MyTable must be open
= appendfromxlsx('MyExcelFile.xlsx', 'MyTable')
* 3) append only into some fields
= appendfromxlsx('MyExcelFile.xlsx' , , 'Field1,Field2')
* 4) Skip first row, and start the import with the second one
= appendfromxlsx('MyExcelFile.xlsx' , , , 2)
* 5) Import from a specific sheet
= appendfromxlsx('MyExcelFile.xlsx' , , , , 'Sheet name')
The function with some test data and prg can be downloaded from here
Append from xlsx 1.2
Related posts
http://praisachion.blogspot.com/2016/06/inspectpptx-10.html
http://praisachion.blogspot.com/2016/06/inspectdocx-10.html
MSOffice -> DBF
http://praisachion.blogspot.com/2017/08/importfromxlsx-40.html
http://praisachion.blogspot.com/2017/06/append-from-xlsx-30.html
http://praisachion.blogspot.com/2016/08/importfromxlsx-34.html
http://praisachion.blogspot.com/2016/08/importfromxlsx-33.html
http://praisachion.blogspot.com/2016/06/importfromxlsx-32-appendfromxlsx-21.html
http://praisachion.blogspot.com/2016/06/appendfrompptx-10.html
http://praisachion.blogspot.com/2016/06/appendfromdocx-21.html
http://praisachion.blogspot.com/2016/06/importfromdocx-31.html
http://praisachion.blogspot.com/2016/06/importfrompptx-11.html
http://praisachion.blogspot.com/2016/06/importfromxlsx-31.html
http://praisachion.blogspot.com/2016/06/importfrompptx-10.html
http://praisachion.blogspot.com/2016/06/importfromdocx-30.html
http://praisachion.blogspot.com/2016/05/importfromxlsx-22.html
http://praisachion.blogspot.com/2016/02/import-dbf-from-msoffice-2007-xlsx-docx.html
http://praisachion.blogspot.com/2016/01/importfromdocx-20.html
http://praisachion.blogspot.com/2016/01/appendfromdocx-20.html
http://praisachion.blogspot.com/2016/01/importfromxlsx-13.html
http://praisachion.blogspot.com/2016/01/appendfromxlsx-20.html
http://praisachion.blogspot.com/2015/12/appendfromxlsx-15.html
http://praisachion.blogspot.com/2015/11/importfromxlsx-13.html
http://praisachion.blogspot.com/2015/09/importfromxlsx-12.html
http://praisachion.blogspot.com/2015/09/appendfromxlsx-14.html
http://praisachion.blogspot.com/2015/09/appendfromnxlsx-13.html
http://praisachion.blogspot.com/2015/08/importfromxlsx-11.html
http://praisachion.blogspot.com/2015/07/import-from-xlsx.html
http://praisachion.blogspot.com/2015/07/insert-from-focx.html
http://praisachion.blogspot.com/2015/06/append-from-docx.html
DBF -> MSOffice
Dbf2Xlsx6 4.2 (VFP6)
http://praisachion.blogspot.com/2017/04/export-dbf-to-excel-2007.html
http://praisachion.blogspot.com/2017/01/export-dbf-to-msexcel-xlsx.html
http://praisachion.blogspot.com/2017/01/export-dbf-to-mspowerpoin-pptx.html
http://praisachion.blogspot.com/2017/01/export-dbf-to-msword-docx.html
http://praisachion.blogspot.com/2016/11/export-to-xlsx.html
http://praisachion.blogspot.com/2016/11/export-to-pptx.html
http://praisachion.blogspot.com/2016/11/export-to-docx.html
http://praisachion.blogspot.com/2016/11/export-from-vfp6-to-msoffice-docx-pptx.html
http://praisachion.blogspot.com/2016/09/copytoxlsx6-10.html
http://praisachion.blogspot.com/2016/01/export-dbf-to-msoffice-2007-xlsx-docx_24.html
http://praisachion.blogspot.com/2016/01/export-dbf-to-msoffice-2007-xlsx-docx.html
http://praisachion.blogspot.com/2016/01/exporttopptx-20.html
http://praisachion.blogspot.com/2016/01/exporttodocx-20.html
http://praisachion.blogspot.com/2016/01/copytopptx-20.html
http://praisachion.blogspot.com/2016/01/exporttoxlsx-20.html
http://praisachion.blogspot.com/2016/01/copytoxlsx-30.html
http://praisachion.blogspot.com/2015/12/exporttoxlsx-19-class.html
http://praisachion.blogspot.com/2015/12/copytoxlsx-210-procedure.html
http://praisachion.blogspot.com/2015/12/exporttoxlsx-18-class.html
http://praisachion.blogspot.com/2015/12/copytoxlsx-29.html
http://praisachion.blogspot.com/2015/02/export-pptx-13.html
http://praisachion.blogspot.com/2015/01/copytodocx-12.html
http://praisachion.blogspot.com/2015/01/exportdocx-1.html
OOffice -> DBF
http://praisachion.blogspot.com/2016/11/import-from-openoffice-libreoffice-for.html
http://praisachion.blogspot.com/2016/09/importfromoowrtext-10.html
http://praisachion.blogspot.com/2016/09/importfromooffice-1o.html
http://praisachion.blogspot.com/2016/08/importfromoocalc.html
DBF -> OOffice
http://praisachion.blogspot.com/2016/09/export-dbf-to-openoffice-libreoffice_52.html
http://praisachion.blogspot.com/2016/09/export-dbf-to-openoffice-libreoffice_16.html
http://praisachion.blogspot.com/2016/09/copy-to-ods-10-openoffice-calc.html
http://praisachion.blogspot.com/2016/09/export-dbf-to-openoffice-libreoffice.html
http://praisachion.blogspot.com/2016/09/copy-to-odt-10.html
- appends the data from the xlsx document into one already existing and opened cursor or table.
- the field type and name are the ones from the cursor / table (no validations are performed)
The function appendfromxlsx appends data from an Excel 2007+ file (xlsx)
* 1) append all columns into the current alias
= appendfromxlsx('MyExcelFile.xlsx')
* 2) append all columns into MyTable
* MyTable must be open
= appendfromxlsx('MyExcelFile.xlsx', 'MyTable')
* 3) append only into some fields
= appendfromxlsx('MyExcelFile.xlsx' , , 'Field1,Field2')
* 4) Skip first row, and start the import with the second one
= appendfromxlsx('MyExcelFile.xlsx' , , , 2)
* 5) Import from a specific sheet
= appendfromxlsx('MyExcelFile.xlsx' , , , , 'Sheet name')
The function with some test data and prg can be downloaded from here
Append from xlsx 1.2
Related posts
http://praisachion.blogspot.com/2016/06/inspectpptx-10.html
http://praisachion.blogspot.com/2016/06/inspectdocx-10.html
MSOffice -> DBF
http://praisachion.blogspot.com/2017/08/importfromxlsx-40.html
http://praisachion.blogspot.com/2017/06/append-from-xlsx-30.html
http://praisachion.blogspot.com/2016/08/importfromxlsx-34.html
http://praisachion.blogspot.com/2016/08/importfromxlsx-33.html
http://praisachion.blogspot.com/2016/06/importfromxlsx-32-appendfromxlsx-21.html
http://praisachion.blogspot.com/2016/06/appendfrompptx-10.html
http://praisachion.blogspot.com/2016/06/appendfromdocx-21.html
http://praisachion.blogspot.com/2016/06/importfromdocx-31.html
http://praisachion.blogspot.com/2016/06/importfrompptx-11.html
http://praisachion.blogspot.com/2016/06/importfromxlsx-31.html
http://praisachion.blogspot.com/2016/06/importfrompptx-10.html
http://praisachion.blogspot.com/2016/06/importfromdocx-30.html
http://praisachion.blogspot.com/2016/05/importfromxlsx-22.html
http://praisachion.blogspot.com/2016/02/import-dbf-from-msoffice-2007-xlsx-docx.html
http://praisachion.blogspot.com/2016/01/importfromdocx-20.html
http://praisachion.blogspot.com/2016/01/appendfromdocx-20.html
http://praisachion.blogspot.com/2016/01/importfromxlsx-13.html
http://praisachion.blogspot.com/2016/01/appendfromxlsx-20.html
http://praisachion.blogspot.com/2015/12/appendfromxlsx-15.html
http://praisachion.blogspot.com/2015/11/importfromxlsx-13.html
http://praisachion.blogspot.com/2015/09/importfromxlsx-12.html
http://praisachion.blogspot.com/2015/09/appendfromxlsx-14.html
http://praisachion.blogspot.com/2015/09/appendfromnxlsx-13.html
http://praisachion.blogspot.com/2015/08/importfromxlsx-11.html
http://praisachion.blogspot.com/2015/07/import-from-xlsx.html
http://praisachion.blogspot.com/2015/07/insert-from-focx.html
http://praisachion.blogspot.com/2015/06/append-from-docx.html
DBF -> MSOffice
Dbf2Xlsx6 4.2 (VFP6)
http://praisachion.blogspot.com/2017/04/export-dbf-to-excel-2007.html
http://praisachion.blogspot.com/2017/01/export-dbf-to-msexcel-xlsx.html
http://praisachion.blogspot.com/2017/01/export-dbf-to-mspowerpoin-pptx.html
http://praisachion.blogspot.com/2017/01/export-dbf-to-msword-docx.html
http://praisachion.blogspot.com/2016/11/export-to-xlsx.html
http://praisachion.blogspot.com/2016/11/export-to-pptx.html
http://praisachion.blogspot.com/2016/11/export-to-docx.html
http://praisachion.blogspot.com/2016/11/export-from-vfp6-to-msoffice-docx-pptx.html
http://praisachion.blogspot.com/2016/09/copytoxlsx6-10.html
http://praisachion.blogspot.com/2016/01/export-dbf-to-msoffice-2007-xlsx-docx_24.html
http://praisachion.blogspot.com/2016/01/export-dbf-to-msoffice-2007-xlsx-docx.html
http://praisachion.blogspot.com/2016/01/exporttopptx-20.html
http://praisachion.blogspot.com/2016/01/exporttodocx-20.html
http://praisachion.blogspot.com/2016/01/copytopptx-20.html
http://praisachion.blogspot.com/2016/01/exporttoxlsx-20.html
http://praisachion.blogspot.com/2016/01/copytoxlsx-30.html
http://praisachion.blogspot.com/2015/12/exporttoxlsx-19-class.html
http://praisachion.blogspot.com/2015/12/copytoxlsx-210-procedure.html
http://praisachion.blogspot.com/2015/12/exporttoxlsx-18-class.html
http://praisachion.blogspot.com/2015/12/copytoxlsx-29.html
http://praisachion.blogspot.com/2015/02/export-pptx-13.html
http://praisachion.blogspot.com/2015/01/copytodocx-12.html
http://praisachion.blogspot.com/2015/01/exportdocx-1.html
OOffice -> DBF
http://praisachion.blogspot.com/2016/11/import-from-openoffice-libreoffice-for.html
http://praisachion.blogspot.com/2016/09/importfromoowrtext-10.html
http://praisachion.blogspot.com/2016/09/importfromooffice-1o.html
http://praisachion.blogspot.com/2016/08/importfromoocalc.html
DBF -> OOffice
http://praisachion.blogspot.com/2016/09/export-dbf-to-openoffice-libreoffice_52.html
http://praisachion.blogspot.com/2016/09/export-dbf-to-openoffice-libreoffice_16.html
http://praisachion.blogspot.com/2016/09/copy-to-ods-10-openoffice-calc.html
http://praisachion.blogspot.com/2016/09/export-dbf-to-openoffice-libreoffice.html
http://praisachion.blogspot.com/2016/09/copy-to-odt-10.html
luni, 22 iunie 2015
Detect KeyUp (Like MouseUp)
While the mouse is reach in events (Click, DblClick, MouseDown, MouseUp, MouseMove, etc.) the keyboard is very poor in such events.
Keypress can be associated with KeyDown, but for keyUp there is no such an event.
A solution is to use Bindevent() to bind the WM_KEYUP message
PUBLIC ofrm
ofrm = CREATEOBJECT("MyForm")
SET SYSMENU OFF
ofrm.show()
DEFINE CLASS MyForm as Form
ADD OBJECT txt as textbox
ADD OBJECT cmd as commandbutton WITH top = 50
PROCEDURE Init
* BINDEVENT(This.HWnd,0x0101,This,"detectkeyup") && intercept keyup
BINDEVENT(_vfp.HWnd,0x0101,This,"detectkeyup") && intercept keyup
ENDPROC
PROCEDURE detectkeyup
LPARAMETERS p1,p2,p3,p4
* p1 = ThisForm.hwnd
* p2 - The message; 257 = 0x101 in this case
* p3 = Virtual-key code
* p4 % 65536 - the number of times the keystroke is autorepeated as a result of the user holding down the key. The repeat count is always 1 for a WM_KEYUP message
* FLOOR(p4 / 65536) % 256 - The scan code. The value depends on the OEM.
* BITTEST(p4, 24) - ndicates whether the key is an extended key, such as the right-hand ALT and CTRL keys that appear on an enhanced 101- or 102-key keyboard. The value is .t. if it is an extended key; otherwise, it is .f.
IF TYPE("This.ActiveControl") = "U"
lcObj = "ThisForm"
ELSE
lcObj = This.ActiveControl.Name
ENDIF
ACTIVATE SCREEN
? lcObj,"Virtual-key code",p3,"The scan code",FLOOR(p4 / 65536) % 256,IIF(BITTEST(p4, 24),"Extended key","Normal key")
ENDPROC
ENDDEFINE
One final note: WM_KEYDOWN is almost identical, but the value of the message is 0x0100, not 0x0101
Biblio
http://www.foxite.com/archives/detect-keypress-release-0000424382.htm
http://www.tek-tips.com/faqs.cfm?fid=7701
https://msdn.microsoft.com/en-us/library/windows/desktop/ms646281%28v=vs.85%29.aspx
http://www.win.tue.nl/~aeb/linux/kbd/scancodes-1.html
https://msdn.microsoft.com/en-us/library/aa925780.aspx
Related posts
http://praisachion.blogspot.com/2017/08/easter-eggs-4.html
http://praisachion.blogspot.com/2017/08/easter-eggs-3.html
http://praisachion.blogspot.com/2017/08/easter-eggs-2.html
http://praisachion.blogspot.com/2017/08/easter-eggs-1.html
http://praisachion.blogspot.com/2016/02/interceptin-ctrlshiftenter.html
http://praisachion.blogspot.com/2015/06/detect-keyup-like-mouseup.html
http://praisachion.blogspot.com/2015/01/how-can-i-prevent-undocking-docked-form.html
Keypress can be associated with KeyDown, but for keyUp there is no such an event.
A solution is to use Bindevent() to bind the WM_KEYUP message
PUBLIC ofrm
ofrm = CREATEOBJECT("MyForm")
SET SYSMENU OFF
ofrm.show()
DEFINE CLASS MyForm as Form
ADD OBJECT txt as textbox
ADD OBJECT cmd as commandbutton WITH top = 50
PROCEDURE Init
* BINDEVENT(This.HWnd,0x0101,This,"detectkeyup") && intercept keyup
BINDEVENT(_vfp.HWnd,0x0101,This,"detectkeyup") && intercept keyup
ENDPROC
PROCEDURE detectkeyup
LPARAMETERS p1,p2,p3,p4
* p1 = ThisForm.hwnd
* p2 - The message; 257 = 0x101 in this case
* p3 = Virtual-key code
* p4 % 65536 - the number of times the keystroke is autorepeated as a result of the user holding down the key. The repeat count is always 1 for a WM_KEYUP message
* FLOOR(p4 / 65536) % 256 - The scan code. The value depends on the OEM.
* BITTEST(p4, 24) - ndicates whether the key is an extended key, such as the right-hand ALT and CTRL keys that appear on an enhanced 101- or 102-key keyboard. The value is .t. if it is an extended key; otherwise, it is .f.
IF TYPE("This.ActiveControl") = "U"
lcObj = "ThisForm"
ELSE
lcObj = This.ActiveControl.Name
ENDIF
ACTIVATE SCREEN
? lcObj,"Virtual-key code",p3,"The scan code",FLOOR(p4 / 65536) % 256,IIF(BITTEST(p4, 24),"Extended key","Normal key")
ENDPROC
ENDDEFINE
One final note: WM_KEYDOWN is almost identical, but the value of the message is 0x0100, not 0x0101
Biblio
http://www.foxite.com/archives/detect-keypress-release-0000424382.htm
http://www.tek-tips.com/faqs.cfm?fid=7701
https://msdn.microsoft.com/en-us/library/windows/desktop/ms646281%28v=vs.85%29.aspx
http://www.win.tue.nl/~aeb/linux/kbd/scancodes-1.html
https://msdn.microsoft.com/en-us/library/aa925780.aspx
Related posts
http://praisachion.blogspot.com/2017/08/easter-eggs-4.html
http://praisachion.blogspot.com/2017/08/easter-eggs-3.html
http://praisachion.blogspot.com/2017/08/easter-eggs-2.html
http://praisachion.blogspot.com/2017/08/easter-eggs-1.html
http://praisachion.blogspot.com/2016/02/interceptin-ctrlshiftenter.html
http://praisachion.blogspot.com/2015/06/detect-keyup-like-mouseup.html
http://praisachion.blogspot.com/2015/01/how-can-i-prevent-undocking-docked-form.html
duminică, 14 iunie 2015
Enable / disable form's scrollbars
The EnableScrollBar API allows to enable or disable scrollbars.
It can be enabled or disabled all of them or only some of them.
The documentation claims that the minimum OS must be Vista.
***************
* Begin code
***************
# DEFINE SB_BOTH 3
# DEFINE SB_HORZ 0
# DEFINE SB_VERT 1
# DEFINE ESB_DISABLE_BOTH 3
# DEFINE ESB_DISABLE_DOWN 2
# DEFINE ESB_DISABLE_LEFT 1
# DEFINE ESB_DISABLE_LTUP 1
# DEFINE ESB_DISABLE_RIGHT 2
# DEFINE ESB_DISABLE_RTDN 2
# DEFINE ESB_DISABLE_UP 1
# DEFINE ESB_ENABLE_BOTH 0
DECLARE INTEGER EnableScrollBar IN user32 INTEGER hwnd, INTEGER wSBflags, INTEGER wArrows
PUBLIC ofrm
ofrm = CREATEOBJECT("MyForm")
ofrm.show()
DEFINE CLASS myform as Form
scrollbars = 3
ADD OBJECT edt as editbox WITH left=100,top=100,width=400,height=400,value=REPLICATE("Disco, Duhamel"+CHR(13),40)
ADD OBJECT chk as checkbox WITH value=.T.,caption='Enabled'
PROCEDURE chk.interactivechange
IF This.Value
EnableScrollBar(ThisForm.HWnd,SB_BOTH,ESB_ENABLE_BOTH)
ELSE
EnableScrollBar(ThisForm.HWnd,SB_BOTH,ESB_DISABLE_BOTH )
ENDIF
ENDPROC
ENDDEFINE
***************
* End code
***************
Biblio
http://www.cs.uofs.edu/~beidler/Ada/win32/win32-winuser.html
https://msdn.microsoft.com/en-us/library/windows/desktop/bb787579%28v=vs.85%29.aspx
It can be enabled or disabled all of them or only some of them.
The documentation claims that the minimum OS must be Vista.
***************
* Begin code
***************
# DEFINE SB_BOTH 3
# DEFINE SB_HORZ 0
# DEFINE SB_VERT 1
# DEFINE ESB_DISABLE_BOTH 3
# DEFINE ESB_DISABLE_DOWN 2
# DEFINE ESB_DISABLE_LEFT 1
# DEFINE ESB_DISABLE_LTUP 1
# DEFINE ESB_DISABLE_RIGHT 2
# DEFINE ESB_DISABLE_RTDN 2
# DEFINE ESB_DISABLE_UP 1
# DEFINE ESB_ENABLE_BOTH 0
DECLARE INTEGER EnableScrollBar IN user32 INTEGER hwnd, INTEGER wSBflags, INTEGER wArrows
PUBLIC ofrm
ofrm = CREATEOBJECT("MyForm")
ofrm.show()
DEFINE CLASS myform as Form
scrollbars = 3
ADD OBJECT edt as editbox WITH left=100,top=100,width=400,height=400,value=REPLICATE("Disco, Duhamel"+CHR(13),40)
ADD OBJECT chk as checkbox WITH value=.T.,caption='Enabled'
PROCEDURE chk.interactivechange
IF This.Value
EnableScrollBar(ThisForm.HWnd,SB_BOTH,ESB_ENABLE_BOTH)
ELSE
EnableScrollBar(ThisForm.HWnd,SB_BOTH,ESB_DISABLE_BOTH )
ENDIF
ENDPROC
ENDDEFINE
***************
* End code
***************
Biblio
http://www.cs.uofs.edu/~beidler/Ada/win32/win32-winuser.html
https://msdn.microsoft.com/en-us/library/windows/desktop/bb787579%28v=vs.85%29.aspx
Using GetLocaleInfo and GetLocaleInfoEx for currencies (3) HTML example
In a similar way, a HTML document can be created.
First, the GetLocaleInfo example.
****************
* Begin code
****************
Declare INTEGER GetLocaleInfo in Win32API LONG Locale, LONG LCType, STRING @LpLCData, INTEGER cchData
LOCAL LpLCData,cchData,nretval,lni,lcPos,lcSetPoint,lcPoint,lcSetSep,lcSep,lcSetDec,lcDec,lcNumber,lcCurr,lcStr
LpLCData = space(255) && Address of buffer information.
cchData = LEN(LpLCData) && Size of buffer, LpLCData.
nretval = 0 && Number returned from API call.
RAND(-1)
**************
lcSetPoint = SET("Point")
lcSetSep = SET("Separator")
lcSetDec = SET("Decimals")
*
nretval = GetLocaleInfo(1024, 0x16, @LpLCData, cchData)
lcPoint = LEFT(LpLCData,nretval-1)
SET POINT TO lcPoint
nretval = GetLocaleInfo(1024, 0x17, @LpLCData, cchData)
lcSep = LEFT(LpLCData,nretval-1)
SET SEPARATOR TO lcSep
nretval = GetLocaleInfo(1024, 0x19, @LpLCData, cchData)
lcDec = LEFT(LpLCData,nretval-1)
SET DECIMALS TO &lcDec
nretval = GetLocaleInfo(1024, 0x14, @LpLCData, cchData)
lcCurr = LEFT(LpLCData,nretval-1)
nretval = GetLocaleInfo(1024, 0x1B, @LpLCData, cchData)
lcPos = LEFT(LpLCData,nretval-1)
lcNumber = ALLTRIM(TRANSFORM(1000000 * RAND(),"###" + REPLICATE(",###" , 4) + "." + REPLICATE("9",VAL(m.lcDec))))
lcStr = [<!DOCTYPE html><html><body>]
DO CASE
CASE lcPos = "0"
lcStr = m.lcStr + m.lcCurr + m.lcNumber
CASE lcPos = "1"
lcStr = m.lcStr + m.lcNumber + m.lcCurr
CASE lcPos = "2"
lcStr = m.lcStr + m.lcCurr + " " + m.lcNumber
CASE lcPos = "3"
lcStr = m.lcStr + m.lcNumber + " " + m.lcCurr
ENDCASE
lcStr = m.lcStr + [</body></html>]
STRTOFILE(m.lcStr,"test.htm")
SET POINT TO lcSetPoint
SET SEPARATOR TO lcSetSep
SET DECIMALS TO &lcSetDec
****************
* End code
****************
Obviously, because of Unicode the GetLocaleInfoEx example is a little more complicated.
Note the reversed order of the two UNICODE bytes, between Word and HTML
****************
* Begin code
****************
Declare INTEGER GetLocaleInfoEx in Win32API String Locale, LONG LCType, STRING @LpLCData, INTEGER cchData
LOCAL LpLCData,cchData,nretval,lni,lcPos,lcSetPoint,lcPoint,lcSetSep,lcSep,lcSetDec,lcDec,lcNumber,lcCurrh,lcStrex
LpLCData = space(255) && Address of buffer information.
cchData = LEN(LpLCData) && Size of buffer, LpLCData.
nretval = 0 && Number returned from API call.
RAND(-1)
**************
lcSetPoint = SET("Point")
lcSetSep = SET("Separator")
lcSetDec = SET("Decimals")
*
nretval = GetLocaleInfoEx(Null, 0x16, @LpLCData, cchData)
lcPoint = LEFT(LpLCData,nretval-1)
SET POINT TO lcPoint
nretval = GetLocaleInfoEx(Null, 0x17, @LpLCData, cchData)
lcSep = LEFT(LpLCData,nretval-1)
SET SEPARATOR TO lcSep
nretval = GetLocaleInfoEx(Null, 0x19, @LpLCData, cchData)
lcDec = LEFT(LpLCData,nretval-1)
SET DECIMALS TO &lcDec
nretval = GetLocaleInfoEx(Null, 0x14, @LpLCData, cchData)
lcCurrh = ""
FOR lni = 1 TO nretval-1
lcCurrh = m.lcCurrh + "&#x" + RIGHT(TRANSFORM(ASC(SUBSTR(LpLCData,2*lni)),"@0"),2) + RIGHT(TRANSFORM(ASC(SUBSTR(LpLCData,2*lni-1)),"@0"),2) + ";"
NEXT
nretval = GetLocaleInfoEx(Null, 0x1B, @LpLCData, cchData)
lcPos = LEFT(LpLCData,nretval-1)
lcNumber = ALLTRIM(TRANSFORM(1000000 * RAND(),"###" + REPLICATE(",###" , 4) + "." + REPLICATE("9",VAL(m.lcDec))))
lcStrex = [<!DOCTYPE html><html><body>]
DO CASE
CASE lcPos = "0"
lcStrex = m.lcStrex + m.lcCurrh + m.lcNumber
CASE lcPos = "1"
lcStrex = m.lcStrex + m.lcNumber + m.lcCurrh
CASE lcPos = "2"
lcStrex = m.lcStrex + m.lcCurrh + " " + m.lcNumber
CASE lcPos = "3"
lcStrex = m.lcStrex + m.lcNumber + " " + m.lcCurrh
ENDCASE
lcStrex = m.lcStrex + [</body></html>]
STRTOFILE(m.lcStrex,"testex.htm")
SET POINT TO lcSetPoint
SET SEPARATOR TO lcSetSep
SET DECIMALS TO &lcSetDec
****************
* End code
****************
Related posts
http://praisachion.blogspot.com/2015/06/using-getlocaleinfo-and-getlocaleinfoex_79.html
http://praisachion.blogspot.com/2015/06/using-getlocaleinfo-and-getlocaleinfoex_14.html
http://praisachion.blogspot.com/2015/06/using-getlocaleinfo-and-getlocaleinfoex.html
First, the GetLocaleInfo example.
****************
* Begin code
****************
Declare INTEGER GetLocaleInfo in Win32API LONG Locale, LONG LCType, STRING @LpLCData, INTEGER cchData
LOCAL LpLCData,cchData,nretval,lni,lcPos,lcSetPoint,lcPoint,lcSetSep,lcSep,lcSetDec,lcDec,lcNumber,lcCurr,lcStr
LpLCData = space(255) && Address of buffer information.
cchData = LEN(LpLCData) && Size of buffer, LpLCData.
nretval = 0 && Number returned from API call.
RAND(-1)
**************
lcSetPoint = SET("Point")
lcSetSep = SET("Separator")
lcSetDec = SET("Decimals")
*
nretval = GetLocaleInfo(1024, 0x16, @LpLCData, cchData)
lcPoint = LEFT(LpLCData,nretval-1)
SET POINT TO lcPoint
nretval = GetLocaleInfo(1024, 0x17, @LpLCData, cchData)
lcSep = LEFT(LpLCData,nretval-1)
SET SEPARATOR TO lcSep
nretval = GetLocaleInfo(1024, 0x19, @LpLCData, cchData)
lcDec = LEFT(LpLCData,nretval-1)
SET DECIMALS TO &lcDec
nretval = GetLocaleInfo(1024, 0x14, @LpLCData, cchData)
lcCurr = LEFT(LpLCData,nretval-1)
nretval = GetLocaleInfo(1024, 0x1B, @LpLCData, cchData)
lcPos = LEFT(LpLCData,nretval-1)
lcNumber = ALLTRIM(TRANSFORM(1000000 * RAND(),"###" + REPLICATE(",###" , 4) + "." + REPLICATE("9",VAL(m.lcDec))))
lcStr = [<!DOCTYPE html><html><body>]
DO CASE
CASE lcPos = "0"
lcStr = m.lcStr + m.lcCurr + m.lcNumber
CASE lcPos = "1"
lcStr = m.lcStr + m.lcNumber + m.lcCurr
CASE lcPos = "2"
lcStr = m.lcStr + m.lcCurr + " " + m.lcNumber
CASE lcPos = "3"
lcStr = m.lcStr + m.lcNumber + " " + m.lcCurr
ENDCASE
lcStr = m.lcStr + [</body></html>]
STRTOFILE(m.lcStr,"test.htm")
SET POINT TO lcSetPoint
SET SEPARATOR TO lcSetSep
SET DECIMALS TO &lcSetDec
****************
* End code
****************
Obviously, because of Unicode the GetLocaleInfoEx example is a little more complicated.
Note the reversed order of the two UNICODE bytes, between Word and HTML
****************
* Begin code
****************
Declare INTEGER GetLocaleInfoEx in Win32API String Locale, LONG LCType, STRING @LpLCData, INTEGER cchData
LOCAL LpLCData,cchData,nretval,lni,lcPos,lcSetPoint,lcPoint,lcSetSep,lcSep,lcSetDec,lcDec,lcNumber,lcCurrh,lcStrex
LpLCData = space(255) && Address of buffer information.
cchData = LEN(LpLCData) && Size of buffer, LpLCData.
nretval = 0 && Number returned from API call.
RAND(-1)
**************
lcSetPoint = SET("Point")
lcSetSep = SET("Separator")
lcSetDec = SET("Decimals")
*
nretval = GetLocaleInfoEx(Null, 0x16, @LpLCData, cchData)
lcPoint = LEFT(LpLCData,nretval-1)
SET POINT TO lcPoint
nretval = GetLocaleInfoEx(Null, 0x17, @LpLCData, cchData)
lcSep = LEFT(LpLCData,nretval-1)
SET SEPARATOR TO lcSep
nretval = GetLocaleInfoEx(Null, 0x19, @LpLCData, cchData)
lcDec = LEFT(LpLCData,nretval-1)
SET DECIMALS TO &lcDec
nretval = GetLocaleInfoEx(Null, 0x14, @LpLCData, cchData)
lcCurrh = ""
FOR lni = 1 TO nretval-1
lcCurrh = m.lcCurrh + "&#x" + RIGHT(TRANSFORM(ASC(SUBSTR(LpLCData,2*lni)),"@0"),2) + RIGHT(TRANSFORM(ASC(SUBSTR(LpLCData,2*lni-1)),"@0"),2) + ";"
NEXT
nretval = GetLocaleInfoEx(Null, 0x1B, @LpLCData, cchData)
lcPos = LEFT(LpLCData,nretval-1)
lcNumber = ALLTRIM(TRANSFORM(1000000 * RAND(),"###" + REPLICATE(",###" , 4) + "." + REPLICATE("9",VAL(m.lcDec))))
lcStrex = [<!DOCTYPE html><html><body>]
DO CASE
CASE lcPos = "0"
lcStrex = m.lcStrex + m.lcCurrh + m.lcNumber
CASE lcPos = "1"
lcStrex = m.lcStrex + m.lcNumber + m.lcCurrh
CASE lcPos = "2"
lcStrex = m.lcStrex + m.lcCurrh + " " + m.lcNumber
CASE lcPos = "3"
lcStrex = m.lcStrex + m.lcNumber + " " + m.lcCurrh
ENDCASE
lcStrex = m.lcStrex + [</body></html>]
STRTOFILE(m.lcStrex,"testex.htm")
SET POINT TO lcSetPoint
SET SEPARATOR TO lcSetSep
SET DECIMALS TO &lcSetDec
****************
* End code
****************
Related posts
http://praisachion.blogspot.com/2015/06/using-getlocaleinfo-and-getlocaleinfoex_79.html
http://praisachion.blogspot.com/2015/06/using-getlocaleinfo-and-getlocaleinfoex_14.html
http://praisachion.blogspot.com/2015/06/using-getlocaleinfo-and-getlocaleinfoex.html
Using GetLocaleInfo and GetLocaleInfoEx for currencies (2) Word automation example
The information given by GetLocaleInfo and GetLocaleInfoEx, can be used to write formatted numbers in Word, using automation.
The first example use GetLocaleInfo
Because the values returned by GetLocaleInfo are ASCII, it's easy to use them.
****************
* Begin code
****************
Declare INTEGER GetLocaleInfo in Win32API LONG Locale, LONG LCType, STRING @LpLCData, INTEGER cchData
LOCAL LpLCData,cchData,nretval,lni,lcCurr,lcPos,lcSetPoint,lcPoint,lcSetSep,lcSep,lcSetDec,lcDec,lcNumber,oWrd,oDoc,oRange
LCData = space(255) && Address of buffer information.
cchData = LEN(LpLCData) && Size of buffer, LpLCData.
nretval = 0 && Number returned from API call.
RAND(-1)
**************
lcSetPoint = SET("Point")
lcSetSep = SET("Separator")
lcSetDec = SET("Decimals")
oWrd = CREATEOBJECT("Word.application")
oDoc = oWrd.documents.add()
orange=odoc.range()
*
nretval = GetLocaleInfo(1024, 0x16, @LpLCData, cchData)
lcPoint = LEFT(LpLCData,nretval-1)
SET POINT TO lcPoint
nretval = GetLocaleInfo(1024, 0x17, @LpLCData, cchData)
lcSep = LEFT(LpLCData,nretval-1)
SET SEPARATOR TO lcSep
nretval = GetLocaleInfo(1024, 0x19, @LpLCData, cchData)
lcDec = LEFT(LpLCData,nretval-1)
SET DECIMALS TO &lcDec
nretval = GetLocaleInfo(1024, 0x14, @LpLCData, cchData)
lcCurr = LEFT(LpLCData,nretval-1)
nretval = GetLocaleInfo(1024, 0x1B, @LpLCData, cchData)
lcPos = LEFT(LpLCData,nretval-1)
lcNumber = ALLTRIM(TRANSFORM(1000000 * RAND(),"###" + REPLICATE(",###" , 4) + "." + REPLICATE("9",VAL(m.lcDec))))
DO CASE
CASE lcPos = "0"
orange.text = m.lcCurr + m.lcNumber
CASE lcPos = "1"
orange.text = m.lcNumber + m.lcCurr
CASE lcPos = "2"
orange.text = m.lcCurr + " " + m.lcNumber
CASE lcPos = "3"
orange.text = m.lcNumber + " " + m.lcCurr
ENDCASE
oWrd.visible = .T.
SET POINT TO lcSetPoint
SET SEPARATOR TO lcSetSep
SET DECIMALS TO &lcSetDec
****************
* End code
****************
The second example use GetLocaleInfoEx
Because the values returned by GetLocaleInfoEx are UNICODE, it's a little more complicated.
Each UNICODE character has two bytes, and to because it's easier to insert strings into Word, I build up a blob constant.
****************
* Begin code
****************
Declare INTEGER GetLocaleInfoEx in Win32API String Locale, LONG LCType, STRING @LpLCData, INTEGER cchData
LOCAL LpLCData,cchData,nretval,lni,lcCurr,lcPos,lcSetPoint,lcPoint,lcSetSep,lcSep,lcSetDec,lcDec,lcNumber,oWrd,oDoc,oRange
LCData = space(255) && Address of buffer information.
cchData = LEN(LpLCData) && Size of buffer, LpLCData.
nretval = 0 && Number returned from API call.
RAND(-1)
**************
lcSetPoint = SET("Point")
lcSetSep = SET("Separator")
lcSetDec = SET("Decimals")
oWrd = CREATEOBJECT("Word.application")
oDoc = oWrd.documents.add()
orange=odoc.range()
*
nretval = GetLocaleInfoEx(Null, 0x16, @LpLCData, cchData)
lcPoint = LEFT(LpLCData,nretval-1)
SET POINT TO lcPoint
nretval = GetLocaleInfoEx(Null, 0x17, @LpLCData, cchData)
lcSep = LEFT(LpLCData,nretval-1)
SET SEPARATOR TO lcSep
nretval = GetLocaleInfoEx(Null, 0x19, @LpLCData, cchData)
lcDec = LEFT(LpLCData,nretval-1)
SET DECIMALS TO &lcDec
nretval = GetLocaleInfoEx(Null, 0x14, @LpLCData, cchData)
lcCurr = "0h"
FOR lni = 1 TO nretval-1
lcCurr = m.lcCurr + RIGHT(TRANSFORM(ASC(SUBSTR(LpLCData,2*lni-1)),"@0"),2) + RIGHT(TRANSFORM(ASC(SUBSTR(LpLCData,2*lni)),"@0"),2)
NEXT
nretval = GetLocaleInfoEx(Null, 0x1B, @LpLCData, cchData)
lcPos = LEFT(LpLCData,nretval-1)
lcNumber = ALLTRIM(TRANSFORM(1000000 * RAND(),"###" + REPLICATE(",###" , 4) + "." + REPLICATE("9",VAL(m.lcDec))))
DO CASE
CASE lcPos = "0"
orange.text = EVALUATE(m.lcCurr)
orange.insertafter(m.lcNumber)
CASE lcPos = "1"
orange.text = m.lcNumber
orange.insertafter(EVALUATE(m.lcCurr))
CASE lcPos = "2"
orange.text = EVALUATE(m.lcCurr)
orange.insertafter(" " + m.lcNumber)
CASE lcPos = "3"
orange.text = m.lcNumber + " "
orange.insertafter(EVALUATE(m.lcCurr))
ENDCASE
oWrd.visible = .T.
SET POINT TO lcSetPoint
SET SEPARATOR TO lcSetSep
SET DECIMALS TO &lcSetDec
****************
* End code
****************
Related posts
http://praisachion.blogspot.com/2015/06/using-getlocaleinfo-and-getlocaleinfoex_79.html
http://praisachion.blogspot.com/2015/06/using-getlocaleinfo-and-getlocaleinfoex_14.html
http://praisachion.blogspot.com/2015/06/using-getlocaleinfo-and-getlocaleinfoex.html
The first example use GetLocaleInfo
Because the values returned by GetLocaleInfo are ASCII, it's easy to use them.
****************
* Begin code
****************
Declare INTEGER GetLocaleInfo in Win32API LONG Locale, LONG LCType, STRING @LpLCData, INTEGER cchData
LOCAL LpLCData,cchData,nretval,lni,lcCurr,lcPos,lcSetPoint,lcPoint,lcSetSep,lcSep,lcSetDec,lcDec,lcNumber,oWrd,oDoc,oRange
LCData = space(255) && Address of buffer information.
cchData = LEN(LpLCData) && Size of buffer, LpLCData.
nretval = 0 && Number returned from API call.
RAND(-1)
**************
lcSetPoint = SET("Point")
lcSetSep = SET("Separator")
lcSetDec = SET("Decimals")
oWrd = CREATEOBJECT("Word.application")
oDoc = oWrd.documents.add()
orange=odoc.range()
*
nretval = GetLocaleInfo(1024, 0x16, @LpLCData, cchData)
lcPoint = LEFT(LpLCData,nretval-1)
SET POINT TO lcPoint
nretval = GetLocaleInfo(1024, 0x17, @LpLCData, cchData)
lcSep = LEFT(LpLCData,nretval-1)
SET SEPARATOR TO lcSep
nretval = GetLocaleInfo(1024, 0x19, @LpLCData, cchData)
lcDec = LEFT(LpLCData,nretval-1)
SET DECIMALS TO &lcDec
nretval = GetLocaleInfo(1024, 0x14, @LpLCData, cchData)
lcCurr = LEFT(LpLCData,nretval-1)
nretval = GetLocaleInfo(1024, 0x1B, @LpLCData, cchData)
lcPos = LEFT(LpLCData,nretval-1)
lcNumber = ALLTRIM(TRANSFORM(1000000 * RAND(),"###" + REPLICATE(",###" , 4) + "." + REPLICATE("9",VAL(m.lcDec))))
DO CASE
CASE lcPos = "0"
orange.text = m.lcCurr + m.lcNumber
CASE lcPos = "1"
orange.text = m.lcNumber + m.lcCurr
CASE lcPos = "2"
orange.text = m.lcCurr + " " + m.lcNumber
CASE lcPos = "3"
orange.text = m.lcNumber + " " + m.lcCurr
ENDCASE
oWrd.visible = .T.
SET POINT TO lcSetPoint
SET SEPARATOR TO lcSetSep
SET DECIMALS TO &lcSetDec
****************
* End code
****************
The second example use GetLocaleInfoEx
Because the values returned by GetLocaleInfoEx are UNICODE, it's a little more complicated.
Each UNICODE character has two bytes, and to because it's easier to insert strings into Word, I build up a blob constant.
****************
* Begin code
****************
Declare INTEGER GetLocaleInfoEx in Win32API String Locale, LONG LCType, STRING @LpLCData, INTEGER cchData
LOCAL LpLCData,cchData,nretval,lni,lcCurr,lcPos,lcSetPoint,lcPoint,lcSetSep,lcSep,lcSetDec,lcDec,lcNumber,oWrd,oDoc,oRange
LCData = space(255) && Address of buffer information.
cchData = LEN(LpLCData) && Size of buffer, LpLCData.
nretval = 0 && Number returned from API call.
RAND(-1)
**************
lcSetPoint = SET("Point")
lcSetSep = SET("Separator")
lcSetDec = SET("Decimals")
oWrd = CREATEOBJECT("Word.application")
oDoc = oWrd.documents.add()
orange=odoc.range()
*
nretval = GetLocaleInfoEx(Null, 0x16, @LpLCData, cchData)
lcPoint = LEFT(LpLCData,nretval-1)
SET POINT TO lcPoint
nretval = GetLocaleInfoEx(Null, 0x17, @LpLCData, cchData)
lcSep = LEFT(LpLCData,nretval-1)
SET SEPARATOR TO lcSep
nretval = GetLocaleInfoEx(Null, 0x19, @LpLCData, cchData)
lcDec = LEFT(LpLCData,nretval-1)
SET DECIMALS TO &lcDec
nretval = GetLocaleInfoEx(Null, 0x14, @LpLCData, cchData)
lcCurr = "0h"
FOR lni = 1 TO nretval-1
lcCurr = m.lcCurr + RIGHT(TRANSFORM(ASC(SUBSTR(LpLCData,2*lni-1)),"@0"),2) + RIGHT(TRANSFORM(ASC(SUBSTR(LpLCData,2*lni)),"@0"),2)
NEXT
nretval = GetLocaleInfoEx(Null, 0x1B, @LpLCData, cchData)
lcPos = LEFT(LpLCData,nretval-1)
lcNumber = ALLTRIM(TRANSFORM(1000000 * RAND(),"###" + REPLICATE(",###" , 4) + "." + REPLICATE("9",VAL(m.lcDec))))
DO CASE
CASE lcPos = "0"
orange.text = EVALUATE(m.lcCurr)
orange.insertafter(m.lcNumber)
CASE lcPos = "1"
orange.text = m.lcNumber
orange.insertafter(EVALUATE(m.lcCurr))
CASE lcPos = "2"
orange.text = EVALUATE(m.lcCurr)
orange.insertafter(" " + m.lcNumber)
CASE lcPos = "3"
orange.text = m.lcNumber + " "
orange.insertafter(EVALUATE(m.lcCurr))
ENDCASE
oWrd.visible = .T.
SET POINT TO lcSetPoint
SET SEPARATOR TO lcSetSep
SET DECIMALS TO &lcSetDec
****************
* End code
****************
Related posts
http://praisachion.blogspot.com/2015/06/using-getlocaleinfo-and-getlocaleinfoex_79.html
http://praisachion.blogspot.com/2015/06/using-getlocaleinfo-and-getlocaleinfoex_14.html
http://praisachion.blogspot.com/2015/06/using-getlocaleinfo-and-getlocaleinfoex.html
Using GetLocaleInfo and GetLocaleInfoEx for currencies (1)
GetLocaleInfo and GetLocaleInfoEx can be used to get the local settings for currencies (the ones from Control Panel -> Regional Settings)
Both GetLocaleInfo and GetLocaleInfoEx gives plenty of informations. They can be invoked similarly, and gives similar results.
The main difference between the the functions signature is the first parameter. GetLocaleInfo have a LONG parameter, while GetLocaleInfoEx a character parameter.
GetLocaleInfo can be used in Windows XP, Vista and above. GetLocaleInfo tends to become deprecated.
GetLocaleInfoEx can be used in Windows Vista and above, but cannot be used in Windows XP.
GetLocaleInfo provide ASCII results, while GetLocaleInfoEx supports Unicode.
This means many currencies (like English India) can be obtained only with GetLocaleInfoEx.
To get the values for the default settings, the first parameter of GetLocaleInfoEx must be Null.
For other values, use the format <language> - <REGION>, but converted to Unicode
For example
StrConv ("en-AU", 5) + CHR (0)
or
StrConv ("en-US", 5) + CHR (0)
****************
* Begin code
****************
Declare INTEGER GetLocaleInfo in Win32API LONG Locale, LONG LCType, STRING @LpLCData, INTEGER cchData
Declare INTEGER GetLocaleInfoEx in Win32API String Locale, LONG LCType, STRING @LpLCData, INTEGER cchData
LOCAL LpLCData,cchData,nretval
LpLCData = space(255) && Address of buffer information.
cchData = LEN(LpLCData) && Size of buffer, LpLCData.
nretval = 0 && Number returned from API call.
? "currency symbol - user default"
LPCWSTR = Null
nretval = GetLocaleInfoEx(LPCWSTR, 0x14, @LpLCData, cchData)
?nretval,LpLCData,TRANSFORM(ASC(SUBSTR(LpLCData,2)),"@0"),TRANSFORM(ASC(LpLCData),"@0") && Euro (Unicode 0x20 0x0AC)
? "currency symbol - english - Great Britain"
LPCWSTR = STRCONV("en-GB",5)+CHR(0)
nretval = GetLocaleInfoEx(LPCWSTR, 0x14, @LpLCData, cchData)
?nretval,LpLCData,TRANSFORM(ASC(SUBSTR(LpLCData,2)),"@0"),TRANSFORM(ASC(LpLCData),"@0") && pounds (Unicode 0x000 0x0A3 ou ASCII 0xA3)
? "currency symbol"
nretval = GetLocaleInfo(1024, 0x14, @LpLCData, cchData)
?nretval,LEFT(LpLCData,nretval-1)
nretval = GetLocaleInfoEx(Null, 0x14, @LpLCData, cchData)
?nretval
FOR lni = 1 TO nretval-1
?? TRANSFORM(ASC(SUBSTR(LpLCData,2*lni)),"@0"),TRANSFORM(ASC(SUBSTR(LpLCData,2*lni-1)),"@0")
NEXT
? "currency position"
nretval = GetLocaleInfoEx(Null, 0x1B, @LpLCData, cchData)
?nretval,LpLCData
? "decimal separator"
nretval = GetLocaleInfoEx(Null, 0x16, @LpLCData, cchData)
?nretval,LpLCData
? "thousand separator"
nretval = GetLocaleInfoEx(Null, 0x17, @LpLCData, cchData)
?nretval,LpLCData
? "number of decimals"
nretval = GetLocaleInfoEx(Null, 0x19, @LpLCData, cchData)
?nretval,LpLCData
****************
* End code
****************
Biblio
http://www.foxite.com/archives/getlocaleinfoex-fountain-of-knowledge-0000424218.htm
ftp://ftp.microsoft.com/misc1/DEVELOPR/FOX/KB/Q177/1/46.TXT
https://msdn.microsoft.com/en-us/library/windows/desktop/dd318103%28v=vs.85%29.aspx
https://msdn.microsoft.com/en-us/library/windows/desktop/dd318101%28v=vs.85%29.aspx
https://msdn.microsoft.com/en-us/library/windows/desktop/dd464799%28v=vs.85%29.aspx
https://msdn.microsoft.com/en-us/library/windows/desktop/dd373755%28v=vs.85%29.aspx
http://www.pinvoke.net/default.aspx/kernel32/GetLocaleInfoEx.html
Related posts
http://praisachion.blogspot.com/2015/06/using-getlocaleinfo-and-getlocaleinfoex_79.html
http://praisachion.blogspot.com/2015/06/using-getlocaleinfo-and-getlocaleinfoex_14.html
http://praisachion.blogspot.com/2015/06/using-getlocaleinfo-and-getlocaleinfoex.html
Abonați-vă la:
Postări (Atom)