ASCII 0 to 256 EditControl

Windows specific questions.
caseih
Posts: 2157
Joined: Feb 26, 2007 5:32

Re: ASCII 0 to 256 EditControl

Post by caseih »

albert wrote:I need to be able to print all 256 ascii chars so you can open *.exe's in my Vari_Cyph program.
Its for opening *.exe files in the edit box. So you can cypher them.
But why is it important to see them and represent them? Your algorithm can still work on the bytes from a file. Sorry I'm not understanding (I have looked at your program). Furthermore why is a certain character set so important? So what if windows wants to display in CP1512 instead of CP437? The bytes are still the same.
albert
Posts: 6000
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: ASCII 0 to 256 EditControl

Post by albert »

How do you create a Rich Edit ctrl ?

Maybe a rich edit can display all 256 chars.
albert
Posts: 6000
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: ASCII 0 to 256 EditControl

Post by albert »

@Caseih

The regular fonts all have repetitive characters like chr(0) - chr(30) are all the same block chr...and GetWindowText can differentiate between a chr(2) and a chr(7)

If two or more characters are the same as in the ansi fonts , you cant tell what chr it is. So i need to display all 256 chrs and all the chars ned to be different.
caseih
Posts: 2157
Joined: Feb 26, 2007 5:32

Re: ASCII 0 to 256 EditControl

Post by caseih »

If you really want to visually represent 256 different byte values so that the user can see that they are different, maybe you should do blocks of colors or patterns to display it more graphically, instead of trying to make an edit control do something it was never designed to do. When it comes to a binary file, typically the only view that makes sense is going to be hex. That's why I mentioned that hex output like

Code: Select all

0000000: 7f45 4c46 0201 0100 0000 0000 0000 0000  .ELF............
0000010: 0200 3e00 0100 0000 484b 4000 0000 0000  ..>.....HK@.....
0000020: 4000 0000 0000 0000 e8c3 0100 0000 0000  @...............
might be as useful as anything.

But as to your problem and questions, I don't know of any way to make things work precisely the way you want, short of writing your own GUI control that will display things exactly as you want.
MichaelW
Posts: 3500
Joined: May 16, 2006 22:34
Location: USA

Re: ASCII 0 to 256 EditControl

Post by MichaelW »

The FreeBASIC fonts include the entire character set, and are the VGA pattern. I'm not sure what your display requirements are, but you could render your characters to an appropriate image buffer (ImageCreate), BSAVE the buffer to a bitmap, then display the bitmap in a static control. Forcing the use of the 9x16 font could be a problem.
marcov
Posts: 3455
Joined: Jun 16, 2005 9:45
Location: Netherlands
Contact:

Re: ASCII 0 to 256 EditControl

Post by marcov »

albert wrote:I want to display the 256 characters of the DOS character set.
But edit and rich_edit controls are all unicode by default and use 2 or 4 byte chars.

I want 1 byte chars DOS char(0) to char(255) to display in the edit control..

Can you do it with set font?
Use OEMtoCharBufW to convert OEM (dos) encoding to unicode and then display that.
albert
Posts: 6000
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: ASCII 0 to 256 EditControl

Post by albert »

@Marcov

How , and where do you use it ??
Can you give a code snippet to demonstrate it?
fxm
Moderator
Posts: 12081
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: ASCII 0 to 256 EditControl

Post by fxm »

fxm wrote:For input/output ("input", "print", "draw string" ...), FreeBasic seems to use DOS/OEM character set (as QuickBasic), but Windows Editor uses Windows/ANSI character set.

As I am French, I use many characters with accents (ascii code > 127).


To convert string OEM/DOS <-> Windows/ANSI

You can use these windows functions (see WIN32.HLP) :
CharToOem
CharToOemBuff
OemToChar
OemToCharBuff

where "Char" corresponds to ANSI Character
See example in my post at http://www.freebasic.net/forum/viewtopi ... 40#p194040
Post Reply