The MASM Forum

General => The Laboratory => Topic started by: 0000 on September 02, 2015, 07:15:58 AM

Title: Autohide Toolbar
Post by: 0000 on September 02, 2015, 07:15:58 AM
I have been playing around with creating an autohide toolbar.

This little program will demonstrate several things.

First, rolling your own vertical toolbars.

Make them at least semi-automatic; there are narrow (6 pixels) wide static controls of
either side of the main window. Click on either one, and a toolbar opens.

There are a few buttons on each toolbar. Click on any button, the toolbar closes.

Very simple to achieve.

The other thing this program demonstrates is changing the background color and text
color of a rich edit control.



Latest example attached, source code included in the attachment




 vertical toolbar example  (https://www.dropbox.com/s/6g2uxrgr8211s0e/vertical3a.zip?dl=1)
Title: Re: Autohide Toolbar
Post by: 0000 on September 03, 2015, 11:36:34 AM
See first post of the thread for the example - source code included

in the attachment (vertical3a.zip)

Title: Re: Autohide Toolbar
Post by: dedndave on September 04, 2015, 04:36:31 AM
i think i've shown you my divider window example
in it, i used "mouse capture" and the WM_CAPTURECHANGED message
that would be one way to get what you want (probably how i would do it)

http://masm32.com/board/index.php?topic=2977.msg31084#msg31084 (http://masm32.com/board/index.php?topic=2977.msg31084#msg31084)
Title: Re: Autohide Toolbar
Post by: 0000 on September 04, 2015, 04:55:39 AM
See first post of the thread for the example - source code included

in the attachment (vertical3a.zip)

Title: Re: Autohide Toolbar
Post by: dedndave on September 04, 2015, 05:29:44 AM
ok - let's try this....

rather than using GetWindowRect, use GetClientRect
see if it changes when the toolbar is animated
Title: Re: Autohide Toolbar
Post by: dedndave on September 04, 2015, 05:33:10 AM
i've never played iwth AnimateWindow
primarily, i suppose, due to all the problems reported in the communty section on MSDN - lol

but, i'm sure we can figure it out
Title: Re: Autohide Toolbar
Post by: dedndave on September 04, 2015, 05:51:52 AM
Code: [Select]
INVOKE  GetWindowLong,hWnd,GWL_STYLEthe result in EAX should have the WS_VISIBLE bit set when the window is showing

still researching....
Title: Re: Autohide Toolbar
Post by: dedndave on September 04, 2015, 06:06:03 AM
wow - with all the problems reported, i'd be tempted to animate the window(s) myself
you can roll your own animation, so that both windows "roll" together
Title: Re: Autohide Toolbar
Post by: 0000 on September 04, 2015, 06:47:58 AM
You know dave, I'm just tempted to leave it as is.

I mean so what if the toolbar covers a small part of the richedit control.

The toolbar will automatically hide itself once any button therein is pressed anyway.

So I think that is how I will proceed....

I won't post in this thread again until I have a working (somewhat) example to post.

I could as you say 'roll my own' also. That option is always there. I just liked the automated

'AnimateWindow' for it's simplicity (from the outside, anyway).
Title: Re: Autohide Toolbar
Post by: 0000 on September 04, 2015, 06:55:25 AM
I think I have a tentative solution. Not very elegant, but I think it should work...

Since I click on a 'gripper' (see example in attachment above in post #4) to open the toolbar via a timer,

why not also have the richedit control simply jump to the toolbar 'opened' position, once the toolbar is completely open?

Like I said, not as elegant as having the richedit 'slide' into position adjacent to the opened toolbar,

but for practical purposes it should work.

Anyway as I have said again, this project is basically on the back burner for now. I have work to do

making my plugin builder a plugin itself. - more on that later in another thread.
Title: Re: Autohide Toolbar
Post by: 0000 on September 05, 2015, 01:18:44 PM
I have another idea regarding the 'Autohide Toolbar'. I'm currently working one that I hope to make

generic enough so that the user can specify top, left, right or bottom for the toolbar location.

Right now I am simply experimenting but am hopeful to have a working example soon.
Title: Re: Autohide Toolbar
Post by: 0000 on September 05, 2015, 06:25:08 PM
I have another idea regarding the 'Autohide Toolbar'....

generic enough so that the user can specify top, left, right or bottom for the toolbar location.

 ::)  Yeah, sure. When pigs fly!

So much for my bright ideas. Anyway I attempted the same feat using 'SetWindowPos' this time, basically

with the same results. I have truly given up this time. Not that I haven't made the toolbars and they are at least

semi-automatic, I am just not satisfied with the results. I'll just stick with a couple of tried and true toolbars

for now. ....

Possibly forever. lol  :(

This task was much harder than I thought it would be. Maybe I should take up VisualBasic. lol  ::)
Title: Re: Autohide Toolbar
Post by: rrr314159 on September 06, 2015, 12:40:33 AM
Quote from: Richard Nixon
Winners never quit, and quitters never win

Quote from: Bill Gates
I created Visual Basic because I hate real programmers
Title: Re: Autohide Toolbar
Post by: dedndave on September 06, 2015, 01:26:32 AM
i know how i'd do it   :biggrin:

start with a small tool window, say 2 to 4 pixels wide - something like that
WM_MOUSEMOVE - when the tool window proc gets this message, begin expansion of the tool window
capture the mouse - that means that all mouse messages come to this window proc until you release capture
that way, you can test to see if they left the window

once they leave the window, release capture
that will send a WM_CAPTURECHANGED message => begin contraction of the tool window

use BeginDeferWindowPos/DeferWindowPos/EndDeferWindowPos to handle size of the windows and controls
Title: Re: Autohide Toolbar
Post by: 0000 on September 06, 2015, 03:12:12 AM
Quote
Winners never quit, and quitters never win

I never REALLY quit.

Quote
I created Visual Basic because I hate real programmers

I was just kidding about VB. lol

Quote

..WM_MOUSEMOVE.....BeginDeferWindowPos/DeferWindowPos/EndDeferWindowPos......WM_CAPTURECHANGED..

 
Yeah, I had considered using mouse messages for activation.

There's probably a half dozen different ways.


I'll return to this at some point...
Title: Re: Autohide Toolbar
Post by: 0000 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)                                   ;;
;;                                                                       ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Title: Re: Autohide Toolbar
Post by: dedndave 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

;***********************************************************************************************
Title: Re: Autohide Toolbar
Post by: dedndave 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

;***********************************************************************************************
Title: Re: Autohide Toolbar
Post by: 0000 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
Title: Re: Autohide Toolbar
Post by: dedndave 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
Title: Re: Autohide Toolbar
Post by: dedndave 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
Title: Re: Autohide Toolbar
Post by: 0000 on September 06, 2015, 05:15:35 AM
Listview??

Title: Re: Autohide Toolbar
Post by: dedndave 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
Title: Re: Autohide Toolbar
Post by: dedndave 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
Title: Re: Autohide Toolbar
Post by: 0000 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...
Title: Auto Hide Vertical Toolbar Demo
Post by: 0000 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)                                   ;;
;;                                                                       ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Title: Re: Autohide Toolbar
Post by: dedndave 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
Title: Re: Autohide Toolbar
Post by: 0000 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)


Title: update
Post by: 0000 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)                                   ;;
;;                                                                       ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Title: Re: Autohide Toolbar
Post by: 0000 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.)
Title: Re: Autohide Toolbar
Post by: xanatose on December 14, 2015, 01:21:37 PM
Quote from: Richard Nixon
Winners never quit, and quitters never win

The winner does quit, when the job is done. And the legend quits, when its at its peak.