April 19, 2024, 01:30:04 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Icons in a listview header.

Started by LarryMc, July 02, 2008, 05:03:23 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

LarryMc

July 02, 2008, 05:03:23 PM Last Edit: July 03, 2008, 09:04:19 AM by Larry McCaughn
Playing around with some old code mostly by sapero and bevets(rip).

Listview will do 2 and 3-state sorts on a selected column.
I've got an up/down arrow in the headers.

Problem is that when I move from column to column the previous sorted columns icon does not clear.

Attached is source.See below
Any help aprreciated.
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

sapero

Hello Larry,
On my XP it works pretty good, after switching to another column, the previous icon disappear.

You may manually invalidate the entire rectangle of header item (or only the icon rect)
Declare Import,DeleteObject(int obj)
Declare Import,GetBkColor(int hdc),int
Declare Import,FillRect(int hdc, pointer rc, int brush)
Declare Import,CreateSolidBrush(int colo),int

' before returing from CDDS_ITEMPREPAINT, but after SetBkColor; for all items

int bkcolor, brush
' get the background color set by SetBkColor and convert it to HBRUSH
bkcolor = GetBkColor(#lParam.hDC)
brush = CreateSolidBrush(bkcolor)

' fill the entire header item with background color (or only the icon rectangle)
FillRect(#lParam.hDC, #lParam.rc, brush)
DeleteObject(brush)

LarryMc

Boy is this weird.

This morning it is working on my machine AND I HAVEN"T CHANGED ANYTHING!

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

LarryMc

July 03, 2008, 09:09:14 AM #3 Last Edit: July 03, 2008, 02:56:23 PM by Larry McCaughn
Attached is cleaned up demo that demonstrates sorting in a listview by any column .
Also shows icon in column header to indicate direction of sort.

Based upon old work by sapero and bevets.

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

pistol350

Hi Larry!
It seems that you forgot to attach the zip above.
Regards,

Peter B.

LarryMc

LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Brian

Hi,

Is it possible that this program - lv_sort_icon.zip - can be reworked
so it works in a WINDOW type program? Would be handy to have both
a DIALOG and WINDOW example

Brian

LarryMc

Quote from: Brian Pugh on June 06, 2012, 02:44:22 AM
Hi,

Is it possible that this program - lv_sort_icon.zip - can be reworked
so it works in a WINDOW type program? Would be handy to have both
a DIALOG and WINDOW example

Brian
The attached zip contains both a dialog and a windows version.
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Brian

Thanks, Larry,

I had made a start converting from a dialog, but after looking at your code,
I was doing it all wrong - as usual!

Brian

LarryMc

Converting from a dailog to a window is pretty straight forward:

1. change DIALOG xx to WINDOW xx
2. change CREATEDIALOG  to OPENWINDOW
3. insure you have the proper style flags set for the window
4. if the dialog was activated with domodal d1 then that line will need to be deleted and
   replaced with an idle loop  WAITUNTIL ISWindowClosed(xx)
   if the dialog was activated SHOWDIALOG xx then delete that line and use the existing idle loop.
5. Change any CLOSEDIALOG xx commands to CLOSEWINDOW xx

The last part is where I get caught napping sometimes.
It is standard practice to use CONTROL commands immediately following CREATEDIALOG  and OPENWINDOW commands.
Key Point: Controls in a dialog are not actually created (do not exists) until the DOMODAL or SHOWDIALOG command is executed.
Therefore any command that modifies a control has to be executed after that point in time.
The the purpose for the @IDINITDIALOG message handler for dialogs. After the dialog is actually built and the controls exists this messaged is sent. So, we put setfont and other commands here.
KEY Point: When you create a window, its controls are created immediately when the CONTROL command is executed.
This would lead you to think you'd be okay by just changing the @IDINITDIALOG to @IDCREATE and letting the code that modifies the controls stay where it was.

The problem lies in when the @IDCREATE message is sent. It is sent when the OPENWINDOW is executed and before any CONTROL commands are executed. Therefore, all control modifying commands in the @IDCREATE section are trying to change controls that don't exist yet; including the subclassing of a listview,in this case, that isn't there.

So, taking the above into consideration it should be a little easier for users to switch back and forth between dialogs and windows.

as my own personal preferences with dialogs I have a init subroutine for each dialog that runs after my main window is built. The init routine has the CREATEDIALOG and CONTROL commands in it.  There is no need to execute that portion of the code more than once regardless of how many times you open and close a dialog.

Hope this helps a little.
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library