Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Column Moved or Header Clicked - VFP Error ??

Status
Not open for further replies.

benman

Programmer
May 3, 2006
35
HK
Is it internal error on VFP on firing between Column Moved Event and Header Click Event when someone move a column (say column1) to the 2nd column; then from 2nd column to 3rd column ?

Any Tips please.

Code:
DEFINE CLASS form1 AS form

	Top = 13
	Left = 4
	Height = 250
	Width = 482
	DoCreate = .T.
	Caption = "Form1"
	Name = "Form1"


	ADD OBJECT grid1 AS grid WITH ;
		ColumnCount = 4, ;
		Height = 157, ;
		Left = 36, ;
		Top = 72, ;
		Width = 420, ;
		Name = "Grid1", ;
		Column1.Name = "Column1", ;
		Column2.Name = "Column2", ;
		Column3.Name = "Column3", ;
		Column4.Name = "Column4"


	ADD OBJECT form1.grid1.column1.header1 AS header WITH ;
		Caption = "Header1", ;
		Name = "Header1"


	ADD OBJECT form1.grid1.column1.text1 AS textbox WITH ;
		BorderStyle = 0, ;
		Margin = 0, ;
		ForeColor = RGB(0,0,0), ;
		BackColor = RGB(255,255,255), ;
		Name = "Text1"


	ADD OBJECT form1.grid1.column2.header1 AS header WITH ;
		Caption = "Header1", ;
		Name = "Header1"


	ADD OBJECT form1.grid1.column2.text1 AS textbox WITH ;
		BorderStyle = 0, ;
		Margin = 0, ;
		ForeColor = RGB(0,0,0), ;
		BackColor = RGB(255,255,255), ;
		Name = "Text1"


	ADD OBJECT form1.grid1.column3.header1 AS header WITH ;
		Caption = "Header1", ;
		Name = "Header1"


	ADD OBJECT form1.grid1.column3.text1 AS textbox WITH ;
		BorderStyle = 0, ;
		Margin = 0, ;
		ForeColor = RGB(0,0,0), ;
		BackColor = RGB(255,255,255), ;
		Name = "Text1"


	ADD OBJECT form1.grid1.column4.header1 AS header WITH ;
		Caption = "Header1", ;
		Name = "Header1"


	ADD OBJECT form1.grid1.column4.text1 AS textbox WITH ;
		BorderStyle = 0, ;
		Margin = 0, ;
		ForeColor = RGB(0,0,0), ;
		BackColor = RGB(255,255,255), ;
		Name = "Text1"


	ADD OBJECT label1 AS label WITH ;
		WordWrap = .T., ;
		Caption = "Try moving 1st Column then to 2nd Column then 3rd Column to see result", ;
		Height = 36, ;
		Left = 48, ;
		Top = 12, ;
		Width = 385, ;
		Name = "Label1"


	PROCEDURE Load
		      CREATE CURSOR cursorcopy (NAME c(10),Num c(10),Phone C(10),QTY c(10))
		      INSERT INTO cursorcopy (NAME,Num,Phone,Qty) VALUES ("Bill","00725","555 1212","125")
		      INSERT INTO cursorcopy (NAME,Num,Phone,Qty) VALUES ("Mikel","00728","555 1232","25")
		      INSERT INTO cursorcopy (NAME,Num,Phone,Qty) VALUES ("Jan","00729","555 5432","13")
		      INSERT INTO cursorcopy (NAME,Num,Phone,Qty) VALUES ("Rosa","00730","555 5555","177")
		      INSERT INTO cursorcopy (NAME,Num,Phone,Qty) VALUES ("John","00735","666 6666","250")
		      INSERT INTO cursorcopy (NAME,Num,Phone,Qty) VALUES ("Henry","00742","777 7777","60")
		      GO TOP
	ENDPROC


	PROCEDURE grid1.Column1.Moved
		WAIT WINDOW "Column1.Moved"
	ENDPROC


	PROCEDURE grid1.Column2.Moved
		WAIT WINDOW "Column2.Moved"
	ENDPROC


	PROCEDURE grid1.Column3.Moved
		WAIT WINDOW "Column3.Moved"
	ENDPROC


	PROCEDURE grid1.Column4.Moved
		WAIT WINDOW "Column4.Moved"
	ENDPROC


	PROCEDURE header1.Click
		WAIT WINDOW "Column1.header1.click"
	ENDPROC


	PROCEDURE header1.Click
		WAIT WINDOW "Column2.header1.click"
	ENDPROC


	PROCEDURE header1.Click
		WAIT WINDOW "Column3.header1.click"
	ENDPROC


	PROCEDURE header1.Click
		WAIT WINDOW "Column4.header1.click"
	ENDPROC

ENDDEFINE
 
Please copy & paste below code for testing. Many thanks.

Code:
oForm = CREATEOBJECT("form1")
oGrid = oForm.ADDOBJECT("newgrid", "grid01")

oForm.show(1)
&&READ events

DEFINE CLASS form1 AS form
	Top = 13
	Left = 4
	Height = 250
	Width = 482
	DoCreate = .T.
	Caption = "Form1"
	Name = "Form1"
	
		ADD OBJECT label1 AS label WITH ;
		WordWrap = .T., ;
		Caption = "Try moving 1st Column then to 2nd Column then 3rd Column to see result", ;
		Height = 36, ;
		Left = 48, ;
		Top = 12, ;
		Width = 385, ;
		Name = "Label1"

	PROCEDURE Load
		      CREATE CURSOR cursorcopy (NAME c(10),Num c(10),Phone C(10),QTY c(10))
		      INSERT INTO cursorcopy (NAME,Num,Phone,Qty) VALUES ("Bill","00725","555 1212","125")
		      INSERT INTO cursorcopy (NAME,Num,Phone,Qty) VALUES ("Mikel","00728","555 1232","25")
		      INSERT INTO cursorcopy (NAME,Num,Phone,Qty) VALUES ("Jan","00729","555 5432","13")
		      INSERT INTO cursorcopy (NAME,Num,Phone,Qty) VALUES ("Rosa","00730","555 5555","177")
		      INSERT INTO cursorcopy (NAME,Num,Phone,Qty) VALUES ("John","00735","666 6666","250")
		      INSERT INTO cursorcopy (NAME,Num,Phone,Qty) VALUES ("Henry","00742","777 7777","60")
		      GO TOP
	ENDPROC
ENDDEFINE

DEFINE CLASS grid01 AS grid
	ColumnCount = 4
	Height = 157
	Left = 36
	Top = 72
	Width = 420
	Name = "Grid1"
	visible = .T.
	Column1.Name = "Column1"
	Column2.Name = "Column2"
	Column3.Name = "Column3"
	Column4.Name = "Column4"
	
	PROCEDURE INIT
		WITH THIS.Columns(1)
    		BINDEVENT(.header1, "Click", this, "oHeader1")
   		ENDWITH
		WITH THIS.Columns(2)
    		BINDEVENT(.header1, "Click", this, "oHeader2")
   		ENDWITH
   		WITH THIS.Columns(3)
    		BINDEVENT(.header1, "Click", this, "oHeader3")
   		ENDWITH
		WITH THIS.Columns(4)
    		BINDEVENT(.header1, "Click", this, "oHeader4")
   		ENDWITH
   		
	PROCEDURE Column1.Moved
		WAIT WINDOW "Column1.Moved"
	ENDPROC


	PROCEDURE Column2.Moved
		WAIT WINDOW "Column2.Moved"
	ENDPROC


	PROCEDURE Column3.Moved
		WAIT WINDOW "Column3.Moved"
	ENDPROC


	PROCEDURE Column4.Moved
		WAIT WINDOW "Column4.Moved"
	ENDPROC

	PROCEDURE oheader1
		WAIT WINDOW "Column1.header1.click"
		
	PROCEDURE oheader2
		WAIT WINDOW "Column2.header1.click"
		
	PROCEDURE oheader3
		WAIT WINDOW "Column3.header1.click"
		
	PROCEDURE oheader4
		WAIT WINDOW "Column4.header1.click"						
ENDDEFINE
 
Hi All :

Any feedback to resolve or avoid the error posted here ?

Smarty
 
Let me make sure I understand the problem you're pointing out. The first time you drag a column, the Moved event fires. If you then drag the same column again, all you get is a Click event for the header. That's what you're seeing?

Interesting, I just tried this with the Event Tracker turned on and it looks likes Moved fires, but for some reason, your code isn't firing.

Okay, I changed all your WAIT WINDOWs to DEBUGOUTs, so that clearing the WAIT WINDOW wouldn't interfere with the test, and everything seems to be working as expected.

Tamar
 
Dear TamarGranor :

It is confirmed that you understand the problem it is pointing to: the first time a column is dragged, the Moved event fires. If the same column is dragged again, all you get is a Click event for the header. That's what you're seeing and EXPERIENCING?

Your approach to try to resolve is innovative though not to the point.

Please try following code for testing. What's added is timeout seconds to WAIT WINDOWS:

I want a solution on such because header calling of other real codes of my little system is to call for ascending/descending sorting. The code posted here is a simulation on such and for easy testing and discussion.

Code:
oForm = CREATEOBJECT("form1")
oGrid = oForm.ADDOBJECT("newgrid", "grid01")

oForm.show(1)
&&READ events

DEFINE CLASS form1 AS form
	Top = 13
	Left = 4
	Height = 250
	Width = 482
	DoCreate = .T.
	Caption = "Form1"
	Name = "Form1"
	
		ADD OBJECT label1 AS label WITH ;
		WordWrap = .T., ;
		Caption = "Try moving 1st Column then to 2nd Column then 3rd Column to see result", ;
		Height = 36, ;
		Left = 48, ;
		Top = 12, ;
		Width = 385, ;
		Name = "Label1"

	PROCEDURE Load
		      CREATE CURSOR cursorcopy (NAME c(10),Num c(10),Phone C(10),QTY c(10))
		      INSERT INTO cursorcopy (NAME,Num,Phone,Qty) VALUES ("Bill","00725","555 1212","125")
		      INSERT INTO cursorcopy (NAME,Num,Phone,Qty) VALUES ("Mikel","00728","555 1232","25")
		      INSERT INTO cursorcopy (NAME,Num,Phone,Qty) VALUES ("Jan","00729","555 5432","13")
		      INSERT INTO cursorcopy (NAME,Num,Phone,Qty) VALUES ("Rosa","00730","555 5555","177")
		      INSERT INTO cursorcopy (NAME,Num,Phone,Qty) VALUES ("John","00735","666 6666","250")
		      INSERT INTO cursorcopy (NAME,Num,Phone,Qty) VALUES ("Henry","00742","777 7777","60")
		      GO TOP
	ENDPROC
ENDDEFINE

DEFINE CLASS grid01 AS grid
	ColumnCount = 4
	Height = 157
	Left = 36
	Top = 72
	Width = 420
	Name = "Grid1"
	visible = .T.
	Column1.Name = "Column1"
	Column2.Name = "Column2"
	Column3.Name = "Column3"
	Column4.Name = "Column4"
	
	PROCEDURE INIT
		WITH THIS.Columns(1)
    		BINDEVENT(.header1, "Click", this, "oHeader1")
   		ENDWITH
		WITH THIS.Columns(2)
    		BINDEVENT(.header1, "Click", this, "oHeader2")
   		ENDWITH
   		WITH THIS.Columns(3)
    		BINDEVENT(.header1, "Click", this, "oHeader3")
   		ENDWITH
		WITH THIS.Columns(4)
    		BINDEVENT(.header1, "Click", this, "oHeader4")
   		ENDWITH
   		
	PROCEDURE Column1.Moved
		WAIT WINDOW "Column1.Moved" TIMEOUT 0.5
	ENDPROC


	PROCEDURE Column2.Moved
		WAIT WINDOW "Column2.Moved" TIMEOUT 0.5
	ENDPROC


	PROCEDURE Column3.Moved
		WAIT WINDOW "Column3.Moved" TIMEOUT 0.5
	ENDPROC


	PROCEDURE Column4.Moved
		WAIT WINDOW "Column4.Moved" TIMEOUT 0.5
	ENDPROC

	PROCEDURE oheader1
		WAIT WINDOW "Column1.header1.click" TIMEOUT 0.5

	PROCEDURE oheader2
		WAIT WINDOW "Column2.header1.click" TIMEOUT 0.5

	PROCEDURE oheader3
		WAIT WINDOW "Column3.header1.click" TIMEOUT 0.5

	PROCEDURE oheader4
		WAIT WINDOW "Column4.header1.click" TIMEOUT 0.5					

ENDDEFINE
 
I still think the Waits are interfering here. Did you try it with Debugout instead?

I understand this isn't your real code, but a repro. But let's make sure the test code doesn't interfere with the problem.

Tamar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top