From: Mark M. <mie...@gm...> - 2012-12-06 00:25:01
|
On Wed, Dec 5, 2012 at 2:03 PM, Mark Miesfeld <mie...@gm...> wrote: > I can help you with this, give me a little bit of time to put something > together. > > Walter, Here's a simple start of a program. I used the '-' line continuation character so that lines won't wrap. I'm sure you will have some questions but I'm not sure how much fooling around with ooDialog you have done. So, I'm not sure what parts might be confusing. Just take a look at it and ask any questions you may have. The basic logic is straight forward. The dialog opens up with the German word Vater displayed and an edit control below that the user can type in. When the user hits enter or clicks on Ok, the dialog puts the correct English word in the edit control and displays a line of text with your "Press F2 .." The dialog catches the F2 or F3 key press and updates the state of the dialog. When the user cancels the dialog, the number of correct words is displayed. As a user interface goes, it is okay, but simplistic. Improvements can be made depending on exactly want. /* Simple Vocabulary Dialog */ dlg = .SimpleDialog~new dlg~execute("SHOWTOP", IDI_DLG_OOREXX) ::requires "ooDialog.cls" ::class 'SimpleDialog' subclass UserDialog ::method init expose germanWords englishWords currentIndex lastIndex - correct displayed forward class (super) continue self~createCenter(150, 110, "Vocabularey Quiz", - "CENTER", , "Tahoma", 10) germanWords = .array~of('Vater', 'Matter', 'Gutan', - 'Tag') englishWords = .array~of('Father', 'Mother', 'Good', - 'Day') currentIndex = 0 lastIndex = 4 correct = 0 displayed = 0 ::method defineDialog self~createStaticText(-1, 10, 13, 28, 12, - "LEFT CENTERIMAGE", 'German:') self~createStaticText(1003, 44, 13, 72, 12, - "LEFT CENTERIMAGE", '') self~createStaticText(-1, 10, 35, 28, 12, - "LEFT CENTERIMAGE", 'English:') text = "Press F2 if you knew it, F3 if you didn't." self~createEdit(1005, 44, 35, 72, 12, "AUTOSCROLLH") self~createStaticText(1007, 10, 62, 135, 12, - "LEFT CENTERIMAGE HIDDEN", text) self~createPushButton(IDOK, 34, 86, 50, 14, "DEFAULT", - "Ok") self~createPushButton(IDCANCEL, 89, 86, 50, 14, , "Quit") ::method initDialog expose stGerman edit stInstructions stGerman = self~newStatic(1003) edit = self~newEdit(1005) stInstructions = self~newStatic(1007) self~newWord self~connectKeyPress(onF2, .VK~F2, 'NONE') self~connectKeyPress(onF3, .VK~F3, 'NONE') ::method newWord expose germanWords currentIndex lastIndex stGerman - stInstructions edit displayed currentIndex += 1 if currentIndex > lastIndex then currentIndex = 1 stInstructions~hide stGerman~setText(germanWords[currentIndex]) displayed += 1 edit~setText('') edit~enable ::method onF2 unguarded expose correct correct += 1 self~newWord ::method onF3 unguarded self~newWord ::method ok unguarded expose edit stInstructions currentIndex englishWords stInstructions~show edit~setText(englishWords[currentIndex]) edit~disable ::method initAutoDetection self~noAutoDetection ::method cancel expose correct displayed wd1 = 'words' if correct == 1 then wd1 = 'word' wd2 = 'words' if displayed == 1 then wd2 = 'word' msg = 'You got' correct wd1 'out of' displayed wd2 - 'correct.' title = 'Vocabulary Quiz Results' j = MessageDialog(msg, self~hwnd, title) return self~cancel:super -- Mark Miesfeld |