News:

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

LOOK HERE User Defined Static Control that hides!!!

Started by xandaz, February 02, 2012, 12:06:50 PM

Previous topic - Next topic

xandaz

    I've been working on this example for an Extra Controls Library and got this made for now. I feel kinda happy though maybe the code seems a bit dirty. Just wanted to get it to work.
    Enjoy

xandaz

    well... There are some things that need fixing.
    i'll post later.

xandaz

   I think i might need some help... Can someone look at it? Why doesn't DrawText draw the text when i send STXM_ADDCONTENT and the Static Control is visible?

qWord

What I've found after a quick view:
STXM_ADDCONTENT:
        invoke  SendMessage,hWnd,WM_PAINT,0,0              ; <- make no sense - do not send WM_PAINT explecit -> InvalidRect()
        invoke  InvalidateRect,hWnd,addr [esi].rect,TRUE   ; <- is RECT properly filled?

WM_PAINT:
            invoke  ShowWindow,hWnd,SW_SHOW                     ; WM_PAINT is for painting!
            invoke  ShowWindow,[esi].ChevStruct.hCh,SW_HIDE     ;
            invoke  SetTimer,hWnd,0100,2000,addr StaticExProc   ;
            ...
FPU in a trice: SmplMath
It's that simple!

xandaz

    lmao q. I've tried InvalidateRect at first but it didn't work out. So, ... i'll remove that nonsense and report later. Thanks Q.

dedndave

if you want to update the window immediately, follow the InvalidateRect with UpdateWindow
also - you can use InvalidateRgn with the handle of the static control and NULL for hRgn
it's probably easier than InvalidateRect because you don't need a RECT

xandaz

   I'm getting pretty tired of this control. I've fixed all that nonsense although some tihngs might be overlooked. I'm having some trouble finding why i can't process the STXN_HEIGHTCHANGED notify message.
   Q... i was trying a lot of things and left some functions lying around that's why those WM_PAINT and InvalidateRect were together. Also i had tried InvalidateRect and it wasn't working somehow and i tried the PAINT. This new zip is more acoording to the publics liking. It just doesn't resize the list view control. I'm tired and need sometime to freshen up my ideas. It's one of those obvious mistakes i'm making but i always fail to see the obvious.
   Thanks for all the help guys.

qWord

hi,
maybe I will step in the next days. However, you may read in the good old win32.hlp or at msdn about windows and painting/drawing. Also I've seen, that there is still a SetTimer() in you WM_PAINT-handler.

BTW: there is a nice trick in you code:
        push    hInstance
        pop     wcStaticEx.hInstance
        sub     esp,4
        pop     wcChevron.hInstance
:dance:
FPU in a trice: SmplMath
It's that simple!

dedndave

        mov     eax,hInstance
        mov     wcStaticEx.hInstance,eax
        mov     wcChevron.hInstance,eax

jj2007

Quote from: dedndave on February 06, 2012, 01:28:00 AM
        mov     eax,hInstance
        mov     wcStaticEx.hInstance,eax
        mov     wcChevron.hInstance,eax


4 bytes shorter, and probably 1 or 2 nanoseconds faster :bg
But the sub esp, 4 trick is cute anyway :thumbu

qWord

hi,
after some modification, it seems to work for me - but I'm not sure, if the result is what you expect.

Some points/hint about your code:
o  you are always using + to combine flags -> OR
o  SetTimer() is used incorrect -> SetTimer(hWnd,ID,0)
o  GDI:
        obj = SelectObject(hDC,CreateWhatEverGDI_Obj());
        draw/paint
        DeleteObject(SelectObject(hDC,obj));       
o typing error?: && used for testing a bit/flag -> &
o SHGetFileInfo: SHGFI_ICON is missing
o it seems like the used RECT-structures are not proper  filled -> this was/is a problem when using them with InvalidRect()
o hint: fill API structures before the call, thus the code is quickly comprehensible (e.g. FillListView)
o hint: create copies off all data/object that your control receives: alloc()+szCopy() , CopyIcon() , ...
        This makes clear who owns the object and also avoids usage of invalid handles/pointers.
        Of course this is not practical for memory consuming stuff like huge bitmaps.
o hint: use INT3 to test if a specific path is execute


in the attachment the code. For convenience I've merged the source files
FPU in a trice: SmplMath
It's that simple!

jj2007

Hi qWord,

The exe in your attachment won't start on XP - access denied. Reassembling helps, though. Attached both versions.

qWord

hi,
Quote from: jj2007 on February 06, 2012, 12:43:27 PMThe exe in your attachment won't start on XP - access denied. Reassembling helps, though. Attached both versions.
so it requires adminstator rights for reading C:\ ?
FPU in a trice: SmplMath
It's that simple!

dedndave

i had a similar problem with qWord's network time program
i got the "not a valid wn32 application error" - re-assembling fised it
i am guessing it may be a problem with the libs

qWord

Quote from: dedndave on February 06, 2012, 01:12:11 PMi am guessing it may be a problem with the libs
Currently I think it is a problem of the linker: I'm using link.exe, v11 ...
jj, can you test attached EXEs?

qWord
FPU in a trice: SmplMath
It's that simple!