473,403 Members | 2,071 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,403 software developers and data experts.

How to set DrawFocusRectangle() correctly using custom DrawItemEventArgs?

How can I set e.DrawFocusRectangle() correct in an owerdrawn
multiselect listbox?

I do all my drawing (e.g. OnMouseMove) calling OnDrawItem and
constructing the DrawItemEventArgs. The problem is that I never know
exactly when to draw the focus rectangle. The DrawFocusRectangle()
method is always called in the DrawItem event, but keeping track of
which DrawItemState needed to pass is hard work. I have a gut feeling
this can be done easier, but don't know how. It seems redundant that I
will need to pass on every time a mouse click is done or arrows or
pgup/dn/home/end etc are pressed. This info must be kept somewhere in
the listBox , I'm sure.

....when I invalidate the control, the win API kicks in and draws the
focusrectangle as it should be. Unfortunately, this is not an option
since it will cause a lot of flicker. I simply (?) need something to
test on (like an ideal Item.focused), so I can pass the proper
DrawItemEventArgs. Surely, someone must have bounced into problem
before...

Finally, is it possible to mark an item as both e.g. selected and
focused using an & operator or something?

- Peder -
Nov 16 '05 #1
1 3861
Well, I found out at last. Since noone responded after several posts I
recon this really was a tough nut. The solution was finally to use
SendMessage(this.Handle, LB_GETCARETINDEX, (IntPtr) 0, (IntPtr) 0) and
retrieve the index from that call. Hope this will help anyone else who
stumbles upon the same problem.

- Peder -
py*****@ec.auckland.ac.nz (Peder Y) wrote in message news:<10**************************@posting.google. com>...
How can I set e.DrawFocusRectangle() correct in an owerdrawn
multiselect listbox?

I do all my drawing (e.g. OnMouseMove) calling OnDrawItem and
constructing the DrawItemEventArgs. The problem is that I never know
exactly when to draw the focus rectangle. The DrawFocusRectangle()
method is always called in the DrawItem event, but keeping track of
which DrawItemState needed to pass is hard work. I have a gut feeling
this can be done easier, but don't know how. It seems redundant that I
will need to pass on every time a mouse click is done or arrows or
pgup/dn/home/end etc are pressed. This info must be kept somewhere in
the listBox , I'm sure.

...when I invalidate the control, the win API kicks in and draws the
focusrectangle as it should be. Unfortunately, this is not an option
since it will cause a lot of flicker. I simply (?) need something to
test on (like an ideal Item.focused), so I can pass the proper
DrawItemEventArgs. Surely, someone must have bounced into problem
before...

Finally, is it possible to mark an item as both e.g. selected and
focused using an & operator or something?

- Peder -

Nov 16 '05 #2

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

Similar topics

0
by: Peder Y | last post by:
I'm making an ownerdrawn multiselect multiextended ListBox where I'm calling the DrawItem event in my code on specific events and need to make my own DrawItemEventArgs. However, when do I need to...
3
by: Peder Y | last post by:
How can I set e.DrawFocusRectangle() correct in an owerdrawn multiselect listbox? I do all my drawing (e.g. OnMouseMove) calling OnDrawItem and constructing the DrawItemEventArgs. The problem is...
0
by: Peder Y | last post by:
How can I set e.DrawFocusRectangle() correct in an owerdrawn multiselect listbox? I do all my drawing (e.g. OnMouseMove) calling OnDrawItem and constructing the DrawItemEventArgs. The problem is...
1
by: TT (Tom Tempelaere) | last post by:
Hi there, I made a custom drawn ComboBox. The DrawItem event handler is (explanation follows) <code> private void OnDrawItem ( object sender, System.Windows.Forms.DrawItemEventArgs e ) {
0
by: Sanjay Tibrewal | last post by:
Hello, I am trying out a piece of code I downloaded from a link on msdn site. It's a server menu generating control that I tried to add to my custom control assembly. I was able to compile the...
1
by: Tom | last post by:
Hi I am trying to force a drawitem for an owner drawn menuitem. As the menuitem has no invalidate method i thought that i could just call the overriden drawitem method, this need a...
0
by: graeme g | last post by:
hi everybody, i've been working on a collection of custom controls and started working on a base listbox but i have run into an issue... how can i change how the background draws? for instance...
8
by: Alec MacLean | last post by:
Hi, I'm using the DAAB Ent Lib (Jan 2006) for .NET 2.0, with VS 2005 Pro. My project is a Web app project (using the WAP add in). Background: I'm creating a survey system for our company, for...
3
by: =?Utf-8?B?R3JhaGFt?= | last post by:
I've added 2 tracking services to the wf runtime; one is the standard SqlTrackingService: trackingService = new SqlTrackingService(<trackingConnectionString>); <workflow...
3
by: =?Utf-8?B?UHVjY2E=?= | last post by:
Hi, I'm using vs2005, .net 2 for C# windows application. One of my column on the Listview control has numericstring. Other columns are sorting correctly except this one. It seems to be sorting...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...

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.