Getprop and setprop usage

Source: Internet
Author: User
In Baidu encyclopedia, getprop and setprop are interpreted as follows:
Getprop

Function: This function retrieves data handles from the attribute list of a given window. The given string identifies the handle to be retrieved. The string and handle must have been added to the attribute table when the setprop function was called the previous time.

Function prototype: handle getprop (hwnd, lpctstr lpstring );

Parameters:

Hwnd: indicates the window to search for Attribute tables.

Lpstring: A string pointer that ends with null or contains an atom that identifies a string. If this parameter is an atom, it must be created using the globaladdatom function. The atom is a 16-bit data value, which must be placed in the low rate of the lpstring parameter, and the high word must be o.

Returned value: If the attribute table contains a given string, the returned value is the relevant data handle. Otherwise, the return value is null.

Setprop

Function: adds a new item to the Attribute Table of the specified window or modifies an existing item. If the specified string is not in the Attribute Table, the new item is added. The new item contains the string and handle. Otherwise, the entire front handle of the string is replaced with the specified handle.

Function prototype: bool setprop (hwnd, lpctstr lpstring, handle hdata );

Parameters:

Hwnd: The handle pointing to the window. The properties table of the window needs to receive a new item.

Lpstring: A string pointer that ends with null or contains an atom that identifies a string. If this parameter is an atom, it must have been previously created using the globaladdatom function. The atom is a 16-bit data value. It must be placed in the lpstring parameter's low-level word, and the high-level word must be o.

Hdata: the handle to copy data to the Attribute Table. This data handle can identify any value useful to the application.

Returned value: if the data handle and string are added to the Attribute Table, the returned value is non-zero. If this function fails, zero is returned. To obtain more error information, call the getlasterror function.

Note: before clearing the window (that is, before processing the wm_destroy message), the application must clear all the items it adds to the Attribute Table. The application must use the removeprop function to clear these items.


You can use the getprop and setprop functions to find the window of the started program.
Use setprop to add strings to the properties table of the window. You can add the following statement at the end of the oninitdialog function in the dialog box.
: Setprop (this-> m_hwnd, "string", (handle) 1 );
Use getprop to search for strings in the properties table of the window.
: Getprop (hwnd, "string ")
Bool cautorunapp: ensureoneinstance ()
{
M_hmutex = createmutex (null, false, _ T ("autorun "));
If (m_hmutex)
{
If (getlasterror () == 183/* error_already_exists */)
{
Closehandle (m_hmutex );
Hwnd hwndprevious =: getwindow (: get1_topwindow (), gw_child );
While (: iswindow (hwndprevious ))
{
If (: getprop (hwndprevious, exeprop ))
{
If (: isiconic (hwndprevious ))
{
: Showwindow (hwndprevious, sw_restore );
: Setforegroundwindow (hwndprevious );
}
Else
{
: Setforegroundwindow (: getlastactivepopup (hwndprevious ));
}
Return false;
}
Hwndprevious =: getwindow (hwndprevious, gw_hwndnext );
}
Return false;
}
}
Return true;
}

 

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.