News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Using BITMAPS to create borderless window

Started by GoneFishing, September 22, 2013, 01:36:21 AM

Previous topic - Next topic

MichaelW

Quote from: vertograd on September 23, 2013, 05:33:44 AM
One detail though:
if I specify 512 as width/height your window's title becomes 511x511,  and 512x512 if I pass 513,513 as parameters

Sorry, I must have made an error somewhere, that unfortunately I don't have time to fix any time soon.
Well Microsoft, here's another nice mess you've gotten us into.

GoneFishing

It's OK , Michael
I'll try to find it myself  (tomorrow maybe )

dedndave

Michael...
it is interesting to note that looking at the data in different ways accentuates different repeat patterns
if i had looked at it in terms of a series of individual bits, i might not have noticed a pattern that was byte related

some time ago, there was a thread where we were using a series of tests to check randomness
many of the tests used were designed to examine data on a byte-by-byte basis
we were using them to look at several generators that spit out dword and qword data
i just don't think these byte-size tests are a valid way to examine qword data
the results we are seeing here seem to validate that view

jj2007

Quote from: dedndave on September 23, 2013, 05:48:44 AM
many of the tests used were designed to examine data on a byte-by-byte basis
we were using them to look at several generators that spit out dword and qword data
i just don't think these byte-size tests are a valid way to examine qword data

Bytes should be as "random" as their longer brothers, and vice versa. But it seems we discussed this already ;-)

Quote from: KeepingRealBusy on December 06, 2012, 10:32:12 AM
Test several different RNGs, save the results to a file, then run ENT (http://www.fourmilab.ch/random/) to check the randomness.

dedndave

of course they should be
but, examining everything as bytes (as ENT does) is like taking all your pictures with a telephoto lens
i have known a few women that required a wide-angle lens   :lol:
not the wife, of course

jj2007

If the BYTEs inside a DWORD show a different degree of randomness, it means that e.g. low values or negative values of the DWORD are overrepresented. Consider a bitstream with n bytes....
A good RNG (like Alex' Rand() :P) does not show such bias. But there are many bad ones around, of course, including highly "official" ones from CRT etc...

GoneFishing

that's an advanced stuff, guys
I don't quite understand what you're talking about :biggrin:

Jochen, thank you for the useful links
A link to AxRand  algo from your page didn't work for me :(
       
*** ***  ***
One  question still remains very unclear :

Is it possible to create borderless window using an image
There's  a splash example in \MASM32\examples\exampl01\splash folder . It uses a brush  ... but I want a BITMAP  ...
Does anybody here know how to do it?

dedndave

first, create a class structure and register it with RegisterClassEx
then use CreateWindowEx to create a child window
create the child window in the WndProc, WM_CREATE handler of the main window

CreateWindowEx has a dwStyle parameter that allows you to set up borders, title bars, etc
use
WS_CHILD or WS_VISIBLE or WS_CLIPCHILDREN

jj2007

Quote from: vertograd on September 23, 2013, 08:50:42 PM
A link to AxRand  algo

http://www.masmforum.com/board/index.php?topic=11679

Re Bitmap: WM_PAINT handler & BitBlt are the starting points...

GoneFishing

Now I'm recalling I saw an example of custom windows in the previous MASM pack ...
must switch to another computer for it  :(

Ok , thank you all
Now I'm unplugging from this system for ah hour or two

MichaelW

Quote from: vertograd on September 23, 2013, 05:33:44 AM
Michael,
I've just tested your routine. It works fine .One detail though:
if I specify 512 as width/height your window's title becomes 511x511,  and 512x512 if I pass 513,513 as parameters

I have now verified that this code:

            invoke GetClientRect, hDlg, ADDR rc
            inc ctr
            cmp ctr, 1000
            jb  @f
            invoke szappend, addr sz, chr$("  "), 0
            mov esi, eax
            invoke szappend, addr sz, str$(rc.right), esi
            mov esi, eax
            invoke szappend, addr sz, chr$(" x "), esi
            mov esi, eax
            invoke szappend, addr sz, str$(rc.bottom), esi
            invoke SetWindowText, hDlg, addr sz


Displays the correct size in the title bar, so the error is probably in my SetClientSize procedure. Try Dave's version.
Well Microsoft, here's another nice mess you've gotten us into.

GoneFishing

Quote from: MichaelW on September 23, 2013, 11:03:53 PM
Displays the correct size in the title bar, so the error is probably in my SetClientSize procedure. Try Dave's version.

Tried Dave's version. It works correctly : if I specify 512x512 in the parameters  I get 512x512 in the title bar.
I'll try to find the error ...

EDIT: Commenting out "DEC EAX" solved the problem but it unlikely to be the ERROR because your comment shows that you intentionally decremented it for some unknown for me reason (sorry, I'm newbie) :
Quote
SetClientSize proc hwnd:HWND, pixelWidth:DWORD, pixelHeight:DWORD, fCenter:DWORD

    LOCAL _x:DWORD, _y:DWORD, nWidth:DWORD, nHeight:DWORD
    LOCAL rcc:RECT, rcw:RECT

    invoke GetClientRect, hwnd, ADDR rcc
    invoke GetWindowRect, hwnd, ADDR rcw

    mov ecx, rcw.right
    sub ecx, rcw.left       ; ecx = window width - 1

    mov eax, pixelWidth
   ;dec eax                 ; eax = pixelWidth - 1
    mov edx, rcc.right      ; edx = client width - 1
    sub edx, eax            ; edx = difference
    sub ecx, edx            ; adjust width
    mov nWidth, ecx

    mov ecx, rcw.bottom
    sub ecx, rcw.top        ; ecx = window height - 1

    mov eax, pixelHeight
   ;dec eax                 ; eax = pixelHeight - 1
    mov edx, rcc.bottom     ; edx = client height - 1
    sub edx, eax            ; edx = difference
    sub ecx, edx            ; adjust height
    mov nHeight, ecx

The possibility to center the window on the screen is very nice  :t

*** *** ***
I've found that example in old MASM32 pack:
\masm32\examples\exampl06\mob\cws       (i.e. CUSTOM WINDOWS SHAPE )

Again , thank you all for the help!

dedndave

here is another version that sets the window size by client size and centers the window on the screen

SetClientSizeCntr PROTO :HWND,:DWORD,:DWORD

SetClientSizeCntr PROC USES EDI hWnd:HWND,dwClientWidth:DWORD,dwClientHeight:DWORD

    LOCAL   _rcClient       :RECT
    LOCAL   _rcWindow       :RECT

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

    INVOKE  GetClientRect,hWnd,addr _rcClient
    INVOKE  GetWindowRect,hWnd,addr _rcWindow
    INVOKE  GetSystemMetrics,SM_CXSCREEN
    xchg    eax,edi                                 ;EDI = screen width
    INVOKE  GetSystemMetrics,SM_CYSCREEN            ;EAX = screen height

    mov     edx,dwClientHeight
    mov     ecx,dwClientWidth
    add     edx,_rcWindow.bottom
    add     ecx,_rcWindow.right
    add     edx,_rcClient.top
    add     ecx,_rcClient.left
    sub     edx,_rcClient.bottom
    sub     ecx,_rcClient.right
    sub     edx,_rcWindow.top
    sub     ecx,_rcWindow.left
    sub     eax,edx
    sub     edi,ecx
    sar     eax,1
    sar     edi,1

    INVOKE  MoveWindow,hWnd,edi,eax,ecx,edx,TRUE
    ret

SetClientSizeCntr ENDP

GoneFishing

Dave:
tnank you  for new version of SetClientSize procedure, I'll try it in my next test

Michael:
thank you for the attached well commented code

In my case "Black and White" test doesn't have any controls , only rectangles which I want to redraw if the user hits the hot key ("r" for example)

Gunther

Hi Dave,

Quote from: dedndave on September 24, 2013, 01:47:15 AM
here is another version that sets the window size by client size and centers the window on the screen

good idea.  :t Can I incorporate it into my code repository?

Gunther
You have to know the facts before you can distort them.