Article View: borland.public.cppbuilder.nativeapi
Article #15818Re: force a form to be on top
From: Ron Dafoe
Date: Fri, 13 Jun 2003 17:04
Date: Fri, 13 Jun 2003 17:04
100 lines
3445 bytes
3445 bytes
Mike,
Try this Win32 call in you form's Show event.
SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0,SWP_NOSIZE | SWP_NOMOVE);
Where hWnd is the handle property of your form.
If this doesn't work as is then try some variations on the parameters or
event from which it is called after you read through the Win32 documentation
for the function.
There are more complex methods for resolving this type of problem. I'd
rather not post them unless this doesn't work for you so let me know.
Regards,
Ron
"Mike" <mike@joylimsli.com> wrote in message
news:3ee30abc@newsgroups.borland.com...
> Hello,
>
> I had create a DLL (check.dll) for my customers. They include this to
their
> software project. My DLL shows a form, weather this software products is
not
> registrated.
>
> In my DLL i show this form via a dynamical function (CheckVersion) by
> folliwing code:
>
> TForm1 *form = new TForm1(NULL);
> form->ShowModal();
> delete form;
>
> On my computer this works fine and the window is on top.
>
> My customer use following code to load my dll and to start the function in
> the dll which check weather a function is registered:
>
> this is pcs7 code:
>
> #include "apdefap.h"
> void OnClick(char* lpszPictureName, char* lpszObjectName, char*
> lpszPropertyName)
> {
> #pragma code ("user32.DLL");
> HWND FindWindow(LPCTSTR lpClassName, LPCTSTR lpWindowName);
> BOOL BringWindowToTop(HWND hWnd);
> #pragma code();
>
> #pragma code ("check.DLL");
> int CheckVersion();
> #pragma code();
>
> int val = CheckVersion();
>
> if (val == -1)
> {
> // nicht registriert
> }
> else
> {
> // registriert
> #define PIC_1 "Bild_1.pdl"
> SSMChangeWorkField(SSMGetScreen(lpszPictureName),PIC_1,TRUE);
> }
> }
>
> On my customer PC my Code works fine to, but my window of the DLL is not
on
> top, but it has to.
>
> Now i thought about how to force my form to be on top. So i use
>
> BEGIN_MESSAGE_MAP
> VCL_MESSAGE_HANDLER(WM_KILLFOCUS, TMessage, OnKillFocus)
> END_MESSAGE_MAP(TForm)
>
> and
>
> void __fastcall TForm1::OnKillFocus(TMessage& Msg)
> {
> Sleep(500);
> SetForegroundWindow(Handle);
> BringWindowToTop(Handle);
> }
>
> But when I compile my dll now, i get warning: (translated to english)
>
> W8027 Functions, which includes switch, will not be expand as inline
>
> As is try to use my dll now it does not work.
>
> Does anybody have any idea what to do, that my form is really on top?
>
> Mike
>
>
Technical Details
Message-ID:
<3eea03bd$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!newshosting.com!news-xfer1.atl.newshosting.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mailReferences:
<3ee30abc@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,937603d7f68e8363 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-06-13 10:10:00 PST From: "Ron Dafoe" <rdafoe@gleason.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <3ee30abc@newsgroups.borland.com> Subject: Re: force a form to be on top Date: Fri, 13 Jun 2003 13:04:12 -0400 Lines: 102 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 NNTP-Posting-Host: 198.204.123.4 Message-ID: <3eea03bd$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1055523773 198.204.123.4 (13 Jun 2003 10:02:53 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!newshosting.com!news-xfer1.atl.newshosting.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail