1. Focus rectangle problem after switching to eu4
- Posted by wynco Sep 18, 2011
- 1522 views
I recently switched to eu4 from eu3. It went really well and actually have had some win32lib (v0.70.20) problems go away (such as using setIndex on a list was changing the color of that line and not just highlighting the selection).
One odd thing has come up. When I run my program, the dotted line focus rectangles that are suppose to appear on objects with focus no longer appear. That is unless I click or tab to a list view, then use the arrow keys to move the selection in the list. From that point on the focus rectangle appears as normal when tabbing to or clicking a object.
Below is a sample program to demonstrate this.
Run the program then tab between the button and list view, the focus rectangle will not show, now tab to the list view, use the down arrow key to move the selection, then tab to the button and the rectangle is there as it should be.
Anyone have any idea what is going on, or does the same thing even happen on anyone elses machine.
I'm running Vista Home Premium SP2, AMD Athlon XS 64, on a Toshiba Satellite
include Win32lib.ew object Tmp constant Main_Window = createEx(Window, "Main", 0, Center, Center, 200, 200, {WS_THICKFRAME, WS_SYSMENU, WS_MINIMIZEBOX, WS_MAXIMIZEBOX}, {WS_EX_DLGMODALFRAME}) constant Button_One = createEx(PushButton, "Button One", Main_Window, 8, 4, 80, 40, 0, 0) constant List_One = createEx(ListView, "Name", Main_Window, 8, 60, 100, 100, w32or_all({LVS_REPORT, LVS_SHOWSELALWAYS}), 0) Tmp = addLVItem({List_One, -1}, 0, "Item one") Tmp = addLVItem({List_One, -1}, 0, "Item Two") procedure Button_One_onClick (integer self, integer event, sequence params) -- Do nothing end procedure setHandler(Button_One, w32HClick, routine_id("Button_One_onClick")) openWindow(Main_Window, Modal) setIndex(List_One, 1) setFocus(Button_One) WinMain(Main_Window,Normal)
2. Re: Focus rectangle problem after switching to eu4
- Posted by euphoric (admin) Sep 19, 2011
- 1497 views
When I run my program, the dotted line focus rectangles that are suppose to appear on objects with focus no longer appear...
I'm running Vista Home Premium SP2, AMD Athlon XS 64, on a Toshiba Satellite
I'm running Windows 7 and get the same behavior. However, this tiny change makes it behave as expected:
include Win32lib.ew object Tmp constant Main_Window = createEx(Window, "Main", 0, Center, Center, 200, 200, {WS_THICKFRAME, WS_SYSMENU, WS_MINIMIZEBOX, WS_MAXIMIZEBOX}, {WS_EX_DLGMODALFRAME}) constant Button_One = createEx(PushButton, "Button One", Main_Window, 8, 4, 80, 40, 0, 0) constant List_One = createEx(ListView, "Name", Main_Window, 8, 60, 100, 100, w32or_all({LVS_REPORT, LVS_SHOWSELALWAYS}), 0) Tmp = addLVItem({List_One, -1}, 0, "Item one") Tmp = addLVItem({List_One, -1}, 0, "Item Two") procedure Button_One_onClick (integer self, integer event, sequence params) -- Do nothing end procedure setHandler(Button_One, w32HClick, routine_id("Button_One_onClick")) openWindow(Main_Window, Modal) setIndex(List_One, 1) setFocus(List_One) -- INSERT THIS LINE HERE setFocus(Button_One) WinMain(Main_Window,Normal)
I can't explain that behavior.
3. Re: Focus rectangle problem after switching to eu4
- Posted by wynco Sep 20, 2011
- 1319 views
Thanks euphoric for the suggestion.
I have a good news/bad news/good/bad news/great news reply!
Good News: adding the setFocus() in my sample also works.
Bad News: when I added it to my actual program it did not work.
Good/Bad News: I tried something I usually try when a win32lib command acts up, I added a doEvents(0) after the command that is not working as expected (this has worked on numerous occasions) this time between the two setFocus() statements and it works, 1/2 of the time.
Great News: I moved the first setFocus() and the doEvents() up in the code to just after assigning values to the list view (early in the onActivate procedure for the main window), and left the 2nd setFocus() at the end of the onActivate procedure for the main window. Now it works all of the time. HURRAY!
The button I'm setting the focus to when the program starts initializes a windows timer to cause a blinking highlight of it's caption to draw the users attention to this button. When I changed the start up focus to a button without a related timer it works just like the sample program. My uneducated guess is that the timer was somehow interfering with the messages going back and forth to windows.
I had a similar(?) problem with the popup menus in the program. The popups are created dynamically so they can change to fit the state of program, and after the user clicks on an item then the menus are destroyed, problem was the menus were being destroyed before the click events were registering and nothing was happening. After inserting a doEvents(0) between the popup() call and the destroy() call, the menus work perfectly.
Thanks again for your help