View Full Version : Bible Flash Cards
marcuslee
11-12-2009, 07:41
I wanted to share with everyone what I have been working on. Problems which have been solved with the help of the thinbasic team (at least a couple of other threads recently) are no longer a problem. The program is far from done, but all the features I wanted in it to start out are here. I just need to add more flash cards. As it is, this version has 154 cards.
I don't have the source code on this computer. If anyone would like to see it, just let me know.
Mark :eusadance:
this is beautifull , of course post the code if possible
also i suggest you may add pictures, illustrations in addition to the text
regards
Petr Schreiber
11-12-2009, 14:31
Nice GUI Mark,
I like it, maybe you could just remove WS_MAXIMIZEBOX.
marcuslee
11-12-2009, 17:02
this is beautifull , of course post the code if possible
I will post the code later today.
also i suggest you may add pictures, illustrations in addition to the text
Where do you mean? The actual flash cards?
Now, if you mean the actual flash cards, a picture for each card. That would be a daunting task. I already have 154 cards and I have ideas for thousands more. I also have the idea of having sound with each card, like a reading of the verse. I or someone with a cool voice wouldn't have to physically read most of it because I have this version of the Bible on CD, but it would still be a lot of work.
But, if you mean just dressing up the GUI a little to make it look nicer ... sure.
My brother reminded me of an idea I had a while back. I would like to further design the GUI to look like a stack of idex cards or one index card ... or at least something resembling flash cards. There's a way to design a window from a bmp. I saw the topic a while back. I will first research that.
Mark :D
Michael Clease
11-12-2009, 17:15
Mark look at SAPI in the help ;)
marcuslee
11-12-2009, 17:30
Nice GUI Mark,
I like it, maybe you could just remove WS_MAXIMIZEBOX.
I first searched and couldn't find any reference to WS_MAXIMIZEBOX in my source. It took me a while and some trial and error. But, the culprit was WS_OVERLAPPEDWINDOW. After I took him out and got all the punctuation in the right place, everything looks great. Thanks for the tip.
Mark
marcuslee
11-12-2009, 17:46
Mark look at SAPI in the help ;)
At first I thought you were serious. Then, I saw the ;)
I played around with the module. Computer speech just isn't there yet. Unless ... y'all know something I don't know. About a year ago I tried a computerized singing voice ... that was just as bad even though people were proclaiming how life like it was ... UGH!
When my wife heard Microsoft Sam, she said, "No one will be learning from your flash cards. They will be laughing at the voice."
No, I think I would rather do the extra work and do the voices myself. :P
Mark
Hi Mark
i mean artistic Ornaments like this picture:
http://i48.tinypic.com/2ivmamp.jpg
which can surround the text.
Michael Clease
11-12-2009, 18:15
Ok, if the speech module isnt upto what you want then how about the TBASS module that could be used to play mp3's.
@Zak, using the graphics is not a problem, Mark could use the GDI routines to paste them around his window
marcuslee
11-12-2009, 19:18
Ok, if the speech module isnt upto what you want then how about the TBASS module that could be used to play mp3's.
@Zak, using the graphics is not a problem, Mark could use the GDI routines to paste them around his window
Yeah, both of those things. Although I think I will take a break from adding bells and whistles for a while. When I am ready, I am sure I will need the team's help at some point or another. Thanks for the suggestions.
@Zak - The artistic ornaments you refer to remind me of a time when everything had a little class, especially hand written notes or letters. Kinda like a Victorian style. Now, the question is ... Where can I get my hands on a wax seal?
I wouldn't have thought about putting any artistic ornaments like that in the program. The suggestion certainly adds options. Thanks.
Mark
Lionheart008
11-12-2009, 21:46
hi mark :)
a) have done a short test, nice and good example you've done, I like that ! Do you have used ListviewCheckbox or Treeview features or both combined, anything else ?
b) missing "close" button in your start ui ;)
c) perhaps there is a little mistake in your example focussed Line "337", I have got one error message after my second test. but I am not sure.
good luck for your project !
best regards, frank
marcuslee
12-12-2009, 04:41
a) have done a short test, nice and good example you've done, I like that ! Do you have used ListviewCheckbox or Treeview features or both combined, anything else ?
It is a tree view. The check box is simulated. It is an ImageList.
b) missing "close" button in your start ui ;)
Well, there is the button in the top right corner of the window. Even the new version that I have attached has that. Though it doesn't have a Max or Min button. So, I am not sure what you mean. Do you think I need to put another button inside the dialog for the user?
c) perhaps there is a little mistake in your example focussed Line "337", I have got one error message after my second test. but I am not sure.
Well, I don't know what is on line 337 since the program has changed. I was getting an error message with my Deck() array, but I didn't get it all the time, so I ignored it. Or, I may have solved it. I don't really know.
If you know what you did to get the error message, try it with this version attached. Maybe we will solve it together.
Here's the source code (the support files are included in the attachment):
Uses "UI"
Uses "File"
'---Constant declarations
Begin Const
%ID_Button_01 = %IDOK
%ID_Label_01
%ID_Button_02
%ID_Button_03
%ID_Button_04
%ID_Button_05
%ID_Label_02
%ID_Label_03
%ID_MenuTREE
End Const
Type FlashCard
Front As ASCIIZ * 400
Back As ASCIIZ * 400
Quoted As ASCIIZ * 17
BibleBook As ASCIIZ * 16
Format As ASCIIZ * 19
End Type
'Arrays and Array Assignments
Dim Deck() As DWord
'Global Declarations
Dim hFont1 As DWord Resource = Font_Create("Arial Black", 12)
Dim hFont2 As DWord Resource = Font_Create("Arial Black", 16)
Dim LabelText As String = "Choose a Deck of Flash Cards"
Dim hDlg, hDlg2 As DWord
Dim Result As Byte
Dim CardNumber As Integer = 3
Dim MaxCardNumber As Integer
Dim FileName As String = APP_SourcePath & "FlashCards.DAT"
Dim File As DWord = FILE_Open (FileName, "random" , SIZEOF (FlashCard))
Dim SingleCard As FlashCard
Dim BackUpCard As FlashCard
Dim RandomCard As Integer
Dim WhichSide As Byte = 1
Dim CardCounter As DWord = 1
Dim LastArrayItem As DWord
Dim cPink As Long = RGB(255, 0, 255) '---Color for image transparency
Dim EasyVerse(10) As DWord
Dim HardVerse(10) As DWord
Dim RandomCards(3) As DWord
Dim hTreeItem As DWord
Dim hRoot As DWord
'------------------------------------------------------------------------------
' Program start point
'------------------------------------------------------------------------------
Function TBMain() As Long
'---Create and load image list
Global iList As Long = ImageList_New(ICON, 16, 16, 32)
Global PicA As Long = ImageList_Add MASKED, iList, APP_SourcePath & "Icons\testa.bmp" , cPink
Global PicB As Long = ImageList_Add MASKED, iList, APP_SourcePath & "Icons\testb.bmp" ', cPink
Global PicC As Long = ImageList_Add MASKED, iList, APP_SourcePath & "Icons\testc.bmp" ', cPink
Global PicD As Long = ImageList_Add MASKED, iList, APP_SourcePath & "Icons\testd.bmp" ', cPink
Dialog NEW PIXELS, 0, "New World Translation Flash Cards", -1, -1, 600, 400,%WS_DLGFRAME | _
%DS_CENTER | _
%WS_CAPTION | _
%WS_SYSMENU, %WS_EX_STATICEDGE To hDlg
Dialog NEW PIXELS, 0, "New World Translation Flash Cards", -1, -1, 800, 400, _
%WS_DLGFRAME | _
%DS_CENTER | _
%WS_CAPTION | _
%WS_SYSMENU, %WS_EX_STATICEDGE To hDlg2
'---Set window minimum size
Dialog SET MINSIZE hDlg, 600, 400
Dialog SET MINSIZE hDlg2, 800, 400
Dialog SHOW MODAL hDlg, Call cbDialog
End Function
'------------------------------------------------------------------------------
' Callback procedure for main window
'------------------------------------------------------------------------------
CallBack Function cbDialog() As Long
Select Case CBMSG
Case %WM_INITDIALOG
Control ADD TREEVIEW, CBHNDL, %ID_MenuTREE, "", 100, 50, 400, 285, _
%WS_CHILD | _
%WS_VISIBLE | _
%TVS_HASBUTTONS | _
%TVS_HASLINES | _
%TVS_LINESATROOT | _
%TVS_SHOWSELALWAYS , _
%WS_EX_CLIENTEDGE, Call cbTreeView
TreeView_SetImageList CBHNDL, %ID_MenuTREE, iList
hRoot = TreeView_InsertItem CBHNDL, %ID_MenuTREE, 0, %TVI_FIRST,PicD ,PicD , "Full Verse Flash Cards"
RandomCards(1) = TreeView_InsertItem CBHNDL, %ID_MenuTREE, hRoot, %TVI_LAST,PicC ,PicC , "Decks of Random Cards"
RandomCards(2) = TreeView_InsertItem CBHNDL, %ID_MenuTREE, RandomCards(1), %TVI_LAST,PicA ,PicB , "10 Random Cards (Genesis - Deuteronomy)"
RandomCards(3) = TreeView_InsertItem CBHNDL, %ID_MenuTREE, RandomCards(1), %TVI_LAST,PicA ,PicB , "25 Random Cards (Genesis - Deuteronomy)"
EasyVerse(1) = TreeView_InsertItem CBHNDL, %ID_MenuTREE, hRoot, %TVI_LAST,PicC ,PicC , "Easier Verses"
EasyVerse(2) = TreeView_InsertItem CBHNDL, %ID_MenuTREE, EasyVerse(1), %TVI_LAST, PicA , PicB , "Genesis"
EasyVerse(3) = TreeView_InsertItem CBHNDL, %ID_MenuTREE, EasyVerse(1), %TVI_LAST, PicA , PicB , "Exodus"
EasyVerse(4) = TreeView_InsertItem CBHNDL, %ID_MenuTREE, EasyVerse(1), %TVI_LAST, PicA , PicB , "Leviticus, Numbers, and Deuteronomy"
TreeView_SetExpanded CBHNDL, %ID_MenuTREE, EasyVerse(1), %FALSE
HardVerse(1) = TreeView_InsertItem CBHNDL, %ID_MenuTREE, hRoot, %TVI_LAST, PicC , PicC , "Somewhat Harder Verses"
HardVerse(2) = TreeView_InsertItem CBHNDL, %ID_MenuTREE, HardVerse(1), %TVI_LAST, PicA , PicB , "Genesis"
HardVerse(3) = TreeView_InsertItem CBHNDL, %ID_MenuTREE, HardVerse(1), %TVI_LAST, PicA , PicB , "Exodus"
HardVerse(4) = TreeView_InsertItem CBHNDL, %ID_MenuTREE, HardVerse(1), %TVI_LAST, PicA , PicB , "Leviticus & Numbers"
HardVerse(5) = TreeView_InsertItem CBHNDL, %ID_MenuTREE, HardVerse(1), %TVI_LAST, PicA , PicB , "Deuteronomy"
TreeView_SetExpanded CBHNDL, %ID_MenuTREE, HardVerse(1), %FALSE
TreeView_SetExpanded CBHNDL, %ID_MenuTREE, hRoot, %TRUE
'---Add controls
Control ADD BUTTON, CBHNDL, %ID_Button_01, "OK", 250, 350, 100, 35, %BS_NOTIFY | %WS_TABSTOP, , Call cbButton()
Control ADD LABEL, CBHNDL, %ID_Label_01, LabelText, 0, 10, 600, 40 ,%SS_NOTIFY | %SS_CENTER
'Set the font
Control SEND CBHNDL, %ID_Label_01, %WM_SETFONT, hFont2, 0
Control SEND CBHNDL, %ID_Button_01, %WM_SETFONT, hFont1, 0
End Select
End Function
CallBack Function cbDialog2() As Long
Select Case CBMSG
Case %WM_INITDIALOG
'---Add controls
Control ADD BUTTON, CBHNDL, %ID_Button_05, "Start Over", 95, 300, 150, 35, %BS_NOTIFY | %WS_TABSTOP, Call cbButton2
Control ADD BUTTON, CBHNDL, %ID_Button_02, "Previous Card",250, 300, 150, 35, %BS_NOTIFY | %WS_TABSTOP, Call cbButton2
Control ADD BUTTON, CBHNDL, %ID_Button_03, "Next Card", 405, 300, 150, 35, %BS_NOTIFY | %WS_TABSTOP, Call cbButton2
Control ADD BUTTON, CBHNDL, %ID_Button_04, "Flip Card", 560, 300, 150, 35, %BS_NOTIFY | %WS_TABSTOP, Call cbButton2
Control ADD LABEL, CBHNDL, %ID_Label_01, LabelText, 75, 40, 650, 50 ,%SS_NOTIFY | %SS_CENTER , , Call cbLabel2
Control ADD LABEL, CBHNDL, %ID_Label_02, "", 75, 100, 650, 160,%SS_NOTIFY ,%WS_EX_TRANSPARENT, Call cbLabel2
Control ADD LABEL, CBHNDL, %ID_Label_03, "", 0, 350, 200, 50 ,%SS_NOTIFY | %SS_CENTER , , Call cbLabel2
' Setting the font for labels and textboxes
Control SEND CBHNDL, %ID_Label_01, %WM_SETFONT, hFont2, 0
Control SEND CBHNDL, %ID_Label_02, %WM_SETFONT, hFont1, 0
Control SEND CBHNDL, %ID_Button_02, %WM_SETFONT, hFont1, 0
Control SEND CBHNDL, %ID_Button_03, %WM_SETFONT, hFont1, 0
Control SEND CBHNDL, %ID_Button_04, %WM_SETFONT, hFont1, 0
Control SEND CBHNDL, %ID_Button_05, %WM_SETFONT, hFont1, 0
'Show the first flash card
Call EmptyCard() To Result
Call ShowCard() To Result
Control SET TEXT CBHNDL, %ID_Label_03, "Number of Verses: " & LastArrayItem
Case %WM_DESTROY
ImageList_Kill(iList)
End Select
End Function
CallBack Function cbTreeView() As Long
Local nmTV As NM_TREEVIEW PTR
Select Case CBMSG
Case %WM_NOTIFY
'---Get the pointer of treeview notification structure
nmTV = CBNMHDR
'---Check what happen
Select Case nmTV.hdr.Code
Case %TVN_SELCHANGED
hTreeItem = TreeView_GetSelect(CBHNDL,%ID_MenuTREE)
Select Case hTreeItem
Case hRoot
TreeView_Select CBHNDL,%ID_MenuTREE, 0
TreeView_SetExpanded CBHNDL, %ID_MenuTREE, hRoot, %TRUE
Case EasyVerse(1)
TreeView_Select CBHNDL,%ID_MenuTREE, 0
TreeView_SetExpanded CBHNDL, %ID_MenuTREE, EasyVerse(1), %TRUE
Case HardVerse(1)
TreeView_Select CBHNDL,%ID_MenuTREE, 0
TreeView_SetExpanded CBHNDL, %ID_MenuTREE, HardVerse(1), %TRUE
End Select
End Select
End Select
End Function
CallBack Function cbButton() As Long
If CBMSG = %WM_COMMAND Then
Select Case CBCTLMSG
Case %BN_CLICKED
Select Case CBCTL
Case %ID_Button_01
hTreeItem = TreeView_GetSelect(CBHNDL,%ID_MenuTREE)
If hTreeItem <> 0 Then Call GetContents() To Result
End Select
End Select
Function = %TRUE
End If
End Function
CallBack Function cbButton2() As Long
If CBMSG = %WM_COMMAND Then
Select Case CBCTLMSG
Case %BN_CLICKED
Select Case CBCTL
Case %ID_Button_02
Call PreviousCard() To Result
Case %ID_Button_03
Call NextCard() To Result
Case %ID_Button_04
Call FlipCard() To Result
Case %ID_Button_05
Dialog End hdlg2
LabelText = "Choose a Deck of Flash Cards"
Call TBMain() To Result
End Select
End Select
Function = %TRUE
End If
End Function
CallBack Function cbLabel2() As Long
If CBMSG = %WM_COMMAND Then
Select Case CBCTLMSG
Case %STN_CLICKED
Select Case CBCTL
Case %ID_Label_02
Call FlipCard() To Result
End Select
Case %STN_DBLCLK
Select Case CBCTL
Case %ID_Label_02
Call ShowCard() To Result
End Select
End Select
Function = %TRUE
End If
End Function
Function GetContents() As Long
Local ChosenDeck As DWord
ChosenDeck = TreeView_GetSelect(hdlg,%ID_MenuTREE)
Select Case ChosenDeck
Case RandomCards(2)
ReDim Deck(154)
Deck(1) = 1,2,3,4,5,6,7,8,9,10,11,16,19,20,29,34,35,36, _
40,41,42,59,60,61,62,63,64,65,66,67,68,71,72, _
73,75,76,81,84,87,92,102,103,107,112,118,119,120,123,124, _
128,129,130,132,136,139,140,141,148,149,150,153, _
12,13,14,15,17,18,21,22,23,24,25,26,27,28,30,31,32,33,37,38,39, _
43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,69,70, _
74,77,78,79,80,82,83,85,88,89,90,93,94,95,96,97,98,99,100,86, _
101,104,105,106,108,109,110,111,113,114,115,116,117,121,122,91, _
125,126,127,131,133,134,135,137,138,142,143,144,145,146,147, _
151,152,154
Array Shuffle Deck For 100000
ReDim Preserve Deck(10)
Case RandomCards(3)
ReDim Deck(154)
Deck(1) = 1,2,3,4,5,6,7,8,9,10,11,16,19,20,29,34,35,36, _
40,41,42,59,60,61,62,63,64,65,66,67,68,71,72, _
73,75,76,81,84,87,92,102,103,107,112,118,119,120,123,124, _
128,129,130,132,136,139,140,141,148,149,150,153, _
12,13,14,15,17,18,21,22,23,24,25,26,27,28,30,31,32,33,37,38,39, _
43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,69,70, _
74,77,78,79,80,82,83,85,88,89,90,93,94,95,96,97,98,99,100,86, _
101,104,105,106,108,109,110,111,113,114,115,116,117,121,122,91, _
125,126,127,131,133,134,135,137,138,142,143,144,145,146,147, _
151,152,154
Array Shuffle Deck For 100000
ReDim Preserve Deck(25)
Case EasyVerse(2)'Genesis
ReDim Deck(18)
Deck(1) = 1,2,3,4,5,6,7,8,9,10,11,16,19,20,29,34,35,36
Case EasyVerse(3)'Exodus
ReDim Deck(15)
Deck(1) = 40,41,42,59,60,61,62,63,64,65,66,67,68,71,72
Case EasyVerse(4)'Leviticus, Numbers, and Deuteronomy
ReDim Deck(28)
Deck(1) = 73,75,76,81,84,87,92,102,103,107,112,118,119,120,123,124, _
128,129,130,132,136,139,140,141,148,149,150,153
Case HardVerse(2)'Genesis Non Familiar
ReDim Deck(21)
Deck(1) = 12,13,14,15,17,18,21,22,23,24,25,26,27,28,30,31,32,33,37,38,39
Case HardVerse(3)'Exodus
ReDim Deck(18)
Deck(1) = 43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,69,70
Case HardVerse(4)'Leviticus and Numbers
ReDim Deck(36)
Deck(1) = 74,77,78,79,80,82,83,85,88,89,90,93,94,95,96,97,98,99,100,86, _
101,104,105,106,108,109,110,111,113,114,115,116,117,121,122,91
Case HardVerse(5)'Deuteronomy
ReDim Deck(18)
Deck(1) = 125,126,127,131,133,134,135,137,138,142,143,144,145,146,147, _
151,152,154
End Select
LastArrayItem = UBound(Deck)
Array Shuffle Deck
'This next line may be changed so that hDlg is hidden not ended.
Dialog End hdlg
LabelText = "New World Translation Flash Cards"
Dialog SHOW MODAL hDlg2, Call cbDialog2
Function = %TRUE
End Function
Function NextCard() As Long
'Goes to the next card
If CardCounter = LastArrayItem Then
CardCounter = 1
Else
CardCounter = CardCounter + 1
End If
Call ShowCard() To Result
Function = %TRUE
End Function
Function PreviousCard() As Long
'Goes to the previous card
If CardCounter = 1 Then
CardCounter = LastArrayItem
Else
CardCounter = CardCounter - 1
End If
Call ShowCard() To Result
Function = %TRUE
End Function
Function FlipCard() As Long
If WhichSide = 1 Then
Control SET TEXT hdlg2, %ID_Label_02, Trim$(SingleCard.Back)
WhichSide = 2
Else
Control SET TEXT hdlg2, %ID_Label_02, String$(5, Chr$(32)) & Trim$(SingleCard.Front)
WhichSide = 1
End If
Function = %TRUE
End Function
Function ShowCard() As Long
CardNumber = Deck(CardCounter)
FILE_GetR (File, CardNumber, SingleCard)
Control SET TEXT hdlg2, %ID_Label_02, String$(5, Chr$(32)) & Trim$(SingleCard.Front)
Function=%TRUE
End Function
Function EmptyCard() As Long
'Brings up the first empty flash card
MaxCardNumber = 1
Do
FILE_GetR (File, MaxCardNumber, BackUpCard)
If BackUpCard.Front = "" Then
Exit Do
Else
MaxCardNumber = MaxCardNumber + 1
End If
Loop
MaxCardNumber = MaxCardNumber - 1
Function=%TRUE
End Function
Mark
Lionheart008
12-12-2009, 12:23
hi mark, checked fast you new example, I will try to help. there are still one or two error message(s) for me and try to fix it (for example "array suffle deck" and "Ubound deck" and some other values are not 100 percent perfect, some arrays are not dimensioned). thanks for code but it takes a while, because I am at the afternoon out of house for two days. in order to live real family life and take a breath of sport, nature and love ;)
try to activate per mouse "decks of random cards" and push "ok" so here I get the error message: "variable not dimensioned, array shuffle deck", see my picture below...
Uses "UI"
Uses "File"
'---Constant declarations
Begin Const
%ID_Button_01 = %IDOK
%ID_CLOSE
%ID_Label_01
%ID_Button_02
%ID_Button_03
%ID_Button_04
%ID_Button_05
%ID_Label_02
%ID_Label_03
%ID_MenuTREE
End Const
Type FlashCard
Front As ASCIIZ * 400
Back As ASCIIZ * 400
Quoted As ASCIIZ * 17
BibleBook As ASCIIZ * 16
Format As ASCIIZ * 19
End Type
'Arrays and Array Assignments
Dim Deck() As DWord
'Global Declarations
Dim hFont1 As DWord Resource = Font_Create("Arial Black", 12)
Dim hFont2 As DWord Resource = Font_Create("Arial Black", 16)
Dim LabelText As String = "Choose a Deck of Flash Cards"
Dim hDlg, hDlg2 As DWord
Dim Result As Byte
Dim CardNumber As Integer = 3
Dim MaxCardNumber As Integer
Dim FileName As String = APP_SourcePath & "FlashCards.DAT"
Dim File As DWord = FILE_Open (FileName, "random" , SIZEOF (FlashCard))
Dim SingleCard As FlashCard
Dim BackUpCard As FlashCard
Dim RandomCard As Integer
Dim WhichSide As Byte = 1
Dim CardCounter As DWord = 1
Dim LastArrayItem As DWord
Dim cPink As Long = RGB(255, 0, 255) '---Color for image transparency
Dim EasyVerse(10) As DWord
Dim HardVerse(10) As DWord
Dim RandomCards(3) As DWord
Dim hTreeItem As DWord
Dim hRoot As DWord
'------------------------------------------------------------------------------
' Program start point
'------------------------------------------------------------------------------
Function TBMain() As Long
'---Create and load image list
Global iList As Long = ImageList_New(ICON, 16, 16, 32)
Global PicA As Long = ImageList_Add MASKED, iList, APP_SourcePath & "Icons\testa.bmp" , cPink
Global PicB As Long = ImageList_Add MASKED, iList, APP_SourcePath & "Icons\testb.bmp" ', cPink
Global PicC As Long = ImageList_Add MASKED, iList, APP_SourcePath & "Icons\testc.bmp" ', cPink
Global PicD As Long = ImageList_Add MASKED, iList, APP_SourcePath & "Icons\testd.bmp" ', cPink
Dialog NEW PIXELS, 0, "New World Translation Flash Cards", -1, -1, 600, 400,%WS_DLGFRAME | _
%DS_CENTER | _
%WS_CAPTION | _
%WS_SYSMENU, %WS_EX_STATICEDGE To hDlg
Dialog NEW PIXELS, 0, "New World Translation Flash Cards", -1, -1, 800, 400, _
%WS_DLGFRAME | _
%DS_CENTER | _
%WS_CAPTION | _
%WS_SYSMENU, %WS_EX_STATICEDGE To hDlg2
'---Set window minimum size
Dialog SET MINSIZE hDlg, 600, 400
Dialog SET MINSIZE hDlg2, 800, 400
Dialog SHOW MODAL hDlg, Call cbDialog
End Function
'------------------------------------------------------------------------------
' Callback procedure for main window
'------------------------------------------------------------------------------
CallBack Function cbDialog() As Long
Select Case CBMSG
Case %WM_INITDIALOG
Control ADD TREEVIEW, CBHNDL, %ID_MenuTREE, "", 100, 50, 400, 285, _
%WS_CHILD | _
%WS_VISIBLE | _
%TVS_HASBUTTONS | _
%TVS_HASLINES | _
%TVS_LINESATROOT | _
%TVS_SHOWSELALWAYS , _
%WS_EX_CLIENTEDGE, Call cbTreeView
TreeView_SetImageList CBHNDL, %ID_MenuTREE, iList
hRoot = TreeView_InsertItem CBHNDL, %ID_MenuTREE, 0, %TVI_FIRST,PicD ,PicD , "Full Verse Flash Cards"
RandomCards(1) = TreeView_InsertItem CBHNDL, %ID_MenuTREE, hRoot, %TVI_LAST,PicC ,PicC , "Decks of Random Cards"
RandomCards(2) = TreeView_InsertItem CBHNDL, %ID_MenuTREE, RandomCards(1), %TVI_LAST,PicA ,PicB , "10 Random Cards (Genesis - Deuteronomy)"
RandomCards(3) = TreeView_InsertItem CBHNDL, %ID_MenuTREE, RandomCards(1), %TVI_LAST,PicA ,PicB , "25 Random Cards (Genesis - Deuteronomy)"
EasyVerse(1) = TreeView_InsertItem CBHNDL, %ID_MenuTREE, hRoot, %TVI_LAST,PicC ,PicC , "Easier Verses"
EasyVerse(2) = TreeView_InsertItem CBHNDL, %ID_MenuTREE, EasyVerse(1), %TVI_LAST, PicA , PicB , "Genesis"
EasyVerse(3) = TreeView_InsertItem CBHNDL, %ID_MenuTREE, EasyVerse(1), %TVI_LAST, PicA , PicB , "Exodus"
EasyVerse(4) = TreeView_InsertItem CBHNDL, %ID_MenuTREE, EasyVerse(1), %TVI_LAST, PicA , PicB , "Leviticus, Numbers, and Deuteronomy"
TreeView_SetExpanded CBHNDL, %ID_MenuTREE, EasyVerse(1), %FALSE
HardVerse(1) = TreeView_InsertItem CBHNDL, %ID_MenuTREE, hRoot, %TVI_LAST, PicC , PicC , "Somewhat Harder Verses"
HardVerse(2) = TreeView_InsertItem CBHNDL, %ID_MenuTREE, HardVerse(1), %TVI_LAST, PicA , PicB , "Genesis"
HardVerse(3) = TreeView_InsertItem CBHNDL, %ID_MenuTREE, HardVerse(1), %TVI_LAST, PicA , PicB , "Exodus"
HardVerse(4) = TreeView_InsertItem CBHNDL, %ID_MenuTREE, HardVerse(1), %TVI_LAST, PicA , PicB , "Leviticus & Numbers"
HardVerse(5) = TreeView_InsertItem CBHNDL, %ID_MenuTREE, HardVerse(1), %TVI_LAST, PicA , PicB , "Deuteronomy"
TreeView_SetExpanded CBHNDL, %ID_MenuTREE, HardVerse(1), %FALSE
TreeView_SetExpanded CBHNDL, %ID_MenuTREE, hRoot, %TRUE
'---Add controls
Control ADD BUTTON, CBHNDL, %ID_Button_01, "OK", 270, 350, 100, 35, %BS_NOTIFY | %WS_TABSTOP, , Call cbButton()
Control ADD BUTTON, CBHNDL, %ID_CLOSE, "CLOSE", 170, 350, 100, 35, %BS_NOTIFY | %WS_TABSTOP, , Call closeme()
Control ADD LABEL, CBHNDL, %ID_Label_01, LabelText, 0, 10, 600, 40 ,%SS_NOTIFY | %SS_CENTER
'Set the font
Control SEND CBHNDL, %ID_Label_01, %WM_SETFONT, hFont2, 0
Control SEND CBHNDL, %ID_Button_01, %WM_SETFONT, hFont1, 0
End Select
End Function
CallBack Function cbDialog2() As Long
Select Case CBMSG
Case %WM_INITDIALOG
'---Add controls
Control ADD BUTTON, CBHNDL, %ID_Button_05, "Start Over", 95, 300, 150, 35, %BS_NOTIFY | %WS_TABSTOP, Call cbButton2
Control ADD BUTTON, CBHNDL, %ID_Button_02, "Previous Card",250, 300, 150, 35, %BS_NOTIFY | %WS_TABSTOP, Call cbButton2
Control ADD BUTTON, CBHNDL, %ID_Button_03, "Next Card", 405, 300, 150, 35, %BS_NOTIFY | %WS_TABSTOP, Call cbButton2
Control ADD BUTTON, CBHNDL, %ID_Button_04, "Flip Card", 560, 300, 150, 35, %BS_NOTIFY | %WS_TABSTOP, Call cbButton2
Control ADD LABEL, CBHNDL, %ID_Label_01, LabelText, 75, 40, 650, 50 ,%SS_NOTIFY | %SS_CENTER , , Call cbLabel2
Control ADD LABEL, CBHNDL, %ID_Label_02, "", 75, 100, 650, 160,%SS_NOTIFY ,%WS_EX_TRANSPARENT, Call cbLabel2
Control ADD LABEL, CBHNDL, %ID_Label_03, "", 0, 350, 200, 50 ,%SS_NOTIFY | %SS_CENTER , , Call cbLabel2
' Setting the font for labels and textboxes
Control SEND CBHNDL, %ID_Label_01, %WM_SETFONT, hFont2, 0
Control SEND CBHNDL, %ID_Label_02, %WM_SETFONT, hFont1, 0
Control SEND CBHNDL, %ID_Button_02, %WM_SETFONT, hFont1, 0
Control SEND CBHNDL, %ID_Button_03, %WM_SETFONT, hFont1, 0
Control SEND CBHNDL, %ID_Button_04, %WM_SETFONT, hFont1, 0
Control SEND CBHNDL, %ID_Button_05, %WM_SETFONT, hFont1, 0
'Show the first flash card
Call EmptyCard() To Result
Call ShowCard() To Result
Control SET TEXT CBHNDL, %ID_Label_03, "Number of Verses: " & LastArrayItem
Case %WM_DESTROY
ImageList_Kill(iList)
End Select
End Function
CallBack Function cbTreeView() As Long
Local nmTV As NM_TREEVIEW PTR
Select Case CBMSG
Case %WM_NOTIFY
'---Get the pointer of treeview notification structure
nmTV = CBNMHDR
'---Check what happen
Select Case nmTV.hdr.Code
Case %TVN_SELCHANGED
hTreeItem = TreeView_GetSelect(CBHNDL,%ID_MenuTREE)
Select Case hTreeItem
Case hRoot
TreeView_Select CBHNDL,%ID_MenuTREE, 0
TreeView_SetExpanded CBHNDL, %ID_MenuTREE, hRoot, %TRUE
Case EasyVerse(1)
TreeView_Select CBHNDL,%ID_MenuTREE, 0
TreeView_SetExpanded CBHNDL, %ID_MenuTREE, EasyVerse(1), %TRUE
Case HardVerse(1)
TreeView_Select CBHNDL,%ID_MenuTREE, 0
TreeView_SetExpanded CBHNDL, %ID_MenuTREE, HardVerse(1), %TRUE
End Select
End Select
End Select
End Function
CallBack Function cbButton() As Long
If CBMSG = %WM_COMMAND Then
Select Case CBCTLMSG
Case %BN_CLICKED
Select Case CBCTL
Case %ID_Button_01
hTreeItem = TreeView_GetSelect(CBHNDL,%ID_MenuTREE)
If hTreeItem <> 0 Then Call GetContents() To Result
End Select
End Select
Function = %TRUE
End If
End Function
CallBack Function cbButton2() As Long
If CBMSG = %WM_COMMAND Then
Select Case CBCTLMSG
Case %BN_CLICKED
Select Case CBCTL
Case %ID_Button_02
Call PreviousCard() To Result
Case %ID_Button_03
Call NextCard() To Result
Case %ID_Button_04
Call FlipCard() To Result
Case %ID_Button_05
Dialog End hdlg2
LabelText = "Choose a Deck of Flash Cards"
Call TBMain() To Result
End Select
End Select
Function = %TRUE
End If
End Function
CallBack Function cbLabel2() As Long
If CBMSG = %WM_COMMAND Then
Select Case CBCTLMSG
Case %STN_CLICKED
Select Case CBCTL
Case %ID_Label_02
Call FlipCard() To Result
End Select
Case %STN_DBLCLK
Select Case CBCTL
Case %ID_Label_02
Call ShowCard() To Result
End Select
End Select
Function = %TRUE
End If
End Function
Function GetContents() As Long
Local times As Long
Local ChosenDeck As DWord
ChosenDeck = TreeView_GetSelect(hdlg,%ID_MenuTREE)
Select Case ChosenDeck
Case RandomCards(2)
ReDim Deck(154)
Deck(1) = 1,2,3,4,5,6,7,8,9,10,11,16,19,20,29,34,35,36, _
40,41,42,59,60,61,62,63,64,65,66,67,68,71,72, _
73,75,76,81,84,87,92,102,103,107,112,118,119,120,123,124, _
128,129,130,132,136,139,140,141,148,149,150,153, _
12,13,14,15,17,18,21,22,23,24,25,26,27,28,30,31,32,33,37,38,39, _
43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,69,70, _
74,77,78,79,80,82,83,85,88,89,90,93,94,95,96,97,98,99,100,86, _
101,104,105,106,108,109,110,111,113,114,115,116,117,121,122,91, _
125,126,127,131,133,134,135,137,138,142,143,144,145,146,147, _
151,152,154
Array Shuffle Deck For 100000
ReDim Preserve Deck(10)
Case RandomCards(3)
ReDim Deck(154)
Deck(1) = 1,2,3,4,5,6,7,8,9,10,11,16,19,20,29,34,35,36, _
40,41,42,59,60,61,62,63,64,65,66,67,68,71,72, _
73,75,76,81,84,87,92,102,103,107,112,118,119,120,123,124, _
128,129,130,132,136,139,140,141,148,149,150,153, _
12,13,14,15,17,18,21,22,23,24,25,26,27,28,30,31,32,33,37,38,39, _
43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,69,70, _
74,77,78,79,80,82,83,85,88,89,90,93,94,95,96,97,98,99,100,86, _
101,104,105,106,108,109,110,111,113,114,115,116,117,121,122,91, _
125,126,127,131,133,134,135,137,138,142,143,144,145,146,147, _
151,152,154
Array Shuffle Deck For 100000
ReDim Preserve Deck(25)
Case EasyVerse(2)'Genesis
ReDim Deck(18)
Deck(1) = 1,2,3,4,5,6,7,8,9,10,11,16,19,20,29,34,35,36
Case EasyVerse(3)'Exodus
ReDim Deck(15)
Deck(1) = 40,41,42,59,60,61,62,63,64,65,66,67,68,71,72
Case EasyVerse(4)'Leviticus, Numbers, and Deuteronomy
ReDim Deck(28)
Deck(1) = 73,75,76,81,84,87,92,102,103,107,112,118,119,120,123,124, _
128,129,130,132,136,139,140,141,148,149,150,153
Case HardVerse(2)'Genesis Non Familiar
ReDim Deck(21)
Deck(1) = 12,13,14,15,17,18,21,22,23,24,25,26,27,28,30,31,32,33,37,38,39
Case HardVerse(3)'Exodus
ReDim Deck(18)
Deck(1) = 43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,69,70
Case HardVerse(4)'Leviticus and Numbers
ReDim Deck(36)
Deck(1) = 74,77,78,79,80,82,83,85,88,89,90,93,94,95,96,97,98,99,100,86, _
101,104,105,106,108,109,110,111,113,114,115,116,117,121,122,91
Case HardVerse(5)'Deuteronomy
ReDim Deck(18)
Deck(1) = 125,126,127,131,133,134,135,137,138,142,143,144,145,146,147, _
151,152,154
End Select
'-xxx ---------------------------------------------------------------------------
'-- frank: Local deck(154) As Long
'-- frank: LastArrayItem = UBound(Deck(154))
'-- Array Shuffle Deck(1) For 100000 times
LastArrayItem = UBound(Deck)
Array Shuffle Deck
'Array Shuffle ArrayVariable[([StartIndex])] [For nTimes]
'-xxx ---------------------------------------------------------------------------
'This next line may be changed so that hDlg is hidden not ended.
Dialog End hdlg
LabelText = "New World Translation Flash Cards"
Dialog SHOW MODAL hDlg2, Call cbDialog2
Function = %TRUE
End Function
Function NextCard() As Long
'Goes to the next card
If CardCounter = LastArrayItem Then
CardCounter = 1
Else
CardCounter = CardCounter + 1
End If
Call ShowCard() To Result
Function = %TRUE
End Function
Function PreviousCard() As Long
'Goes to the previous card
If CardCounter = 1 Then
CardCounter = LastArrayItem
Else
CardCounter = CardCounter - 1
End If
Call ShowCard() To Result
Function = %TRUE
End Function
Function FlipCard() As Long
If WhichSide = 1 Then
Control SET TEXT hdlg2, %ID_Label_02, Trim$(SingleCard.Back)
WhichSide = 2
Else
Control SET TEXT hdlg2, %ID_Label_02, String$(5, Chr$(32)) & Trim$(SingleCard.Front)
WhichSide = 1
End If
Function = %TRUE
End Function
Function ShowCard() As Long
CardNumber = Deck(CardCounter)
FILE_GetR (File, CardNumber, SingleCard)
Control SET TEXT hdlg2, %ID_Label_02, String$(5, Chr$(32)) & Trim$(SingleCard.Front)
Function=%TRUE
End Function
Function EmptyCard() As Long
'Brings up the first empty flash card
MaxCardNumber = 1
Do
FILE_GetR (File, MaxCardNumber, BackUpCard)
If BackUpCard.Front = "" Then
Exit Do
Else
MaxCardNumber = MaxCardNumber + 1
End If
Loop
MaxCardNumber = MaxCardNumber - 1
Function=%TRUE
End Function
CallBack Function closeme()
Select Case CBMSG
Case %WM_COMMAND
Select Case CBCTL
Case %ID_CLOSE
If CBCTLMSG = %BN_CLICKED Then
Dialog End CBHNDL
End If
End Select
End Select
End Function
I am not quite sure, but there will be some more fixes to do ;) more to come, have a good day, frank (out now !)
Michael Hartlef
12-12-2009, 16:08
Franck, when you attach screenshots, can you make them in a little bigger screensolution? I can not read the small stuff.
marcuslee
12-12-2009, 16:55
try to activate per mouse "decks of random cards" and push "ok" so here I get the error message: "variable not dimensioned, array shuffle deck", see my picture below...
Thank You!
That told me exactly where the problem was. That item in the treeview isn't suppose to be selectable. Just like the "Easier Verses" and the "Somewhat Harder Verses." So, I added this code to the callback function of the tree view:
Case RandomCards(1)
TreeView_Select CBHNDL,%ID_MenuTREE, 0
TreeView_SetExpanded CBHNDL, %ID_MenuTREE, RandomCards(1), %TRUE
The Deck() array wasn't dimensioned because I hadn't told the computer what to do with RandomCards(1), that first line of the Random Deck of Cards section.
It probably would have taken me a long time to find that error because it is one of those things that I wouldn't have been looking for. Thank you.
I also noticed that you added a CLOSE button, but I didn't see a closeme() callback function. Plus, I would probably just put it in the cbButton() callback function, anyway. Thanks for the suggestion, though.
Mark
:whacky34: