This Is the first time I have attempted to make a program with TWO Dialog boxes.
I have created a working dialog box using the same method before, that works (see here).
when the user clicks the "delete all" checkbox, the other controls are supposed to Enable/Disable respectively.
However, it does not seem that the messages are getting handled properly(?)
When the Child-dialog box is closed, the message "Invalid handle"(look up the window error #) is returned,
I know that this error occurs in the dialog box procedure, but not where.
Also, I have noticed a memory leak while the Child-dialog box window is being moved, could this be related to the error?
Synchronize.bas:
Code: Select all
#Include Once "windows.bi"
#Include Once "win/commctrl.bi"
#Include Once "win/commdlg.bi"
#Include Once "win/shellapi.bi"
InitCommonControls()
#Include "Synchronize.bi"
#Include "Words.bi"
'----------Dim application variables.
Dim Shared As Integer chooseradio, wordnumber = 1, minecraftexist(1), StepProcess /'Represents the step the copy process is on.'/
Dim Shared As String wordname, param, param2, param3, wordlist, source, destination, force, version
Dim Shared As ZString*256 wordbuff, bttntext
Dim Shared As WIN32_FIND_DATA fhand
Declare Function DelPCDialog(ByVal hWin As HWND, ByVal uMsg As UINT, ByVal wParam As WPARAM, ByVal lParam As LPARAM) As Integer
wordname = " "
version = "1.5.1"
force = " /d"
Function WndProc(ByVal hWin As HWND,ByVal uMsg As UINT,ByVal wParam As WPARAM,ByVal lParam As LPARAM) As Integer
Select Case uMsg
Case WM_INITDIALOG
hWnd = hWin
'
Case WM_COMMAND
Select Case HiWord(wParam)
Case BN_CLICKED,1
Select Case LoWord(wParam)
'----------Menu.
Case IDM_OPEN_COMP
ShellExecute(hWin,"explore",Environ("appdata") + "\.minecraft","","",SW_SHOWNORMAL)
'----------Open computer
Case IDM_OPEN_DEVICE
ShellExecute(hWin,"explore",CurDir + "\.minecraft","","",SW_SHOWNORMAL)
'----------Open device.
Case IDM_HELP_ABOUT
Select Case fb_message(" About", " Version is: " + version + Chr(10,13) + " Synchronize by Joshua Wiker" + Chr(10,13) + " Website: https://sites.google.com/site/joshwiker14mine/home/minecraft" + Chr(10,13) + "I am not in any way, responsible for corrupted or missing worlds,stats,acheivements, or mods." , MB_OK)
Case IDOK
'
End Select
'
Case IDM_CHECK_UPDATE
'----------Display version and open homepage.
Select Case fb_message(" Just so you know...", " Version is: " + version, MB_OKCANCEL)
Case IDOK
ShellExecute(hWin,"open","https://sites.google.com/site/joshwiker14mine/home/minecraft","","",SW_SHOWNORMAL)
Case IDCANCEL
'
End Select
Case IDM_Chelp
Select Case fb_message(" Control Help","About the groups:" + Chr(10,13,10,13) + "Which way?: Choose the place you want to copy to." + Chr(10,13) + "Worlds: Select the worlds you want to copy." + Chr(10,13) + "Stats: Select stats and acheivments that you want to copy." + Chr(10,13) + "Extras: Extra options to fine tune copying." + Chr(10,13) + " Copy bin folders: Copies minecraft bin folder.(mincraft.jar,etc.)" + Chr(10,13) + " Copy resources: Copies minecrafts sounds." + Chr(10,13) + " Copy screenshots: Copies game screenshots." + Chr(10,13) + " Copy texturepacks: Copies texturepacks folder." + Chr(10,13) + " Copy options: Copies minecraft options.(settings,servers. Plus everything else)" + Chr(10,13) + " Overwrite: Forces copying the selected options.(Replaces files)" + Chr(10,13,10,13) + "Useful for keeping your friends mods:" + Chr(10,13) + " Backup button: Copies minecraft.jar to ""\backup"" folder." + Chr(10,13) + " Restore button: Copies minecraft.jar from the ""backup"" folder to the computer." + Chr(10,13,10,13) + "NOTE: Worlds and Stats Fields may have multiple names in them," +Chr(10,13) + "but the names must be separated by commas.(e.g. name1,name2,name3)",MB_OK)
Case IDOK
'
End Select
'
'----------Other controls.
Case tocomputer
enablecon(hWin)
source = "%cd%"
destination = "%appdata%"
'
Case todevice
enablecon(hWin)
source = "%appdata%"
destination = "%cd%"
'
Case wrldchckbx
Select Case SendMessage(GetDlgItem(hWin,wrldchckbx),BM_GETCHECK,0,0)
Case BST_CHECKED
'----------User checks the checkbox, disable worldslist.
EnableWindow(GetDlgItem(hWin,worldslist),FALSE)
'
Case BST_UNCHECKED
'----------User unchecks the checkbox, enable worldslist.
EnableWindow(GetDlgItem(hWin,worldslist),TRUE)
'
End Select
'
Case statschckbx
Select Case SendMessage(GetDlgItem(hWin,statschckbx),BM_GETCHECK,0,0)
Case BST_CHECKED
'----------User checks the stats checkbox, disable usrnm.
EnableWindow(GetDlgItem(hWin,usrnm),FALSE)
Case BST_UNCHECKED
'----------User unchecks the stats chkbox, enable usrnm.
EnableWindow(GetDlgItem(hWin,usrnm),TRUE)
End Select
'
Case backupbttn
Select Case fb_message(" Are you sure?", " Are you sure you want to backup minecraft.jar from the computer?" + Chr(10,13) + " This will overwrite the current backup.",MB_OKCANCEL)
Case IDOK
bttntext = "Backing up..."
SetDlgItemText(hWin,backupbttn,@bttntext)
EnableWindow(hWin,FALSE)
MkDir CurDir + "\backup"
If FileCopy(Environ("appdata") + "\.minecraft\bin\minecraft.jar",CurDir + "\backup\minecraft.jar") = 1 Then 'Backup minecraft.jar
bttntext = "Error"
Else
bttntext = "Backup minecraft.jar"
EndIf
SetDlgItemText(hWin,backupbttn,@bttntext)
EnableWindow(hWin,TRUE)
Case IDCANCEL
'
End Select
'
Case restorebttn
Select Case fb_message(" Are you sure?", " Are you sure you want to Restore minecraft.jar to the computer?" + Chr(10,13) + " This will overwrite the current minecraft.jar.",MB_OKCANCEL)
Case IDOK
bttntext = "Restoring..."
SetDlgItemText(hWin,restorebttn,@bttntext)
EnableWindow(hWin,FALSE)
If FileCopy(CurDir + "\backup\minecraft.jar",Environ("appdata") + "\.minecraft\bin\minecraft.jar") = 1 Then
bttntext = "Error"
Else
bttntext = "Restore minecraft.jar"
EndIf
SetDlgItemText(hWin,restorebttn,@bttntext)
EnableWindow(hWin,TRUE)
Case IDCANCEL
'
End Select
'
Case delpc
AllocConsole
Print GetLastError()
Sleep
FreeConsole
DialogBoxParam(GetModuleHandle(NULL), Cast(ZString Ptr,DelPCDialogBox), NULL, @DelPCDialog, NULL)
AllocConsole
Print GetLastError()
Sleep
FreeConsole
'
Case sync_bttn
'----------Set the force variable.
Select Case SendMessage(GetDlgItem(hWin,forcechckbx),BM_GETCHECK,0,0)
Case BST_CHECKED
force = ""
Case BST_UNCHECKED
'----------/d is xcopy's option to copy the source file if it newer than its destination.
force = " /d"
End Select
'----------Disable the window.
EnableWindow(hWin,FALSE)
'----------Open a console window.
AllocConsole
Shell("color f0")
bttntext = "Synchronize"
SetConsoleTitle(@bttntext)
'----------Create exclude file for xcopy.exe.
Open "exclude.txt" For Output As #1
Print #1, "\bin"
Print #1, "\resources"
Print #1, "\texturepacks"
Print #1, "\screenshots"
Print #1, "\saves"
Print #1, "\stats"
Print #1, "stats_*_unsent.dat"
Close #1
'----------Check if optionschckbx is checked.
Select Case SendMessage(GetDlgItem(hWin,optionschckbx),BM_GETCHECK,0,0)
Case BST_CHECKED
'----------Copy minecraft settings.
Shell ("xcopy.exe """ + source + "\.minecraft"" """ + destination + "\.minecraft\"" /exclude:exclude.txt /e /i /y" + force + "")
End Select
'----------Check if binchckbx is checked.
Select Case SendMessage(GetDlgItem(hWin,binchckbx),BM_GETCHECK,0,0)
Case BST_CHECKED
'----------Copy Minecraft Binaries.
Shell ("xcopy.exe """ + source + "\.minecraft\bin"" """ + destination + "\.minecraft\bin\"" /e /i /y" + force + "")
End Select
'----------Check if reschckbx is checked.
Select Case SendMessage(GetDlgItem(hwin,reschckbx),BM_GETCHECK,0,0)
Case BST_CHECKED
'----------Copy minecraft resources.
Shell ("xcopy.exe """ + source + "\.minecraft\resources"" """ + destination + "\.minecraft\resources\"" /e /i /y" + force + "")
End Select
'----------Check if the texchckbx is checked.
Select Case SendMessage(GetDlgItem(hwin,texchckbx),BM_GETCHECK,0,0)
Case BST_CHECKED
'----------Copy minecraft texturepacks folder.
Shell ("xcopy.exe """ + source + "\.minecraft\texturepacks"" """ + destination + "\.minecraft\texturepacks\"" /e /i /y" + force + "")
End Select
'----------Copy Screenshots.
Select Case SendMessage(GetDlgItem(hWin,shotchckbx),BM_GETCHECK,0,0)
Case BST_CHECKED
Shell ("xcopy.exe """ + source + "\.minecraft\screenshots"" """ + destination + "\.minecraft\screenshots\"" /e /i /y" + force + "")
End Select
'----------Prepare to copy worlds.
Select Case SendMessage(GetDlgItem(hWin,wrldchckbx),BM_GETCHECK,0,0)
Case BST_CHECKED
'----------The user marked the checkbox, copy all worlds.
Shell ("xcopy.exe """ + source + "\.minecraft\saves"" """ + destination + "\.minecraft\saves\"" /e /i /y" + force + "")
Case BST_UNCHECKED
GetDlgItemText(hWin,worldslist,@wordbuff,SizeOf(wordbuff))
If wordbuff <> "" Then
'----------Copy worldnames in textbox to variable.
wordlist = wordbuff
'----------Seperate wordnames and copy appropriately.
wordname = Trim(words(wordlist,wordnumber,","))
Do Until wordname = ""
'----------Sets parameter string.
param = "xcopy.exe """ + source + "\.minecraft\saves\" + wordname + """ """ + destination + "\.minecraft\saves\" + wordname + """ /s /i /y" + force + ""
'----------Copies world.
Shell(param)
'----------Get next world.
wordnumber += 1
wordname = Trim(words(wordlist,wordnumber,","))
Loop
EndIf
End Select
'----------Prepare to copy stats.
Select Case SendMessage(GetDlgItem(hWin,statschckbx),BM_GETCHECK,0,0)
Case BST_CHECKED
'----------The user marked the checkbox, copy all stats.
Shell ("xcopy.exe """ + source + "\.minecraft\stats"" """ + destination + "\.minecraft\stats\"" /e /i /y" + force + "")
Shell ("xcopy.exe """ + source + "\.minecraft\stats_*_unsent.dat"" """ + destination + "\.minecraft"" /e /i /y" + force + "")
Case BST_UNCHECKED
GetDlgItemText(hWin,usrnm,@wordbuff,SizeOf(wordbuff))
If wordbuff <> "" Then
'----------Copy stats in textbox to variable.
wordlist = wordbuff
'----------Fix for bug, if worldlist is read and copied, wordnumber is too high.
wordnumber = 1
'----------Seperate wordnames and copy appropriately.
wordname = Trim(words(wordlist,wordnumber,","))
Do Until wordname = ""
'----------Set parameter strings.
'----------xcopy.exe will use the source name by default.
Shell("xcopy.exe """ + source + "\.minecraft\stats\stats__unsent.dat"" """ + destination + "\.minecraft\stats\"" /s /y" + force + "")
Shell("xcopy.exe """ + source + "\.minecraft\stats\stats__unsent.old"" """ + destination + "\.minecraft\stats\"" /s /y" + force + "")
Shell ("xcopy.exe """ + source + "\.minecraft\stats\stats_player_unsent.dat"" """ + destination + "\.minecraft\stats\"" /s /y" + force + "")
Shell ("xcopy.exe """ + source + "\.minecraft\stats\stats_player_unsent.old"" """ + destination + "\.minecraft\stats\"" /s /y" + force + "")
param = "xcopy.exe """ + source + "\.minecraft\stats\stats_" + wordname + "_unsent.dat"" """ + destination + "\.minecraft\stats\"" /s /y" + force + ""
param2 = "xcopy.exe """ + source + "\.minecraft\stats\stats_" + wordname + "_unsent.old"" """ + destination + "\.minecraft\stats\"" /s /y" + force + ""
param3 = "xcopy.exe """ + source + "\.minecraft\stats_" + wordname + "_unsent.dat"" """ + destination + "\.minecraft"" /s /y" + force + ""
'----------Copies stats.
Shell(param)
Shell(param2)
Shell(param3)
'----------Get next stat name.
wordnumber += 1
wordname = Trim(words(wordlist,wordnumber,","))
Loop
EndIf
End Select
'----------Delete exclude file for xcopy.exe.
Kill "exclude.txt"
FreeConsole
EnableWindow(hWin,TRUE)
SetForegroundWindow(hWnd)
End Select
'
End Select
'
Case WM_SIZE
'
Case WM_CLOSE
FindClose(@fhand)
DestroyWindow(hWin)
'
Case WM_DESTROY
PostQuitMessage(NULL)
'
Case Else
Return DefWindowProc(hWin,uMsg,wParam,lParam)
'
End Select
'----------Placed down here to avoid serious memory leak.
'----------Detect .minecraft folders.
'----------FindFirstFile returns handle if successful, returns -1 if not.
minecraftexist(0) = Cast(Integer,FindFirstFile(Environ("appdata") + "\.minecraft",@fhand))
minecraftexist(1) = Cast(Integer,FindFirstFile(CurDir + "\.minecraft",@fhand))
If minecraftexist(0) < 0 Then
EnableMenuItem(GetMenu(hWin),IDM_OPEN_COMP,MF_GRAYED)
EnableWindow(GetDlgItem(hWin,DelPC),FALSE)
EnableWindow(GetDlgItem(hWin,todevice),FALSE)
EnableWindow(GetDlgItem(hWin,backupbttn),FALSE)
Else
EnableMenuItem(GetMenu(hWin),IDM_OPEN_COMP,MF_ENABLED)
EnableWindow(GetDlgItem(hWin,delpc),TRUE)
EnableWindow(GetDlgItem(hWin,todevice),TRUE)
EnableWindow(GetDlgItem(hWin,backupbttn),TRUE)
EndIf
If minecraftexist(1) < 0 Then
EnableMenuItem(GetMenu(hWin),IDM_OPEN_DEVICE,MF_GRAYED)
EnableWindow(GetDlgItem(hWin,tocomputer),FALSE)
Else
EnableMenuItem(GetMenu(hWin),IDM_OPEN_DEVICE,MF_ENABLED)
EnableWindow(GetDlgItem(hWin,tocomputer),TRUE)
EndIf
'----------Notify user that synchronize can't do anything.
If (minecraftexist(0) < 1) And (minecraftexist(1) < 1) Then
Select Case fb_message(" Umm..."," There is no .minecraft on the computer or on the device." + Chr(10,13) + " Synchronize can not copy something that isn't there!" + Chr(10,13) + " Press OK to quit.",MB_OK)
Case IDOK
End -1
'
End Select
EndIf
'-----------Detect backup file. (\backup\minecraft.jar)
If Cast(Integer, FindFirstFile(CurDir + "\backup\minecraft.jar", @fhand)) < 0 Then
EnableWindow(GetDlgItem(hWin, restorebttn), FALSE)
Else
EnableWindow(GetDlgItem(hWin, restorebttn), TRUE)
EndIf
'----------Detect that minecraft.jar is in \.minecraft\bin
If Cast(Integer, FindFirstFile(Environ("appdata") + "\.minecraft\bin\minecraft.jar", @fhand)) < 0 Then
'--------------------------------------------------This line has problems, causes memory leak when file doesn't exist.
EnableWindow(GetDlgItem(hWin,backupbttn),FALSE)
Else
EnableWindow(GetDlgItem(hWin,backupbttn),TRUE)
EndIf
Return 0
'
End Function
Function WinMain(ByVal hInst As HINSTANCE,ByVal hPrevInst As HINSTANCE,ByVal CmdLine As ZString Ptr,ByVal CmdShow As Integer) As Integer
Dim wc As WNDCLASSEX
Dim msg As MSG
'----------Single Instance
hWnd = FindWindow(@ClassName,NULL)
If hWnd Then
ShowWindow(hWnd,SW_RESTORE)
SetForegroundWindow(hWnd)
Return 0
EndIf
'----------Setup and register class for dialog
wc.cbSize = SizeOf(WNDCLASSEX)
wc.style = CS_HREDRAW Or CS_VREDRAW
wc.lpfnWndProc = @WndProc
wc.cbClsExtra = 0
wc.cbWndExtra = DLGWINDOWEXTRA
wc.hInstance = hInst
wc.hbrBackground = Cast(HBRUSH,COLOR_BTNFACE+1)
'wc.lpszMenuName = Cast(ZString Ptr,IDM_MENU)
wc.lpszClassName = @ClassName
wc.hCursor = LoadCursor(NULL,IDC_ARROW)
RegisterClassEx(@wc)
'----------Create and show the dialog
CreateDialogParam(hInstance,Cast(ZString Ptr,IDD_DIALOG),NULL,@WndProc,NULL)
ShowWindow(hWnd,SW_SHOWNORMAL)
UpdateWindow(hWnd)
'----------Message loop
Do While GetMessage(@msg,NULL,0,0)
TranslateMessage(@msg)
DispatchMessage(@msg)
Loop
Return msg.wParam
End Function
Function DelPCDialog(ByVal subhWin As HWND, ByVal uMsg As UINT, ByVal wParam As WPARAM, ByVal lParam As LPARAM) As Integer
Dim As Long id, Event
Select Case uMsg
Case WM_INITDIALOG
SendMessage(GetDlgItem(subhwin, DelAllchckbx), BM_SETCHECK, BST_CHECKED,0)
'
Case WM_CLOSE
EndDialog(subhWin, 0)
'
Case WM_COMMAND
id = LoWord(wParam)
Event = HiWord(wParam)
Select Case id
Case DelAllchckbx
Dim As BOOLEAN EnableBool
Select Case SendMessage(GetDlgItem(subhWin, DelAllchckbx),BM_GETCHECK,0,0)
Case BST_CHECKED
EnableBool = FALSE
'
Case BST_UNCHECKED
EnableBool = TRUE
'
End Select
EnableWindow(GetDlgItem(subhWin,Worlds2chckbx),EnableBool)
EnableWindow(GetDlgItem(subhWin,AllWorlds2chckbx),EnableBool)
EnableWindow(GetDlgItem(subhWin,WorldsTxt),EnableBool)
EnableWindow(GetDlgItem(subhWin,Stats2chckbx),EnableBool)
EnableWindow(GetDlgItem(subhWin,AllStats2chckbx),EnableBool)
EnableWindow(GetDlgItem(subhWin,StatsTxt),EnableBool)
EnableWindow(GetDlgItem(subhWin,Lastlogchckbx),EnableBool)
EnableWindow(GetDlgItem(subhWin,Bin2chckbx),EnableBool)
EnableWindow(GetDlgItem(subhWin,Options2chckbx),EnableBool)
EnableWindow(GetDlgItem(subhWin,Shots2chckbx),EnableBool)
EnableWindow(GetDlgItem(subhWin,Worlds2chckbx),EnableBool)
EnableWindow(GetDlgItem(subhWin,Packschckbx),EnableBool)
'
Case Delbttn
'----------Confirmation.
Select Case fb_message(" Confirmation", " Are you sure you want to delete these parts from the computer?", MB_YESNO)
Case IDYES
'----------Disable the window.
EnableWindow(getparent(subhWin),FALSE)
EnableWindow(subhWin,FALSE)
AllocConsole
'----------Remove files and folders.
'Shell("color f0")
'Shell("del ""%appdata%\.minecraft"" /f /s /q")
'Shell("rd ""%appdata%\.minecraft"" /s /q")
FreeConsole
EnableWindow(GetParent(subhWin),TRUE)
EnableWindow(subhWin,TRUE)
Case IDNO
'
End Select
'
End Select
'
Case Else
Return FALSE
'
End Select
Return TRUE
End Function
'----------Program start
hInstance = GetModuleHandle(NULL)
CommandLine = GetCommandLine
InitCommonControls
WinMain(hInstance,NULL,CommandLine,SW_SHOWDEFAULT)
ExitProcess(0)
Code: Select all
#Define IDD_DIALOG 1000
'Define groups.
#Define direction_grp 1001
#Define world_grp 1004
#Define stats_grp 1012
#Define misc_grp 1015
'Define static texts.
#Define worldtext 1005
'#Define maintext 1009
#Define stattext 1014
'Define radio buttons.
#Define tocomputer 1002
#Define todevice 1003
'Define textedit controls.
#Define worldslist 1007
#Define usrnm 1010
'Define checkboxes.
#Define wrldchckbx 1006
#Define statschckbx 1011
#Define shotchckbx 1016
#Define Binchckbx 1017
#Define forcechckbx 1018
#Define optionschckbx 1019
#Define texchckbx 1009
#Define reschckbx 1020
'Define buttons.
#Define sync_bttn 1008
#Define delpc 1013
#Define backupbttn 1021
#Define restorebttn 1022
'Define menu items.
#Define IDM_MENU 10000
#Define IDM_OPEN_COMP 10001
#Define IDM_OPEN_DEVICE 10002
#Define IDM_HELP_ABOUT 10003
#Define IDM_CHECK_UPDATE 10004
#Define IDM_Chelp 10005
'Define items in second dialog box.
#Define DelPCDialogBox 1100
'Define Checkboxes.
#Define DelAllchckbx 1102
#Define Worlds2chckbx 1105
#Define AllWorlds2chckbx 1114
#Define Stats2chckbx 1105
#Define AllStats2chckbx 1115
#Define LastLogchckbx 1103
#Define Bin2chckbx 1106
#Define Options2chckbx 1111
#Define Shots2chckbx 1112
#Define Packschckbx 1113
'Define Buttons.
#Define Delbttn 1116
'Define text controls.
#Define WorldsTxt 1109
#Define StatsTxt 1110
Dim Shared hInstance As HMODULE
Dim Shared As ZString Ptr CommandLine
Dim Shared hWnd As HWND
Const ClassName = "SYNCCLASS"
Const AppName = "Synchronize"
#Include Once "file.bi"
Declare Sub enablecon(windowhand As HWND)
Sub enablecon(windowhand As HWND)
'----------User chooses the direction to copy, enable the other controls.
EnableWindow(GetDlgItem(windowhand,sync_bttn),TRUE)
EnableWindow(GetDlgItem(windowhand,wrldchckbx),TRUE)
EnableWindow(GetDlgItem(windowhand,statschckbx),TRUE)
EnableWindow(GetDlgItem(windowhand,shotchckbx),TRUE)
EnableWindow(GetDlgItem(windowhand,binchckbx),TRUE)
EnableWindow(GetDlgItem(windowhand,optionschckbx),TRUE)
EnableWindow(GetDlgItem(windowhand,forcechckbx),TRUE)
EnableWindow(GetDlgItem(windowhand,texchckbx),TRUE)
EnableWindow(GetDlgItem(windowhand,reschckbx),TRUE)
EnableWindow(GetDlgItem(windowhand,worldslist),TRUE)
EnableWindow(GetDlgItem(windowhand,usrnm),TRUE)
EnableWindow(GetDlgItem(windowhand,worldtext),TRUE)
EnableWindow(GetDlgItem(windowhand,stattext),TRUE)
EnableWindow(GetDlgItem(windowhand,delPC),TRUE)
End Sub
Declare Function fb_message(title As String ,text As String,style As Integer) As Integer
Function fb_message(title As String ,text As String,style As Integer) As Integer
If title = "" Then
Return MessageBox(NULL,text," ",style)
Else
Return MessageBox(NULL,text,title,style)
End If
End Function
Code: Select all
#define MANIFEST 24
#define IDC_CHK6 1113
#define Main 1000
#define worldtext 1005
#define tocomputer 1002
#define todevice 1003
#define worldslist 1007
#define wrldchckbx 1006
#define usrnm 1010
#define statschckbx 1011
#define Binchckbx 1017
#define Reschckbx 1020
#define shotchckbx 1016
#define texchckbx 1009
#define optionschckbx 1019
#define forcechckbx 1018
#define syncbttn 1008
#define DelPC 1013
#define World_grp 1004
#define direction_grp 1001
#define stats_grp 1012
#define stattext 1014
#define misc_grp 1015
#define backupbttn 1021
#define restorebttn 1022
#define IDM_MENU 10000
#define IDM_OPEN_COMP 10001
#define IDM_OPEN_DEVICE 10002
#define IDM_HELP_ABOUT 10003
#define IDM_CHECK_UPDATE 10004
#define IDM_Chelp 10005
#define Icon1 100
#define IDR_XPMANIFEST1 1
#define IDR_VERSION1 1
#define DelPCDialogBox 1100
#define IDC_GRP1 1101
#define DelAllchckbx 1102
#define IDC_GRP2 1107
#define Worlds2chckbx 1105
#define WorldsTxt 1109
#define IDC_GRP3 1108
#define Stats2chckbx 1104
#define StatsTxt 1110
#define LastLogchckbx 1103
#define Bin2chckbx 1106
#define Options2chckbx 1111
#define Shots2chckbx 1112
#define Packschckbx 1113
#define AllWorlds2chckbx 1114
#define AllStats2chckbx 1115
#define Delbttn 1116
Main DIALOGEX 6,6,315,114
CAPTION "Synchronize"
FONT 8,"MS Sans Serif",0,0,0
CLASS "SYNCCLASS"
MENU IDM_MENU
LANGUAGE 9,1
STYLE 0x10CA0880
EXSTYLE 0x00000001
BEGIN
CONTROL "Type world names to copy worlds.",worldtext,"Static",0x58000000,6,36,108,9
CONTROL "Sync to computer.",tocomputer,"Button",0x50014009,6,12,69,9
CONTROL "Sync to device.",todevice,"Button",0x50014009,81,12,60,9
CONTROL "",worldslist,"Edit",0x18000090,6,45,147,12,0x00000200
CONTROL "Copy all worlds.",wrldchckbx,"Button",0x58034003,6,60,60,9
CONTROL "",usrnm,"Edit",0x58000090,162,21,147,12,0x00000200
CONTROL "Copy all stats",statschckbx,"Button",0x58010003,162,36,54,9
CONTROL "Copy bin folder",Binchckbx,"Button",0x58010003,165,60,66,9
CONTROL "Copy resources",Reschckbx,"Button",0x58010003,237,60,63,9
CONTROL "Copy screenshots",shotchckbx,"Button",0x58010003,165,72,69,9
CONTROL "Copy texturepacks",texchckbx,"Button",0x58010003,237,72,72,9
CONTROL "Copy options",optionschckbx,"Button",0x58010003,165,84,54,9
CONTROL "Overwrite",forcechckbx,"Button",0x58010003,237,84,42,9
CONTROL "Synchronize",syncbttn,"Button",0x58014000,3,75,75,36
CONTROL "Delete parts from computer",DelPC,"Button",0x50012000,81,75,75,36
CONTROL "Worlds",World_grp,"Button",0x50000007,3,27,153,45
CONTROL "Which way?",direction_grp,"Button",0x50000007,3,3,153,21
CONTROL "Stats",stats_grp,"Button",0x50000007,159,3,153,45
CONTROL "Type username to copy stats.",stattext,"Static",0x58000000,162,12,93,9
CONTROL "Extras",misc_grp,"Button",0x50000007,159,51,153,45
CONTROL "Backup minecraft.jar",backupbttn,"Button",0x58000000,159,96,75,15
CONTROL "Restore minecraft.jar",restorebttn,"Button",0x58000000,237,96,75,15
END
IDM_MENU MENU
LANGUAGE 9,1
BEGIN
POPUP "&File"
BEGIN
MENUITEM "Open on &Computer",IDM_OPEN_COMP
MENUITEM "Open on &Device",IDM_OPEN_DEVICE
END
POPUP "&Help"
BEGIN
MENUITEM "&About",IDM_HELP_ABOUT
MENUITEM "&Check for updates",IDM_CHECK_UPDATE
MENUITEM "&Explain synchronize",IDM_Chelp
END
END
Icon1 ICON DISCARDABLE "Res/synchronize.ico"
IDR_XPMANIFEST1 MANIFEST "xpmanifest.xml"
IDR_VERSION1 VERSIONINFO
FILEVERSION 1,5,1,0
PRODUCTVERSION 1,5,1,0
FILEOS 0x00000004
FILETYPE 0x00000001
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904B0"
BEGIN
VALUE "FileVersion", "1.5.1\0"
VALUE "ProductVersion", "1.5.1.0\0"
VALUE "InternalName", "Synchronize.exe\0"
VALUE "ProductName", "Synchronize\0"
VALUE "OriginalFilename", "Synchronize\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0409, 0x04B0
END
END
DelPCDialogBox DIALOGEX 10,10,178,158
CAPTION "Delete Parts"
FONT 8,"MS Sans Serif",0,0,0
CLASS "SYNCCLASS"
LANGUAGE 9,1
STYLE 0x10C80804
EXSTYLE 0x00000288
BEGIN
CONTROL "",IDC_GRP1,"Button",0x58000007,3,3,173,139
CONTROL "Delete All",DelAllchckbx,"Button",0x50000003,9,3,45,9
CONTROL "",IDC_GRP2,"Button",0x58000007,9,15,159,30
CONTROL "Worlds",Worlds2chckbx,"Button",0x58000003,15,15,36,9
CONTROL "",WorldsTxt,"Edit",0x58000000,15,27,147,15,0x00000200
CONTROL "",IDC_GRP3,"Button",0x58000007,9,48,159,27
CONTROL "Stats",Stats2chckbx,"Button",0x58020003,15,48,30,9
CONTROL "",StatsTxt,"Edit",0x58000000,15,57,147,15,0x00000200
CONTROL "Last Login Info",LastLogchckbx,"Button",0x58020003,15,78,60,9
CONTROL "Binaries(bin and Resources)",Bin2chckbx,"Button",0x58000003,15,90,102,9
CONTROL "Options",Options2chckbx,"Button",0x58000003,15,102,36,9
CONTROL "Screenshots",Shots2chckbx,"Button",0x58000003,15,114,54,9
CONTROL "Texturepacks",Packschckbx,"Button",0x58010003,15,126,54,9
CONTROL "All Worlds",AllWorlds2chckbx,"Button",0x58010003,111,15,45,9
CONTROL "All Stats",AllStats2chckbx,"Button",0x58010003,111,48,39,9
CONTROL "Delete",Delbttn,"Button",0x50010F00,2,144,176,14
END
Code: Select all
/'Parameters:
Sentence
The string that you want to parse.
Wordnum
The number of the section you want to retrieve.
Delimeter
The characters that seperate each section.'/
Declare Function words(sentence As String, wordnum As UInteger, delimiter As String) As String
Function words(sentence As String, wordnum As UInteger, delimiter As String)As String
Dim As String word
Dim As Integer letter, findword = 1
If sentence <> "" And delimiter <> "" Then '//////////Strings must not be empty
'//////////Find the requested word.
For letter = 0 To Len(sentence)
If findword = wordnum Then '////////////If it found the word.
Do '//////////Add letters together until word is finished.
word += Chr(sentence[letter])
letter += 1
Loop While Chr(sentence[letter]) <> delimiter And letter <= (Len(sentence) - 1)
Exit For
ElseIf sentence[letter] = Asc(delimiter) Then '//////////Count words.
findword += 1
EndIf
Next letter
EndIf
If wordnum = 0 Then
Return Str(findword)
Else
Return word
EndIf
End Function
I am sure(not really) that these problems are related to conflicts of some kind? Or am I way off?
P.S. I don't want to post an entirely new topic for this, Has anyone made(or have example code) of a function that can replace the calls to xcopy?
might be awhile before I get back, I have a state competition on 29/30 th of March.