Page 1 of 1
How to go about it
Posted: Mon Jul 26, 2010 7:30 pm
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
Re: How to go about it
Posted: Mon Jul 26, 2010 7:56 pm
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.
Re: How to go about it
Posted: Mon Jul 26, 2010 9:09 pm
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!!!
Re: How to go about it
Posted: Mon Jul 26, 2010 9:16 pm
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
Re: How to go about it
Posted: Mon Jul 26, 2010 10:51 pm
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.
Re: How to go about it
Posted: Sat Aug 07, 2010 2:20 pm
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