Solved

Force messagebox to be on top

Posted on 2004-08-13
8
596 Views
Last Modified: 2010-05-18
Hi.
I'm developing av project in VB.NET

I'm using a SDK from a supplier which trough a event-drive-model which allows me to interact with the program..(long story..)
..
..
..
Whenever im using a msgbox function the msgbox always comes on the bottom or "under" the main app. as a separate window.
So the user have to click in the taskbar to move on or use alt-tab so he can address the message.
(see what i mean)?

Is'nt there a msgbox API around that i can use and connect to my app somehow?
or
get the handle of the msgbox and "bring it to top"?

(badly explained on a hot friday in norway but hope U get the picture)

thanks
perove



0
Comment
Question by:perove
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 18

Expert Comment

by:DotNetLover_Baan
ID: 11794097
Is your MainApplication form is set to   "TopMost = True"...  this may be the reason.
Because.. MsgBox()  is bydefault Topmost...

-Baan
0
 
LVL 19

Expert Comment

by:Desp
ID: 11794149
yes you can find a window and bring that window to top by playing with APIs


Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    Declare Function BringWindowToTop Lib "user32" Alias "BringWindowToTop" (ByVal hwnd As Long) As Boolean

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click
        Dim h As Long
        h = FindWindow(Nothing, "YOUR MESSAGE BOX CAPTION") ' this will bring your messagebox on top
        BringWindowToTop(h)
    End Sub
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 11795710
Are you talking about a System Model dialog box?

Bob
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 9

Author Comment

by:perove
ID: 11808557
DotNetLover_Baan/TheLearnedOne

My MainApp does not have a Form.
Let me try to explain a bit better.


It is the same way as if I Create a new exe project where i include a referce to Excel (with events)
When I start my VB.NET app all it does is start excel.

And  I can use the Excel-Events (in my .net app) to f.ex validate a cell input, but if i want to give the user a feedback that the input is not valid the msgbox comes in a "own window".
Clearer now?

Desp:
Can I use this code when the msgbox is already there? I mean... the the code will halt until the msgbox buttin is pushed.

perove





0
 
LVL 9

Author Comment

by:perove
ID: 11808754
Ive made a small ex. using EXCEL and VB-.NET
Create a new standard exe project using sub main as the startup..


Public Class Class1
    Private WithEvents XLAPP As Excel.Application
    Private bolRunning As Boolean = True



    Public Sub New()
        XLAPP = New Excel.Application
        XLAPP.Visible = True
        While bolRunning = True
            System.Threading.Thread.Sleep(1)
            System.Windows.Forms.Application.DoEvents()
        End While

    End Sub

    Private Sub XLAPP_SheetActivate(ByVal Sh As Object) Handles XLAPP.SheetActivate

    End Sub

    Public Shared Sub Main()
        Dim XLClass As Class1 = New Class1
    End Sub

    Private Sub XLAPP_NewWorkbook(ByVal Wb As Excel.Workbook) Handles XLAPP.NewWorkbook
        MsgBox("Im activated") 'This is the one I want to 'hook up' in excel not as a "alone window" from the exe project
    End Sub
End Class

****

My original problem was is another library that are .NET (not COM) (if that is a differnce)

perove


0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 250 total points
ID: 11809069
I don't think that this is possible, without a lot of Windows magic, that I wouldn't be able to help you with.

Bob
0

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question