Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Show form (Topmost), running code (ADO, API etc), but not active (I not stealing keyboard focus).

Posted on 2009-04-20
Medium Priority
Last Modified: 2012-05-06
HI Guys

I am trying to write a word shorthand autocompletion program, and need a form with a database driven list box to provide expansion strings. as the user types
eg. atineof =  and there is no evidence of

My problem, is that my app needs to remain on top, but not be stealing the keyboard focus,

I believe that vb NET has the SHOWNOACTIVATE  or the SHOWWITHOUTACTIVATION stuff,
but how do I implement this in VB6.

Some code I have borrowed from the Net is included here,

private const int SW_SHOWNOACTIVATE = 4;
private const int HWND_TOPMOST = -1;
private const uint SWP_NOACTIVATE = 0x0010;

[DllImport("user32.dll", EntryPoint = "SetWindowPos")]
static extern bool SetWindowPos(
int hWnd, // window handle
int hWndInsertAfter, // placement-order handle
int X, // horizontal position
int Y, // vertical position
int cx, // width
int cy, // height
uint uFlags); // window positioning flags

static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);

static void ShowInactiveTopmost(Form frm)
ShowWindow(frm.Handle, SW_SHOWNOACTIVATE);
SetWindowPos(frm.Handle.ToInt32(), HWND_TOPMOST,
frm.Left, frm.Top, frm.Width, frm.Height,

This may be C++ or VB.NET code.

Can some body please help me with a good vb6 method that works

Many thanks

Question by:simpath
LVL 86

Accepted Solution

Mike Tomlinson earned 1000 total points
ID: 24184959

Author Closing Comment

ID: 31572212
Dear Idle Mind

Thank you so much for your prompt response and help = AWESOME


Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
Having trouble getting your hands on Dynamics 365 Field Service or Project Service trial? Worry No More!!!
Viewers will learn the different options available in the Backstage view in Excel 2013.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

571 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