Author Topic: Autohide Toolbar  (Read 9938 times)

zedd151

  • Member
  • ****
  • Posts: 871
Re: Autohide Toolbar
« Reply #15 on: September 06, 2015, 03:57:39 AM »

Code: [Select]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;                                                                       ;;
;;  See first post of the thread for the example - source code included  ;;
;;                                                                       ;;
;;  in the attachment (vertical3a.zip)                                   ;;
;;                                                                       ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
« Last Edit: September 27, 2015, 04:51:05 PM by zedd151 »
I'm not always the sharpest knife in the drawer, but I have my moments.  :P

dedndave

  • Member
  • *****
  • Posts: 8827
  • Still using Abacus 2.0
    • DednDave
Re: Autohide Toolbar
« Reply #16 on: September 06, 2015, 04:23:09 AM »
here is a routine i use to size windows and controls - it will handle a window and it's children (not grandchildren)
it uses/destroys all registers - it's meant to be called from a "shell" routine specific to each case or use
the shell routine preserves and restores registers, as required

Code: [Select]
;***********************************************************************************************

SetWndPos PROC

;Call With: EBX = window/control count
;           ESI = handle structure pointer
;           5 stack parms per window
;
;  Returns: EBX = 0
;           ESI = pointer to next handle in structure
;
;Also Uses: EDI and EBP are destroyed

        pop     edi
        INVOKE  BeginDeferWindowPos,ebx
        mov     ebp,eax

SetWp0: xchg    eax,edx
        or      ebp,ebp
        lodsd
        push    HWND_TOP                         ;DeferWindowPos/SetWindowPos:hWndInsertAfter
        push    eax                              ;DeferWindowPos/SetWindowPos:hWnd
        jnz     SetWp1

        CALL    SetWindowPos                     ;fallback method
        jmp short SetWp2

SetWp1: push    edx                              ;DeferWindowPos:hWinPosInfo
        CALL    DeferWindowPos                   ;defer method

SetWp2: dec     ebx                              ;window count
        jnz     SetWp0

        or      ebp,ebp
        jz      SetWp3

        INVOKE  EndDeferWindowPos,eax

SetWp3: jmp     edi

SetWndPos ENDP

;***********************************************************************************************

dedndave

  • Member
  • *****
  • Posts: 8827
  • Still using Abacus 2.0
    • DednDave
Re: Autohide Toolbar
« Reply #17 on: September 06, 2015, 04:30:26 AM »
to use that routine, the handles are placed in a structure (basically an orderly list of child handles)
you push the arguments for each control onto the stack, set the qty, and call it

here is an example - a rather complex window with many child windows
the advantage is - when you calculate dimensions, all the values are in register
so, calculate and push all of them, maintaining the register values
DeferWindowPos will perform all of it at once, rather that each window individually
when you call EndDeferWindowPos - bang - everything is redrawn

Code: [Select]
;***********************************************************************************************

wmSize  PROC

;Call With: ECX = client width
;           EDX = client height

        push    ebp
        push    ebx
        push    ecx
        xor     ebp,ebp
        push    edx
        INVOKE  SendMessage,chs.hHiResWin,WM_SETREDRAW,ebp,ebp
        INVOKE  SendMessage,chs.hVPlotWin,WM_SETREDRAW,ebp,ebp
        INVOKE  SendMessage,chs.hHPlotWin,WM_SETREDRAW,ebp,ebp
        pop     edx
        pop     ecx
        call    MinAdjust
        dec     ecx
        push    esi
        mov     olds.uDim3,ecx
        push    edi
        sub     ecx,TOOLA_WIDTH
        mov     esi,cg.h.uPlotSize
        mov     eax,cg.v.uScBarSizeX2
        mov     ebp,SP_FLAGSET      ;EBP = SP_FLAGSET
        add     esi,DIV_WIDTH       ;ESI = cg.h.uPlotSize+DIV_WIDTH
        xor     ebx,ebx             ;EBX = 0
        mov     edi,edx             ;EDI = EDX = ClientHeight
        sub     ecx,esi             ;ECX = ClientWidth-TOOLA_WIDTH-cg.h.uPlotSize-DIV_WIDTH-1
        sub     edi,eax             ;EDI = ClientHeight-(cg.v.uScBarSizeX2)
        mov     cg.v.rcDiv.left,ebx

;ScrolWin

        push    ebp           ;DeferWindowPos/SetWindowPos:uFlags = SP_FLAGSET
        push    eax           ;DeferWindowPos/SetWindowPos:cy = cg.v.uScBarSizeX2
        push    ecx           ;DeferWindowPos/SetWindowPos:cx = ClientWidth-TOOLA_WIDTH-cg.h.uPlotSize-DIV_WIDTH-1
        push    edi           ;DeferWindowPos/SetWindowPos:y = ClientHeight-(cg.v.uScBarSizeX2)
        push    esi           ;DeferWindowPos/SetWindowPos:x = cg.h.uPlotSize+DIV_WIDTH
        dec     edi           ;EDI = ClientHeight-(cg.v.uScBarSizeX2)-1
        mov     olds.uDim2,edi
        mov     eax,cg.v.uPlotSize
        sub     edi,eax       ;EDI = ClientHeight-(cg.v.uScBarSizeX2)-cg.v.uPlotSize-1

;HPlotWin

        push    ebp           ;DeferWindowPos/SetWindowPos:uFlags = SP_FLAGSET
        push    eax           ;DeferWindowPos/SetWindowPos:cy = cg.v.uPlotSize
        push    ecx           ;DeferWindowPos/SetWindowPos:cx = ClientWidth-TOOLA_WIDTH-cg.h.uPlotSize-DIV_WIDTH-1
        mov     cg.v.rcDiv.bottom,edi
        push    edi           ;DeferWindowPos/SetWindowPos:y = ClientHeight-(cg.v.uScBarSizeX2)-cg.v.uPlotSize-1
        push    esi           ;DeferWindowPos/SetWindowPos:x = cg.h.uPlotSize+DIV_WIDTH
        sub     edi,DIV_WIDTH ;EDI = ClientHeight-(cg.v.uScBarSizeX2)-cg.v.uPlotSize-DIV_WIDTH-1

;HiResWin

        push    ebp           ;DeferWindowPos/SetWindowPos:uFlags = SP_FLAGSET
        push    edi           ;DeferWindowPos/SetWindowPos:cy = ClientHeight-(cg.v.uScBarSizeX2)-cg.v.uPlotSize-DIV_WIDTH-1
        push    ecx           ;DeferWindowPos/SetWindowPos:cx = ClientWidth-TOOLA_WIDTH-cg.h.uPlotSize-DIV_WIDTH-1
        push    ebx           ;DeferWindowPos/SetWindowPos:y = 0
        push    esi           ;DeferWindowPos/SetWindowPos:x = cg.h.uPlotSize+DIV_WIDTH
        mov     cg.h.rcDiv.right,esi
        mov     cg.v.rcDiv.top,edi
        mov     hs.nPage,ecx
        sub     esi,DIV_WIDTH ;ESI = cg.h.uPlotSize

;VPlotWin

        push    ebp           ;DeferWindowPos/SetWindowPos:uFlags = SP_FLAGSET
        push    edi           ;DeferWindowPos/SetWindowPos:cy = ClientHeight-(cg.v.uScBarSizeX2)-cg.v.uPlotSize-DIV_WIDTH-1
        push    esi           ;DeferWindowPos/SetWindowPos:cx = cg.h.uPlotSize
        push    ebx           ;DeferWindowPos/SetWindowPos:y = 0
        push    ebx           ;DeferWindowPos/SetWindowPos:x = 0
        mov     eax,edx
        add     edi,DIV_WIDTH ;EDI = ClientHeight-(cg.v.uScBarSizeX2)-cg.v.uPlotSize-1
        mov     cg.h.rcDiv.left,esi
        sub     eax,edi       ;EAX = (cg.v.uScBarSizeX2)+cg.v.uPlotSize+1

;ToolBWin

        push    ebp           ;DeferWindowPos/SetWindowPos:uFlags = SP_FLAGSET
        push    eax           ;DeferWindowPos/SetWindowPos:cy = (cg.v.uScBarSizeX2)+cg.v.uPlotSize+1
        push    esi           ;DeferWindowPos/SetWindowPos:cx = cg.h.uPlotSize
        push    edi           ;DeferWindowPos/SetWindowPos:y = ClientHeight-(cg.v.uScBarSizeX2)-cg.v.uPlotSize-1
        push    ebx           ;DeferWindowPos/SetWindowPos:x = 0

        add     ecx,esi       ;ECX = ClientWidth-TOOLA_WIDTH-DIV_WIDTH-1
        mov     edi,PAL_WIN_HEIGHT+1
        add     ecx,DIV_WIDTH ;ECX = ClientWidth-TOOLA_WIDTH-1
        mov     eax,TOOLA_WIDTH
        mov     cg.v.rcDiv.right,ecx
        mov     olds.uDim1,ecx
        sub     edx,edi       ;EDX = ClientHeight-PAL_WIN_HEIGHT-1
        inc     ecx           ;ECX = ClientWidth-TOOLA_WIDTH

;ToolAWin

        mov     nToolAHeight,edx
        push    ebp           ;DeferWindowPos/SetWindowPos:uFlags = SP_FLAGSET
        push    edx           ;DeferWindowPos/SetWindowPos:cy = ClientHeight-PAL_WIN_HEIGHT-1
        push    eax           ;DeferWindowPos/SetWindowPos:cx = TOOLA_WIDTH
        push    edi           ;DeferWindowPos/SetWindowPos:y = PAL_WIN_HEIGHT+1
        push    ecx           ;DeferWindowPos/SetWindowPos:x = ClientWidth-TOOLA_WIDTH
        dec     edi           ;EDI = PAL_WIN_HEIGHT
        mov     edx,PAL_WIN_WIDTH

;PalWin

        push    ebp           ;DeferWindowPos/SetWindowPos:uFlags = SP_FLAGSET
        push    edi           ;DeferWindowPos/SetWindowPos:cy = PAL_WIN_HEIGHT
        push    edx           ;DeferWindowPos/SetWindowPos:cx = PAL_WIN_WIDTH
        push    ebx           ;DeferWindowPos/SetWindowPos:y = 0
        push    ecx           ;DeferWindowPos/SetWindowPos:x = ClientWidth-TOOLA_WIDTH
        add     ecx,eax       ;ECX = ClientWidth
        mov     edx,3*TRACK_WIDTH
        sub     ecx,edx       ;ECX = ClientWidth-(3X TRACK_WIDTH)
        lea     eax,[ecx-1]
        mov     olds.uDim4,eax

;TrackWin

        push    ebp           ;DeferWindowPos/SetWindowPos:uFlags = SP_FLAGSET
        push    edi           ;DeferWindowPos/SetWindowPos:cy = PAL_WIN_HEIGHT
        push    edx           ;DeferWindowPos/SetWindowPos:cx = 3X TRACK_WIDTH
        push    ebx           ;DeferWindowPos/SetWindowPos:y = 0
        push    ecx           ;DeferWindowPos/SetWindowPos:x = ClientWidth-(3X TRACK_WIDTH)

;update scroll bar and strategy values

        call    SetMovScroll  ;ESI = control handle structure address

;update window and control positions

        add     esi,ControlHandleStruct.hTrackWin
        mov     bl,8
        call    SetWndPos
        INVOKE  SendMessage,chs.hHiResWin,WM_SETREDRAW,TRUE,ebx
        INVOKE  SendMessage,chs.hVPlotWin,WM_SETREDRAW,TRUE,ebx
        INVOKE  SendMessage,chs.hHPlotWin,WM_SETREDRAW,TRUE,ebx
        INVOKE  RedrawWindow,hWin,ebx,ebx,RDW_INVALIDATE or RDW_UPDATENOW or RDW_ALLCHILDREN

;restore registers and exit

        pop     edi
        pop     esi
        pop     ebx
        pop     ebp
        ret

wmSize  ENDP

;***********************************************************************************************

zedd151

  • Member
  • ****
  • Posts: 871
Re: Autohide Toolbar
« Reply #18 on: September 06, 2015, 04:43:40 AM »
Thanks dave. I knew this was going to get a little complicated.

I will have to look into this.  I was looking into 'BeginDeferWindowPos' and the others earlier on msdn.

This sounds like a pretty good plan.

collapse the toolbar to 6 pixels (I'm going blind, lol)

then use mouse messages - say the mouse has to hover for xxx milliseconds before opening the toolbar

collapsing the toolbar could then be done by either mouse clicks (on buttons on toolbar)  and/or the mouse leaving the toolbar control.

Now I have something new to try out and investigate!


I have rethought the idea of resizing the richedit control with the changed toolbar position,

I now think that it would be a little too 'busy'. And in most cases unwanted.

edit = corrections
« Last Edit: September 06, 2015, 06:12:12 AM by zedd151 »
I'm not always the sharpest knife in the drawer, but I have my moments.  :P

dedndave

  • Member
  • *****
  • Posts: 8827
  • Still using Abacus 2.0
    • DednDave
Re: Autohide Toolbar
« Reply #19 on: September 06, 2015, 05:10:44 AM »
you could resize the columns
and, it's not that it would too busy
but, i just think it might look nicer if the listview left-justifed, moved to the right, and clipped on that end
it's only a guess - i try to imagine how it will look in my head
that doesn't always turn out right - lol

dedndave

  • Member
  • *****
  • Posts: 8827
  • Still using Abacus 2.0
    • DednDave
Re: Autohide Toolbar
« Reply #20 on: September 06, 2015, 05:12:26 AM »
even better - put the toolbar on the right and just clip the listview
most users are right handed, so buttons on the right makes more sense, anyways

zedd151

  • Member
  • ****
  • Posts: 871
Re: Autohide Toolbar
« Reply #21 on: September 06, 2015, 05:15:35 AM »
Listview??

I'm not always the sharpest knife in the drawer, but I have my moments.  :P

dedndave

  • Member
  • *****
  • Posts: 8827
  • Still using Abacus 2.0
    • DednDave
Re: Autohide Toolbar
« Reply #22 on: September 06, 2015, 05:18:27 AM »
rich edit - whatever control you have in the main window - lol

toolbar on the bottom is more generic - good for lefties and righties - and, you've got a wide format, anyways
that's if you don't mind hiding a couple rows

dedndave

  • Member
  • *****
  • Posts: 8827
  • Still using Abacus 2.0
    • DednDave
Re: Autohide Toolbar
« Reply #23 on: September 12, 2015, 06:15:22 AM »
well - i have a test program running   :P

when i have a little time, i just need to add the mouse capture and timers

zedd151

  • Member
  • ****
  • Posts: 871
Re: Autohide Toolbar
« Reply #24 on: September 12, 2015, 11:09:38 AM »
hey dave, looks nice.

I've been working on something here as well - little by little.
Most of the framework is in place, but as you I haven't done the mouse captures/releases, etc...
I'm not always the sharpest knife in the drawer, but I have my moments.  :P

zedd151

  • Member
  • ****
  • Posts: 871
Auto Hide Vertical Toolbar Demo
« Reply #25 on: September 20, 2015, 02:39:50 PM »
Code: [Select]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;                                                                       ;;
;;  See first post of the thread for the example - source code included  ;;
;;                                                                       ;;
;;  in the attachment (vertical3a.zip)                                   ;;
;;                                                                       ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

« Last Edit: September 25, 2015, 10:39:36 PM by zedd151 »
I'm not always the sharpest knife in the drawer, but I have my moments.  :P

dedndave

  • Member
  • *****
  • Posts: 8827
  • Still using Abacus 2.0
    • DednDave
Re: Autohide Toolbar
« Reply #26 on: September 20, 2015, 03:43:20 PM »
i got busy and forgot about this project - lol
maybe tomorrow, i'll try and finish mine - it's sunday   :P

zedd151

  • Member
  • ****
  • Posts: 871
Re: Autohide Toolbar
« Reply #27 on: September 21, 2015, 12:36:38 AM »
A slight modification to the source (better commenting, for clarity).

For those who have been following some of my work, (except the counting/timing fiasco)
I intent to integrate this into my 'zedds editor'. The toolbar there was becoming too
cluttered. I do like the idea though of keeping the search/replace function always visible.

So stay tuned for further development of  zedds editor, or simply 'ZeddsEd". :biggrin:
(It will also integrate several of my other recent projects)


« Last Edit: September 25, 2015, 10:28:04 PM by zedd151 »
I'm not always the sharpest knife in the drawer, but I have my moments.  :P

zedd151

  • Member
  • ****
  • Posts: 871
update
« Reply #28 on: September 21, 2015, 10:20:48 AM »
Added some more commenting, and redesigned the calculating of the variables for
the controls' coordinates - it's more readable now.  :P


Also added the start of an additional horizontal toolbar.

Code: [Select]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;                                                                       ;;
;;  See first post of the thread for the example - source code included  ;;
;;                                                                       ;;
;;  in the attachment (vertical3a.zip)                                   ;;
;;                                                                       ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

« Last Edit: September 25, 2015, 10:40:53 PM by zedd151 »
I'm not always the sharpest knife in the drawer, but I have my moments.  :P

zedd151

  • Member
  • ****
  • Posts: 871
Re: Autohide Toolbar
« Reply #29 on: October 07, 2015, 07:03:58 AM »
I am currently working to fully automate the hiding/opening the Toolbar.

I will use timers to auto-close it, and I am coding it so if he mouse hovers for a ceratin period over
the toolbar, it automatically opens the toolbar.

Source code coming soon... (I don't have the sources available at the moment - I am at a physically different location from most of my source codes.)
I'm not always the sharpest knife in the drawer, but I have my moments.  :P