User Name
Password

Go Back   Planetarion Forums > Non Planetarion Discussions > Programming and Discussion

Reply
Thread Tools Display Modes
Unread 6 May 2005, 12:16   #1
Structural Integrity
Rawr rawr
 
Structural Integrity's Avatar
 
Join Date: Dec 2000
Location: Upside down
Posts: 5,300
Structural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriend
VB6 - blocking dialogs, and returning values from dialogs

I'm trying to make a dialog with which the user can edit a text. This text should be "returned" to the calling dialog.
So in this first dialog, the user clicks on "edit", which opens a new dialog with fancy buttons and options. And when the user clicks "OK" in the edit dialog, the new editted text is put somewhere in the original dialog where the user clicked "edit".
The problem is: how do I get the text back to the original dialog?

I've been thinking about casting an event to the original dialog when the user clicks "OK", with a "me" reference to the edit dialog. But it doesn't seem a clean solution. The nicest would be to have it just return a string.

Also, how can I make a dialog "blocking", so that no other open dialog of that app can be made active untill the "blocking" dialog is closed. In MFC they call it modal dialogs I think. Not sure as it's been a long time since I worked with MFC.
__________________
"Yay"
Structural Integrity is offline   Reply With Quote
Unread 6 May 2005, 19:16   #2
JetLinus
Friendly geek of GD :-/
 
JetLinus's Avatar
 
Join Date: Nov 2000
Location: On my metal roid
Posts: 923
JetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud of
Re: VB6 - blocking dialogs, and returning values from dialogs

Well, this one is "easy".
VB provides the option to display forms modal. Default option is modeless however.
Just use frmSomeForm.Show vbModal. Code will only be executed after this statement, until frmSomeForm is hidden or unload again.

BTW, I personally didn't really think that passing back the me-reference or casting an event with it would be that bad. I mean, why not let your function return the link to a text-control?
Anyway, I didn't exactly understand how you tried to solve that anyway.

So a nice method for you would be:

Code:
' This inside your modal edit dialog, let's call it frmUserEdit:

' Damnit I think it's gotta be private, but maybe without a keyword is ok? Or try public. Whatever:
Function GetEditFromUser() As String

    Me.Show vbModal  ' the second parameter is "OwnerForm", sometimes you specify "Me"
    'I don't know exactly when. Maybe you wanna pass the OwnerForm as reference to this function?

    ' The code in here will only be exited, once you decide to unload / hide the Form... Choose appropriate.

    GetEditFromUser = txtEdit.Text

End Function

I noticed this might be bullshit, to put the modal-calling function inside the modal-form itself. If it's unload, the Text-Information will be gone.


Probably better put the whole thing in a Module. Then:
Code:
' In a module:

Public Function GetEditFromUser(ByRef frmModalEditDialog as Form, ByRef frmOwnerForm as Form) as String

     frmModalEditDialog.Show vbModal, frmOwnerForm

     ' In that form, make sure that "Form_Show" or "Form_Load" does everything is need.
     ' In "cmdOk_Click" or so, call Me.Hide

     ' This requires the passed form to have a text-control named this way, obviously
     GetEditFromUser =  frmModalEditDialog.txtEdit.Text

     ' Now it is optional to Unload the form, depends on how often you wanna use it etc...

     Unload frmModalEditDialog

End Function
__________________
[»] Entropy increases! :-/
JetLinus is offline   Reply With Quote
Unread 8 May 2005, 00:37   #3
JetLinus
Friendly geek of GD :-/
 
JetLinus's Avatar
 
Join Date: Nov 2000
Location: On my metal roid
Posts: 923
JetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud of
Arrow Re: VB6 - blocking dialogs, and returning values from dialogs

I was just browsing about classes and "OO in VB", and I found something useful for you too:

Forms can set other form's properties.
So you could either create a hidden text-control in the calling form. Then, the modal show dialog set's this hidden text's text-property when everything is done.


Or, you could use the Form.Tag property. AFAIK this is a free usable String-Property, that has no purpose at all and that you can set at will...


Now you should've plenty of opportunities.

But I agree with you, that for people who do really know (and support) the true OO paradigma and who have some experience in classing etc, this stupid cheap and non-conform non-consquent VB sucks a tiny bit....
Still like it
__________________
[»] Entropy increases! :-/
JetLinus is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Forum Jump


All times are GMT +1. The time now is 11:52.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2002 - 2018