Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / allways ontop

Author
Message
Code eater
18
Years of Service
User Offline
Joined: 17th Feb 2008
Location: Behind You!
Posted: 29th Apr 2008 21:28
is it possible to make it so that my program allways appears infront of all other programsthat are running?
jinzai
19
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 29th Apr 2008 23:50 Edited at: 29th Apr 2008 23:50
Yes.

Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 30th Apr 2008 00:32
@jinzai

Sweet!

@Code Eater

To use the win32 api functions in DBC, you should set your application to windowed mode. Here's a variation of jinzai's code with that taken into account and also modified slightly for DBC. I load the DLL outside of the function just because I prefer to maintain management of the DLL ID numbers, their loading and deleting, and not leave it up to the function.
You could ignore my changes and leave everything as jinzai had it but get rid of

local user32 as integer
local hwnd as dword
local i as integer

and change 0x0043 to 67



Enjoy your day.
TDK
Retired Moderator
23
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 30th Apr 2008 01:59
Just to add, Jinzai's rather nice solution is for DBPro and this is the DBC board (there are no globals in DBC).

But, more importantly, it uses a DLL, so you do need DBC V1.2.0 or the enhanced version of an earlier DBC to use it - or Latch's modification.

TDK_Man

jinzai
19
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 30th Apr 2008 02:05
Yes, I work against a couple of things when I post stufff like that.

First, I have DBP...So, I am sort of in the blind about applicability, and such. Thanks Latch for applying those changes. Perhaps it would be a good idea to document these snippets somewhere, I've got a lot of them now.

Next, I actually do it that way myself...to the point of having a UDT just for Windows dlls, and I also keep them loaded all the time.

In the case of user32, kernel32 and GDI32...there is no point in deleting them because they are ever present already...they are Windows. There are literally hundreds of functions in user32 alone that involove almost every aspect of the application you care to care about, and more that you'd rather forget about. kernel32 is also full of useful functions.

The C runtime dll "msvcrt.dll" is quite powerful, too. You can almost write a C program using it, although you don't get C, just the library it uses.

The next thing usually invloves a flag, and SetWindowPos is taking two values that are defined literally in that snippet. The first is -1, which is the handle of the window you are inserting your window after in the Z-order. The value -1 is HWND_TOPMOST. This tells the function that you want to be the topmost window, no matter what. (Even when you are not the active window.) It makes your window the most obnoxious one, I think! The next value is the 0x0043, or 67. That is a combination of three flags that I pass to eliminate any moving or resizing of the window. The flags are SWP_NOMOVE(2) and SWP_NOSIZE(1) and SWP_SHOWWINDOW(64). That way, I do not need to know the x/y and x/y sizes to make the function call. (All I want to do is make it topmost.)
Code eater
18
Years of Service
User Offline
Joined: 17th Feb 2008
Location: Behind You!
Posted: 5th May 2008 18:32
thank you. just what i needed

Login to post a reply

Server time is: 2026-07-06 18:58:25
Your offset time is: 2026-07-06 18:58:25