Attribute table and property page problem set

zhaozj2021-02-08  221

Attribute table and property page problem set

First, the ID of the "Application" button

"Apply" ID is: ID_Apply_NOW (actually 0x3021).

In the AFXRES.H file in the VC Include directory, the definition is as follows:

... # define id_apply_now 0x3021 # define id_wizback 0x3023 # define id_wiznext 0x3024 # define id_wizfinish 0x3025 ...

Second, add a control to the property sheet

Each property page has its own control settings. Only the control shared the standard button in the attribute table. If you want to add an edit control, a preview button or other control, you have to do it when you run. The following code shows how you add an editing control.

Step 1: Delicate your own class from CpropertySheet We can't use the CPROPERTYSHEET class directly because we need to add a member variable. If you are derived, there is no subclass of CPROPERTYSHEET before.

Step 2: Adding a member variable Add a member variable to the CPropertySheet derived class. The editor control will be newly created and used using this member.

PUBLIC:

Cedit m_edit;

Step 3: New Edit Controls in OnInitDialog Upload the OnInitDialog () function and add a new editing control to the new edit control in this function. The base class version of the call function is a good idea before doing the details of the derived class.

The primary table first adjusts the size to accommodate the new editing control. Editing is built in the position you desire. WS_EX_CLIENTEDGE gives it a 3D style. Editing controls can be built more than other controls. We call setFont () to install this property and set the settings as the properties.

The text value in the editor control can be set or acquired using the m_edit object.

Bool cmypropsheet :: oninitdialog ()

{

Bool Bresult = CPROPERTYSHEET :: OnInitdialog ();

CRECT RECTWND;

GetWindowRect (RectWnd);

SetwindowPos (NULL, 0, 0,

RectWnd.Width () 100,

RectWnd.Height (),

SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);

M_EDit.createex (WS_EX_CLIENTEDGE, _T ("Edit"), NULL,

WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER,

RectWnd.Width (), 20, 80, 24, m_hwnd, 0, 0);

m_edit.setfont (getFont ());

CenterWindow ();

Return BRESULT;

}

Third, change Tab's label font

We can use the TAB control to change the font and use the setFont () function in the CWnd class to redraw this tag. The following code is the most common, and it is not necessary to restore the size of the TAB control or the property table. The font set by this work is smaller than the font of the TAB control. OnInitDialog () in the derived class of CPROPERTYSHEET is the best place to place these code.

// m_fontedit is a member variable

// Newly create a bold font

M_FONTEDIT.CREATEFONT (-8, 0, 0, 0, 700, 0, 0, 0, 1,

0, 0, 0, 0, _t ("MS SANS Serif");

GetTabControl () -> setFont (& m_fontedit);

Fourth, change the text of the Tab tag

The label is used by the TAB control in the property table, which is obtained from the title of the property sheet. To change this tag at runtime, we have to first get the pointer to the TAB control object, and then call its setItem () function. The following code tells the first Tab tag. To change this label at runtime, we have to first get a pointer to the tab control object and call its function The following code changes the label of the first tab.CString sCaption = _T ( "New Caption").;

Tc_item tcitem;

Tcitem.mask = TCIF_Text;

Tcitem.psztext = (lptstr) ((lpctstr) scAption;

GetTabControl () -> setItem (0, & tcitem);

V. Hide "Apply" button

When the property is displayed, the default "Skin" button is visible. Often, we do not need the "Application" button in all procedures. How to remove it? Add a PSH_NOApplyNow tag after you have a new property table object.

PropSheet.m_psh.dwflags | = psh_noapplynow;

Six, hidden standard buttons

The following code hides the "OK" button. The standard button ID is IDOK, IDCANCEL, IDHELP, and ID_APPLY_NOW.

CWND * PWND = Getdlgitem (IDOK);

PWND-> ShowWindow (False);

转载请注明原文地址:https://www.9cbs.com/read-3427.html

New Post(0)