How to se focus and stay in second window?

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

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

How to se focus and stay in second window?

Post by mol »

Hi guys!
I'm working on my billing project.
I want to create one window with new invoice and call second window with grid with table of goodies to sell.

I'm using something like that:
activate window F_Invoice, F_TableOfGoodies
to acitvate both windows.
F_TableOfGoodies is hidden from definition.

after pressing F6 key, I'm trying to move focus to F_TableOfGoodies:
F_TableOfGoodies.Show
F_TableOfGoodies.SetFocus


after these commands, form F_TableOfGoodies appear, but immediately losts focus.
So, my question is:
How to stop focus in F_TableOfGoodies to let the operator select position from table of goodies?

Did sb. realised such a problem?

Best regards, Marek
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 to se focus and stay in second window?

Post by Rathinagiri »

Marek,

Can you please post a small sample?
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 to se focus and stay in second window?

Post by mol »

It's hard to prepare sample because this project is very huge now.
I'll try to describe it:

1. Form Invoice appears on screen
2. Operator presses "Add Position" Button
3. Form Table_Of_Goodies appears on screen
4. Operator selects position from table and double clicks on it.
5. Form Table_Of_Goodies disappears from screen
6. Selected article is added to Invoice


Ive realised it by creating Table_of_Goodies everytime, when operator clicks "add" button.
But it takes too much time in network environment (I don't know why).
So, I want to hide this window, not release it.

Marek
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 to se focus and stay in second window?

Post by Rathinagiri »

Hi Marek,

Kindly see this small sample prepared by me. Is this what you need?

Code: Select all

#include <hmg.ch>

Function Main
   private cTarget := ''
   define window inv at 0, 0 width 600 height 400 main

      define label name1
         row 10
         col 10
         width 50
         value 'Item 1'
      end label
      define textbox item1
         row 10
         col 60
         width 100
         value ''
      end textbox
      define button b1
         row 10
         col 170
         width 80
         caption 'Add'
         action selectitem( 'item1' )
      end button
      define label name2
         row 40
         col 10
         width 50
         value 'Item 1'
      end label
      define textbox item2
         row 40
         col 60
         width 100
         value ''
      end textbox
      define button b2
         row 40
         col 170
         width 80
         caption 'Add'
         action selectitem( 'item2' )
      end button
   end window 

   define window items at 0, 0 width 200 height 300 child noshow 
      define listbox itemlist
         row 10
         col 10
         width 180
         height 240
         items { 'Item 1', 'Item 2', 'Item 3', 'Item 4', 'Item  5', 'Item 6' }
         ondblclick itemselected()
         value 1
      end listbox
   end window
   inv.center
   items.center

   activate window inv, items
      
   Return

function selectitem( cTargetControl )
   cTarget := cTargetControl
   items.show
return nil

function itemselected
   setproperty( 'inv', cTarget, 'VALUE', items.itemlist.item( items.itemlist.value ) )
   items.hide
return nil
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 to se focus and stay in second window?

Post by mol »

Hi Rathi!

I've modified a little your sample to fit it to my situation, where INV form is called from MainWindow.
And then, something is going wrong:

Code: Select all

#include <hmg.ch>

Function Main
   private cTarget := ''
   define window MainWindow at 0, 0 width 600 height 400 main title "Testing program"

      define label name1
         row 10
         col 10
         width 200
         value 'Here is main window'
      end label
	  define button b1
         row 40
         col 170
         width 80
         caption 'Start test'
         action Start_test()
      end button
	end window
	
	MainWindow.center
	MainWindow.activate
 return

function Start_Test	

   define window inv at 0, 0 width 600 height 400 title "Invoice" modal
      define label name1
         row 10
         col 10
         width 50
         value 'Item 1'
      end label
      define textbox item1
         row 10
         col 60
         width 100
         value ''
      end textbox
      define button b1
         row 10
         col 170
         width 80
         caption 'Add'
         action selectitem( 'item1' )
      end button
      define label name2
         row 40
         col 10
         width 50
         value 'Item 1'
      end label
      define textbox item2
         row 40
         col 60
         width 100
         value ''
      end textbox
      define button b2
         row 40
         col 170
         width 80
         caption 'Add'
         action selectitem( 'item2' )
      end button
   end window

   define window items at 0, 0 width 200 height 300 title "Items" child noshow 
      define listbox itemlist
         row 10
         col 10
         width 180
         height 240
         items { 'Item 1', 'Item 2', 'Item 3', 'Item 4', 'Item  5', 'Item 6' }
         ondblclick itemselected()
         value 1
      end listbox
   end window
   inv.center
   items.center

   activate window inv, items
     
   Return

function selectitem( cTargetControl )
   cTarget := cTargetControl
   items.show
return nil

function itemselected
   setproperty( 'inv', cTarget, 'VALUE', items.itemlist.item( items.itemlist.value ) )
   items.hide
return nil

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 to se focus and stay in second window?

Post by Rathinagiri »

It is because of the 'modal' type of window definition.

So, either change 'inv' to 'child' or 'items' to 'modal' and try again.
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 to se focus and stay in second window?

Post by mol »

I've tried with both modal windows and it doesn't work OK.
I can't use child window, because child window is not blocking main window.
I'll make some tests later.

Thanks, Rathi!
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 to se focus and stay in second window?

Post by Rathinagiri »

For me, at least for this sample, it works by making both the windows as modal.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
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 to se focus and stay in second window?

Post by Rathinagiri »

Yes. I have changed like the below:

Code: Select all

#include <hmg.ch>

Function Main
   private cTarget := ''
   define window MainWindow at 0, 0 width 600 height 400 main title "Testing program"

      define label name1
         row 10
         col 10
         width 200
         value 'Here is main window'
      end label
     define button b1
         row 40
         col 170
         width 80
         caption 'Start test'
         action Start_test()
      end button
   end window
   
   MainWindow.center
   MainWindow.activate
return

function Start_Test   

   define window inv at 0, 0 width 600 height 400 title "Invoice" modal
      define label name1
         row 10
         col 10
         width 50
         value 'Item 1'
      end label
      define textbox item1
         row 10
         col 60
         width 100
         value ''
      end textbox
      define button b1
         row 10
         col 170
         width 80
         caption 'Add'
         action selectitem( 'item1' )
      end button
      define label name2
         row 40
         col 10
         width 50
         value 'Item 1'
      end label
      define textbox item2
         row 40
         col 60
         width 100
         value ''
      end textbox
      define button b2
         row 40
         col 170
         width 80
         caption 'Add'
         action selectitem( 'item2' )
      end button
   end window

   define window items at 0, 0 width 200 height 300 title "Items" modal noshow
      define listbox itemlist
         row 10
         col 10
         width 180
         height 240
         items { 'Item 1', 'Item 2', 'Item 3', 'Item 4', 'Item  5', 'Item 6' }
         ondblclick itemselected()
         value 1
      end listbox
   end window
   inv.center
   items.center

   activate window inv, items
     
   Return

function selectitem( cTargetControl )
   cTarget := cTargetControl
   items.show
return nil

function itemselected
   setproperty( 'inv', cTarget, 'VALUE', items.itemlist.item( items.itemlist.value ) )
   items.hide
return nil
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
Post Reply