Author |
Topic: Removing focus from a bitmap button. (Read 1363 times) |
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
Re: Removing focus from a bitmap button.
« Reply #3 on: Dec 11th, 2013, 1:50pm » |
|
on Dec 11th, 2013, 11:02am, net2014 wrote:| Run In LBB, focus moves to B3 but the focus rectangle remains around B1 and B3. |
|
Right, here is the explanation. Microsoft says you are not supposed to move focus between controls using SetFocus, but instead by sending the WM_NEXTDLGCTL message:
http://blogs.msdn.com/b/oldnewthing/archive/2004/08/02/205624.aspx http://msdn.microsoft.com/en-us/library/windows/desktop/ms645432.aspx
If you do that your program will work as expected in LBB:
Code:nomainwin ' open no main window
button #1.1, "B1", [b1], UL, 30, 10
button #1.2, "B2", [b2], UL, 30, 40
button #1.3, "B3", [b3], UL, 30, 70
open "Button Focus" for window as #1
hw = hwnd(#1)
print #1, "trapclose [quit]"
wait
[b1]
h=hwnd(#1.3)
calldll #user32, "SendMessageA", hw as ulong, _
_WM_NEXTDLGCTL as long, h as ulong, 1 as long, _
result as long
wait
[b2]
wait
[b3]
wait
[quit]
close #1
end For maximum compatibility I should probably arrange that the "!setfocus" command also sends a WM_NEXTDLGCTL message. I will make a note of that for a future version of LBB.
Richard.
|
|
Logged
|
|
|
|
net2014
New Member
member is offline


Posts: 37
|
 |
Re: Removing focus from a bitmap button.
« Reply #4 on: Dec 11th, 2013, 3:49pm » |
|
on Dec 11th, 2013, 1:50pm, Richard Russell wrote:Right, here is the explanation. Microsoft says you are not supposed to move focus between controls using SetFocus, but instead by sending the WM_NEXTDLGCTL message:
If you do that your program will work as expected in LBB:
For maximum compatibility I should probably arrange that the "!setfocus" command also sends a WM_NEXTDLGCTL message. I will make a note of that for a future version of LBB.
Richard. |
|
Thank you Richard, superb result, the fix works brilliantly and I've noted it for further use (which will be redundant if you incorporate it into a future LBB release.)
Wish you and Carl could make a team.
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
Re: Removing focus from a bitmap button.
« Reply #5 on: Mar 15th, 2014, 4:30pm » |
|
on Dec 11th, 2013, 3:49pm, net2014 wrote:| Thank you Richard, superb result, the fix works brilliantly and I've noted it for further use (which will be redundant if you incorporate it into a future LBB release.) |
|
Now incorporated in LBB v2.50 and later.
Richard.
|
|
Logged
|
|
|
|
|