Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Xdialog graphic and button options

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Xdialog graphic and button options

    I would like to do the following to an Xdialog and could use some assistance.

    1. Add a graphic (See attachment)
    2. Gray out the Login/OK button until a value exists in the password field

    My current dialog code is shown below:

    ' ---------------- Now get user info and verify ------------------
    'Pasted this code from Xdialog Genie which created the code
    'Xdialog that asks for user name and password for system logon
    DIM GLOBAL gvuser as C
    DIM SHARED vuserpass as C
    DIM SHARED varC_result as C
    DIM vuserfound as C

    '---------------
    Retry_here:
    '---------------
    heading_string = "Enter Your Username and Password."
    ok_button_label = "&OK"
    cancel_button_label = "&Cancel"
    varC_result = ui_dlg_box("EIM Track",<<%dlg%
    {font=Arial,10}
    {region}
    {text=55,1:heading_string};
    {endregion};
    {region}
    Username:| [.40gvuser];
    Password:| [%p%.40vuserpass];
    {endregion};
    {line=1,0};
    {region}
    <*15=ok_button_label!OK> <15=cancel_button_label!CANCEL>
    {endregion};
    %dlg%)

    IF varC_result = "OK"
    'Let Admin user in if they enter the appropriate info
    IF gvuser = "Admin" .and. vuserpass = "Admin"
    ui_msg_box("Admin Login","Administrator Login Successful")
    END'
    END IF

    ' Get data from Employee Master file to verify password - make one text string that has both values and then parse it out below
    ' Lookup the records for the matching username and password
    lres = lookupc("F",alltrim(gvuser),"alltrim(emplognid)+' -- '+alltrim(emppass)",a5.Get_Path()+"\emp.dbf","_emplognid")
    vuserfound = word(lres,1," -- ")
    vpassfound = word(lres,2," -- ")



    'Compare user name entered to that in the Employee Master file (found with lookupc above)
    IF alltrim(lower(gvuser)) = alltrim(lower(vuserfound))
    'Name matches - now look at the password for a match

    IF alltrim(lower(vuserpass)) = alltrim(lower(vpassfound)) ' Password matches too
    gvuser = alltrim(lower(gvuser))

    'Clear vuserpass variable
    vuserpass = ""

    'Set a Global Variable that contains the employees full name
    DIM GLOBAL gvEmpName as C
    gvEmpName = lookupc("F", gvuser, "alltrim(Empfname)+' '+ alltrim(Emplname)", "emp","_Emplognid")

    'Opens the Main Menu Form
    form.view("Main_Menu")
    END'
    ELSE
    'Password does not match - try again
    ui_msg_box("Password Error!","Password entered is incorrect.",UI_STOP_SYMBOL)

    'Clear vuserpass variable
    vuserpass = ""
    GOTO retry_here
    END IF

    ELSE 'User Name is wrong - this is from first IF statement
    ui_msg_box("User Name Not Found","The User Name you entered could not be found",UI_STOP_SYMBOL)
    gvuser = ""
    vuserpass = ""
    GOTO Retry_here

    END IF

    END IF 'End if for varC_result - user pushed the ok button

    ' If user presses the Cancel button - just terminate the whole program
    IF varC_result = "Cancel"
    ' Implement this on live program to exit program completely if user hits cancel and decides not to login
    a5.close()
    END IF

    #2
    Re: Xdialog graphic and button options

    We do something reasonably similar. I have attached a picture of our login dialog. Notice the "OK" button. The code to produce it is below. There is quite a bit going on, but if you follow the code, you can see that it does pretty much what you are attempting.

    Code:
    userid = ""
    passwd = ""
    
    f = file.open(aa.bcbss.path+"\bcbss\seal.jpg",FILE_RO_SHARED)
    UI_BITMAP_LOAD("BCBSS",F.READB(10000000))
    f.close()
    
    rslt = ui_dlg_box(aa.bcbss.agency+" - Security",<<%dlg%
    {background=#255+253+159}
    {frame=1,1}
    {region1}
    {sp=20}{image=BCBSS};
    {sp=3} Welcome to the {text=38aa.bcbss.agency};
    {lf};
    Before proceeding, You Must Enter YOUR User-ID and Password
    {lf};
    {endregion1};
    {lf};
    {frame=1,1:Please Sign In:}
    {region2}
    {lf};
    {sp=10} Enter User-ID: |{initial_focus}[5.8userid!userid_killfocus] ;
    {lf};
    {sp=10} Enter Password: |[%p%6.8passwd] ;
    {lf};
    {endregion2};
    {lf};
    {frame=1,1:Error Messages:}
    {region3}
    {sp=5}{text=60,2errmsg}
    {endregion3};
    {frame=1,1}
    {region4}
    {sp=7} <10&OK ?.not.(userid="").and.errmsg=""> {sp=4} <&Clear> {sp=4} <10&Exit>
    {endregion4}
    %dlg%, <<%code%
    IF a_dlg_button = "&Exit"
    	:A5.close()
    END IF
    IF a_dlg_button = "&Clear"
    	a_dlg_button = ""
    	if upper(left(errmsg,3))="USE"
    		errmsg = ""
    		userid = ""
    		passwd = ""
    		ui_dlg_ctl_goto(aa.bcbss.agency+" - Security","userid")
    	end if
    	if upper(left(errmsg,3))="PAS"
    		errmsg = ""
    		passwd = ""
    		ui_dlg_ctl_goto(aa.bcbss.agency+" - Security","passwd")
    	end if
    end if
    if a_dlg_button = "userid_killfocus"
    	a_dlg_button = ""
      	if ((left(userid,3)="SYS".or.left(userid,3)="ADM".or.left(userid,3)="SSS".or.left(userid,3)="CLE".or.left(userid,3)="CSP".or.left(userid,3)="LEG".or.left(userid,3)="FIN".or.left(userid,3)="REL").and.len(userid)<5).or.len(userid)<4
      		'OK now
      		a_dlg_button = "" 	
       	  else
       		a_dlg_button = ""
    		'get the secure2 user_id and password
    		TBL_SECURE = table.open("secure2.dbf",FILE_RW_SHARED)
    		TBL_SECURE.index_primary_put("User")
    
    		recno=TBL_SECURE.fetch_find(UT(userid))
    		if recno < 0
    			errmsg = "User_ID Entered is Invalid - Click \"Clear\""
    			trys = trys+1
    			IF trys <4 THEN
    				'OK now
    	  		  ELSE
    	  		  	a_dlg_button = "&Exit"
    				ui_msg_box(aa.bcbss.agency+" - Security Error","Too many tries, Application Closing")
    				:A5.Close()
    			END IF
    		end if
     	 end if
    end if
    if a_dlg_button = "&OK"
    	if ut(passwd) <> tbl_secure.passwd
    		a_dlg_button = ""
    		if errmsg = ""
    			errmsg = "Password Entered is Invalid - Click \"Clear\""
    		  ELSE
    		  	errmsg = errmsg+crlf()+"Password Entered is Invalid - Click \"Clear\""
    		end if
    		trys = trys+1
    		IF trys <4 THEN
    			'OK now
    	  	  ELSE
    	  	  	a_dlg_button = "&Exit"
    			ui_msg_box(aa.bcbss.agency+" - Security Error","Too many tries, Application Closing")
    			:A5.Close()
    		END IF
    	ui_dlg_ctl_goto(aa.bcbss.agency+" - Security",passwd)
    	end if
    	'tbl_secure.close()
    end if
    %code%)
    
    'place this after a dialog box to see if the user clicked on the "X"
    'rslt is the name of the variable created by the dialog 
    'if it is created by the dialog genie, it is called varC_result
    if rslt =""
    	ui_msg_box(aa.bcbss.agency+" - Security","Action Cancelled at user request")
    	:A5.Close()
    end if
    
    IF DATE()>=ADDMONTHS(tbl_secure.PWDDATE,2) .or. ut(tbl_secure.passwd)= "NEW"  
    	errmsg = ""
    	trys = 0
    rslt1 = ui_dlg_box("Password Security",<<%dlg%
    	{background=Pale Yellow}
    	{frame=1,1}
    	{region}
    	{sp=3} Your Current Password Has Expired
    	{lf=2}
    	You Must Enter a NEW Password and VERIFY it. 
    	{lf=2}	
    	{endregion};
    	{lf};
    	{frame=1,1:Please Enter your New Password - Maximum 6 characters}
    	{region2}
    	{lf};
    	{sp=10} Enter Password: |[%p%6.8.pwd1];
    	{lf};
    	{sp=7} Re-Enter Password: |[%p%6.8pwd2];
    	{lf};
    	{endregion2};
    	{lf};
    	{frame=1,1:Error Messages:}
    	{region3}
    	{text=60,4errmsg};
    	{endregion3};
    	{lf};
    	{frame=1,1}
    	{region4}
    	{sp=6} <10&OK?errmsg=""> {sp=4}<10&Clear> {sp=4} <10&Exit>
    	{endregion4}
    	%dlg%, <<%code%
    	IF a_dlg_button = "&Exit"
    		:A5.close()
    	END IF
    	IF a_dlg_button = "&Clear"
    		a_dlg_button = ""
    		if errmsg<>""
    			errmsg = ""
    			pwd1 = ""
    			pwd2 = ""
    			ui_dlg_ctl_goto("Password Security","pwd1")
    		end if
    	end if
    	if a_dlg_button = "&OK"
    		debugcheck()
    		if len(pwd1) >6
    			errmsg = "1st New PASSWORD Error, Password Entered is too long"
    			IF trys <4
    				pwd1 = ""
    				a_dlg_button = "" 
    			end if
    		  ELSEIF PWD1 = "" .or. PWD1 = "******"
    			errmsg = "1st New PASSWORD Error, Nothing was Entered"
    			IF trys <4
    				pwd1 = ""
    			
    				a_dlg_button = "" 
    			  ELSE
    			  	a_dlg_button = "&Exit"
    				ui_msg_box(aa.bcbss.agency+" Password Security Error","Too many tries, Application Closing")
    				:A5.close()
    			END IF
    		END IF
    		if len(pwd2) >6
    			if errmsg = ""
    				errmsg = "2nd New PASSWORD Error, Password Entered is too long"
    			  else
    			  	errmsg = errmsg+crlf()+"2nd New PASSWORD Error, Password Entered is too long"
    			end if
    			IF trys <4
    				pwd1 = ""
    				pwd2 = ""
    				a_dlg_button = "" 
    			end if
    		  ELSEIF pwd2 = "" .or. pwd2 = "******"
    			a_dlg_button = "" 
    			if errmsg = ""
    				errmsg = "2nd New PASSWORD Error, Nothing was Entered"
    			  else
    			  	errmsg = errmsg+crlf()+"2nd New PASSWORD Error, Nothing was Entered"
    			end if
    			IF trys <4
    				pwd2 = ""
    				a_dlg_button = ""
    		 	  ELSE
    		  		a_dlg_button = "&Exit"
    				ui_msg_box(aa.bcbss.agency+" Password Security Error","Too many tries, Application Closing")
    				:A5.close()
    			END IF
    		end if
    		if ut(pwd1) <> ut(pwd2)
    			pwd1 = ""
    			pwd2 = ""
    			if errmsg = ""
    				errmsg = "1st and 2nd New Passwords Do NOT match "
    			  ELSE
    			  	errmsg = errmsg+crlf()+"1st and 2nd New Passwords Do NOT match"
    			end if
    			IF trys <4 THEN
    				a_dlg_button = ""
    		  	  ELSE
    		  	  	a_dlg_button = "&Exit"
    				ui_msg_box(aa.bcbss.agency+" Password Security Error","Too many tries, Application Closing")
    				:A5.Close()
    			END IF
    		end if
    	 	if errmsg <>""
    	 		errmsg = errmsg+crlf()+crlf()+" - Click \"CLEAR\""
    			a_dlg_button = "" 
    			trys = trys+1
    			ui_dlg_ctl_goto("Password Security","pwd1")
    		end if
    	end if
    	%code%)
    	if rslt1 =""
    		ui_msg_box(aa.bcbss.agency+" - Security","Action Cancelled at user request")
    		:A5.Close()
    	end if
    	TBL_SECURE.change_begin()
    		tbl_secure.passwd=PWD1
    		tbl_secure.pwddate = date()
    	TBL_SECURE.change_end(.T.)
    	ui_msg_box("PASSWORD","Password Changed Successfully"+chr(13)+chr(13)+"New Password = "+PWD1,16)
    	'tbl_secure.close()
    end if	
    
    'Set user as "Active"
    IF tbl_secure.mode_get() > 0 THEN
    	GOTO BYPASSt
      ELSE
      	TBL_SECURE.change_begin()
      	bypasst:
    		tbl_secure.active="X"
    		tbl_secure.activetime=time()
    	TBL_SECURE.change_end(.T.)
    END IF
    
    
    'define global variable for access
    access=tbl_secure.access
    level = tbl_secure.type
    vn_emp_id = tbl_secure.empid
    'define super-global variable for access
    aa.bcbss.access = tbl_secure.access
    aa.bcbss.level = tbl_secure.type
    aa.bcbss.vn_emp_id = tbl_secure.empid
    aa.bcbss.agency = agency
    tbl_secure.close()
    'check if we need to close out now
    'closeit = upper(lookupc("F",1,"closeit",aa.bcbss.path+"\bcbss\indicato.dbf","recno"))
    if closeit = "X"
    	'system problems,  get out now
    	ui_msg_box(aa.bcbss.agency,"System Maintenance Required, Shutting Down!!")
    	if aa.bcbss.level <>"A"
    		:a5.close()
    	end if
    end if
    
    a5.show()
    now you know how to hack into our system.

    Tom

    Comment


      #3
      Re: Xdialog graphic and button options

      Tom,

      Thank-you for your reply. I am new to Xbasic and having a little trouble locating the code that grays out the ok button and shows it when a pasword is entered. Can you tell me what lines to look at for that specific function?

      Scott

      Comment


        #4
        Re: Xdialog graphic and button options

        no problem... On ours, it is disabled until a user-id is entered, but you could change the condition to when a password is entered.

        Right on the line where you define the "OK" button.

        Code:
        {sp=7} <10&OK [COLOR="Red"][B]?.not.(userid="").and.errmsg=""[/B][/COLOR]> {sp=4} <&Clear> {sp=4} <10&Exit>
        the "?" says that conditional code follows. If the condition is met, then the button will be enabled, else it is disabled.

        Comment


          #5
          Re: Xdialog graphic and button options

          I am a real newbie with Xbasic and having trouble getting the conditional statement to work properly. My prompt code is shown below, can you mod the code so the OK buttons is grayed out if the password is null?

          vuserpass=""

          '---------------
          Retry_here:
          '---------------
          ok_button_label = "&OK"
          cancel_button_label = "&Cancel"
          varC_result = ui_dlg_box("EIM Track",<<%dlg%
          {font=Arial,10}
          {region}
          {endregion};
          {frame=1,1:Please Sign In:}
          {region}
          {lf};
          Username:| [.40gvuser];
          Password:| [%p%.40vuserpass];
          {lf};
          {endregion};
          {lf};
          {region}
          <*15=ok_button_label!OK> <15=cancel_button_label!CANCEL>
          {endregion};
          %dlg%)

          Comment


            #6
            Re: Xdialog graphic and button options

            Lesson 4 in the "Learning Xdialog - Desktop" tutorial explains how to conditionally disable (or enable) controls. Your button is a control. Take a look.

            Comment


              #7
              Re: Xdialog graphic and button options

              see below

              Code:
              {sp=7} <*15=ok_button_label!OK[B][COLOR="Red"]?.not.(vuserpass="")>[/COLOR][/B] {sp=4}  <15&Exit>

              Comment


                #8
                Re: Xdialog graphic and button options

                Worked like a charm, thank-you Mr. Henkel.

                Comment


                  #9
                  Re: Xdialog graphic and button options

                  Tom,

                  Another question for you, how are you centering the buttons on the dialog? I am looking at the code and it is not sticking out at me.

                  Comment


                    #10
                    Re: Xdialog graphic and button options

                    For those interested in justifying the buttons on the dialog. Above the buttons, place....

                    {justify=left} or {justify=right} or {justify=center}

                    Comment


                      #11
                      Re: Xdialog graphic and button options

                      Scott

                      Here is another take on the log in dialog - it uses the xdialog header section and gradient colors.

                      FWIW

                      Code:
                      dim xp as p  ' dim xp for use by xdialog header
                      
                      'the next three line create the header for the xdialog
                      xp.bodytext=""  ' I leave this blank for log in screen
                      xp.headingtext=crlf()+space(4)+"Enter your user name and password" 'this is the title 
                      xp.image="$$large.generic.key" 'this is the image
                      dim varC_result as c
                      
                      'the next four line allow for gradient coloring in the xdialog body
                      delete xdialogstyle
                      dim xdialogstyle as p
                      xdialogstyle.accentcolor="Light Yellow"
                      xdialogstyle.color="white"
                      
                      
                      varC_result=ui_dlg_box("Login",<<%dlg%
                      {xdialogtitlesection=70,5xp};  {comment this initializes the xdialog header section}
                      {windowstyle=gradient horizontal};  {comment this initializes the windowstyle for gradient coloring}
                      
                      {region}
                      {font=arial,8,B};
                      
                           USERNAME:| [.25vc_user];
                           PASSWORD:| [%p%.25vc_pwd];
                      {font=arial,8};
                      {endregion};
                      {line=1,0};
                      {region}
                      {lf};
                      {justify=center}
                      <10OK!OK>  <10CANCEL!CANCEL>
                      {endregion}
                      %dlg%)
                      if varC_result<> "OK" then
                          end
                      end if
                      
                      msgbox("","Username = "+vc_user)

                      Comment


                        #12
                        Re: Xdialog graphic and button options

                        Scott,

                        In reply to your question...

                        Brute force and trial and error. See the code on the line for the buttons. Notice the {sp=7} I played with it until it looked OK. Didn't know about the {justify}. That would have made things much easier.:o

                        Code:
                         [COLOR="Red"]{sp=7}[/COLOR] <10&OK ?.not.(userid="").and.errmsg=""> {sp=4} <&Clear> {sp=4} <10&Exit>
                        later...
                        I found the "Key" image for your sign-in screen:

                        Code:
                        {image=$$generic.key};
                        have fun
                        Tom
                        Last edited by Tom Henkel; 05-28-2010, 08:47 AM. Reason: code for "Key" image

                        Comment

                        Working...
                        X