Author Topic: Uncle Remus Tales  (Read 10749 times)

zedd151

  • Member
  • ****
  • Posts: 847
Re: Uncle Remus Tales
« Reply #90 on: August 05, 2018, 07:41:28 PM »
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???
« Last Edit: August 06, 2018, 04:11:56 AM by zedd151 »
I'm not always the sharpest knife in the drawer, but I have my moments.  :P

Mikl__

  • Member
  • ****
  • Posts: 681
Re: Uncle Remus Tales
« Reply #91 on: August 05, 2018, 08:50:43 PM »
Hi, zedd151!
Thanks for the noticed error. I'll try to fix the blinking text

zedd151

  • Member
  • ****
  • Posts: 847
Re: Uncle Remus Tales
« Reply #92 on: August 05, 2018, 09:41:59 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..
I'm not always the sharpest knife in the drawer, but I have my moments.  :P

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 5659
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Uncle Remus Tales
« Reply #93 on: August 06, 2018, 03:55:13 AM »
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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

Mikl__

  • Member
  • ****
  • Posts: 681
Re: Uncle Remus Tales
« Reply #94 on: August 06, 2018, 09:16:03 AM »
Hi, hutch--!
Well, I will not abuse and upload bitmaps.

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 5659
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Uncle Remus Tales
« Reply #95 on: August 06, 2018, 01:17:37 PM »
 :biggrin:

Спасибо.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

Mikl__

  • Member
  • ****
  • Posts: 681
Re: Uncle Remus Tales
« Reply #96 on: August 08, 2018, 11:46:07 PM »
Work with Fonts
asm-file
Code: [Select]
; 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
Code: [Select]
#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
« Last Edit: August 09, 2018, 09:37:37 AM by Mikl__ »