News:

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

Main Menu

Uncle Remus Tales

Started by Mikl__, May 26, 2017, 08:43:47 PM

Previous topic - Next topic

zedd151

#90
I fubarred the captioning.

The TOP image is from Windows 10 Home 64 bit - all drivers installed. No flicker, but the text is odd.

The bottom image is from Windows 7 Pro 64 bit - No proper video drivers available, old OS New Hardware.
So the flickering is from my end, your program works well in Windows 10 - other than the odd font (strike
through and underlined) - might be an odd font variation from the OS???

Mikl__

Hi, zedd151!
Thanks for the noticed error. I'll try to fix the blinking text

zedd151

Quote from: Mikl__ on August 05, 2018, 08:50:43 PM
Hi, zedd151!
Thanks for the noticed error. I'll try to fix the blinking text

Don't worry about that just yet. Let a few others test your program.
My Windows 7 setup does not have the proper video drivers installed, only the default stock
Microsoft video drivers.

The program shows no signs of flickering in WIndows 10, in which I have the factory installed
RADEON video drivers installed. just the font looks weird..

hutch--

Mikl__, could I impose on you not to use too many bitmaps that are stored on this server as it takes up a lot more space than code and I cannot let the storage space fill up.

Mikl__

Hi, hutch--!
Well, I will not abuse and upload bitmaps.

hutch--


Mikl__

#96
Work with Fonts
asm-file; GUI #
include win64a.inc
ID_RESET equ 0
ID_FONT equ 1
ID_HELP equ 2
ID_EXIT equ 3
IDM_MENU equ 37
IDC_ICON1 equ 500
IDR_MAINACCEL equ 105
.code
WinMain proc
local msg:MSG
   
xor ebx,ebx
mov ecx,offset FileName
invoke LoadCursorFromFile
mov esi,IMAGE_BASE
mov edi,offset ClassName
push rax    ;hIconSm
push rdi    ;lpszClassName
push IDM_MENU    ;lpszMenuName
push COLOR_WINDOW;hbrBackground
push 10003h ;hCursor
push rax    ;hIcon 
push rsi    ;hInstance
push rbx    ;cbClsExtra & cbWndExtra
pushaddr WndProc ;lpfnWndProc
push sizeof WNDCLASSEX;cbSize & style
invoke RegisterClassEx,esp;addr WNDCLASSEX
push rbx
push rsi    ;rsi=400000h
shl esi,9   ;rsi=CW_USEDEFAULT
push rbx
push rbx
push rsi
push rsi
push rsi
push rsi
sub esp,20h
    invoke CreateWindowEx,0,edi,edi,WS_OVERLAPPEDWINDOW or WS_VISIBLE
mov hwnd,rax
invoke LoadAccelerators,IMAGE_BASE,IDR_MAINACCEL
mov ACC,rax
    lea edi,msg
@@:     invoke GetMessage,edi,0,0,0
        invoke TranslateAccelerator,hwnd,ACC,edi
or eax,eax
jne @b
invoke TranslateMessage,edi
invoke DispatchMessage,edi
jmp @b
WinMain endp
;----------------------------------------
WndProc proc hWnd:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
local ps:PAINTSTRUCT
local hdc:qword
local size0:POINT
local string[255]:byte
local cf:CHOOSEFONT
local lf:LOGFONT

        mov hWnd,rcx
   
        cmp edx,WM_DESTROY
        je wmDESTROY
        cmp edx,WM_CREATE
        je wmCREATE
        cmp edx,WM_PAINT
        je wmPAINT
        cmp edx,WM_COMMAND
        je wmCOMMAND
        leave
        jmp NtdllDefWindowProc_
wmDESTROY:invoke DeleteDC,memDC
invoke DeleteObject,hNewFont1
invoke DeleteObject,hNewFont2
invoke RtlExitUserProcess,0
wmCOMMAND:and r8d,11111y;wParam
cmp r8d,ID_EXIT
ja wmBYE
jmp handler[r8*8]
FONT:
;----------------------------------
push rdi
xor eax,eax
mov ecx,(sizeof CHOOSEFONT)/8
lea edi,cf
rep stosq
pop rdi; ZeroMemory
mov     cf.lStructSize,sizeof CHOOSEFONT
mov rax,hwnd
mov cf.hwndOwner,rax
lea eax,lf
mov cf.lpLogFont,rax
mov cf.Flags,CF_SCREENFONTS or CF_EFFECTS;
lea ecx,cf
invoke ChooseFont
or eax,eax
jz wmBYE
lea ecx,lf
invoke CreateFontIndirect
invoke SelectObject,memDC,eax
invoke SetTextColor,memDC,cf.rgbColors
invoke SetBkMode,memDC,TRANSPARENT
mov edx,offset tm
invoke GetTextMetrics,memDC
lea ecx,string
mov edx,offset fmt1
lea r8d,lf.lfFaceName
mov r9d,tm.tmHeight
invoke wsprintf
;выводим строку
lea r9d,string
invoke TextOut,memDC,X,Y,,rax
mov eax,tm.tmHeight
add eax,tm.tmExternalLeading
add Y,rax
mov qword ptr [rsp+20h],sizeof string1
lea r9d,string1
invoke TextOut,memDC,X,Y
mov r8d,sizeof string1
lea edx,string1
lea r9d,size0
invoke GetTextExtentPoint32,memDC
mov eax,size0.x
mov X,rax
lea ecx,string
mov edx,offset fmt2
mov r8d,size0.x
invoke wsprintf
lea r9d,string
invoke TextOut,memDC,X,Y,,rax
mov eax,tm.tmHeight
add eax,tm.tmExternalLeading
add Y,rax
and X,0
lea ecx,string
mov edx,offset fmt3
invoke wsprintf,,,maxX,maxY
lea r9d,string
invoke TextOut,memDC,X,Y,,rax
mov eax,tm.tmHeight
add eax,tm.tmExternalLeading
add Y,rax
invoke InvalidateRect,hWnd,0,1
jmp wmBYE
RESET:  and X,0
and Y,0
invoke PatBlt,memDC,0,0,maxX,maxY,PATCOPY
        invoke InvalidateRect,hWnd,0,1
jmp wmBYE
HELP: mov ecx,offset mb
invoke MessageBoxIndirect
jmp wmBYE
wmCREATE:invoke GetSystemMetrics,SM_CXSCREEN
mov maxX,rax
        invoke GetSystemMetrics,SM_CYSCREEN
mov maxY,rax
invoke GetDC,hWnd
mov hdc,rax
invoke CreateCompatibleDC,eax
mov memDC,rax
invoke CreateCompatibleBitmap,hdc,maxX,maxY
        invoke SelectObject,memDC,eax
invoke GetStockObject,WHITE_BRUSH
        invoke SelectObject,memDC,eax
invoke PatBlt,memDC,0,0,maxX,maxY,PATCOPY
invoke SetBkMode,memDC,TRANSPARENT
        invoke ReleaseDC,hWnd,hdc
jmp wmBYE
wmPAINT:lea edx,ps
        invoke BeginPaint       
mov hdc,rax
        invoke BitBlt,eax,0,0,maxX,maxY,memDC,0,0,SRCCOPY       
        lea edx,ps
        invoke EndPaint,hWnd
wmBYE:  leave
        retn
handler dq RESET,FONT,HELP,wmDESTROY
WndProc endp
;-----------------------------------------
ClassName db "Uncle Remus tales:#5e Work with Font",0
expTxt db "Win64 assembly with MASM is great and easy",0
FileName db "br_Rabbit3.cur",0
hwnd dq ?
fmt1 db 'Font height "%s" is %d pixels',0
string1 db "This is the next line.",0
fmt2 db "Length of the previous line is %d units",0
fmt3 db "Screen size is %d by %d",0
ACC dq ?
tm TEXTMETRICA <>
X dq 0
Y dq 0
maxX dq ?
maxY dq ?
memDC dq ?
hOldFont dq ?
hNewFont1 dq ?
hNewFont2 dq ?
MBText db "F1: Help",10,"F2: Choose font",10,"F3: Clear screen",10,"Ctrl+X: Exit",0
mb label   MSGBOXPARAMS
  dd sizeof MSGBOXPARAMS,?;cbSize      
  dq 0  ;hwndOwner
  dq IMAGE_BASE  ;hInstance      
  dq MBText  ;lpszText    
  dq ClassName  ;lpszCaption
  dd MB_OK or MB_USERICON or MB_TOPMOST,?;dwStyle
  dq IDC_ICON1  ;lpszIcon
  dd 0,?;dwContextHelpId
  dq 0  ;lpfnMsgBoxCallback
  dd 0,?;dwLanguageId
end
rc-file#include "resource.h"
#define ID_RESET 0
#define ID_FONT 1
#define ID_HELP 2
#define ID_EXIT 3
#define IDM_MENU 37
#define IDC_ICON1 500
#define IDR_MAINACCEL 105
IDC_ICON1 ICON DISCARDABLE "br_Bear4.ico"
IDM_MENU MENU
{
    POPUP "&Font"
    {
    MENUITEM "Choose &font\tF2",ID_FONT
    MENUITEM "&Clear Screeen\tF3",ID_RESET
    MENUITEM "&Help\tF1",ID_HELP
MENUITEM SEPARATOR
        MENUITEM "E&xit\tCtrl+X",ID_EXIT
}
    MENUITEM "E&xit",ID_EXIT
}
IDR_MAINACCEL ACCELERATORS DISCARDABLE

VK_F1, ID_HELP,VIRTKEY
VK_F2, ID_FONT,VIRTKEY
VK_F3, ID_RESET,VIRTKEY
"^X",  ID_EXIT
}
P.S. Hi, hutch--! Size of zip-file and png-files are 83 kBytes

Mikl__

The program demonstrates the text output on the screen in 10 ways
I have already shown a similar program. But it had to be redone, as with an increase in the volume of the text, problems begin with its redrawing and blinking.
In the attachment the source code of the program, the icon and the exe-file

felipe

mikl__ looks like an interesting program, but unfortunately seems like it dosen't work well (at least in my system... :idea:). when i run the program no window is displayed and the program remains running (i can see it with the taskmanager). so after that i have to kill the process... :idea:

TimoVJL

What codepage the source text use ?
May the source be with you

Mikl__

Hei Timo,
käytin Windows-1251-kooditaulukkoa (used the code page Windows-1251)
This is the Russian translation of "Uncle Remus's Tales". But this is not critical. This is a demonstration of displaying a few dozen lines..

TimoVJL

Спасибо!
With notepad2 it is possible to convert and see the russian language text and comments.
Notepad2 have a Encoding Recode option.
May the source be with you

jj2007

Looks exotic :P
mov r8d,offset expTxt0
mov edx,offset aStatic
sub esp,20h
invoke CreateWindowEx,0,,,SS_LEFT or WS_CHILD or WS_VISIBLE
mov hStaticText1,rax
;создания элемента STATIC для вывода текста функцией SendMessage

aw27

It does not launch as well here and I can't find a version of the win64a.inc that does not produce errors when building. I am sure Mikl__ might have posted a link to a working version somewhere, or may be I am just confused (Alzheimer, may be?).

Mikl__