Editing cells in ListIcons (updated for Vista)

Share your advanced PureBasic knowledge/code with the community.
Amnesty
User
User
Posts: 54
Joined: Wed Jul 04, 2007 4:34 pm
Location: Germany

Post by Amnesty »

srod wrote: Do you mean that instead of a double click to edit a cell we use a siingle click? Or do you mean that when a cell is first edited, rather than place the caret at the end of the text, we select the whole text? Either is simple to add.
Sorry for my bad describing. YES I m speaking about your last scenario. When you click the cell, the whole text is selected. Thats great, because I can start to edit without moving cursor.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Simply comment out (or remove completely) the line :

Code: Select all

SendMessage_(hWnd, #EM_SETSEL, -1,0)
in the _LIEeditProc() procedure.

:)
I may look like a mule, but I'm not a complete ass.
RichardL
Enthusiast
Enthusiast
Posts: 532
Joined: Sat Sep 11, 2004 11:54 am
Location: UK

Numeric only cell

Post by RichardL »

Hi,
Thanks for this very useful utility, I have to finish a demo program this week and your utility has just cut 25% off the job... great. I have added code to limit which columns can be eddited (as per your comments) All I need now is to restrict some columns to numeric only. Can you give me a hint please.

Best regards,

RichardL

PS: Why does the sun come out when I need an excuse to write code?
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: Numeric only cell

Post by srod »

RichardL wrote:All I need now is to restrict some columns to numeric only. Can you give me a hint please.

Best regards,

RichardL

PS: Why does the sun come out when I need an excuse to write code?
Just add a #WM_CHAR handler to the _LIEeditProc() procedure. E.g. the following will only allow the user to enter numeric characters in column 1 (any character in other columns) :

Code: Select all

Case #WM_CHAR
  ;For cells in column 1, only allow numeric characters.
    If *liedit\subitem <> 1 Or (wParam>=48 And wParam<=57)
      result=CallWindowProc_(oldwinproc, hWnd, uMsg, wParam, lParam)
    EndIf
I may look like a mule, but I'm not a complete ass.
RichardL
Enthusiast
Enthusiast
Posts: 532
Joined: Sat Sep 11, 2004 11:54 am
Location: UK

Post by RichardL »

Good morning.

Thanks a lot, thats perfect.

Richard
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

You're welcome Richard.
I may look like a mule, but I'm not a complete ass.
klaver
Enthusiast
Enthusiast
Posts: 147
Joined: Wed Jun 28, 2006 6:55 pm
Location: Schröttersburg

Post by klaver »

srod wrote: Just add a #WM_CHAR handler to the _LIEeditProc() procedure. E.g. the following will only allow the user to enter numeric characters in column 1 (any character in other columns) :

Code: Select all

Case #WM_CHAR
  ;For cells in column 1, only allow numeric characters.
    If *liedit\subitem <> 1 Or (wParam>=48 And wParam<=57)
      result=CallWindowProc_(oldwinproc, hWnd, uMsg, wParam, lParam)
    EndIf
Hmm, it's impossible to use a backspace key in such cell :D
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

klaver wrote:Hmm, it's impossible to use a backspace key in such cell :D
Nothing's impossible :

Code: Select all

Case #WM_CHAR
  ;For cells in column 1, only allow numeric characters.
    If *liedit\subitem <> 1 Or (wParam>=48 And wParam<=57) Or wParam=8
      result=CallWindowProc_(oldwinproc, hWnd, uMsg, wParam, lParam)
    EndIf
:)
I may look like a mule, but I'm not a complete ass.
aaron
Enthusiast
Enthusiast
Posts: 267
Joined: Mon Apr 19, 2004 3:04 am
Location: Canada
Contact:

Post by aaron »

Just used this in my code. Thanks! I was scratching my head trying to figure out how to edit a single cell in the listicon gadget and then decided to check the forums. Huge timesaver! :D
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

You're welcome aaron.
I may look like a mule, but I'm not a complete ass.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Update: 08/07/08. Vista compatible.
Getting this to run on Vista required a couple of dirty hacks as we are doing something here which Windows (especially Vista) is set up to prevent! :) In fact, earlier version of Windows are also set up to prevent us moving the edit control reserved for editing labels (column 0) in order to edit other cells - it's just that the prevention fails! Not on Vista (with XP themes enabled) however!

I'll not bore you with the details of the evil hacks - suffice to say that I have tested on XP and Vista and everything seems okay. I am suspicious that the edit control alignment will be out on Win Server 2003, but this is easily fixed if it proves to be the case.

Code is in the first post.
I may look like a mule, but I'm not a complete ass.
Pureabc
User
User
Posts: 76
Joined: Mon Jan 16, 2006 1:11 am

Post by Pureabc »

Very nice, thank you.

Is it possible to highlight only one cell when it is clicked once?
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Thanks.

Do you mean you wish to edit the cell when clicked once or you want the cell highlighted or the cell in the first column highlighted? :)
I may look like a mule, but I'm not a complete ass.
Pureabc
User
User
Posts: 76
Joined: Mon Jan 16, 2006 1:11 am

Post by Pureabc »

Double-click to edit.
Single click to highlight the cell. (the cell highlighted, not edit the cell)

Thank you.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Well, the thing is that the original column zero has been blanked out because it is somewhat badly behaved when attempting to edit cells. The first column you see in the example is in fact column 1. Thus if you want to highlight a cell in response to a selection then you will have to add that code yourself. This is not necessarily as easy as it sounds, however, depending on how you approach this.

What is easier is to simply apply the #PB_ListIcon_FullRowSelect flag to the listicon. This will of course result in the entire row being highlighted.
I may look like a mule, but I'm not a complete ass.
Post Reply