Using HMG or HMG Extended with xHarbour.com

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
swapan
Posts: 242
Joined: Mon Mar 16, 2009 4:23 am
Location: Kolkata, India
Contact:

Re: Using HMG or HMG Extended with xHarbour.com

Post by swapan »

dhaine_adp wrote:Hi Tom,

If you have coded using HMG library before, perhaps you know how you can handle the transition. For sure DOS and GUI is two different things. The instruction pointer will not return to where you are expecting it as in DOS.

Danny
Dear Danny:

Thanks for this detailed explanation....really good one. Actually we all (who are still using Clipper applications) have to go through this situation..THE MIGRATION ISSUE.
Thanks & Regards,
Swapan Das

http://www.swapandas.com/
tomfromdare
Posts: 6
Joined: Mon Dec 15, 2008 4:28 pm

Re: Using HMG or HMG Extended with xHarbour.com

Post by tomfromdare »

Danny (and the rest)

Please explain a concept that is still fuzzy. In the DOS program, there's a single window and the contents are erased and replaced with the next content needed. In the GUI world, is there the equivalent, and if so is it considered bad practice? Is the normal way to change from one screen of content to the next, a process of destroying a window and creating a new one?

I'm just wanting to get the flow correct from the start. My demo for the client will be a login screen which, if successful, will bring up the main menu. If login is unsuccessful, how would I show that to the user, and wouldn't I return to the login screen for another try? I imagine that the main menu could be displayed at all times after login, with each menu choice launching a new window. In this way the user could have multiple tasks in progress a the same time, though all would be applying changes only to the warehouse that they are logged into.

Thanks!
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: Using HMG or HMG Extended with xHarbour.com

Post by Rathinagiri »

Hi Tomfromdare

I see myself in you. :) Yes. I had asked almost all these questions before jumping into the GUI stream!

Then, I learned from the samples/examples provided by Roberto.

GUI is just event driven. It is like dinner with all the items already served on the plate. The user can take anyone he wants in any order he wishes.

Take your case, a login screen.

Please consider this small sample: (It's not complete though)

Code: Select all

function showlogin()
private nTries := 0
private nMaxTriesAllowed := 3
lAuthenticated := .f.
define login at 0,0 width 200 height 200 modal
   define label usernamelabel
      row 10
      col 10
      width 80
      value "User ID"
   end label
   define textbox userid
      row 10
      col 90
      width 80
      value ""
      maxlength 10
   end textbox
   define label passlabel
      row 40
      col 10
      width 80
      value "Password"
   end label
   define textbox pass
      row 40
      col 90
      width 80
      value ""
      password .t.
   end textbox
   define button loginok
      row 70
      col 10
      caption "Login"
      width 80
      action dologin()
   end button
   define button close
      row 70
      col 110
      width 80
      caption "Exit"
      action login.release()
   end button
end window
login.center
login.activate
return nil
Once you login window is activated using login.activate, a window with two labels and two textboxes are shown. The user enters the user-id and password and clicks login. Immediately the control is transferred to dologin() function. In dologin() function, we have to check the username and password for authentication. If it is right, then we can release the login window. Otherwise, we can just return back.

See this function...

Code: Select all

function dologin
if login.userid.value == "Correct User" and login.pass.value == "Correct Password"
   lAuthenticated := .t.
   login.release()
else
   nTries := nTries + 1
   if nTries > nMaxTriesAllowed
      msgstop("Wrong credentials! You have to restart!")
      lAuthenticated := .f.
      login.release()
   else
      msgstop("Invalid Username/Password! Please try again.")
      login.userid.value := ""
      login.pass.value := ""
   endif
endif
return nil
Since login window is a modal window, the user can not access any other window than this. If he succeeded, login window will be closed with lAuthenticated := .t. Otherwise, lAuthenticated := .f. which can be verified from the calling function.

I think I had not confused you. :)
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
Post Reply