News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Of Mice and Messages

Started by NoCforMe, October 04, 2011, 07:36:55 PM

Previous topic - Next topic

dedndave

3. yah - this is really a matter of personal taste   :P
i have gotten used to [reg].structtype.member
a habit i picked up from qWord, i think

4. well - there are a number of caveats to enumerating fonts - good you got it working, actually   :U
you may also want to look into ChooseFont - there are 1 or 2 examples in masm32\examples
http://msdn.microsoft.com/en-us/library/windows/desktop/ms646914%28v=vs.85%29.aspx

5. well - i create a temporary RECT structure on the stack (without using LOCAL)
        sub     esp,sizeof RECT
after the call, i pop the RECT members into registers - it makes for small code
what i am really after, there, is the position and size for the status bar
so - i get the RECT for the client
the X position for the status bar is always 0
the Y position is the client height minus the status bar height (client height = bottom minus top)
the width is the same as the client width (client width = right minus left)
the height is the height of a status bar (measured and stored in StbHeight during WM_CREATE)

now that i think about it, that code could be simpler
because the left and top are always 0   :P
so - the first 2 SUB instructions could be removed, i guess

as for the stack stuff, you'll get used to it
the win32 API always passes parameters on the stack
so - it is something you'll see a lot of
also, the stack is a great place for small temporary allocations
fast - small code to access it

NoCforMe

New .zip of source & exe is attached.

You'll notice there's still the problem of the child window borders getting messed up. Since you can drag them over the status bar, try that and see what happens to them.

Speaking of the status bar, it's working fine (including resizing--piece of cake). However, one thing I don't like: I tried to adjust the clipping rectangle I used to clip the cursor by subtracting the height of the status bar, but it doesn't seem to work correctly:



INVOKE GetWindowRect, hWin, ADDR gpRect
; Adjust clipping rectangle to exclude status bar:
MOV EAX, SBheight
SUB gpRect.bottom, EAX
INVOKE ClipCursor, ADDR gpRect



I can't be sure, but it looks as if the clip area may be correct, but the child windows can extend below it by their height (in other words, since the window is being dragged by the upper-left corner (0,0), the rest of the window goes out of the clip area. Or something like that. Yet more evidence that I'm doing something wrong with the children.

dedndave

it appears that you attached the old version   :P

NoCforMe

whoops, sorry 'bout that.

Regarding the problems I'm having with constraining the mouse (ClipRect() and all that), seems to me that it's probably working correctly, but the problem lies elsewhere. The cursor is being correctly constrained; it cannot go beyond the client area. But since the child window is being dragged by its ear (0,0), it extends beyond the bottom and right of the client area.

What I want is an object that will be constrained within the client area. In other words, when any edge of the object bumps into the edge of the client area, I want the object to stop moving.

dedndave

; Now do leading-zero suppression:
MOV ECX, 3 ;Look @ 1st 3 digits
b2a20: INC DI
CMP BYTE PTR [EDI], '0'
JNE b2a499 ;Stop on 1st non-zero digit.
MOV BYTE PTR [EDI], ' '
LOOP b2a20


i am a little surprised this assembles   :bg
b2a20: INC DI
i guess it just puts a size override byte in there - hope we don't wrap a 64 kb boundry   :P

one solution that comes to mind would be to create a large child window that does not include the drop-down and status bar
then, create the little windows under that one
i have done this in the past to prevent scroll bar flicker

dedndave

B2A4 PROC

        MOV ECX, 4 ;4 digits

b2a10: CMP     CL,4
        JZ      b2a11

        OR      EAX,EAX
        JZ      b2a12

b2a11:  PUSH ECX
MOV CL, 10
XOR EDX, EDX
DIV ECX
OR DL, '0' ;Binary--> ASCII
POP ECX
MOV [EDI], DL
DEC EDI
LOOP b2a10

        RET

b2a12:  MOV BYTE PTR [EDI],20h
        DEC     EDI
        LOOP    b2a12

        RET

B2A4 ENDP


i should mention - the LOOP instruction is slow in 32-bit world
we generally use DEC ECX/JNZ
however - speed isn't super critical here

NoCforMe

Quote from: dedndave on October 07, 2011, 06:52:25 PM
one solution that comes to mind would be to create a large child window that does not include the drop-down and status bar
then, create the little windows under that one
i have done this in the past to prevent scroll bar flicker

So like this?

Main window--> big child window--> little kid windows?

The big child window would have no title bar, no resizeable borders, just a big (borderless?) "playground" for the small children.
Would respond to resize messages just like the status bar (handled in parent).

Seems to make sense.

By the way, I think your latest B2A routine needs a little work ...

dedndave

it seems to work ok - i just tried it for the first go - lol
i may have missed something
the point was, though, why convert them after the fact ?
if the dividend is 0, fill the rest in with spaces
of course, you want the first 0, in case the value is 0
there are far more efficient ways to do this - it was a down-and-dirty approach   :P

yes - a child window with no border or title - the style would be "WS_VISIBLE or WS_CHILD or WS_CLIPCHILDREN"
which, btw - i see you using "+" to add flags together
this will byte you in the ass - lol
use "OR"   :U

you write a seperate WndProc for it - of course, one more class to register, too
in a way, it makes it nice because you put all the child stuff in one WndProc and the main window in another
should make it a little easier to read
you can combine them into one, but it's not worth the effort

when the main window is resized, you set the size for the "master" child
that code can be combined with the status bar size code

dedndave

the problem with the little windows seems to be that they are not being redrawn entirely
we must be missing a style bit someplace   :bg

NoCforMe

Quote from: dedndave on October 07, 2011, 07:13:35 PM
yes - a child window with no border or title - the style would be "WS_VISIBLE or WS_CHILD or WS_CLIPCHILDREN"
which, btw - i see you using "+" to add flags together
this will byte you in the ass - lol

Side issue, but I disagree: how do you suppose that there's any difference between 'X or Y or Z" and "X + Y + Z" when they're all unsigned quantities?

I already explained eariler why I do this.

I do realize that there are places where this would byte one in the ass. This isn't one of them. No problems with overflow here.

NoCforMe

Quote from: dedndave on October 07, 2011, 07:25:42 PM
the problem with the little windows seems to be that they are not being redrawn entirely
we must be missing a style bit someplace   :bg
\

Yes! I'm sure that's at least part of the problem.

Gotta leave now, but when I come back I'll go through the code and extract all the style settings and put them in a message. There's some kind of conflict somewhere, I'm sure.

dedndave

ok - rock on   :P

let me think of an example....

try this...
       mov     eax,WS_OVERLAPPEDWINDOW+WS_SYSMENU
       print   str$(eax),13,10
       mov     eax,WS_OVERLAPPEDWINDOW or WS_SYSMENU
       print   str$(eax),13,10

jj2007

Quote from: NoCforMe on October 07, 2011, 07:27:20 PM
Side issue, but I disagree: how do you suppose that there's any difference between 'X or Y or Z" and "X + Y + Z" when they're all unsigned quantities?

Good example, Dave. In many cases - see first three below - Windows shows benign behaviour because only 1 bit is set for each constant. It is the exceptions that will let your code go bang. Chasing such bugs is a nightmare...

WS_VISIBLE     =        00010000000000000000000000000000
WS_CHILD       =        01000000000000000000000000000000
WS_CLIPCHILDREN=        00000010000000000000000000000000
WS_OVERLAPPEDWINDOW=    00000000110011110000000000000000
WS_SYSMENU=             00000000000010000000000000000000
Sys or OverLap=         00000000110011110000000000000000
Sys + OverLap=          00000000110101110000000000000000

dedndave

well - there are better examples, but that one was easy to come up with - lol
the thing is....
like Jochen says, trying to find this bug will make you pull your hair out

NoCforMe

OK, jj, you convinced me. I guess I'm just used to working with single-bit flags in my own code. OR it is.

I'm still having to break myself of my 16-bit habits, like that INC DI in the b2a routine. Still seems strange to type things like EAX, EDX, etc. And realize that PUSH and POP expect 32-bit entities, not 16-bit.

=====================================================

Regarding my child-window problem, before I code another layer of window like you suggested, let's think about this a moment. The problem is that the child windows' borders aren't being redrawn (or not redrawn properly): why is this? Is it something I'm doing or not doing in my program? or do I have the wrong styles somewhere?

I'd like to understand what's actually wrong here, rather than just start throwing darts at the dartboard, if you know what I mean.

I'll wait until you (Dave) have had a chance to look at my newest program.