Skip to content

Commit

Permalink
Fix overlapping buttons and re-use frmNameDialog for renaming a profile
Browse files Browse the repository at this point in the history
  • Loading branch information
MisterVector committed Jan 18, 2021
1 parent f6c7f24 commit bb21c75
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 158 deletions.
1 change: 0 additions & 1 deletion trunk/Launcher/Launcher.vbp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ Class=clsConfig; clsConfig.cls
Module=modURLDetection; modURLDetection.bas
Form=frmConfig.frm
Form=frmStatus.frm
Form=frmRenameProfile.frm
IconForm="frmLauncher"
Startup="frmLauncher"
HelpFile=""
Expand Down
11 changes: 6 additions & 5 deletions trunk/Launcher/frmLauncher.frm
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Begin VB.Form frmLauncher
Begin VB.CommandButton cmdRemoveProfile
Caption = "&Remove Profile"
Enabled = 0 'False
Height = 240
Height = 255
Left = 1800
TabIndex = 2
Top = 3240
Expand All @@ -58,7 +58,7 @@ Begin VB.Form frmLauncher
Height = 240
Left = 240
TabIndex = 3
Top = 3480
Top = 3510
Width = 3135
End
Begin VB.CommandButton cmdLaunchThis
Expand Down Expand Up @@ -245,7 +245,6 @@ On Error GoTo ERROR_HANDLER
'UnHookAllProcs

Unload frmNameDialog
Unload frmRenameProfile
'Unload frmConfig
'Unload frmstatus

Expand Down Expand Up @@ -311,6 +310,7 @@ Private Sub cmdCreateProfile_Click()
On Error GoTo ERROR_HANDLER
Load frmNameDialog
frmNameDialog.Show
frmNameDialog.setWindowData "Create Profile", "Enter the name of the new profile below.", ProfileOption.CREATE_PROFILE

Exit Sub
ERROR_HANDLER:
Expand Down Expand Up @@ -392,8 +392,9 @@ On Error GoTo ERROR_HANDLER

If (Not lstProfiles.SelectedItem Is Nothing) Then
If (modLauncher.ProfileExists(lstProfiles.SelectedItem.Text)) Then
frmRenameProfile.Show
frmRenameProfile.setOriginalProfile lstProfiles.SelectedItem.Text, lstProfiles.SelectedItem.Index
frmNameDialog.Show
frmNameDialog.setWindowData "Rename Profile", "Enter the name you want to rename the profile to.", ProfileOption.RENAME_PROFILE
frmNameDialog.setOldProfileInfo lstProfiles.SelectedItem.Text, lstProfiles.SelectedItem.Index
End If
End If

Expand Down
61 changes: 52 additions & 9 deletions trunk/Launcher/frmNameDialog.frm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ VERSION 5.00
Begin VB.Form frmNameDialog
BackColor = &H00000000&
BorderStyle = 1 'Fixed Single
Caption = "Create Profile"
Caption = "Window Title"
ClientHeight = 1095
ClientLeft = 105
ClientTop = 495
Expand Down Expand Up @@ -72,7 +72,7 @@ Begin VB.Form frmNameDialog
AutoSize = -1 'True
BackColor = &H00000000&
BackStyle = 0 'Transparent
Caption = "Enter the name of the new profile below."
Caption = "[message]"
BeginProperty Font
Name = "Tahoma"
Size = 8.25
Expand All @@ -87,7 +87,7 @@ Begin VB.Form frmNameDialog
Left = 120
TabIndex = 3
Top = 120
Width = 2955
Width = 6255
End
Begin VB.Line line
BorderColor = &H00FFFFFF&
Expand All @@ -108,6 +108,10 @@ Option Explicit
Private Const OBJECT_NAME As String = "frmNameDialog"
Private Const INVALID_CHARS As String = "\/*?"":<>|"

Private m_profileOption As ProfileOption
Private previousProfileName As String
Private previousProfileIndex As Integer

Private Sub Form_Load()
On Error GoTo ERROR_HANDLER
txtName.Text = vbNullString
Expand All @@ -118,11 +122,13 @@ ERROR_HANDLER:
ErrorHandler Err.Number, OBJECT_NAME, "Form_Load"
End Sub

Private Sub cmdOK_Click()
Private Sub cmdOk_Click()
On Error GoTo ERROR_HANDLER
Dim i As Integer
Dim Text As String
Dim Char As String * 1
Dim originalPath As String
Dim destinationPath As String

Text = txtName.Text

Expand All @@ -139,11 +145,27 @@ On Error GoTo ERROR_HANDLER
End If
Next i

If (CreateProfile(Text)) Then
frmLauncher.ListProfile Text
Else
'MsgBox "Failed to create profile!"
End If
Select Case m_profileOption
Case CREATE_PROFILE
If (CreateProfile(Text)) Then
frmLauncher.ListProfile Text
Else
'MsgBox "Failed to create profile!"
End If
Case RENAME_PROFILE
If (ProfileExists(Text)) Then
MsgBox "That profile already exists!"
Exit Sub
End If

originalPath = StringFormat("{0}\StealthBot\{1}", ReplaceEnvironmentVars("%APPDATA%"), previousProfileName)
destinationPath = StringFormat("{0}\StealthBot\{1}", ReplaceEnvironmentVars("%APPDATA%"), Text)

If (CopyFolder(originalPath, destinationPath)) Then
KillFolder originalPath
frmLauncher.renameProfileInList Text, previousProfileIndex
End If
End Select

Unload Me

Expand All @@ -162,3 +184,24 @@ On Error GoTo ERROR_HANDLER
ERROR_HANDLER:
ErrorHandler Err.Number, OBJECT_NAME, "cmdCancel_Click"
End Sub

Public Sub setWindowData(ByVal title As String, ByVal message As String, ByVal po As ProfileOption)
On Error GoTo ERROR_HANDLER
Me.Caption = title
lblText.Caption = message
m_profileOption = po

Exit Sub
ERROR_HANDLER:
ErrorHandler Err.Number, OBJECT_NAME, "setWindowData"
End Sub

Public Sub setOldProfileInfo(ByVal profileName As String, ByVal profileIndex As Integer)
On Error GoTo ERROR_HANDLER
previousProfileName = profileName
previousProfileIndex = profileIndex

Exit Sub
ERROR_HANDLER:
ErrorHandler Err.Number, OBJECT_NAME, "setOldProfileInfo"
End Sub
143 changes: 0 additions & 143 deletions trunk/Launcher/frmRenameProfile.frm

This file was deleted.

5 changes: 5 additions & 0 deletions trunk/Launcher/modLauncher.bas
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ Private Const SW_SHOW As Long = 5
Private Declare Function CreateProcess Lib "kernel32" Alias "CreateProcessA" (ByVal lpApplicationName As String, ByVal lpCommandLine As String, lpProcessAttributes As SECURITY_ATTRIBUTES, lpThreadAttributes As SECURITY_ATTRIBUTES, ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, lpEnvironment As Any, ByVal lpCurrentDriectory As String, lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long
Private Declare Function ShellExecute Lib "shell32" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Public Enum ProfileOption
RENAME_PROFILE
CREATE_PROFILE
End Enum

Private xml_doc As DOMDocument60
Private CommandLine As String
Public Declare Function GetFileAttributes Lib "kernel32" Alias "GetFileAttributesA" (ByVal lpFileName As String) As Long
Expand Down

0 comments on commit bb21c75

Please sign in to comment.