News:

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

Main Menu

Using BITMAPS to create borderless window

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

Previous topic - Next topic

dedndave

you sure may, Gunther
anything i put in here is pretty much do-as-you-like

i might mention.....
you can create the main window with width and height = 0
then, call SetClientSizeCntr with the desired client dimensions in the WM_CREATE code
windows are not displayed until after WM_CREATE exits

Gunther

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

MichaelW

Quote from: vertograd on September 23, 2013, 11:57:52 PM
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) :

The reason is unknown for me too :lol:
Well Microsoft, here's another nice mess you've gotten us into.

dedndave

possibly related to the inclusive/exclusive nature of windows rectangles ?
there are times when an INC or DEC are necessary

GoneFishing

Quote from: dedndave on September 24, 2013, 07:15:27 PM
possibly related to the inclusive/exclusive nature of windows rectangles ?
there are times when an INC or DEC are necessary
I thought so ...
I made a simple test executing  GetClientRect after the window had been moved (256x256, with commented out "DEC EAX") : see the screenshot of locals window

   

dedndave

yes - the left and top members of a rectangle are inclusive
the right and bottom members are exclusive
they do that so that (right-left = width) and (bottom-top = height)

GoneFishing

another test:
I uncommented those two "DEC EAX" lines of code and rebuild an app, ran it, took screenshot, opened it in mspaint and pasted a sample image 256x256 pixels to it.
Then I used ZoomIt utility from Sysinternals suite
P.S.: I made sure that the  left sides of  the client area and of the sample image matched

GoneFishing

Strange behavior of the app (I think it's somehow related to not-releasing the memory)  :
press "r" 17-18 times 
what is your opinion?

dedndave

one problem....
every time you INVOKE  DrawRect, you create a new solid brush
brushes are GDI objects - you only get so many - lol

1) in the WM_CREATE code, create 1 solid brush of that color
2) store the handle in a global variable
3) in DrawRect, use that global handle
4) in the WM_DESTROY code, use DeleteObject to delete the GDI object

dedndave

my mistake.....
you are using a different color each time, so.....

after you do the fill, delete the brush handle
    invoke CreateSolidBrush,bruchcol
    push   eax
    invoke FillRect, hDC,ADDR rct,eax               ; fill rect with fill colour
    pop    eax
    invoke DeleteObject,eax


that can be simplified a little....
    invoke CreateSolidBrush,bruchcol
    push   eax
    invoke FillRect, hDC,ADDR rct,eax               ; fill rect with fill colour
    call   DeleteObject

the parameter for DeleteObject is already on the stack

jj2007

Quote from: dedndave on September 25, 2013, 08:10:30 AM
    push   eax
    invoke FillRect, hDC,ADDR rct,eax               ; fill rect with fill colour
    pop    eax
    invoke DeleteObject,eax

Dave is perfectly right, but since we are in the Campus, let's be explicit...:
    pop    eax
    invoke DeleteObject, eax

Seen by a debugger:
    pop eax
    push eax
    call DeleteObject

Simplified:
    pop eax
    push eax
    call DeleteObject

GoneFishing

Thank you , Dave  and Jochen!  :t
Now it works