CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    Join Date
    Dec 2004
    Posts
    61

    Unhappy How to embed dialog onto another dialog

    I'm facing a problem to embed dialog into another dialog.
    Reason to do is i have a bunch of dialog to show but i don't want user to see it as dialog.

    I have created a Main dialogbox and want to embed the dialog into this main dialog.
    Can someone tell me how?

    I have search the internet. Actually if i able to set the "screentoclient()" i think the problem should able to solve.
    But when i search the "screentoclient", the solution that i found was use to capture the mouse position.
    I want the set the screen to client screen.
    How can i do it?

    Hope someone can help me.
    Thanks.

  2. #2
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: How to embed dialog onto another dialog

    I can't really tell what you are asking. What do you mean by embded a dialog in a dialog? You can show another dialog box from your dialog box, you can change the dialog within the dialog box you can not physically embed another dialog form within a dialog form and even if you could I can see no use for such a thing.
    Always use [code][/code] tags when posting code.

  3. #3
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: How to embed dialog onto another dialog

    Yes, you have to be more specific and detailed to explain what you want.
    What is the dialogbox you have created? Is it a Form? You can create another dialog at any time form the first form, like it was embedded. If the second dialog is a form too, you would show it like
    formDialog2.Show vbModal, Me (showing it from Form1 for instance, where the Me makes the form from where you show the dialog the owner form.

  4. #4
    Join Date
    Dec 2004
    Posts
    61

    Re: How to embed dialog onto another dialog

    Dear DataMiser and WoF,

    Sorry that i did not explain my problem clearly.
    Attached is the structure of what i'm try to do.
    Hope that with my drawing, it able to express what i'm try to say.

    I know that there are few steps needed.
    That is to get the "screentoclient" and move the dialog to the CRect position.

    I not able to "screentoclient" my form so i not able to proceed with my project.
    Hope you guys can help.
    Thanks.
    Attached Images Attached Images  

  5. #5
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: How to embed dialog onto another dialog

    You still have not told us what you are doing. The only way you can put a form inside a form is if the parent is a MDI Parent form and the one you want to put inside is a MID Child but then you can not use a MDI child as a modal dialog form.

    You can show a form on top of a form and center it over the form which calls it. If you also set it modal then it will stay on top of the other form until the modal condition is released. You can also use frames on your form instead of forms and toggle the visible property of each form as needed which is the closest thing you will find to a form in a form.

    All of that said you have not even told us if you are working on a pc app or a web based app and you have shown no code. And your "screentoclient" really has no meaning you'll have to better define what you are doing and/or what you are trying to do before we could be of much help to you.
    Always use [code][/code] tags when posting code.

  6. #6
    Join Date
    Dec 2004
    Posts
    61

    Re: How to embed dialog onto another dialog

    Dear DataMiser,

    I developing a dialog base application.
    one Main dialog and few child dialog.
    I'm not creating a MDI application.

    Code:
    Private Sub Form_Load()
        frmInfo.Show vbModaless, Me
       
        Call MoveWindow(frmInfo.hwnd, Frame1.Left, Frame1.Top, frmInfo.Width, frmInfo.Height, False)
            
    End Sub
    i'm tyring to put a frameless dialog to show on top of my main dialog.
    The problem is the frmInfo cannot show at the position that i want.
    thanks

  7. #7
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: How to embed dialog onto another dialog

    What position are you trying to attain?
    What result are you getting?

    Edit to add:
    If you are simply trying to position the top left corner of the new form over the top left corner of the frame on your existing form then you could do it easy with a little math.
    No need to call the move window function though that would work with the right parameters. You can use the form properties to get what you want.

    Code:
    Form2.Show
    Form2.Top = Frame1.Top + Form1.Top + Form1.Height - Form1.ScaleHeight
    Form2.Left = Frame1.Left + Form1.Left + Form1.Width - Form1.ScaleWidth
    If you want the form centered in the frame then you need a little more math in there but that will set the top left
    Last edited by DataMiser; September 15th, 2011 at 12:16 PM.
    Always use [code][/code] tags when posting code.

  8. #8
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: How to embed dialog onto another dialog

    keep in mind that if you are showing this non modal that the user will be able to click on the initial form and your form will dissappear behind it. In general not a good idea for dialogs.
    Always use [code][/code] tags when posting code.

  9. #9
    Join Date
    Dec 2004
    Posts
    61

    Re: How to embed dialog onto another dialog

    Dear DataMiser,

    I have try the calculation but the form2 position is follow the monitor screen coordinate.
    Is not following the Form1 coordinate.

    Thanks

  10. #10
    Join Date
    Dec 2004
    Posts
    61

    Re: How to embed dialog onto another dialog

    yes. i know about it that is why i try to embed the dialog at the Form1.
    I know in VC++, we can do like this but i don't know how to do in VB.
    Thanks

  11. #11
    Join Date
    Dec 2004
    Posts
    61

    Re: How to embed dialog onto another dialog

    Dear DataMiser,

    the calculation work. Thanks.
    but there another problem. when i drag the from1 dialog, the form2 dialog will not move together.

  12. #12
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: How to embed dialog onto another dialog

    Of course not, they are not joined together. You would have to write code that moves it if that is what you want to do. I still do not understand what you are doing though. Seems to me that using frames on Form1 which toggle on/off would be better suited for dialogs. Or even just one form with or without any frames which is coded to display different messages and if needed buttons do different actions depending on which dialog is shown.

    Trying to make a form over a form and trying to make them move together as one doesn't make a lot of sense especially so if the smaller form is non modal as the moment you try to move the form behind would make the smaller form dissappear behind it and no longer have access to it. I can see a user doing this by accident very easy and often.

    Seems like a very poor design to me, perhaps you should rethink this approach.
    Always use [code][/code] tags when posting code.

  13. #13
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: How to embed dialog onto another dialog

    That's right and good arguments they are.

    Nevertheless, to move the forms together with the main form you simply have to put the positioning code into the Form_Resise() event of Form1.
    And to make the subform stay on top of Form1 you'd have to make use of the SetWindowPos() API.

  14. #14
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: How to embed dialog onto another dialog

    Unfortunately if you use that set window API then the form stays on top not only of your app but all other apps as well. I would be uninstalling the software right away
    Always use [code][/code] tags when posting code.

  15. #15
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: How to embed dialog onto another dialog

    Well, the SetWindowPos() API allows the passing of a hWnd on top of which the secondary form should be placed.
    Using the HWND_TOPMOST constant will put it on top af all other windows.
    Passing the Form.hWnd instead will put it on top of that one, only.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured