Author Topic: DOS characters in an edit control  (Read 1342 times)

jj2007

  • Member
  • *****
  • Posts: 9794
  • Assembler is fun ;-)
    • MasmBasic
DOS characters in an edit control
« on: February 01, 2019, 08:41:27 PM »
Just for fun:

GuiParas equ "DOS font in an edit control", x5, y254, w700, h160
include \masm32\MasmBasic\Res\MbGui.asm         ; part of MasmBasic
  Let esi=New$(256-33)
  For_ ecx=33 To 255
        mov [esi+ecx-33], cl            ; load the chars
  Next
  invoke SetWindowPos, hWnd_, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE OR SWP_NOSIZE
  GuiControl Edit, "edit", ConvertCp$(esi, 437, CP_UTF16), font 24
GuiEnd


Note the Pts to the left in the middle of the edit control, explained here. This symbol does not show in a console print. To the right of Pts, there should be the florin symbol - no luck in the edit control, but it shows in the console if you set a raster font. There are some other symbols that differ between console and edit control. In short: it's as messy as a Micros**t product can be :P
« Last Edit: February 01, 2019, 10:53:33 PM by jj2007 »

TimoVJL

  • Member
  • ***
  • Posts: 476
Re: DOS characters in an edit control
« Reply #1 on: February 02, 2019, 03:49:11 AM »
Verdana UNICODE was able to show glyphs same as MessageBoxW.
Code: [Select]
#define UNICODE
#define WIN32_LEAN_AND_MEAN
#include <windows.h>

#define MAXCHARS 256-33
void __cdecl WinMainCRTStartup(void)
{
char s[MAXCHARS+1];
wchar_t ws[MAXCHARS+1];
char *pc = s;
for (unsigned short c=33; c<=255; c++)
*pc++ = c;
MultiByteToWideChar(437, 0, s, MAXCHARS, ws, MAXCHARS);
HWND hEdit = CreateWindowEx(0, TEXT("EDIT"), TEXT("Chars"),
WS_POPUPWINDOW | WS_VISIBLE | WS_CAPTION
| ES_MULTILINE | ES_NOHIDESEL
, 0, 0, 400, 200, 0, (HMENU)0, GetModuleHandle(NULL), NULL);
if (hEdit) {
HFONT hFont = CreateFont(18,0,0,0,0,0,0,0,DEFAULT_CHARSET,0,0,0,0,TEXT("Verdana"));
SendMessage(hEdit, WM_SETFONT, (UINT)hFont, 0);
SetWindowTextW(hEdit, ws);
}
MessageBoxW(0, ws, L"DOS chars", 0);
ExitProcess(0);
}
EDIT: With UNICODE Arial, Courier New, Lucida Console, Consolas, ...
With dp4 Font Viewer show glyphs
EDIT: add char 255
EDIT: with MS LineDraw ANSI font:
Code: [Select]
#define WIN32_LEAN_AND_MEAN
#include <windows.h>

#define MAXCHARS 256-33

char *sFont = "mlinedraw.ttf";
//char *sFontFace = "MS LineDraw";
LOGFONT lf = {18,0,0,0,0,0,0,0,DEFAULT_CHARSET,0,0,0,0,"MS LineDraw"};
void __cdecl WinMainCRTStartup(void)
{
char s[MAXCHARS+1];
char *pc = s;
for (unsigned short c=33; c<=255; c++)
*pc++ = c;
*pc = 0;
HWND hEdit = CreateWindowEx(0, "EDIT", s,
WS_POPUPWINDOW | WS_VISIBLE | WS_CAPTION
| ES_MULTILINE | ES_NOHIDESEL
, 0, 0, 400, 200, 0, (HMENU)0, GetModuleHandle(NULL), NULL);
if (!AddFontResourceEx(sFont, 0, 0)) // can't be FR_PRIVATE
MessageBox(0, sFont, "Load failed", MB_OK);

if (hEdit) {
//HFONT hFont = CreateFont(18,0,0,0,0,0,0,0,DEFAULT_CHARSET,0,0,0,0,sFontFace);
HFONT hFont = CreateFontIndirect(&lf);
SendMessage(hEdit, WM_SETFONT, (UINT)hFont, 0);
//SetWindowTextA(hEdit, s);
}
MessageBox(0, s, "DOS chars", 0);
RemoveFontResourceEx(sFont, 0, 0);
ExitProcess(0);
}
« Last Edit: February 06, 2019, 06:16:34 PM by TimoVJL »
May the source be with you

jj2007

  • Member
  • *****
  • Posts: 9794
  • Assembler is fun ;-)
    • MasmBasic
Re: DOS characters in an edit control
« Reply #2 on: February 02, 2019, 04:12:13 AM »
Looks pretty similar. Your version shows the florin sign to the right of Pts, too :icon14:

AW

  • Member
  • *****
  • Posts: 2435
  • Let's Make ASM Great Again!
Re: DOS characters in an edit control
« Reply #3 on: February 05, 2019, 07:57:57 PM »
Character 255 is not printable in CP 437, it does not make a difference disregarding it, but will make a difference for other code pages.

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 6758
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: DOS characters in an edit control
« Reply #4 on: February 05, 2019, 09:17:42 PM »
Something I lament after the DOS days is the loss of framing characters in most fonts. The few that still have them look lousy so I very rarely ever bother any more. With console output they were very useful.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

TimoVJL

  • Member
  • ***
  • Posts: 476
Re: DOS characters in an edit control
« Reply #5 on: February 05, 2019, 09:58:55 PM »
Character 255 is not printable in CP 437, it does not make a difference disregarding it, but will make a difference for other code pages.
CP437 NBSP ?? https://en.wikipedia.org/wiki/Non-breaking_space
May the source be with you

AW

  • Member
  • *****
  • Posts: 2435
  • Let's Make ASM Great Again!
Re: DOS characters in an edit control
« Reply #6 on: February 05, 2019, 10:18:07 PM »
Character 255 is not printable in CP 437, it does not make a difference disregarding it, but will make a difference for other code pages.
CP437 NBSP ?? https://en.wikipedia.org/wiki/Non-breaking_space

You edited your downloadable code?  :biggrin:
Before:
for (unsigned char c=33; c<255; c++)
Now ?:
for (unsigned short c=33; c<=255; c++)


This :
char s[MAXCHARS+1];
Should it be this ?:
char s[MAXCHARS] = {0};

My version:
Code: [Select]
char s[MAXCHARS] = {0};
wchar_t ws[MAXCHARS+1] = {0};
HWND hEdit;
HFONT hFont;
int c;
char *pc = s;
for (c = 33; c <= 255; c++)
*pc++ = c;

In attachment, same for CP 1252. .EXE only 1536 bytes.

dedndave

  • Member
  • *****
  • Posts: 8823
  • Still using Abacus 2.0
    • DednDave
Re: DOS characters in an edit control
« Reply #7 on: February 06, 2019, 01:28:56 AM »
i have used "terminal" fonts a few times...

(CreateFontIndirect)

Code: [Select]
;available sizes (W x H)
;8 x 12
;4 x 6
;5 x 12
;6 x 8
;7 x 12

lfn           LOGFONT <8,6,,,,,,,OEM_CHARSET,,,,FIXED_PITCH,"Terminal">
; lfHeight          DWORD ?
; lfWidth           DWORD ?
; lfEscapement      DWORD ?
; lfOrientation     DWORD ?
; lfWeight          DWORD ?
; lfItalic          BYTE  ?
; lfUnderline       BYTE  ?
; lfStrikeOut       BYTE  ?
; lfCharSet         BYTE  ?
; lfOutPrecision    BYTE  ?
; lfClipPrecision   BYTE  ?
; lfQuality         BYTE  ?
; lfPitchAndFamily  BYTE  ?
; lfFaceName        BYTE  LF_FACESIZE dup(?)

there may be other sizes, but i left them out because they were ugly  :badgrin:

AW

  • Member
  • *****
  • Posts: 2435
  • Let's Make ASM Great Again!
Re: DOS characters in an edit control
« Reply #8 on: February 06, 2019, 05:47:00 AM »
Terminal font still exists in Windows 10, but is not Unicode friendly. However, it renders CP 437 fine in Ansi mode (does not appear to recognize CP 1252, so defaults to 437 in Windows).

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 6758
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: DOS characters in an edit control
« Reply #9 on: March 02, 2019, 08:27:19 PM »
Long long ago in the MS_DOS day there was a trick where you could change the font for COMMAND.COM to perform pseudo graphics directly at the command prompt. They were always bitmap fonts and were reasonably easy to either get hold of or even edit your own. I also saw some commercial software use the same technique, the old Norton utilities come to mind here.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

daydreamer

  • Member
  • ****
  • Posts: 942
  • watch Chebyshev on the backside of the Moon
Re: DOS characters in an edit control
« Reply #10 on: March 02, 2019, 09:01:37 PM »
reminds me of old demoidea to make a supersmall matrixscreen kind in DOS with help of take data from builtin charset to save space,never made it,maybe someone else could
Quote from Flashdance
Nick  :  When you give up your dream, you die
*wears a flameproof asbestos suit*
Gone serverside programming p:  :D

jj2007

  • Member
  • *****
  • Posts: 9794
  • Assembler is fun ;-)
    • MasmBasic
Re: DOS characters in an edit control
« Reply #11 on: March 03, 2019, 04:41:39 AM »
Long long ago in the MS_DOS day there was a trick where you could change the font for COMMAND.COM to perform pseudo graphics directly at the command prompt.

Do you mean codepage 437 as in the The console isn't completely dead yet thread, or something else?

HSE

  • Member
  • *****
  • Posts: 1148
  • <AMD>< 7-32>
Re: DOS characters in an edit control
« Reply #12 on: March 03, 2019, 05:13:32 AM »
This is a DOS VGA console program, not graphic. Was maked in Turbo Pascal, including objects assembled with A86 or A386. Using assembler you draw the console font.
When I maked I knows very little assembly, perhaps is replacing codepage with a new one you draw. 
What times  :biggrin:

AW

  • Member
  • *****
  • Posts: 2435
  • Let's Make ASM Great Again!
Re: DOS characters in an edit control
« Reply #13 on: March 03, 2019, 08:03:12 AM »
V860, my first shareware, circa 1992, program had that facility.
They were great times where we got interviews and full page articles in newspapers just for a small utility.
V860 replaced all the MSDOS artillary set to display portuguese characters, so it was very useful and I sold a few although not enough to get rich. Most of it was done in assembly language.








FORTRANS

  • Member
  • *****
  • Posts: 1057
Re: DOS characters in an edit control
« Reply #14 on: March 04, 2019, 04:07:14 AM »
Hi,

Long long ago in the MS_DOS day there was a trick where you could change the font for COMMAND.COM to perform pseudo graphics directly at the command prompt.

Do you mean codepage 437 as in the The console isn't completely dead yet thread, or something else?

   In "Programmer's Guide to PC Video Systems" by Richard
Wilton, he has code to copy a bitmap to the screen in a VGA
text mode.  I can look for the program if you are interested.

Regards,

Steve N.