CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2001
    Posts
    7

    tough modal problem

    I am writing a program that captures another computers print output and using the data. Well here is the problem. When I have to prompt for action code stops so I lose data coming into the port(I am using a parrallel to serial converter). So I either have to write my own msgboxes(I already did the dialogs modaless) or disable my cts , but then the host computer will eventually timeout and have to reprint. I did test an activeX server just to handle and stack input but It was alot of extra code And I'm not that educated on it. I know there is a way to do it. Does anyone have any Ideas how I should fix my problem. I am just not sure what is the best road to take. This progam will be used allot and must be solid(like any good prog). Any insight would be greatly appreciated. thank you


  2. #2
    Join Date
    Mar 2001
    Posts
    7

    Re: tough modal problem

    I know netscape is C. Does anyone know of vb program with source that handles communication and has a modal msgbox. MS has one but it is not modal and only halts transfer


  3. #3
    Join Date
    Dec 2000
    Location
    Los Angeles, CA
    Posts
    34

    Re: tough modal problem

    What don't you like about creating your own message box? That seems like the easiest answer, and it should be very solid.

    The only other approach I could think to start trying is looking for API's that would do it, but API's can be less stable than native VB code.

    Nathan


  4. #4
    Join Date
    Dec 1999
    Location
    Dublin, Ireland
    Posts
    1,173

    Re: tough modal problem

    The thing about message boxes and modal forms is that they suspend the thread that their in from doing anything else whilst they are up.
    The only way you can continue to read from a COMM port whilst a modal form or messagebox is up is to have your comm reading process running in its own thread.
    There are good examples of launching processes in their own thread in VB on this site. Do a search for CreateThread

    HTH,
    Duncan

    -------------------------------------------------
    Ex. Datis: Duncan Jones
    Merrion Computing Ltd
    http://www.merrioncomputing.com
    '--8<-----------------------------------------
    NEW -The printer usage monitoring application
    '--8<------------------------------------------

  5. #5
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: tough modal problem

    You can use either your custom msgbox, or make msgbox automatically disappear after certain time. Here is 2 ways of doing it

    1
    Private Declare Function FindWindow Lib "user32" _
    Alias "FindWindowA" (ByVal lpClassName As String, _
    ByVal lpWindowName As String) As Long
    Private Declare Function SendMessage Lib "user32" _
    Alias "SendMessageA" (ByVal hWnd As Long, ByVal _
    wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

    Private Const WM_CLOSE = &H10

    Private Const MsgTitle As String = "Test Message"

    Private Sub Command1_Click()
    With Timer1
    .Interval = 2000
    .Enabled = True
    End With
    MsgBox "I should disappear in two seconds.", , MsgTitle
    End Sub

    Private Sub Timer1_Timer()
    Dim hWnd As Long
    Timer1.Enabled = False

    hWnd = FindWindow(vbNullString, MsgTitle)
    Call SendMessage(hWnd, WM_CLOSE, 0, ByVal 0&)
    End Sub
    '================================
    2.
    'add reference to Windows Scripting host Object model

    Dim wshShell As New IWshShell_Class
    Dim lngReturn As Long
    Dim intSeconds2Wait As Integer
    intSeconds2Wait = 1
    lngReturn = wshShell.Popup("Place Your Text Here", intSeconds2Wait)



    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

  6. #6
    Join Date
    Mar 2001
    Posts
    7

    Re: tough modal problem

    What I did today was called the message box API. That fixed me up. Thanks for your help. Does anyone know how to unload a msgbox by way of code (API msgbox preferred)? I could just use a form otherwise.


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