How to make a Xojo Window to stay on top of Excel Workbook.

I am following Eugene Dakin book on programming Excel with Xojo. Everything is going great but I cannot find a way to have a xojo window, that called and opened the workbook, to stay on top of the workbook. In this case, on top of worksheet1. which is the first visible sheet when my application opens.
I tried the different Windows Types but could not get the window on top.

I looked into the language reference to see if there was any other method to bring the window on top of the workbook, but failed to find anything suitable.
The question might be generalized to understand if you have more than one window opened and want to choose (programmatically) which one goes on top of the workbook.

Any input will be appreciated.
Thanks.
Luis.

Hello Luis,

Glad to hear that you like the book.

Here is an example which uses declares to Bring the Xojo Application to the front of Excel.

When the pushbutton is pressed a new Excel instance is started and some text is placed in cell A1 in Excel. A method called BringToFront is created to move the Xojo window in front of all other windows. This example also allows the user to click on Excel to regain focus.

Let me know if this helps.

where can I get this book?

Hi Chris. The book is usually at RBLIbary.com, and for some reason it doesn’t seem to be there. I will followup with the administrator @Norman Palardy.

The table of contents for this (and other Xojo books) can be viewed at Scientific Specialties.

Thanks Eugene, I will definitely get one as a scientist I am very interested with such help.

Hello Eugene,
Thanks for your answer. Yes it helps. It does what I was trying to do.
Everytime I get stuck and this forum answers my questions I realize how little I know.!!! :frowning:

Question: where I can find more info regarding the different parts of the code you recommend?:

const HWND_TOPMOST = -2 Window1.BringToFront(Window1)

I am not asking you to explain every line above, just some suggestions on where I can get info about the different parts of the code (links to sites, documentation).

I would like to understand better the use of “const”, the “-2” etc. in this case. This will allow me to apply it to other situations as well.

Thanks once again and great book!!

Luis.

That line is a mistake on my part, the constant (const HWND_TOPMOST = -2) does not need to be there. My apologies. I was piecing parts of code together and didn’t delete it before I placed it online.

The BringToFront method was created to allow multiple calls to bring Window1 to the front. Window1.BringToFront is the method name, and (Window1) is the name of the window to be brought to the front.

There are many declares available for the Windows Operating System that can be viewed on the Microsoft Developer Nework, and there is a book on Xojo Declares , and Third Party Products to help you with pre-built solutions. Bob at BKeeney has training videos. There are many learning options.

Xojo has a very good online community, and feel free to ask questions on the forum! There is always something new and exciting with Xojo.

Hi Chris,

Here is the link for the book I Wish I Knew How To…Program Excel 2010 with Xojo in Windows

Sincerely,

Eugene

You wrote a book Eugene? Damn, I’ve been making it up as I go :slight_smile:

Not one book, Eugene has written various very interesting books.
RBLibrary.com - Eugene Dakin