473,408 Members | 2,839 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Proper LostFocus behavior

All -

I am in the process of developing a custom control that mimics the Office
2003 "Inbox" as closely as possible. After a great deal of frustrating work
trying to do a heavily custom-drawn ListView (which is how I believe MS is
doing it) and getting nowhere, I said "screw it" and built the thing from
scratch. I have a UserControl with a few contained controls, a header
control I'm drawing entirely by hand, and a Panel in which I'm doing all my
item drawing (also entirely by hand.) The hierarchy looks like this:

UserControl
- Label (actually a 3rd party label control so I can get the gradient)
- Panel
--- Custom header control (docked to the top of the parent panel)
--- Vertical scrollbar (docked to the right of the parent panel)
--- "client area" panel (docked as "Fill" of the parent panel)

I have coded up "Enter" and "Leave" events for the "client area" panel, so
that I can get the appropriate colors for selected items, and the focus
rectangle when necessary. However, once I put my control on a form, these
events aren't firing when the containing form loses focus. I have a
TreeView control on the form - purely to test my focus-related code - and
the TreeView does fire a LostFocus event when the form loses focus. The
actual UserControl fires a LostFocus event when I click into my panel (which
kinda makes sense, but not really), but not when the form is deactivated.
Hooking a LostFocus to my panel does nothing at all.

I've tried to switch from a UserControl base to a ContainerControl base,
thinking that the UserControl was somehow "taking over" the focus events
from its contained controls. But that didn't solve anything. Trying the
"ChangeUICues" event didn't get me anywhere either.

I can't believe that the solution is to pass a reference to the containing
form into the control and catch the "Deactivate" event, but that's what I'm
left with. I am obviously missing something fundamental about all this.
Can someone please point me in the right direction?

TIA

- Scott
Nov 22 '05 #1
0 1277

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: MJW | last post by:
Is there a way for me to know if or which command button was just clicked that triggers the LostFocus event for the current control on a Form? I have a form that has many types of users who each...
2
by: vooose | last post by:
Does anyone know the difference between these two? The doc for LostFocus says 'Occurs when the control loses focus.' whereas for Leave it says 'Occurs when the input focus leaves the control'...
4
by: dudzcom | last post by:
hi, this is the first time i've posted to this board, though i have been a devoted lurker for some time i have been working in vb.net and run into a couple problems that seem to require solutions...
4
by: Bernard Bourée | last post by:
I have some TextBoxes created by code. I want to write a procedure to handle the lost of focus of any of these TextBox. How should I do that ? Thanks --
4
by: Wayne Wengert | last post by:
I have a form that has a cbo set to TabIndex 0 (it is the only item set to tabindex 0). On page Load if I step through the code that cbo LostFocus event fires after other initializations are...
6
by: Carmon | last post by:
I am using Managed C++ with a CFormView and a MaskedTextBox and have used MAKE_DELEGATE to sink the LostFocus event of this control. I have other events I've sinked off this control and they all...
14
by: teddysnips | last post by:
WINDOWS FORMS I've a form that has a textbox that allows the user to enter a string. On the LostFocus event, the textbox formats the string into a preferred format. However, if the user...
4
by: dbuchanan | last post by:
On the help page "TextBox Members" clearly there is an event for LostFocus. It is inherited from control. So without the event directly available for TextBox how do I use it? I know I could...
2
by: Jason Huang | last post by:
Hi, In my .Net 1.1 C# windows form Form1 I have nothing but 2 TextBox controls on the Form1, the T1 and T2. I would like to test the sequence of the GotFocus LostFocus things, so I have the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.