When a button is clicked on a dialog box Windows repaints it in an activated state. I have a dialog box with no default buttons that needs to override this behaviour. I want to programmatically set which button is 'activated' (ie. has the 'default' button appearance) so that the user can clearly see the intended sequence of buttons they need to push. However after messing around with the ShowWindow and SetWindowPos APIs it still isn't working. The last button clicked retains the 'default' button appearance and the button I want to highlight simply doesn't change. What should I be coding? Thanks.
Posted on 2003-08-18 19:46:55 by andrew_k
You want the EnableWindow API...

Posted on 2003-08-18 20:09:50 by NaN
Thanks Nan, however I have already been using the EnableWindow API. This simply enables or disables a button, but doesn't stop Windows from painting it with the 'activated' or 'default' appearance even if you disable the button (on Win2K anyway).
Posted on 2003-08-18 20:17:43 by andrew_k
Then i have no clue what your looking for.. got a pic or something? Perhaps SetFocus API is what your getting at then??
Posted on 2003-08-18 21:05:55 by NaN
I know what your looking for and I agree that it is a pain to have that and the darn focus rectangle all of the time. The best that I can gather is that you're stuck with it unless you want to paint the frame yourself. I once tried to have a hidden button that was pressed at the end of the WM_COMMAND handler, can't remember if it worked - didn't do anything just recieved the focus as the last button pressed. It's a hack way of doing it but it saves the mess of drawing your own frames.
Posted on 2003-08-18 22:01:13 by donkey
Thanks Donkey. Nan, check out the delete button on the screenshot. This was the last button clicked. However the button was disabled after been clicked as there were no more items to delete. I want to programmatically 'activate' or paint the frame of the 'add' button in the way the 'delete' button is in the screenshot, and have the 'delete' button appear identical to the buttons surrounding it.
Posted on 2003-08-19 01:25:53 by andrew_k
why don't you set focus to the Add button just before you disable the Delete-Button?

Just my 2 1/100 ?
Posted on 2003-08-19 13:38:00 by phueghy
Thanks phueghy, I have tried this but unfortunately it doesn't work.
Posted on 2003-08-19 16:18:54 by andrew_k
I have found something that solves this problem for me. I'm really not that proud of this - its a hack - but it works:

Invoke GetDlgItem, hWnd, IDC_DELETE
mov hCtrl, eax
Invoke SendMessage, hCtrl, BM_SETSTYLE, BS_PUSHBUTTON, 0
Invoke EnableWindow, hCtrl, FALSE

Doing this means the 'Delete' button doesn't have that 'default' button look around it as in the screenshot. If anyone has a better suggestion I would welcome it. Thanks everyone for your input, it is much appreciated.
Posted on 2003-08-20 16:58:07 by andrew_k