Page 1 of 2
HMG application forms help
Posted: Wed Mar 09, 2011 12:47 am
by raymanw
Hi all,
I am quite new to Harbour & HMG. I have successfully created the main form, a dropdown menu, a indexing form with a progress bar and is working on an user entry form. All this thanks to good people, like CCH, who are kind enough to help me out & also the good examples under the samples folder in the HMG package.
My question:
When I call my indexing form from the dropdown menu, it opens a new window outside & on top of the main form. How can I utilizes only 1 form to accomplish the same? ie. I start the application, the main form opens, I then call the indexing form & I don't want a new window/form to appear but have the progress bar rendered in the same main form.
Or the alternative is to have the indexing form/window opens within the confine of the main form.
Which one or both are doable? Which one is easier?
Thanks.
Re: HMG application forms help
Posted: Wed Mar 09, 2011 2:44 am
by Rathinagiri
Hi,
You can have the progress bar rendered in the same main form.
Instead of creating the forms in the runtime, we have to create controls at runtime. Use the 'Parent' for defining a new control at runtime. I will post a small sample soon.
Re: HMG application forms help
Posted: Wed Mar 09, 2011 12:50 pm
by raymanw
Hi Rathinagiri,
I managed to get the objects to render on the main window by following the example in this topic:
http://hmgforum.com/viewtopic.php?f=5&t ... lit=parent
However, after the processing had finished, how do I clear the form?
Thanks.
Re: HMG application forms help
Posted: Wed Mar 09, 2011 12:58 pm
by raymanw
I did a release of the 3 objects specified:
Main.Progress_1.Release
Main.TextBox_1.Release
Main.TextBox_2.Release
Progress_1 disappeared but the other 2 still remains.
Also, is it possible to clear the window of the 3 objects at one go?
Thanks.
Re: HMG application forms help
Posted: Wed Mar 09, 2011 1:07 pm
by Rathinagiri
Hi Can you give me the sample code?
I wish to know about your HMG version also.
Re: HMG application forms help
Posted: Wed Mar 09, 2011 2:08 pm
by raymanw
Hi Rathinagiri,
My HMG version is 3.0.35.
Part of the code:
Code: Select all
#include "hmg.ch"
Function IndexFile
declare window Main
@ 70,31 PROGRESSBAR Progress_1 ;
parent Main ;
RANGE 0,100 ;
WIDTH 300 HEIGHT 26 ;
TOOLTIP "ProgressBar"
@ 120,155 TEXTBOX TextBox_1 ;
parent Main ;
VALUE " 0 %" WIDTH 60 MAXLENGTH 5
@ 170,31 TEXTBOX TextBox_2 ;
parent Main ;
VALUE " 0 %" WIDTH 300 MAXLENGTH 5
Main.Progress_1.BackColor := YELLOW
Main.Progress_1.ForeColor := BLUE
Main.TextBox_1.Enabled := .f.
Main.TextBox_2.Enabled := .f.
Main.TextBox_2.Value := "Re-arranging Stock Transactions Headers (I)."
use StkHeads
inde on StkHeads->type+StkHeads->reference to StkHeads
Main.TextBox_1.Value := Str(44,3)+" %"
Main.Progress_1.Value := 44
Main.TextBox_2.Value := "Re-arranging Stock Transactions Details (I)."
use StkTrans
inde on StkTrans->type+StkTrans->reference+StkTrans->gold_type+StkTrans->item_type+StkTrans->item to StkTrans
Main.TextBox_1.Value := Str(67,3)+" %"
Main.Progress_1.Value := 67
Main.TextBox_2.Value := "Re-arranging Serial Number."
use Serial
pack
inde on Serial->gold_type+Serial->item_type to Serial
Main.TextBox_1.Value := Str(100,3)+" %"
Main.Progress_1.Value := 100
Main.TextBox_2.Value := "Re-arranging Completed."
close
Main.Progress_1.Release
Main.TextBox_1.Release
Main.TextBox_2.Release
Return Nil
Re: HMG application forms help
Posted: Wed Mar 09, 2011 4:44 pm
by Rathinagiri
Please check is code. The textboxes are released correctly for me.
Code: Select all
#include <hmg.ch>
Function Main
define window sample at 0,0 width 800 height 600 main
define button b1
row 10
col 10
caption "Press Me"
action showprogressbar()
end button
end window
sample.center
sample.activate
Return
function showprogressbar
define progressbar p1
row 100
col 100
width 200
parent sample
value 0
end progressbar
define textbox t1
parent sample
row 240
col 10
width 100
numeric .t.
rightalign .t.
value 0
end textbox
define textbox t2
parent sample
row 270
col 10
width 100
numeric .t.
rightalign .t.
value 0
end textbox
For i := 1 to 100
sample.t1.value := i
for j := 1 to 200
sample.t2.value := j
next j
sample.p1.value := i
next i
sample.p1.release
sample.t1.release
sample.t2.release
return nil
Re: HMG application forms help
Posted: Thu Mar 10, 2011 2:12 am
by raymanw
Hi Rathinagiri,
I tried your code, copy & pasted as sample1.prg & build using the command: c:\hmg.3.0.35\build.bat sample1
I do see the progress bar but don't see the 2 textboxes. The progress bar do disappeared after the run.
Thanks.
Re: HMG application forms help
Posted: Thu Mar 10, 2011 7:26 am
by Rathinagiri
Hi,
In that case, please use the following code with 'Do Events'
Code: Select all
#include <hmg.ch>
Function Main
define window sample at 0,0 width 800 height 600 main
define button b1
row 10
col 10
caption "Press Me"
action showprogressbar()
end button
end window
sample.center
sample.activate
Return
function showprogressbar
define progressbar p1
row 100
col 100
width 200
parent sample
value 0
end progressbar
define textbox t1
parent sample
row 240
col 10
width 100
numeric .t.
rightalign .t.
value 0
end textbox
define textbox t2
parent sample
row 270
col 10
width 100
numeric .t.
rightalign .t.
value 0
end textbox
For i := 1 to 100
sample.t1.value := i
for j := 1 to 200
sample.t2.value := j
DO EVENTS
next j
sample.p1.value := i
next i
sample.p1.release
sample.t1.release
sample.t2.release
return nil
Re: HMG application forms help
Posted: Fri Mar 11, 2011 1:52 am
by raymanw
Hi Rathinagiri,
Thanks for the working example.
Much appreciated.