| |

VerySource

 Forgot password?
 Register
Search
Author: cnrealm

Form sticking problem

[Copy link]

0

Threads

11

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-7-5 23:00:02
| Show all posts
To:cnrealm
Reply:光明之行者

I don't know what program, why should I implement such a function?
Reply

Use magic Report

0

Threads

4

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-7-20 12:30:01
| Show all posts
The original poster means this: after the main form has the focus, the sub form is still visible.

I think this implementation is mainly to reload the virtual function CreateParams of Form and change the member WndParent of TCreateParams.
class TForm2: public TForm
{
__published: // IDE-managed Components
private: // User declarations
protected:
    virtual void __fastcall CreateParams(TCreateParams&Param);
public: // User declarations
    __fastcall TForm2(TComponent* Owner);
};
void __fastcall TForm2::CreateParams(TCreateParams&Param)
{
//Call the function of the base class
TForm::CreateParams(Param);
Param.ExStyle |= WS_EX_TOPMOST;

//The most important thing here is that as long as Param.WndParent is not Application->Handle,
//You don't have to use GetDesktopWindow(), you can use other windows.
Param.WndParent = GetDesktopWindow();
}
Reply

Use magic Report

0

Threads

11

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-8-2 10:00:01
| Show all posts
Interesting, add a Timer control to the subform, BringToFront when the subform loses focus, haha.
Reply

Use magic Report

0

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-8-2 18:45:01
| Show all posts
Form A B C D;
If it is required that A is always in front of B, B is always in front of C, and C is always in front of D. I don't know how to do this in Windows system.

There is only one application at the top, plus the top on the desktop, which means that the three forms of ABC are arranged in sequence, and multiple forms are always arranged in one order. I don't know how to do this.
Reply

Use magic Report

0

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 Invalid IP Address

Post time: 2020-8-2 19:30:01
| Show all posts
The function of the SetWindowPos function is to move a window in three-dimensional space. With it, you can change the position of a window, even on the Z axis (the Z axis determines the relationship between a window and other windows), and you can also change the window size of. In order to realize the TopMost type of window, we only need to call this function, put the window in front of all windows and always keep it on top.

DWORD_PRT SetWindowPos(HWND hWnd,HWND hInsertAfter,int x,int y,int cx,int cy,UINT nFlag)

Table 1 Parameter explanation of SetWindowPos function

Parameter name Parameter meaning
hwnd The handle of the window to be moved (you can use the hwnd attribute of the form)
hWndInsertAfter marks on how to place the window on the Z axis (see Table 2 for details)
x is equivalent to the Left property of the window
y is equivalent to the Top property of the window
cx is equivalent to the Right property of the window
cy is equivalent to the Bottom property of the window
wFlags flags on how to move the window (see Table 3 for details)

Table 2 Possible values ​​and meanings of the HWndInsertAfter parameter

Possible values ​​of hWndInsertAfter Function
The handle of a window puts the window behind the window specified by the handle
HWND_BOTTOM(1) Put the window at the end of the Z axis, that is, behind all windows
HWND_TOP(0) Put the window in front of the Z axis, that is, in front of all windows
HWND_TOPMOST(-1) makes the window a "TopMost" type window, this type
The window is always in front of other windows, so it is closed
HWND_NOTOPMOST(-2) Put the window in all "TopMost" types
Behind the window, in front of other types of windows

Table 3 Possible values ​​and meanings of wFlags parameters

Possible values ​​of wFlags parameter Function
SWP_DRAWFRAME(&H20) Redraw the window and all its contents after moving the window
SWP_HIDEWINDOW(&H80) Hides the window. After the window is hidden, it will neither appear on the screen nor at any time.
Taskbar, but it is still active
SWP_NOACTIVATE(&H10) does not activate the window after the window is moved, of course, if the window is before the move
Active exception
SWP_NOCOPYBITS(&H100) When the window is moved, do not redraw any content on it
SWP_NOMOVE(&H2) does not move the window (ie ignore the X and Y parameters)
SWP_NOSIZE(&H1) does not change the window size (ie ignores the Cx and Cy parameters)
SWP_NOREDRAW(&H8) Do not remove the image of the window in its former position
from the screen. In other words,leave behind a ghost image
of the window in its old position
SWP_NOZORDER(&H4) does not change the window to listen to the Z axis position (that is, ignore the hWndInsertAfter parameter)
SWP_SHOWWINDOW(&H40) display window (SWP_HIDEWINDOW must be used before
Hidden window)


The parameters are very complicated, and you will find the answer if you look at it slowly.
Reply

Use magic Report

2

Threads

7

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-8-8 11:45:01
| Show all posts
The function pays off, and finally solved it, thank you一天世界
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list