How to go about it

Just starting out? Need help? Post your questions and find answers here.
mbecerra
User
User
Posts: 15
Joined: Mon Feb 28, 2005 4:59 am

How to go about it

Post by mbecerra »

I am planning to create a Internet cafe software and need advice. In my program if the user tries to close the window, it asks the user for a password via inputrequester. However it isn't secure as the password is being shown in full text. I can open a new window asking for the via the password text gadget, but the problem is nesting windows inside windows is confusing code-wise and If I decide to add more options(change server ip, operator password, etc.) thus, more windows i will end up with many windows nested upon eachother making the code confusion to understand and very difficult to maintain. What I would like to know is what would be the best approach to take so I don't end up with very hard to maintain code. Any advice in this matter is greatly appreciated.

Sincerely,

PureBasic User
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: How to go about it

Post by srod »

Needn't be a problem really.

What you could do is when you display the 'password' window, simply disable the main window so the user is forced to deal with the password window - either entering a password or closing the window etc. It is a matter of personal preference whether you then use a separate event loop to deal with the password window or use the main event loop etc.

This will of course limit the number of windows on display at any one time.

Personally I tend to always disable my 'main window' when throwing up some kind of dialog requesting some immediate information etc. and rarely have more than two windows open at any given time.
I may look like a mule, but I'm not a complete ass.
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Re: How to go about it

Post by Rook Zimbabwe »

I used to own and run the Blue Iguana Cybercafe in Mazatlan Mexico (back at the turn of the millenium!)

I used something like this:
http://www.handycafe.com/en/
(free and better than what I had!)

http://www.freedownloadmanager.org/down ... _software/

This is what I used v2.0
http://www.freedownloadmanager.org/down ... o_66942_p/
FREE!

Lots of free software for this... don't reinvent the wheel... just DRIVE!!!
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
mbecerra
User
User
Posts: 15
Joined: Mon Feb 28, 2005 4:59 am

Re: How to go about it

Post by mbecerra »

srod wrote:Needn't be a problem really.

What you could do is when you display the 'password' window, simply disable the main window so the user is forced to deal with the password window - either entering a password or closing the window etc. It is a matter of personal preference whether you then use a separate event loop to deal with the password window or use the main event loop etc.

This will of course limit the number of windows on display at any one time.

Personally I tend to always disable my 'main window' when throwing up some kind of dialog requesting some immediate information etc. and rarely have more than two windows open at any given time.
True but my problem is more:

Code: Select all

If OpenWindow(0, 100, 200, 195, 260, "Main Window")

  Repeat
    Event = WaitWindowEvent()

    If Event = #PB_Event_CloseWindow  ; If the user has pressed on the close button
  
    ; open password window
    if OpenWindow(0, 100, 200, 195, 260, "Password Window")

      Event = WaitWindowEvent()

     ; if the user enters the correct password
     If OpenWindow(0, 100, 200, 195, 260, "Options Window")

        Event = WaitWindowEvent()

      ; user choses change server ip button
       if Gadject = 1

                   If OpenWindow(0, 100, 200, 195, 260, "Server IP Window")

              Event = WaitWindowEvent()

           Endif

         Endif

       Endif

     Endif

    EndIf

  Until Quit = 1
  
EndIf

End   ; All the opened windows are closed automatically by PureBasic
By the way this isn't valid PureBasic Code and i just wanted to illistrate the problem more clearly. My point is eventually the code will get very messy making maintence very difficult. If you still think this wouldn't be a problem then please let me know at your earliest convenience.

@Rook Zimbabwe: What your saying is i shouldn't bother creating a new internet cafe software because there are plenty of free ones around? If so what do you reccommend my next project should be?

Sincerely,

PureBasic User
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: How to go about it

Post by srod »

Basically, there is no limit to what you can do in this regards, but I see little sense in the kind of progression you have outlined and so there is very little I can add at this stage. The structure inherent in the above pseudo code doesn't strike me as particularly sensible or workable and so my advice is to use something a little more manageable.
I may look like a mule, but I'm not a complete ass.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Re: How to go about it

Post by Trond »

Whenever you use more than one WaitWindowEvent()/WindowEvent() in your program and you're not absolutely sure what you're doing (and sometimes even then), you're doing it wrong.

Here is one way of doing this without causing any problems:

Code: Select all


Enumeration ; Windows
  #WndMain
  #WndCloseRequester
EndEnumeration

Enumeration ; Gadgets
  #BtnMainOtherGadget
  #StrClosePasswordInput
  #BtnCloseOk
EndEnumeration

Global Quit = 0

Procedure ShowPasswordRequester()
  DisableWindow(#WndMain, 1)
  HideWindow(#WndCloseRequester, 0)
EndProcedure

Procedure BtnCloseOk()
  If GetGadgetText(#StrClosePasswordInput) = "123"
    Quit = 1
  Else
    HideWindow(#wndcloserequester, 1)
    DisableWindow(#wndmain, 0)
  EndIf
EndProcedure

; Create main window
OpenWindow(#WndMain, 200, 200, 512, 384, "", #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget | #PB_Window_SizeGadget | #PB_Window_SystemMenu)
ButtonGadget(#BtnMainOtherGadget, 10, 10, 97, 60, "Hi")

; Create requester window
OpenWindow(#WndCloseRequester, 0, 0, 300, 150, "Input password ('123')", #PB_Window_ScreenCentered | #PB_Window_Invisible, WindowID(#WndMain))
StringGadget(#StrClosePasswordInput, 10, 10, 280, 22, "", #PB_String_Password)
ButtonGadget(#BtnCloseOk, 100, 40, 200, 24, "Ok")

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_Gadget
      Select EventGadget()
        Case #BtnMainOtherGadget
          MessageRequester("", "Normal gadget handling")
        Case #btncloseok
          BtnCloseOk()
      EndSelect
    Case #PB_Event_CloseWindow
      ShowPasswordRequester()
  EndSelect
Until Quit = 1
Post Reply