Is there a way to center the message box over the current form ?

This is not a feature that is built into the MessageBox class and the message box is always centered over the desktop.  I have found some examples written in C# on how to do this but they run for many lines of code and my C# training is not far enough along to where I can translate them into Visual COBOL.  Has anyone written a routine for this in Visual COBOL ?  Our other option would be to write our own message class or use a third-party control that allows positioning.

Tags:

Parents
  • Thanks for the solution!  I can center messages now over my forms.

    Maybe this isn't something we need to worry about but when I build the C# project I get a warning that System.AppDomain.GetCurrentThreadId is obsolete and has been deprecated because it does not provide a stable id when managed threads are running on fibers (lightweight threads).  I get a similar warning when I build the COBOL MsgBox project.

    In the COBOL project, the line giving the error is:

    set threadid to type AppDomain::GetCurrentThreadId

    I replaced this with:

    set threadid to type System.Threading.Thread::CurrentThread::ManagedThreadId

    but this always returns a threadid = 1 and it does not center the message box.

    I'm not sure if we need to get ManagedThreadId working or if we should just use GetCurrentThreadId.

Reply
  • Thanks for the solution!  I can center messages now over my forms.

    Maybe this isn't something we need to worry about but when I build the C# project I get a warning that System.AppDomain.GetCurrentThreadId is obsolete and has been deprecated because it does not provide a stable id when managed threads are running on fibers (lightweight threads).  I get a similar warning when I build the COBOL MsgBox project.

    In the COBOL project, the line giving the error is:

    set threadid to type AppDomain::GetCurrentThreadId

    I replaced this with:

    set threadid to type System.Threading.Thread::CurrentThread::ManagedThreadId

    but this always returns a threadid = 1 and it does not center the message box.

    I'm not sure if we need to get ManagedThreadId working or if we should just use GetCurrentThreadId.

Children
No Data