News:

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

Error on paint windows

Started by 5k3l3t0r, May 16, 2012, 10:16:22 PM

Previous topic - Next topic

dedndave

that is interesting, qWord

but - i do not understand how the modeless dialog messages are handled

also - i see that WS_CLIPSIBLINGS affects the re-paint
however, i do not understand why it should be that way   :red
it seems to me that WS_CLIPSIBLINGS should be optional - not required - lol

i am not getting what i think should be "standard behaviour" out of the child windows
when you click on a child - anywhere - it should come to the the foreground
the behaviour i am seeing is that you must click and release on the title bar before it comes to the front
i don't think we are using the right combination of style bits   :'(

5k3l3t0r

yep, that's right but at least, 80% of the problem is solved...

thanks a lot.

if i get all working 100% i will post the solution here for future reference, since i have searched all over the internet and can't found a working example.

by,
5k3l3t0r

5k3l3t0r

hi again,

after some testing, other strange behavior come:

http://screensnapr.com/v/HmxhNM.png

this append if you drag the child window around for a while, the complete application become crazy on the paint process

if i comment this line in the parent all seems to work correct

.elseif uMsg==WM_CTLCOLORDLG
RGB 206,206,206
invoke CreateSolidBrush,eax
ret


some workaround?

tkx in advance

5k3l3t0r


qWord

The problem is, that you are using dialogs as child controls. They look like top level windows, but behave like common child controls. These controls assumes to be not overlapped by siblings, because the are commonly not moved. The problem with the activation has probably something to do with the fact, the dialogs are designed as popup windows. The following code may helps:
.elseif uMsg == WM_NCLBUTTONDOWN
invoke SetWindowPos,hWnd,HWND_TOP,0,0,0,0,SWP_NOMOVE or SWP_NOSIZE
invoke InvalidateRect,hWnd,0,TRUE
invoke UpdateWindow,hWnd
xor eax,eax
ret
.elseif uMsg == WM_LBUTTONDOWN
invoke SetWindowPos,hWnd,HWND_TOP,0,0,0,0,SWP_NOMOVE or SWP_NOSIZE

(Also remove the TOPMOST-style from the dialog)
FPU in a trice: SmplMath
It's that simple!

qWord

Quote from: 5k3l3t0r on May 17, 2012, 02:08:33 PM
this append if you drag the child window around for a while, the complete application become crazy on the paint process
...
some workaround?
You are producing a handle leak: create a global variable  (or better use a property) and store the brush in it when initializing the dialog. Pass this handle while handling the mesage.
FPU in a trice: SmplMath
It's that simple!

dedndave

well - i have played with this - lol
trying to figure out how to correctly create child windows - something i thought i had already figured out
apparently, i did not have it figured out   :bg

i have looked at:
class styles of both parent and child
extended styles of both parent and child
window styles of both parent and child
and - WndProc's of both parent and child

the answer has to be in there someplace, but still eludes me  :(
there are a seemingly enormous number of combinations to try

another thing i did was - i looked at my little MDI window program
it exhibits the behaviour that we are after
nothing special in the style bits, really
which leads me to consider the default handling of messages in the parent and child WndProc's
this is one place where MDI windows vary greatly from normal modeless windows
the parent window proc uses DefFrameProc instead of DefWindowProc
and the MDI child window proc's use DefMDIChildProc instead of DefWindowProc

another big difference of MDI windows (there are many),
is that there is a 3-tier hierarchy of windows - not just the 2 tiers that we have been trying
i.e., there is a frame window, a client window, then there are the child windows
you have to provide the WndProc's for the frame and the children
but the WndProc for the client is provided by the system
so - you don't really see what is going on, there   :P

in other programs i have written, i often wind up doing something similar
i create windows and controls to fill the client area - never really working directly with the client, itself
i have done this to reduce flicker and to reduce CPU usage in WM_PAINT - things like that
it's also easier to position and size all the controls together during WM_SIZE if you don't deal directly with the client
sometimes, i can use NULL_BRUSH as the client background, because it is covered by other windows   :P
if i have scroll bars, though, i use COLOR_SCROLLBAR as the client background

so - i am going to play with a 3-tier hierarchy for a little while
and - if i get tired of that, i will re-write my MDI program so that others may read it - lol

dedndave

here is a simple MDI window example
i cleaned it up so everyone else can read it - lol
i even used IF/ELSE/ENDIF and indentation, both of which i hate   :P

this one handles the menu correctly - i even provide keyboard accelerators for most menu items

a special version that creates 2 MDI child windows and a "log" window as skeletor wants should be an easy mod

5k3l3t0r

hi,
tkx for the example, i will use it for future ref, since in this project i don't want the mdi features like menu merge etc, but is an interesting peace of code...

tkx all

5k3l3t0r     

dedndave

it is easy to remove the menu features and add a second window
i hope you tried "File menu - New" a few times - then played with the child windows
they behave like they ought to - you click on one anywhere, and it comes to the front

to remove the child list from the menu, just eliminate this code...
        ; ----------- Initialize client create structure -----------

        ;we need a handle to the menu where the client will update the child list

        INVOKE  GetMenu,ebx
        mov     hMenu,eax
        INVOKE  GetSubMenu,eax,edi
        mov     edx,offset ccs
        mov     [edx].CLIENTCREATESTRUCT.hWindowMenu,eax

that will leave the ccs.hWindowMenu member set to 0, and there will be no child list
it is important that the CLIENTCREATESTRUCT has the ID of the first child, however
so, leave this part intact...
;-----------------------------------------

;Client Create Structure

ccs CLIENTCREATESTRUCT <?,IDW_FIRSTCHILD>

the last parameter in CreateWindowEx must be a pointer to the CLIENTCREATESTRUCT structure
        INVOKE  CreateWindowEx,edi,offset szClientClass,edi,
                WS_CHILD or WS_VISIBLE or WS_CLIPCHILDREN,
                edi,edi,edi,edi,ebx,edi,esi,offset ccs

and - you could change the "?" to "0"

to create a second child window...
; ----------- Create the first child "automatically" -----------

;the child window count is already initialized to 1

    INVOKE  SendMessage,esi,WM_MDICREATE,edi,offset mcs

just execute that SendMessage call a second time
you can also eliminate the code that keeps count in nChildCount

to prevent it from making new windows, eliminate the File - New code
making an MDI window not work completely is easy - lol

one more item....
the MDI frame window does not need to be the main application window
it can be a child of the main window

the window hierarchy used in my example looks like this...
frame window (main app)
    MDI client window
        MDI child
        MDI child
        MDI child....


the window hierarchy you may want to use looks something like this...
main app window
    MDI frame window
        MDI client window
            MDI child
            MDI child
    log window

in WM_SIZE, you only need to size the MDI frame window and the log window
the MDI client window sizes itself to fill the MDI frame window client area

5k3l3t0r

yep, i have understand the mdi features (i use a lot in c#), but here isn't suitable since all dialogs (except  the main and the log) come from Dll's coded by others and can't be maximized because the layout, sow that gray part (actually a dialog to serve as parent) in my window is to serve as parent for all dialogs that come from plugins (maybe sounds a bit strange) but wen i have finished all i can post here a copy, or send a copy to you since i don't know if this type of software is welcome in the forum.

by,
5k3l3t0r

dedndave

oh - i did not realize what you were making
no - that isn't allowed, here