View Poll Results: Is the MSGBOX function usefull??

Voters
20. You may not vote on this poll
  • No It really isn't, it su**s

    7 35.00%
  • Sometimes, not always

    2 10.00%
  • Yeh really!

    11 55.00%
  • I haven't got an opinion

    0 0%
Results 1 to 21 of 21

Thread: Why is the MSGBOX so stupid??

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2001
    Posts
    574

    Why is the MSGBOX so stupid??

    Why is the msgbox so stupid.

    I have created a messenger. Now sometimes a user has to be noticed about something (and maybe click on a button). I used the msgbox, but I found out that the whole code wait until a button is pressed, so If a user doesn't react soon enoug some data will be used later. I use a function to see if a user is still online to confirm to a question each time. I give it 10 seconds of time. When the users has a msgbox open for this 10 seconds the program can't react on time so the program thinks it is offline. How to fix this??

    I have made my own msgbox form, but the problem is that some subs must wait until a button is pressed. I used an array of forms. But if a program (sub) has to wait until a button is pressed I can' t call the sub again. Anyone has got any idea how to fix this. I also tried to use activex etc, but nothing.

    Every idea could be helpfull

  2. #2
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    I guess the best way is to look for a better way to see if it's still online. If "online" for you means that the user is in front of the computer doing something I can guarantee that I would be offline in the second MsgBox you open! Don't bother the user if you want your app to keep running. I mean it... I could answer to the messenger one time, two times, even three times... but you bet I'd kill the process and uninstall the messenger when the fourth msgbos appears.

    One way you can use to know if the user is infront of the computer is to detect mouse movements or keystrokes. There are several examples of this on the forums, search for them.
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  3. #3
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    Well

    I agree with MC Brain.. Why not use a label on the form, instead of popping up all the MsgBoxes...

    Use MsgBox sparingly, most users won't even read the text that is displayed
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2001
    Posts
    574
    I Think I wasn't clear.

    It isn't that the messenger is opening the msgboxes. If you for example delete a contact you get a messagebox or when I want to play a game with a contact wich hasn't the plugin it gets a messagebox, or when an error happends or when I give you a new contact. SO the messageboxes can comes at random. But when The program asks are you offline I only want to check if the program on the other computer is still running. Cause when I have winscok opened and someone just pulls the cable out the messenger (even not MSN messenger) will recognize you go offline, so that;s why I want to check once in a while.

    I hope this makes it a little more clear

  5. #5
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    In that case send signals of "I'm still alive" every 30 seconds (winsock to winsock)... the user doesn't even have to know that this is going on. If it's 1 minute or 2 minute (set yhe timeout you want) without getting this "signals", then you could assume the other user went offline.
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2001
    Posts
    574
    That's kinda what I'm doing. Each 10 secons I check one of my buddies in my list and gives the other computer 10 seconds to reply (in case of bad connection). But when the user has (one way or another) a msgbox opened I don;t get the response in time cause the program waits until the msgbox dissapears. How to change this, to make this work??

  7. #7
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    Change these MsgBox to the one you had coded.
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2001
    Posts
    574
    That also doesn't works.

    Cause when the user only has to click ok it works. But when I want for example a Yes,No or Cancel I have the same problems, so has anyone got a solution??

  9. #9
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    What's the problem with that? Code your MsgBox for those buttons also.
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  10. #10
    PowerPoster cafeenman's Avatar
    Join Date
    Mar 2002
    Location
    Florida
    Posts
    2,819
    There is a lot of source code available for custom messageboxes that emulate the VB msgbox. Just do a search on the source code sites. I'm serious. There are a lot of them. Most that I've seen aren't that great, but they'll get you started and you can improve them.

  11. #11
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Curiouser still...why is 'sucks' censored in the poll?
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  12. #12

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2001
    Posts
    574
    The problem is:

    I use a sub. Then I open my own msgbox. So far so good. But then the sub needs to wait for a button to be clicked. SO I show the form modal : frm.show 1. But now when a new request for that sub comes it does nothing anymore. I just waits till the old form is cleared. That's the problem. Even when I use Doevents

  13. #13
    PowerPoster cafeenman's Avatar
    Join Date
    Mar 2002
    Location
    Florida
    Posts
    2,819
    VB Code:
    1. Sub ShowMessage()
    2. Static MsgVisible As Boolean
    3.  
    4. If MsgVisible Then Exit sub
    5.  
    6. MsgVisible = True
    7.  
    8. ' show your msgbox
    9.  
    10. MsgVisible  = False
    11.  
    12. End Sub

  14. #14

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2001
    Posts
    574
    Well caffeenman.

    I could find a good sample of a messagebox (tried for example www.planet-source-code.com) so that's why I started this treath.
    And sucks is censored cause I though it would make it a little nicer and still everyone knows what I mean.

  15. #15

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2001
    Posts
    574
    Sub ShowMessage()
    Static MsgVisible As Boolean

    If MsgVisible Then Exit sub

    MsgVisible = True

    ' show your msgbox

    MsgVisible = False

    End Sub


    Well I don't know what this might be but it isn''t what I want. I will give you some of my code : It might be kinda messy but it's in beta :

    Public Function ownmsgbox(message As String, title As String, cmdcancel As Boolean, cmdyes As Boolean, cmdno As Boolean, cmdok As Boolean, Optional pic As Byte = 0) As integer
    Dim frm As New frmmsgbox
    frm.Caption = title
    frm.label1.caption=message

    frm.value=-1
    frm.cmdok.Visible = cmdok
    frm.cmdcancel.Visible = cmdcancel
    frm.cmdja.Visible = cmdyes
    frm.cmdnee.Visible = cmdno
    frm.show 1

    Set ownmsgbox = frm.value
    End Function

  16. #16
    Junior Member
    Join Date
    Jun 2002
    Posts
    24
    *bump*
    _____________________________

    strength respects strength
    _______________A P J Abdul Kalam

  17. #17
    Swatty
    Guest
    Maybe you can use the Zorder of the form.

    I am not working in VB anymore but play with it .

    I think you can set it like

    frm.show
    frm.Zorder 0

    this way it should stay on top and other events would still work.

    check in its lost focus event to reset it to topform.

    You'ld have to change some code though.

  18. #18
    Swatty
    Guest
    In reply to the poll.

    I voted it isn't stupid.

    Just use it for what it is made.

  19. #19
    Frenzied Member oh1mie's Avatar
    Join Date
    Sep 2001
    Location
    Finland
    Posts
    1,043
    There is another msgbox via API, it works diifferently.

    You can use timer on your own msgbox, than it's unload after 10 seconds.
    oh1mie/Vic


  20. #20

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2001
    Posts
    574
    I couldn't get it working. Anyone a good example for my problem??

  21. #21
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    it isn't only standard in VB, it's standard in c++ too. if you really don't want to build your own messagebox then learn to multithread.
    Remember, if someone's post was not helpful, you can always rate their post negatively .

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