Author Topic: [First timer]Window will not show up  (Read 23682 times)

MichaelW

  • Global Moderator
  • Member
  • *****
  • Posts: 1209
Re: [First timer]Window will not show up
« Reply #15 on: November 22, 2012, 09:10:00 AM »
If the buttons are supposed to behave as the Minesweeper buttons do, then all of the functionality that the MASM32 bitmap button example implements will not be necessary. You will have the initial button face that is replaced by any one of ~11 “flat” bitmaps when the button is actuated.

Well Microsoft, here’s another nice mess you’ve gotten us into.

dedndave

  • Member
  • *****
  • Posts: 8825
  • Still using Abacus 2.0
    • DednDave
Re: [First timer]Window will not show up
« Reply #16 on: November 22, 2012, 09:15:49 AM »
yah - that is way overkill

here is the bitmap used by WinMine
it is oriented vertically instead of horizonally (don't know why - i would use horz)
it kind of tells you that they are not using individual buttons


CommonTater

  • Guest
Re: [First timer]Window will not show up
« Reply #17 on: November 22, 2012, 09:26:08 AM »
it would make much more sense to just handle the displayed grid in WM_PAINT
and handle the mouse clicks by calculating the grid location - essentially making one big customized button, if you will
set up an array that holds the state for each grid square

The WM_MOUSEMOVE, WM_LBUTTONDOWN, WM_RBUTTONDOWN and GetCursorPos() would be particularly suited to this kind of activity.  It's actually pretty easy to do...


dedndave

  • Member
  • *****
  • Posts: 8825
  • Still using Abacus 2.0
    • DednDave
Re: [First timer]Window will not show up
« Reply #18 on: November 22, 2012, 09:32:42 AM »
i think you can do it with just WM_LBUTTONDOWN and WM_RBUTTONDOWN
those 2 messages provide the cursor position in wParam, as i recall
you don't care about WM_MOUSEMOVE, capturing the mouse or any of that
it would be pretty simple, i think

if you wanted to use a small array, 1 byte for each grid-square would be plenty
use the lower 4 bits to hold the current displayed state and the upper 4 bits to hold the "hidden" contents
something like that   :P

CommonTater

  • Guest
Re: [First timer]Window will not show up
« Reply #19 on: November 22, 2012, 10:07:39 AM »
i think you can do it with just WM_LBUTTONDOWN and WM_RBUTTONDOWN
those 2 messages provide the cursor position in wParam, as i recall
you don't care about WM_MOUSEMOVE, capturing the mouse or any of that
it would be pretty simple, i think

if you wanted to use a small array, 1 byte for each grid-square would be plenty
use the lower 4 bits to hold the current displayed state and the upper 4 bits to hold the "hidden" contents
something like that   :P

The WM_MOUSEMOVE message provides a real quick check to see if the mouse is inside the program's window or not... inside the window you get a stream of them, but they stop at the border.


dedndave

  • Member
  • *****
  • Posts: 8825
  • Still using Abacus 2.0
    • DednDave
Re: [First timer]Window will not show up
« Reply #20 on: November 22, 2012, 10:57:30 AM »
right - but in mine sweeper, nothing changes on mouse movement
only when you click does something happen
the program doesn't have to consume a lot of processor cycles handling all those WM_MOUSEMOVE's

CommonTater

  • Guest
Re: [First timer]Window will not show up
« Reply #21 on: November 22, 2012, 11:29:05 AM »
right - but in mine sweeper, nothing changes on mouse movement
only when you click does something happen
the program doesn't have to consume a lot of processor cycles handling all those WM_MOUSEMOVE's

true.

carre89

  • Guest
Re: [First timer]Window will not show up
« Reply #22 on: November 22, 2012, 02:22:15 PM »
That sounds like a better idea haha. Do you know a project/tutorial that I can work off - I need to have this done by next week... Thank you for your help so far.

dedndave

  • Member
  • *****
  • Posts: 8825
  • Still using Abacus 2.0
    • DednDave
Re: [First timer]Window will not show up
« Reply #23 on: November 22, 2012, 02:29:49 PM »
not off-hand
if time permits, i may do a very basic one tomorrow, just so you get the idea

carre89

  • Guest
Re: [First timer]Window will not show up
« Reply #24 on: November 24, 2012, 12:37:33 PM »
So I did a little bit work on it. I found this basic tutorial on how to paint to the Window,
http://www.asmcommunity.net/book/tutorials/iczelion/simple-bitmap

Using this tutorial I was able to paint a cell/button to the window. Now I need to figure out how to catch click events in the window properly. Can someone show me a quick code snippet of catch a mouse click event and getting it's position?

How do I repaint the window with the updated cells?

If you look at my code you can see I added alot of new procedures and structures to the program. Most notably a minefield struct. The problem is I am not sure how to use it properly as it seems. I am getting some sort of error.

I am going to try to figure as much as I can by myself and update this post accordingly. Once again thankyou for your help so far. This has been the most helpful forum I have ever used.  :greenclp: :greenclp: :greenclp:

Edit ********************
I have another quick question. Is it possible to have a struct within a struct? I was thinking about creating a cell struct within the minefield struct that would contain the properties of each cell(e.g. opened || closed, mine || num etc). So I would have an array of mines within the minefield struct. It would make accessing each of the cell's properties much easier and clearer.

dedndave

  • Member
  • *****
  • Posts: 8825
  • Still using Abacus 2.0
    • DednDave
Re: [First timer]Window will not show up
« Reply #25 on: November 24, 2012, 01:00:29 PM »
you can just handle the WM_LBUTTONDOWN and WM_RBUTTONDOWN messages

Code: [Select]
    .elseif uMsg==WM_LBUTTONDOWN
        movzx   ecx,word ptr lParam    ;ECX = X client coordinate
        movzx   edx,word ptr lParam+2  ;EDX = Y client coordinate

        ;rest of button click code

        xor     eax,eax                ;return 0

dedndave

  • Member
  • *****
  • Posts: 8825
  • Still using Abacus 2.0
    • DednDave
Re: [First timer]Window will not show up
« Reply #26 on: November 24, 2012, 01:03:03 PM »
as for repainting, i was thinking of having a 256-color DIB section for the grid area
then, you can modify the bytes directly for a specific square
then, create a RECT that outlines that square and pass it to InvalidateRect
then call UpdateWindow and let the paint routine update just that square

you can create a byte array for the grid
each byte can represent a grid square
the upper 4 bits can be used as an index (0-15) into the image strip, indicating the current display state
the lower 4 bits can describe what the hidden content is

CommonTater

  • Guest
Re: [First timer]Window will not show up
« Reply #27 on: November 24, 2012, 01:47:22 PM »
How do I repaint the window with the updated cells?

You might want to look into the BitBlt function in the Windows API
 
This would require you to store small bitmaps for each button state in your program's resources (a common technique) and drop them into place as needed.
 

carre89

  • Guest
Re: [First timer]Window will not show up
« Reply #28 on: November 24, 2012, 02:21:22 PM »
I think I got a little bit ahead of myself. I had a lot of coffee today :dazzled: . I want to focus on getting it to run first before I worry about anything else.

So I divided up the project into separate source files. main.asm handling the painting while all my minefield functions are in minefield.asm. I just commented a bunch of code I that I'll worry about later. What I need to figure out is why my MineFieldStruct is throwing me an error;

fatal error A1010: unmatched block nesting : MineField

I attached my latest revision if anybody wants to look at it.

dedndave

  • Member
  • *****
  • Posts: 8825
  • Still using Abacus 2.0
    • DednDave
Re: [First timer]Window will not show up
« Reply #29 on: November 24, 2012, 02:37:25 PM »
Code: [Select]
MineFieldStruct STRUCT
;
;
;
MineField ENDS

the name you use to open a structure definition should match the one you use to close   :P
block nesting errors are usually easy "operator error" problems - lol

get some sleep
i started a program for this - was busy yesterday and today
maybe i'll finish it off tomorrow