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

Thread: How Creat New Desktop or Window in VB for secondry display

  1. #1
    Join Date
    Mar 2004
    Posts
    49

    How Creat New Desktop or Window in VB for secondry display

    Hii

    Can any 1 help me. i need help

    How can i creat new desktop to send my output to secondry display
    actualy i wantr to send my softwares output to TV out for that i want to creat new desk top or new window to send my VB formd ,flash. mediaplaye output to TV out ( secondry display), windows current desktop i want remains free to do other work simaltaunasly with my software

    is there VB coder API,Controls please work out and help me

    Thanx

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

    Re: How Creat New Desktop or Window in VB for secondry display

    Actually your second monitor should be configured as to be part of the desktop. This can be done in the Screen settings (Display properties).
    Then you have to determine where the coordinates of your second monitor are in relation to your primary monitor (which is at 0,0), and move any new Form you want to appear on the secondary screen to the new coordinates.

    An example:
    Your primary screen has 1024x768 and your secondary screen is directly located to the right of it, same size.
    Your secondary screen is then located at 1024, 0.
    If you want to open Form2 on the secondary screen, top left corner, you will have to move it there like shown below.
    Code:
    Form2.Show
    Form2.Move 1024*Screen.TwipsPerPixelX, 0
    For VB computes in Twips, rather than pixels you have to convert the coordinates into Twips as shown in the above line.

    I haven't yet found, but I'm sure that you can determine the actual position of the secondary monitor programmatically by an API call, but this should already give you an idea how to put things on the secondary monitor.

  3. #3
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,268

    Re: How Creat New Desktop or Window in VB for secondry display

    To add to what WoF has mentioned, you may also want to look at the EnumDisplayDevices API
    [SIGPIC][/SIGPIC]
    All my Articles
    Hannes

  4. #4
    Join Date
    Mar 2004
    Posts
    49

    Re: How Creat New Desktop or Window in VB for secondry display

    i will try on monday as u told Sir ,, but sir can it will display full form on TV screen secondry display is TV .. i m trying to send u my code

    thanx

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

    Re: How Creat New Desktop or Window in VB for secondry display

    Yes it will.
    Right, Hannes. EnumDisplayDevices will enumerate the available Displays to you.
    Still you have to find out, what relative desktop position the screen of the enumerated display will occupy. I'm not sure, but there must still be an API or a structure which will tell, where the secondary (or even third) monitor sits, in relation to 0,0.

  6. #6
    Join Date
    Apr 2006
    Location
    Kolkata, India
    Posts
    278

    Re: How Creat New Desktop or Window in VB for secondry display

    Dear Wof,

    I did the same task few years back but unfortunately the TV went out of Sync with Horizontal sync failure.but If i try it on a monitor it worked properly.
    TV did not get defective it was okay but whenever i tried to shift it to TV that failure occured.

  7. #7
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,268

    Re: How Creat New Desktop or Window in VB for secondry display

    WoF, If I understand correctly, You could use the DISPLAY_DEVICE Type, with the DISPLAY_DEVICE_ATTACHED_TO_DESKTOP and the DISPLAY_PRIMARY_DEVICE Constants
    [SIGPIC][/SIGPIC]
    All my Articles
    Hannes

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

    Re: How Creat New Desktop or Window in VB for secondry display

    @Hannes: The DISPLAY_DEVICE sructire does not so far contain any information, where it's visible surface is located relative to the primary desktop, as it seems.
    Could be the API EnumDiplayMonitors could provide what we seek here. (Not sure, have to try it first).
    http://msdn2.microsoft.com/en-us/lib...09(VS.85).aspx
    It calls a MonitorEnumProc you write, which is getting passed (for each available monitor) a RECT which I presume is the size of the screen on this particular monitor.

    @dsrahul: I'm not sure, but this could've been an error of the graphics board. I had something like this with a TV output, too. Using a different display adapter remedied the problem.

  9. #9
    Join Date
    Mar 2004
    Posts
    49

    Re: How Send VB forms output to secondry display while using AGP card

    Hii all actualy my all work is on VB form so is thre any API or command that can tell or controll to send VB for display in Seondry output when we use AGP car with TV out Secondry display set to TV .

    when i m using my software Output of Mediaplaye Movie it is allready goes automaticaly to TV ( secondry output ) so Vb form also can goto secondry display

    here is attachment of my code

    Unzip Sample folder and copy sample folder to C:\ drive
    Last edited by shashishukla; April 5th, 2008 at 02:32 AM.

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

    Re: How Creat New Desktop or Window in VB for secondry display

    Could you make a zip file please?
    Sorry, some of us (including me) can't handle some rar files properly.

    Although I believe I explained already on how to put forms on the secondary screen, it seemed it did not work. So for me to understand your situation please attach a scrrenshot of the display properties like I have attached an image. It maybe german, but you will know what I want to see.

    I forgot: before you make the screen shot, put the mouse pointer over the secondary screen so as the starting coordinates are displayed.
    Attached Images Attached Images  
    Last edited by WoF; April 7th, 2008 at 08:51 AM.

  11. #11
    Join Date
    Mar 2004
    Posts
    49

    Re: How Creat New Desktop or Window in VB for secondry display

    Hii WoF

    As you told me that send ZIP format file so here is file for you in ZIP format

    Please run in VB6 and try to solv my probloum

    Important step:1

    1. Unzip Sample file and copy Sample folder in Drive C:
    2. Copy msdxm.ocx file from C:\Windows\System32 to C:\Sample folder
    3. Copy Flash.ocx file into C:\Sample folder , if u do not have Flash.Ocx file then you hve to send me your email edd cause heare i cant send u more then 800 Kb file u will find on net very eazely Flash.Ocx

    run project in VB6

    Thanx
    Attached Files Attached Files
    Last edited by shashishukla; April 14th, 2008 at 09:35 AM.

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

    Re: How Creat New Desktop or Window in VB for secondry display

    Unfortunately I couldn't run your sample cause I had difficulties installing the ocx you use.

    But I've done the following, which should provide you with a solution to your problem.
    I've researched about how to retrieve monitor info and find out the relative coordinates of the secondary screen.
    I have attached a small example. It finds the position of the secondary screen and replicates its own window into the top left corner of this screen.
    The solution code is in the module. It shows, how you determine the coordinates of the secondary monitor.
    The code in the Form (Click event of the button) shows how to move a window to this position.

    This sample works perfectly if you have ONLY one secondary screen.
    Also the monitor must be known to windows as part of the desktop, that is in Display Properties, the option
    [ ]Extend the Desktop to this monitor must be checked.
    If you have more screens in the system, make sure only two of them are part of the desktop. Otherwise the code would need more refinement.
    Attached Files Attached Files

  13. #13
    Join Date
    Mar 2004
    Posts
    49

    Re: How Creat New Desktop or Window in VB for secondry display

    Hii WoF thanx to reply and giving me u r valuable time

    WoF i have TLB registring prob in your sample project
    can u provide me ur TLB file in simple Module file format

    a sample attachment u send me that sample is not running with u r TLB file
    i mean not showing TLB file in Sample code and not click command on form load

    Thanx

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

    Re: How Creat New Desktop or Window in VB for secondry display

    Sorry, I accidentally returned your own file to you.
    I'm so sorry. Sh*t. I worked out such a fine solution.
    I have the files at the office. I shall hook them up tommorrow, right?

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

    Re: How Creat New Desktop or Window in VB for secondry display

    Sorry for letting you wait. Now, here is your solution:

    The following code is mainly a callback function for EnumDisplayMonitors.
    Callback code must be in a module, can for some reason not be in a Form.
    It will store the coordinates of the first monitor which is not the primary monitor and is attached to the desktop in SMXOffset and SMYOffset.

    Code:
    Option Explicit
    
    Public SMXOffset As Long
    Public SMYOffset As Long
    
    Public Const MONITORINFOF_PRIMARY = &H1
    
    Public Type RECT
        Left As Long
        Top As Long
        Right As Long
        Bottom As Long
    End Type
    
    Public Type MONITORINFO
        cbSize As Long
        rcMonitor As RECT
        rcWork As RECT
        dwFlags As Long
    End Type
    
    
    Public Declare Function GetMonitorInfo Lib "user32.dll" Alias "GetMonitorInfoA" (ByVal hMonitor As Long, ByRef lpmi As MONITORINFO) As Long
    Public Declare Function EnumDisplayMonitors Lib "user32.dll" (ByVal hdc As Long, ByRef lprcClip As Any, ByVal lpfnEnum As Long, ByVal dwData As Long) As Long
    
    
    Public Function MonitorEnum(ByVal hMonitor As Long, ByVal hdcMonitor As Long, lprcMonitor As RECT, ByVal dwData As Long) As Long
      Dim mi As MONITORINFO
      
      mi.cbSize = Len(mi)
     'Get the monitor information of the specified monitor
      GetMonitorInfo hMonitor, mi
      If (mi.dwFlags And MONITORINFOF_PRIMARY) = 0 Then
         SMXOffset = mi.rcWork.Left
         SMYOffset = mi.rcWork.Top
         MonitorEnum = 0
      Else
         MonitorEnum = 1
      End If
    
    End Function
    And this is how to use it:
    Code:
    Private Sub btnSetForm_Click()
    
      EnumDisplayMonitors ByVal 0&, ByVal 0&, AddressOf MonitorEnum, ByVal 0&
    
      MyForm.Show
      MyForm.Move SMXOffset * Screen.TwipsPerPixelX, SMYOffset * Screen.TwipsPerPixelY
    
    End Sub
    MyForm is the Form you want to show on the secondary monitor.

    I have attached a working example which replicates it's own window onto the secondary monitor.

    If you have more than two monitors the code may need some refinement.
    Attached Files Attached Files

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
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)