Bonjour à tous.
Je cherche à effectuer plusieurs fonctions sur une application MDI. J'ai crée une feuille Form1 qui sera le modèle des feuilles MDI Filles. J'ai rajouté une feuille MDI Mère avec deux menus déroulant (Fichiers et Format). Je voudrais savoir comment ouvrir un document existant au format rtf et sauvegarder un fichier quelconque. En cherchant un peu j'ai trouvé qu'il fallait utilisé le contrôle: Microsoft Common Dialog mais je n'ai pas réussi à trouve les commandes correspondantes.
Voila le code de la MDI Mère:
Le code de la MDI FIlle:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63 Private Sub Form_Load() Save.Enabled = False Fermer.Enabled = False Sauver.Enabled = False End Sub Private Sub Nouveau_Click() Save.Enabled = True Fermer.Enabled = True Sauver.Enabled = True Static N As Integer Dim F As Form N = N + 1 Set F = New Form1 F.Caption = "Feuille" + Str$(N) F.Show End Sub Private Sub Ouvrir_Click() On Error GoTo ExitOuvrir Save.Enabled = True Fermer.Enabled = True Sauver.Enabled = True CommonDialog1.CancelError = True CommonDialog1.Filter = True CommonDialog1.Filter = "Tous les fichiers|*|Fichier(*txt)|*.txt|Fichier(*rtf)|*rtf" CommonDialog1.ShowOpen Call Nouveau_Click Me.ActiveForm.RichTextBox1.LoadFile CommonDialog1.FileName, rtfRTF ExitOuvrir: End Sub Private Sub Save_Click() On Error GoTo ExitSave CommonDialog1.DialogTitle = "Enregistrer le fichier sous..." CommonDialog1.Filter = "Fichier(*.txt)|*txt|Fichier(*rtf)|*rtf" CommonDialog1.CancelError = True CommonDialog1.ShowSave RichTextBox1.SaveFile ExitSave: End Sub Private Sub Sauver_Clik() On Error GoTo ExitSauver CommonDialog1.CancelError = True CommonDialog1.Filter = "Fichier|*.*" CommonDialog1.ShowSave Me.ActiveForm.RichTextBox1.SaveFile CommonDialog.FileName, rtfRTF ExitSauver: End Sub Private Sub Fermer_Click() Unload Me.ActiveForm End Sub Private Sub Quitter_Click() Unload Me End Sub
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 Private Sub Form_Load() On Error Resume Next Me.Tag = CStr(Me.Width) & ":" & CStr(Me.Height) For Each object In Me object.Tag = CStr(object.X1) & ":" & CStr(object.Y1) & ";" & CStr(object.X2) & "!" & CStr(object.Y2) object.Tag = CStr(object.Width) & ":" & CStr(object.Height) & ";" & CStr(object.Left) & "!" & CStr(object.Top) Next object End Sub Private Sub Form_Resize() On Error Resume Next For Each object In Me object.Width = Val(Mid(object.Tag, 1, InStr(object.Tag, ":") - 1)) * Me.Width / Val(Mid(Me.Tag, 1, InStr(Me.Tag, ":") - 1)) object.Height = Val(Mid(object.Tag, InStr(object.Tag, ":") + 1, Len(object.Tag) - InStr(object.Tag, ":") + 1)) * Me.Height / Val(Mid(Me.Tag, InStr(Me.Tag, ":") + 1, Len(Me.Tag) - InStr(Me.Tag, ":") + 1)) object.Left = Val(Mid(object.Tag, InStr(object.Tag, ";") + 1, Len(object.Tag) - InStr(object.Tag, ";") + 1)) * Me.Width / Val(Mid(Me.Tag, 1, InStr(Me.Tag, ":") - 1)) object.Top = Val(Mid(object.Tag, InStr(object.Tag, "!") + 1, Len(object.Tag) - InStr(object.Tag, "!") + 1)) * Me.Height / Val(Mid(Me.Tag, InStr(Me.Tag, ":") + 1, Len(Me.Tag) - InStr(Me.Tag, ":") + 1)) Next object End Sub
Partager