How can I create dynamically browse or grid?

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
mol
Posts: 3825
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

How can I create dynamically browse or grid?

Post 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.
User avatar
mol
Posts: 3825
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: How can I create dynamically browse or grid?

Post 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
User avatar
Rathinagiri
Posts: 5482
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: How can I create dynamically browse or grid?

Post by Rathinagiri »

Thanks Marek. Might be useful for others. :)
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
mol
Posts: 3825
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

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

Post 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
User avatar
gfilatov
Posts: 1116
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

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

Post 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:
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
User avatar
mol
Posts: 3825
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: How can I create dynamically browse or grid?

Post by mol »

WOW, many thx Grigori!
I'll test it and paste my results here...
User avatar
mol
Posts: 3825
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: How can I create dynamically browse or grid?

Post by mol »

It works exactly as I expected!
Many thanks for help!
Post Reply