Alaska Software Inc. - how to store XbpIcon() in DBF ?
Username: Password:
AuthorTopic: how to store XbpIcon() in DBF ?
Jim Leehow to store XbpIcon() in DBF ?
on Fri, 02 Nov 2018 10:04:26 +0100
hi,

i know how to store XbpBitmap() into DBF but i have Problem with XbpIcon() ?

need some Advice, thx
Carlos A Beling Re: how to store XbpIcon() in DBF ?
on Fri, 02 Nov 2018 09:20:31 -0300
Hi Jim.
Good morning.
Did you already see:
	XbpIcon:getBitmap()
	Returns the icon image as an XbpBitmap object.
May it be that you save it as file and load its string (FRead()) could 
it solve your problem?

Fraternally
Beling


Em 02/11/2018 06:04, Jim Lee escreveu:
> hi,
>
> i know how to store XbpBitmap() into DBF but i have Problem with XbpIcon() ?
>
> need some Advice, thx
>
>
Jim LeeRe: how to store XbpIcon() in DBF ?
on Fri, 02 Nov 2018 21:54:01 +0100
> XbpIcon:getBitmap()
> Returns the icon image as an XbpBitmap object.

no while o:getBitmap() return Bitmap without Transparency

> May it be that you save it as file and load its string (FRead()) could it 
> solve your problem?

that why i want to store hole Icon (String) in DBF so
1.) what Type of DBF (Foxcdx) ?
2.) what Type of  Field "M" oder "V" ?
3.) how to convert ? cBin2Hex / cHex2Bin ?
Carlos A Beling Re: how to store XbpIcon() in DBF ?
on Sat, 03 Nov 2018 12:09:45 -0300
Hi JIm:
good morning.
I think that both can to be used. I normally use 'M' for to hold 
encripted data.
You can use too: dbf->memmofield := Var2Bin(oMyIcon) and, later, using 
oMyIcon := Bin2Var(dbf->memofield.)

Fraternally
Beling


Em 02/11/2018 17:54, Jim Lee escreveu:
>> XbpIcon:getBitmap()
>> Returns the icon image as an XbpBitmap object.
>
> no while o:getBitmap() return Bitmap without Transparency
>
>> May it be that you save it as file and load its string (FRead()) could it
>> solve your problem?
>
> that why i want to store hole Icon (String) in DBF so
> 1.) what Type of DBF (Foxcdx) ?
> 2.) what Type of  Field "M" oder "V" ?
> 3.) how to convert ? cBin2Hex / cHex2Bin ?
>
>
>
Jim LeeRe: how to store XbpIcon() in DBF ?
on Sun, 04 Nov 2018 02:59:08 +0100
hi,

> I think that both can to be used. I normally use 'M' for to hold encripted
> data.
> You can use too: dbf->memmofield := Var2Bin(oMyIcon) and, later, using
> oMyIcon := Bin2Var(dbf->memofield.)

have try FoxPro and Type "V" but get Error when restore from DBF/FPT
not about Object but all Member are empty 

---

when look into \SOURCE\SYS\xbparts.prg like
METHOD XbpIcon:Load()
METHOD XbpIcon:LoadFile()

it produce a ::Handle (HICON) which i guess is missing when restore from 
Bin2Var(dbf->memofield.)
looking at
METHOD XbpIcon:SaveFile( )
it seems more complicate than i hope ... i will try other Way

thx for help
Carlos A Beling Re: how to store XbpIcon() in DBF ?
on Mon, 05 Nov 2018 10:18:11 -0200
Hi Jim.
God morning.
I do not have problem with binary fields in memos with type 'M'.
Please try to use dbf->memo := Var2Bin(XbpIcon) for saving the XbpIcon 
and XbpIcon := Bin2Var(dbf->memo). It is working fine .

Fraternally
Beling

Em 03/11/2018 22:59, Jim Lee escreveu:
> hi,
>
>> I think that both can to be used. I normally use 'M' for to hold encripted
>> data.
>> You can use too: dbf->memmofield := Var2Bin(oMyIcon) and, later, using
>> oMyIcon := Bin2Var(dbf->memofield.)
>
> have try FoxPro and Type "V" but get Error when restore from DBF/FPT
> not about Object but all Member are empty 
>
> ---
>
> when look into \SOURCE\SYS\xbparts.prg like
> METHOD XbpIcon:Load()
> METHOD XbpIcon:LoadFile()
>
> it produce a ::Handle (HICON) which i guess is missing when restore from
> Bin2Var(dbf->memofield.)
> looking at
> METHOD XbpIcon:SaveFile( )
> it seems more complicate than i hope ... i will try other Way
>
> thx for help
>
>
>
>
>
>
Jim LeeRe: how to store XbpIcon() in DBF ?
on Mon, 05 Nov 2018 23:22:13 +0100
hi,

> I do not have problem with binary fields in memos with type 'M'.
> Please try to use dbf->memo := Var2Bin(XbpIcon) for saving the XbpIcon
> and XbpIcon := Bin2Var(dbf->memo). It is working fine .

hm ... i have change from "V" to Type "M" (10) and still have same Problem

FUNCTION SEEKICON(cDLL,nRes,oIcon)
LOCAL cSeek, oBMP

   cSeek := SUBSTR(cDLL+SPACE(32),1,32)
   cSeek += STRZERO(nRes,10)
   SEEK(cSeek)

   IF FOUND()
   ELSE
      APPEND BLANK
      REPLACE SYSICO->DLLNAME WITH cDLL
      REPLACE SYSICO->RESNO   WITH nRes
      REPLACE SYSICO->OSVER   WITH OS(OS_VERSION)
      IF !EMPTY(oIcon)
         REPLACE SYSICO->ICON  WITH VAR2BIN(oIcon)
      ENDIF
   ENDIF
return(.t.)

* --------------------------------------- *

   GO TOP
   FOR j := jMax TO 1 STEP -1
      FOR i := 1 TO iMax
*         oIcon := XbpIcon():New():Create()
*         oIcon:load(cDLL,nIcon)
         oIcon := BIN2VAR(SYSICO->ICON)

* --------------------------------------- *

as i say all Property are empty so no Icon are shown




Restore_Icon.JPG
Andreas Gehrs-Pahl
Re: how to store XbpIcon() in DBF ?
on Mon, 05 Nov 2018 19:52:45 -0500
Carlos,

>I do not have problem with binary fields in memos with type 'M'.
>Please try to use dbf->memo := Var2Bin(XbpIcon) for saving the XbpIcon 
>and XbpIcon := Bin2Var(dbf->memo). It is working fine.

I doubt that very much. You can't (safely) store binary data in a non-binary 
(DBF) "M" memo field. Var2Bin() can contain Ctrl-Z -- chr(26)/hex 1A -- 
bytes, which will corrupt (terminate) Memo field values.

Additionally, "M" Memo fields are also subject to implicit Character Set 
conversions by the Xbase++ runtime/DBE (Database Engine). This will convert 
various non-ASCII (8-bit) characters, modifying and potentially corrupting 
the resulting binary data, depending on the CharSet settings used by the 
runtime and the database table.

If you want to use a standard "M" Memo field, you need to encode the data as 
ASCII text, using one of the many available encoding schemes, like Base64, 
Bin2Hex, UUEncode, or even Quoted-Printable.

Additionally, using Var2Bin() on an object that requires OS Resources, such 
as XbParts as well as Bitmaps and Icons, will leave the object incomplete 
or un-initialized after a corresponding Bin2Var(). To fix this, you need to 
overload the ":NotifyLoaded()" method of the objects' Class, to do some 
post-restore work, which might be complicated or even impossible.

In any case, Var2Bin(oIcon) returns a 60 byte binary string (without any
iVars!) and restoring the XbpIcon object with Bin2Var(cBinary) will give you 
an empty XbpIcon object with all iVars set to NIL!

In case of Icons, it is therefore much better to save them as a file and 
then either save the (binary) file contents directly in a binary Memo field 
("V" or "Z") or encoded in a standard Memo field ("M" or "R"). Of course, 
the simplest option is to just save the file name in a character field and 
load the Icon directly from disk, rather than saving it in the database.

Andreas

Andreas Gehrs-Pahl
Absolute Software, LLC

phone: (989) 723-9927
email: Andreas@AbsoluteSoftwareLLC.com
web:   http://www.AbsoluteSoftwareLLC.com
[F]:   https://www.facebook.com/AbsoluteSoftwareLLC
Jim LeeRe: how to store XbpIcon() in DBF ?
on Tue, 06 Nov 2018 22:53:45 +0100
hi,

thx for Answer.

normal i use Ico as Resource in DLL but in this case i have try to store 
them into DBF.
while XbpIcon have no o:SetBuffer() i was not sure how to store them so i 
ask in News Group.

but it was just a Question and i do not need to store (hole) XbpIcon 
(Object) into DBF.
Thx again for Anwser
Carlos A Beling Re: how to store XbpIcon() in DBF ?
on Thu, 08 Nov 2018 09:20:18 -0200
Hello Andreas:
good morning.
Many thanks again.
I am using for to store binary fields in memo files type  "M" without 
problems for a long time. But I never used it for to store Xbase parts.
It is very good to know what you posted because I would loosing many 
time trying to correct an error that could not to be corrected.
The approach that I use is to create the DBF file using charset ANSI.

Fraternally
Beling

Em 05/11/2018 22:52, Andreas Gehrs-Pahl escreveu:
> Carlos,
>
>> I do not have problem with binary fields in memos with type 'M'.
>> Please try to use dbf->memo := Var2Bin(XbpIcon) for saving the XbpIcon
>> and XbpIcon := Bin2Var(dbf->memo). It is working fine.
>
> I doubt that very much. You can't (safely) store binary data in a non-binary
> (DBF) "M" memo field. Var2Bin() can contain Ctrl-Z -- chr(26)/hex 1A --
> bytes, which will corrupt (terminate) Memo field values.
>
> Additionally, "M" Memo fields are also subject to implicit Character Set
> conversions by the Xbase++ runtime/DBE (Database Engine). This will convert
> various non-ASCII (8-bit) characters, modifying and potentially corrupting
> the resulting binary data, depending on the CharSet settings used by the
> runtime and the database table.
>
> If you want to use a standard "M" Memo field, you need to encode the data as
> ASCII text, using one of the many available encoding schemes, like Base64,
> Bin2Hex, UUEncode, or even Quoted-Printable.
>
> Additionally, using Var2Bin() on an object that requires OS Resources, such
> as XbParts as well as Bitmaps and Icons, will leave the object incomplete
> or un-initialized after a corresponding Bin2Var(). To fix this, you need to
> overload the ":NotifyLoaded()" method of the objects' Class, to do some
> post-restore work, which might be complicated or even impossible.
>
> In any case, Var2Bin(oIcon) returns a 60 byte binary string (without any
> iVars!) and restoring the XbpIcon object with Bin2Var(cBinary) will give you
> an empty XbpIcon object with all iVars set to NIL!
>
> In case of Icons, it is therefore much better to save them as a file and
> then either save the (binary) file contents directly in a binary Memo field
> ("V" or "Z") or encoded in a standard Memo field ("M" or "R"). Of course,
> the simplest option is to just save the file name in a character field and
> load the Icon directly from disk, rather than saving it in the database.
>
> Andreas
>
Carlos A Beling Re: how to store XbpIcon() in DBF ?
on Tue, 20 Nov 2018 09:25:02 -0200
Hello all:
good morning.
I made a mistake when I said that I used data encrypted in fields type 
'M'. Sorry. I use them in 'X' type fields in Dbes FoxCdx.
Excuse me.
Fraternally
Beling

Em 08/11/2018 09:20, Carlos A Beling escreveu:
> Hello Andreas:
> good morning.
> Many thanks again.
> I am using for to store binary fields in memo files type  "M" without
> problems for a long time. But I never used it for to store Xbase parts.
> It is very good to know what you posted because I would loosing many
> time trying to correct an error that could not to be corrected.
> The approach that I use is to create the DBF file using charset ANSI.
>
> Fraternally
> Beling
>
> Em 05/11/2018 22:52, Andreas Gehrs-Pahl escreveu:
>> Carlos,
>>
>>> I do not have problem with binary fields in memos with type 'M'.
>>> Please try to use dbf->memo := Var2Bin(XbpIcon) for saving the XbpIcon
>>> and XbpIcon := Bin2Var(dbf->memo). It is working fine.
>>
>> I doubt that very much. You can't (safely) store binary data in a
>> non-binary
>> (DBF) "M" memo field. Var2Bin() can contain Ctrl-Z -- chr(26)/hex 1A --
>> bytes, which will corrupt (terminate) Memo field values.
>>
>> Additionally, "M" Memo fields are also subject to implicit Character Set
>> conversions by the Xbase++ runtime/DBE (Database Engine). This will
>> convert
>> various non-ASCII (8-bit) characters, modifying and potentially
>> corrupting
>> the resulting binary data, depending on the CharSet settings used by the
>> runtime and the database table.
>>
>> If you want to use a standard "M" Memo field, you need to encode the
>> data as
>> ASCII text, using one of the many available encoding schemes, like
>> Base64,
>> Bin2Hex, UUEncode, or even Quoted-Printable.
>>
>> Additionally, using Var2Bin() on an object that requires OS Resources,
>> such
>> as XbParts as well as Bitmaps and Icons, will leave the object incomplete
>> or un-initialized after a corresponding Bin2Var(). To fix this, you
>> need to
>> overload the ":NotifyLoaded()" method of the objects' Class, to do some
>> post-restore work, which might be complicated or even impossible.
>>
>> In any case, Var2Bin(oIcon) returns a 60 byte binary string (without any
>> iVars!) and restoring the XbpIcon object with Bin2Var(cBinary) will
>> give you
>> an empty XbpIcon object with all iVars set to NIL!
>>
>> In case of Icons, it is therefore much better to save them as a file and
>> then either save the (binary) file contents directly in a binary Memo
>> field
>> ("V" or "Z") or encoded in a standard Memo field ("M" or "R"). Of course,
>> the simplest option is to just save the file name in a character field
>> and
>> load the Icon directly from disk, rather than saving it in the database.
>>
>> Andreas
>>
Jack DuijfRe: how to store XbpIcon() in DBF ?
on Tue, 08 Jan 2019 11:54:06 +0100
Hi,

Below works on any DBE using memo's.
Store and retrieve any binary data in memo fields.

Store binary data:
cString := Bin2Base64(cBin)
REPLACE  FIELD->MEMO with cString

Restore binary data
cBin   := Base642Bin(AllTrim(FIELD->MEMO))

Regards,
Jack Duijf



On Fri, 02 Nov 2018 09:20:31 -0300, Carlos A Beling <beling@bipbip.com.br> wrote:

>Hi Jim.
>Good morning.
>Did you already see:
>	XbpIcon:getBitmap()
>	Returns the icon image as an XbpBitmap object.
>May it be that you save it as file and load its string (FRead()) could 
>it solve your problem?
>
>Fraternally
>Beling
>
>
>Em 02/11/2018 06:04, Jim Lee escreveu:
>> hi,
>>
>> i know how to store XbpBitmap() into DBF but i have Problem with XbpIcon() ?
>>
>> need some Advice, thx
>>
>>