News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Console window size

Started by nidud, September 08, 2013, 10:09:49 PM

Previous topic - Next topic

dedndave

i do it a little differently
i store the HWND of my window
and compare the GetForegroundWindow result against that
    INVOKE  GetForegroundWindow
    .if eax==hwndMain

nidud

#31
deleted

jj2007

Just curious: How did you implement .if GetForegroundWindow() - a macro??

nidud

#33
deleted

jj2007

So it's your own JWasm build. Interesting ;)

dedndave

rv(GetForegroundWindow)
will do the same

i don't use it much, but qWord seems to like it   :P

jj2007

Quote from: dedndave on October 05, 2013, 01:32:05 AM
i don't use it much, but qWord seems to like it   :P

Me too, it condenses the code a little bit:
      mov hMenu, rv(CreateMenu)            ; create the main menu
      mov hM1, rv(CreateMenu)              ; plus three
      mov hM2, rv(CreateMenu)              ; sub menus
      mov ghM3, rv(CreateMenu)


dedndave

i find it a little easier to follow the code by not using it
especially if you are following along in a debugger
but - i have become more accustomed to it through reading qWord's code - lol

nidud

#38
deleted

dedndave

the ones that have the IBM graphics characters in the upper range use the OEM_CHARSET
for the console it's normally a "Terminal" font

here are some links....
http://masm32.com/board/index.php?topic=1108
this one was posted by Vortex...
http://blogs.microsoft.co.il/blogs/pavely/archive/2009/07/23/changing-console-fonts.aspx

and, attached is a little program to enumerate fonts
you can modify it to filter out different requirements

for example, if you just want monospaced fonts, you can look for those that use FIXED_PITCH
unfortunately, it's a little difficult to filter out all the monospace fonts
because a true-type font may be monospaced, without using the FIXED_PITCH flag

dedndave

here is an image of using terminal fonts in a GUI app
kind of "reverse" of what you want to do, i think - lol



i use the following routine to create the fonts
oddly enough - it doesn't always get the font i want, unless i enumerate terminal fonts, first   :redface:
MakeTerminalFont PROC wParam:WPARAM

;valid WxH: 4x6, 5x12, 6x8, 7x12, 8x8, 8x12, 10x18, 12x16, 16x8, 16x12

;--------------------------------

    LOCAL   _lf     :LOGFONT

;_lf              LOGFONT <height,width,,,,,,,OEM_CHARSET,,,,FF_MODERN or FIXED_PITCH,"Terminal">
;  lfHeight         DWORD height
;  lfWidth          DWORD width
;  lfEscapement     DWORD ?
;  lfOrientation    DWORD ?
;  lfWeight         DWORD ?
;  lfItalic         BYTE  ?
;  lfUnderline      BYTE  ?
;  lfStrikeOut      BYTE  ?
;  lfCharSet        BYTE  OEM_CHARSET
;  lfOutPrecision   BYTE  ?
;  lfClipPrecision  BYTE  ?
;  lfQuality        BYTE  ?
;  lfPitchAndFamily BYTE  FF_MODERN or FIXED_PITCH
;  lfFaceName       BYTE  LF_FACESIZE dup(?)        ;"Terminal",0

;--------------------------------

    INVOKE  GetStockObject,OEM_FIXED_FONT
    lea     edx,_lf
    INVOKE  GetObject,eax,sizeof LOGFONT,edx
    movzx   edx,byte ptr wParam[2]                  ;EDX = wParam high word = height
    movzx   ecx,byte ptr wParam                     ;ECX = wParam low word  = width
    mov     _lf.lfCharSet,OEM_CHARSET
    mov     _lf.lfPitchAndFamily,FF_MODERN or FIXED_PITCH
    mov     _lf.lfHeight,edx
    mov     _lf.lfWidth,ecx
    INVOKE  CreateFontIndirect,addr _lf
    ret

MakeTerminalFont ENDP



nidud

#41
deleted

dedndave

as far as i know - a font used in the console must be monospaced
so - if you want to "carry" a font in resource or something, it may be do-able
that particular Lucida font is a monospaced font

Jochen has a lot more experience, here, as he has played with many foreign UNICODE fonts in the console

another possibility is to draw your own line graphics in the console client area
at that point, you may as well write a GUI app - lol

dedndave

i forgot to mention....

you might have some luck with special "programming" fonts, which are typically monospaced
i use inconsolata-dz in NotePad and NotePad++, for example
another one is Proggy Square Slash Zero
there are numerous 3rd party programming fonts out there
some may do what you want
i haven't tried to find one that supported IBM graphics chars, though

nidud

#44
deleted