Page 2 of 3
					
				
				Posted: Sat Dec 09, 2006 7:04 pm
				by Inf0Byt3
				Hi guys! I appologise i wasn't more explicit about what i wanted... Sparkie, that's exactly what i had in mind... Thank you both for saving me again 

.
Code: Select all
AddElement(Saved())
Saved()\Names = "Sparkie, Srod"
Saved()\Times + 1

 
			
					
				
				Posted: Sat Dec 09, 2006 7:13 pm
				by srod
				Code: Select all
GetWrongEndOfStick$ = "srod"
For i = 1 to 10000
  PrintN(GetWrongEndOfStick$)
  KickSrodUpTheArse + 1
Next

 
			
					
				
				Posted: Sat Dec 09, 2006 8:16 pm
				by Inf0Byt3
				There is a problem... If you press space on a such modified item, a checkbox appears... 

 
			
					
				
				Posted: Sat Dec 09, 2006 8:37 pm
				by srod
				That confirms that Windows cycles around the stateicon images!
A quick fix simply discards key presses. Not very subtle and probably not very practical for many purposes which would require something more sophisticated.
Code: Select all
Global oldproc
Procedure RemoveTVIcheckbox(tvGadget, item) 
  tvi.TV_ITEM 
  tvi\mask = #TVIF_HANDLE | #TVIF_STATE 
  tvi\hItem = GadgetItemID(tvGadget, item) 
  tvi\state = 0 << 12 
  tvi\stateMask = #TVIS_STATEIMAGEMASK 
  SendMessage_(GadgetID(1), #TVM_SETITEM, 0, tvi) 
EndProcedure 
Procedure Callback(hWnd, uMsg, wParam, lParam)
  Protected result
  Select uMsg
    Case #WM_KEYDOWN
      result=0
    Case #WM_CHAR ;Stop the infernal beeping!
      result=0
    Default
      result=CallWindowProc_(oldproc, hWnd, uMsg, wParam, lParam)
  EndSelect
  ProcedureReturn Result
EndProcedure
If OpenWindow(0, 0, 0, 400, 380, "TreeGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0)) 
  TreeGadget(1, 180, 10, 160, 360, #PB_Tree_CheckBoxes) 
  For a = 0 To 4 
    AddGadgetItem (1, -1, "Normal Item "+Str(a), 0, 0) 
    AddGadgetItem (1, -1, "Node "+Str(a), 0, 0) 
    AddGadgetItem(1, -1, "Sub-Item 1", 0, 1) 
    AddGadgetItem(1, -1, "Sub-Item 2", 0, 1) 
    AddGadgetItem(1, -1, "Sub-Item 3", 0, 1) 
    AddGadgetItem(1, -1, "Sub-Item 4", 0, 1) 
    AddGadgetItem (1, -1, "File "+Str(a), 0, 0) 
  Next a 
  RemoveTVIcheckbox(1, 1) 
  RemoveTVIcheckbox(1, 6) 
  For i = 8 To 12 
    RemoveTVIcheckbox(1, i) 
  Next i 
  SetGadgetItemState(1, 8, #PB_Tree_Expanded) 
  oldproc=SetWindowLong_(GadgetID(1), #GWL_WNDPROC, @callback())
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow 
EndIf 
 
			
					
				
				Posted: Sat Dec 09, 2006 8:54 pm
				by Inf0Byt3
				U are a saint! (and you're added to the credits 

 ) 
10X!
P.S. Sparkie is added too 

 
			
					
				
				Posted: Sat Dec 09, 2006 11:02 pm
				by Psychophanta
				Sparkie wrote: 
 
Code: Select all
Procedure RemoveTVIcheckbox(tvGadget, item)
  tvi.TV_ITEM
  tvi\mask = #TVIF_HANDLE | #TVIF_STATE 
  tvi\hItem = GadgetItemID(tvGadget, item)
  tvi\state = 0 << 12
  tvi\stateMask = #TVIS_STATEIMAGEMASK 
  SendMessage_(GadgetID(1), #TVM_SETITEM, 0, tvi)
EndProcedure
If OpenWindow(0, 0, 0, 400, 380, "TreeGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
  TreeGadget(1, 180, 10, 160, 360, #PB_Tree_CheckBoxes)
  For a = 0 To 4
    AddGadgetItem (1, -1, "Normal Item "+Str(a), 0, 0)
    AddGadgetItem (1, -1, "Node "+Str(a), 0, 0)
    AddGadgetItem(1, -1, "Sub-Item 1", 0, 1)
    AddGadgetItem(1, -1, "Sub-Item 2", 0, 1)
    AddGadgetItem(1, -1, "Sub-Item 3", 0, 1)
    AddGadgetItem(1, -1, "Sub-Item 4", 0, 1)
    AddGadgetItem (1, -1, "File "+Str(a), 0, 0)
  Next a
  RemoveTVIcheckbox(1, 1)
  RemoveTVIcheckbox(1, 6)
  For i = 8 To 12
    RemoveTVIcheckbox(1, i)
  Next i
  SetGadgetItemState(1, 8, #PB_Tree_Expanded)
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
 
Here is something wierd:
Item index 8 , named as 'Node 1' has the checkbox, but the code removes it. Commenting line 
Code: Select all
SetGadgetItemState(1, 8, #PB_Tree_Expanded)
it works as expected.
 
			
					
				
				Posted: Sat Dec 09, 2006 11:07 pm
				by Inf0Byt3
				Happends here too, and i removed that line too. It seems that if it refreshes, the checkboxes reappear  

 .
 
			
					
				
				Posted: Sat Dec 09, 2006 11:15 pm
				by srod
				Ah, a bug with Purebasic. Purebasic is resetting the stateicon index.
You can see it better with the following:
Code: Select all
If OpenWindow(0, 0, 0, 400, 380, "TreeGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0)) 
  TreeGadget(1, 180, 10, 160, 360, #PB_Tree_CheckBoxes) 
    AddGadgetItem (1, -1, "Normal Item "+Str(a), 0, 0) 
    AddGadgetItem(1, -1, "Sub-Item 1", 0, 1) 
    AddGadgetItem(1, -1, "Sub-Item 2", 0, 1) 
    AddGadgetItem(1, -1, "Sub-Item 3", 0, 1) 
    AddGadgetItem(1, -1, "Sub-Item 4", 0, 1) 
  SetGadgetItemState(1, 0, #PB_Tree_Checked)
  SetGadgetItemState(1, 0, #PB_Tree_Expanded) 
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow 
EndIf
The SetGadgetItemState(1, 0, #PB_Tree_Expanded) command is clearing the checkmark!
Best post this in the bug section.
@Info: if you don't need to use the   SetGadgetItemState(1, 0, #PB_Tree_Expanded) command then you should be fine. I'd say it's most likely a PB issue rather than a Windows one.
 
			
					
				
				Posted: Sat Dec 09, 2006 11:20 pm
				by Inf0Byt3
				Ok 

.
 
			
					
				
				Posted: Sat Dec 09, 2006 11:23 pm
				by srod
				Yes I've run some identical code using pure api (i.e. removed the SetGadgetItemState(1, 0, #PB_Tree_Expanded) and replaced it with api) and it works fine. 
Definitely a PB issue.
			 
			
					
				
				Posted: Sun Dec 10, 2006 10:20 am
				by Psychophanta
				Hi, I've reported the bug about the Sparkie snippet
			 
			
					
				
				Posted: Sun Dec 10, 2006 12:22 pm
				by srod
				Already reported and Freak has explained that it is not actually a bug, just a misuse of SetGadgetItemState() !
I should have realised.  Reckon I should start going to bed earlier!  

 
			
					
				
				Posted: Sun Dec 10, 2006 12:27 pm
				by Psychophanta
				srod wrote:Already reported and Freak has explained that it is not actually a bug, just a misuse of SetGadgetItemState() !
I should have realised.  Reckon I should start going to bed earlier!  

 
Sorry, what i report is not the same.
Inf0Byt3 report is about the 
check mark inside the checkbox appear or dissappear.
My report is about the 
checkbox itself appear or dissappear.
You see?
 
			
					
				
				Posted: Sun Dec 10, 2006 12:34 pm
				by srod
				It actually amounts to the same thing, as Sparkie's code is a bit of a cheat to remove the checkmark box from a treeview which does have the #TVS_CHECKBOXES style after all - which is a slight abuse!  

  So I think that Freak's response already explains this one as PB just resets the imagestate icon in response to SetGadgetItemState(....#PB_Tree_Expanded) etc. i.e. in the absence of #PB_Tree_Checked.
 
			
					
				
				Posted: Sun Dec 10, 2006 12:38 pm
				by Psychophanta
				srod wrote:It actually amounts to the same thing, as Sparkie's code is a bit of a cheat to remove the checkmark box from a treeview which does have the #TVS_CHECKBOXES style after all - which is a slight abuse!  

  So I think that Freak's response already explains this one as PB just resets the imagestate icon in response to SetGadgetItemState(....#PB_Tree_Expanded) etc. i.e. in the absence of #PB_Tree_Checked.
 
may be ok, but sorry: that Freak answer is far to be valid for my report.