Page 1 of 1

How can I create dynamically browse or grid?

Posted: Tue Apr 10, 2012 7:54 am
by mol
Hi guys!
I need to create browse or grid dynamically, but, how to paste parent window name to definition?
I've tried something like this:

Code: Select all

function CreateTable
LOCAL cParentWindowName
	cParentWindowName:= THISWINDOW.NAME

	DEFINE BROWSE Table_Results
		PARENT &cParentWindowName
			WIDTH 500  
			HEIGHT 360 
			HEADERS {"nag"} 
			WIDTHS {100} 
			WORKAREA TRAFO 
			FIELDS {"KOD_STACJI"} 
	END BROWSE 
but it causes runtime error in line h_browse.prg:

Code: Select all

	Public &mVar. := k
I think, tne name of parent window is passed as "&cParentWindowName" not as value contained by this variable...

Parent window is created from definition stored in DBF file, so it's name is created while program's run.

Re: How can I create dynamically browse or grid?

Posted: Tue Apr 10, 2012 9:33 am
by mol
I found problem in my code...
While defining window name, space (chr(32)) was added at the end
Window was created ok, but, this name contained space. I found it when I've called msgbox("->"+ thisWindow.Name+"<-")

Now, everything is OK.
Uff, Two days on searching one space :D :D :D

Re: How can I create dynamically browse or grid?

Posted: Tue Apr 10, 2012 10:06 am
by Rathinagiri
Thanks Marek. Might be useful for others. :)

Re: How can I create dynamically browse or grid placed on TA

Posted: Thu Apr 12, 2012 12:35 pm
by mol
Another problem:
How to define grid on previously defined TAB?

I've tried:

Code: Select all

define grid G_PSP 
				parent OknoTabTowarow.TAB_InfoDodatkowe
but It causes error with not defined OknoTabTowarow.TAB_InfoDodatkowe

Re: How can I create dynamically browse or grid placed on TA

Posted: Thu Apr 12, 2012 2:22 pm
by gfilatov
mol wrote:Another problem:
How to define grid on previously defined TAB?
Hi Mol,

Please take a look for the following working sample:

Code: Select all

/*
 * MINIGUI - Harbour Win32 GUI library Demo
 *
*/

#include "minigui.ch"

Function Main

define window tabsample at 0,0 width 400 height 300 title 'Add control test' main

   define tab tab1 at 10,10 width 370 height 200

      define page 'Page1'

         define button ok
            row 30
            col 10
            caption 'Press here to add a control'
            width 180
            action addnewcontrol()
         end button   

      end page

      define page 'Page2'
      
      end page

   end tab

end window

tabsample.center
tabsample.activate

Return nil

function addnewcontrol

if iscontroldefined(lbl1,tabsample)
   tabsample.lbl1.release
endif

define label lbl1
   parent tabsample
   row 50
   col 10
   width 40
   value 'label'
end label

if iscontroldefined(text1,tabsample)
   tabsample.text1.release
endif

define textbox text1
   parent tabsample
   row 50
   col 50
   width 100
end textbox

tabsample.tab1.addcontrol('lbl1',1,84,10)  // control name, tab page, row, col
tabsample.tab1.addcontrol('text1',1,80,50)

return nil
Hope that helps :idea:

Re: How can I create dynamically browse or grid?

Posted: Thu Apr 12, 2012 3:00 pm
by mol
WOW, many thx Grigori!
I'll test it and paste my results here...

Re: How can I create dynamically browse or grid?

Posted: Fri Apr 13, 2012 8:57 am
by mol
It works exactly as I expected!
Many thanks for help!