Before Delphi, please refer to the following section of the BCB anti-Replay Function in the same window as Delphi. I have never succeeded for a long time and have little knowledge of Delphi, more than enough.

Source: Internet
Author: User
Before Delphi, please refer to the following section of the BCB anti-Replay Function in the same window as Delphi. I have never succeeded for a long time and have little knowledge of Delphi, more than enough. Delphi/Windows SDK/API
Http://www.delphi2007.net/DelphiDB/html/delphi_20061218170853237.html
// Anti-Reopen window
Bool OpenForm (tform * wform)
{
Int I;
Bool formexist;
If (wform = NULL)
Return false;
Formexist = false;
For (I = 0; I <screen-> formcount; I ++)
If (screen-> forms [I]-> classtype () = wform-> classtype ())
{
Formexist = true;
Break;
}
If (formexist = false)
Return formexist;
If (wform-> windowstate = wsminimized)
Showwindow (wform-> handle, sw_showna );
If (! Wform-> visible)
Wform-> visible = true;
Wform-> bringtofront ();
Wform-> setfocus ();
Return true;
}

Function OpenForm (wform: tform): Boolean;
VaR
I: integer;
Begin
Result: = false;
If wform = nil then
Exit;
For I: = 0 to screen. formcount-1 do
If screen. Forms [I]. classtype = wform. classtype then
Begin
Result: = true;
Break;
End;
If not result then exit;
If wform. windowstate = wsminimized then
Showwindow (wform. Handle, sw_showna );
If not wform. Visible then
Wform. Visible: = true;
Wform. bringtofront;
Wform. setfocus;
Result: = true;
End;

I am very grateful. I have put this generation of code in private, but it cannot be accessed. Why ???

I am very grateful. I have put this generation of code in private, but it cannot be accessed. Why ???
========================================================== ========================================================== =
To add the function to the private of tform1, you must modify the precedingCodeIs

Function tform1.openform (wform: tform): Boolean;

Unit unit1;

Interface

Uses
Windows, messages, sysutils, variants, classes, graphics, controls, forms,
Dialogs;

Type
Tform1 = Class (tform)
Private
{Private Declarations}
Function OpenForm (wform: tform): Boolean;
Public
{Public declarations}
End;

VaR
Form1: tform1;

Implementation

{$ R *. DFM}

{Tform1}

Function tform1.openform (wform: tform): Boolean;
VaR
I: integer;
Begin
Result: = false;
If wform = nil then
Exit;
For I: = 0 to screen. formcount-1 do
If screen. Forms [I]. classtype = wform. classtype then
Begin
Result: = true;
Break;
End;
If not result then exit;
If wform. windowstate = wsminimized then
Showwindow (wform. Handle, sw_showna );
If not wform. Visible then
Wform. Visible: = true;
Wform. bringtofront;
Wform. setfocus;
Result: = true;
End;

End.


In Delphi, what is the difference between this parameter in private, public, or directly with procedure ??

Private, which can only be used by the class itself or other classes in the same unit
Public, all...

This type of function is directly written together with procedure and is available to all users. The difference between this function and public is that it does not need to be accessed through class instances.

We recommend that you buy or use it as an entry book online.


Multiple links.
It's a little short.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.