News:

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

Get rid of button focus dotted dashed rectangle

Started by zemtex, July 28, 2011, 11:52:07 PM

Previous topic - Next topic

zemtex

How do you remove or change style of the dotted selection bar on pushbuttons? I think that it is a userfriendly feature, but in my situation I think that it is nice to have only a black underlying rectangle around the button instead of the dotted rectangle inside the button frame.

Can I remove it entirely, if not can I change the style of it?
I have been puzzling with lego bricks all my life. I know how to do this. When Peter, at age 6 is competing with me, I find it extremely neccessary to show him that I can puzzle bricks better than him, because he is so damn talented that all that is called rational has gone haywire.

Twister

I think you are talking about the focusing of a control. Could you possibly take a screen-shot?

You can do this by immediately remove focus of the control after clicking/double-click.

zemtex

I am talking about focus styles, the inner dotted rectangle on the button and you also have a black solid rectangle on the outer layer. I want to keep the black one, the dotted needs to go as it clutters the screen and makes it harder to read the button text.
I've had it working many times before but I have just forgot what I did  :snooty:

Horton: Removing focus from the control requires that I remove IsDialogMessage for handling keyboard with controls. It sounds a bit dirty  :dazzled:

Here is a random google picture, the right button has dashed/dotted rectangle

I have been puzzling with lego bricks all my life. I know how to do this. When Peter, at age 6 is competing with me, I find it extremely neccessary to show him that I can puzzle bricks better than him, because he is so damn talented that all that is called rational has gone haywire.

baltoro

The most aesthetically satisfying solution to your problem would be to create your own custom bitmap of the buttom and paint it in the appropriate location.
Of course, you'd have to write the code to make it completely dysfunctional,... :bg
Baltoro

hutch--

zemtex,

The standard buttons have that characteristic built into them, to do it differently you create a custom control or use a bitmap control instead.

There is a custom bitmap control in the MASM32 library, you provide 2 bitmaps, one up, the other down.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

zemtex

hutch, I checked the bmbutton sample, the dotted rectangle is visible as you click the button but I suppose you didn't paint the edges? A different problem is when you switch windows theme and the buttons have the same look.

I can make it work by using modal dialogs and when IsDialogMessage handles keyboard internally, then it works nicely but I can not get it to work if I create window/controls manually even if I use the exact same styles. If you use modal dialogs and resource files you will notice the dotted rectangle is gone even if you push a button, but as soon as you hit the tab key the dotted rectangle appear again.


EDIT: Solved it, I added an xp manifest and somehow the buttons now dont have dotted rectangle. It will appear if you hit TAB, but I can live with that, as long as the buttons don't show the dotted rectangle by default.
I have been puzzling with lego bricks all my life. I know how to do this. When Peter, at age 6 is competing with me, I find it extremely neccessary to show him that I can puzzle bricks better than him, because he is so damn talented that all that is called rational has gone haywire.

WillASM

Have you tried using DrawFocusRect? Perhaps that would work for you. Not at home right now so can not try this out right now..

zemtex

Alright thanks all. I think I have it the way I want it.
I have been puzzling with lego bricks all my life. I know how to do this. When Peter, at age 6 is competing with me, I find it extremely neccessary to show him that I can puzzle bricks better than him, because he is so damn talented that all that is called rational has gone haywire.

hutch--

The BMbutton example actually uses a standard windows button with the bitmap style and it will have the focus rectangle but the library has a completely different one that does not do it that way, it simply has an UP and DOWN bitmap so you have absolute control of the appearance.

It sounds like you have solved the problem for later OS versions, (XP and later) so this may not matter to you any longer.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

xroot

Hi, Zemtec

To use regular contols with out the focus dots, here is what I do, it's real simple,
just a little subclass of the controls.



include \masm32\include\masm32rt.inc

.data?
hCnt      dd ?
oProc     dd ?
.data

.code

No_Dots Proc hCntl:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD
    .If uMsg==WM_SETFOCUS
        ret
    .endif
    invoke CallWindowProc,oProc,hCntl,uMsg,wParam,lParam
    Ret
No_Dots endp

Msg_Proc Proc hWin:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD
    Switch uMsg
        Case WM_INITDIALOG
            mov hCnt,rv(GetDlgItem,hWin,IDCANCEL)
            invoke SetWindowLong,rv(GetDlgItem,hWin,69),GWL_WNDPROC,offset No_Dots
            invoke SetWindowLong,hCnt,GWL_WNDPROC,offset No_Dots
            mov oProc,eax
        Case WM_COMMAND
            .If wParam==IDCANCEL || wParam==2
                invoke EndDialog,hWin,NULL
            .EndIf
    EndSw
    xor eax,eax
    ret
Msg_Proc endp

start:
    Dialog "Test Dialog","MS Sans Serif",14,WS_OVERLAPPED or WS_MINIMIZEBOX or DS_CENTER or WS_SYSMENU,\
           3,0,0,150,100,512
    DlgButton "Exit",WS_TABSTOP,50,60,50,15,IDCANCEL
    DlgButton "Check-Button",BS_AUTOCHECKBOX,15,25,40,10,69
    DlgStatic "The MASM Forum is Cool",SS_CENTER,5,10,140,9,100
    CallModalDialog FUNC(GetModuleHandle,NULL),NULL,Msg_Proc,NULL
    invoke SetWindowLong,hCnt,GWL_WNDPROC,oProc
    exit
end start

hutch--

Compliments xroot,

That is a nice clean and simple solution to the problem and should work on older versions of Windows.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

donkey

I would use an owner drawn button for this, they are compaitble with all versions of Windows and returning an undefined result from WM_SETFOCUS could have some side effects, such as disabling tab selection etc.. OD buttons are very simple to work with, there is an example on my website:

http://www.quickersoft.com/donkey/files/OwnerDrawBtn.zip
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

MichaelW

The are simple with bitmaps, but not so simple using DrawFrameControl, etc, to draw the components individually.
eschew obfuscation