谁能给我详细说明一下CNNOTIFY的用途,谢谢!(150分)

  • 主题发起人 主题发起人 kissdelphi
  • 开始时间 开始时间
K

kissdelphi

Unregistered / Unconfirmed
GUEST, unregistred user!
谁能给我详细说明一下CNNOTIFY的用途(最好有例子),谢谢!
 
http://www.delphibbs.com/delphibbs/dispq.asp?lid=799967
http://www.delphibbs.com/delphibbs/dispq.asp?lid=318679
 
TCDateTimePicker = class(TDateTimePicker)
private
procedure CNNotify(var Message: TWMNotify); message CN_NOTIFY;
end;

{ TCDateTimePicker }

function IsBlankSysTime(const ST: TSystemTime): Boolean;
type
TFast = array [0..3] of DWORD;
begin
Result := (TFast(ST)[0] or TFast(ST)[1] or TFast(ST)[2] or TFast(ST)[3]) = 0;
end;

procedure TCDateTimePicker.CNNotify(var Message: TWMNotify);
begin
with Message, NMHdr^ do
begin
Result := 0;
if (code = DTN_DATETIMECHANGE) and
(PNMDateTimeChange(NMHdr)^.dwFlags = GDT_VALID) and (not DroppedDown) and
(not (ShowCheckBox and IsBlankSysTime(PNMDateTimeChange(NMHdr)^.st))) then
DateTime := SystemTimeToDateTime(PNMDateTimeChange(NMHdr)^.st);
end;
inherited;
end;
/////////////////
procedure TpnCustomListView.CNNotify( var Msg: TWMNotify );
var
Item: TListItem;
R: TRect;
P: TPoint;
begin
with Msg.NMHdr^ do
begin
Msg.Result := 0;

case code of
lvn_BeginLabelEdit: //编辑 Item
begin
if not FEditOnRowClick then
begin
// This notification message is received when the list view is about
// to put the main item into edit mode. Only go into edit mode if
// the mouse was clicked on the main item.
Item := TListItem( PLVDispInfo( Pointer( Msg.NMHdr ) )^.item.LParam );
R := Item.DisplayRect( drLabel );

GetCursorPos( P );
P := ScreenToClient( P );

if not PtInRect( R, P ) or not CanEdit( Item ) then
Msg.Result := 1;
end;
end;


else
inherited;
end; { case }
end;
end; {= TpnCustomListView.CNNotify =}
///////////////////////////////////
CN_Notify is one of the Control Notification Messages.

CN_Notify message is sent to a Windows common control in response to a WM_Notify
message. Windows send the WM_Notify message to the owner of a common control to
inform it of an event in the control. The NmHdr field points to a TNmHdr recourd,
which contains the notification code. Delphi handles the events that gave rise
to the common control notifications, so the default response to the CN_Notify
message is to do nothing, and there is little reason to handle this message your
self.

The message type is TWMNotify.

TWMNotify = packed record
Msg: Cardinal;
IDCtrl: Longint;
NMHdr: PNMHdr;
Result: Longint;
end;

PNMHdr = ^TNMHdr;
$EXTERNALSYM tagNMHDR}
tagNMHDR = packed record
hwndFrom: HWND;
idFrom: UINT;
code: Integer; { NM_ code }
end;
TNMHdr = tagNMHDR
 
多人接受答案了。
 
后退
顶部