News:

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

Main Menu

hscroll example modification: black console window appears

Started by pavor, July 07, 2012, 03:23:50 AM

Previous topic - Next topic

pavor

Hi everyone.
I ran the hscroll example on a PC with resolution 1366x768 and have noticed that the scroll loop does not actually make the full cycle of scrolling,  it stops before the right screen side with a few pixels left to go.
I wanted to fix it and have found out that all taht was because the used step of scrolling of 8 pixels. So, if your screen resolution is not multiple of 8, you will have that unscrollable area at the end ("reminder").
It seemed to be very easy to fix (lines added by me are marked with '*'):
main proc

    LOCAL swid  :DWORD
    LOCAL shgt  :DWORD
    LOCAL dwid  :DWORD
    LOCAL hDC   :DWORD
    LOCAL cDC   :DWORD
    LOCAL hScr  :DWORD
    LOCAL hBmp  :DWORD
    LOCAL hOld  :DWORD

    LOCAL rest  :DWORD; *My variable


And then

  mov hOld, rv(SelectObject,cDC,hBmp)                 ; select compatible bitmap into compatible DC

    mov ebx, swid;*
    shr ebx, 3;* division by 8
    shl ebx, 3;* multiplication by 8
    mov eax, swid;*
    sub eax, ebx;* 
    mov rest, eax;* save  the reminder


and after the main cycle we have to scroll it by the reminder:

   @@:
    invoke BitBlt,hDC,0,0,swid,shgt,cDC,esi,0,SRCCOPY
    invoke Sleep, 20                                    ; slow it up a bit
    sub esi, 8
    jns @B

    add esi, 8;*
    sub esi, rest;*
    invoke BitBlt,hDC,0,0,swid,shgt,cDC,esi,0,SRCCOPY;*
    invoke Sleep, 20;*
 


It compiles and runs fine, but a console-like window appears for some milliseconds near the startup time and about the end of execution and I don't know why and how to fix it. There was no window appearance during the running of the original example. Please help.

The question: Why and how to fix the issue?
Full source code attached.

dedndave

the console shows up because it was linked as a console application
when you assemble and link it, use the following switches
\masm32\bin\ml /c /coff filename.asm
\masm32\bin\Link /SUBSYSTEM:WINDOWS filename.obj

dedndave



dedndave

my previous post had an attachment - you may have missed it   :t

pavor

I checked out the attachment - the proggys are really cool! Thanks.
However, I still cannot rebuild some of them..