uses CommCtrl;
var OldWindowProc: TWndMethod;
procedure TForm1.MyWindowProc(var Msg: TMessage); begin if Msg.Msg = CN_NOTIFY then begin case TWMNotify(msg).NMHdr.code of MCN_GETDAYSTATE: Memo1.Lines.Add(''''MCN_GETDAYSTATE'''');//點了翻页 MCN_SELECT, MCN_SELCHANGE: Memo1.Lines.Add(''''MCN_SELECT, MCN_SELCHANGE'''');//選中日期 end; end;
OldWindowProc(Msg); end;
procedure TForm1.FormCreate(Sender: TObject); begin OldWindowProc := MonthCalendar1.WindowProc; MonthCalendar1.WindowProc := MyWindowProc; end;
549的問題, 吃完飯看了下VCL的源碼, 應該可以! 不過, 點了翻页按鈕也會觸發日期選中的消息的, 相反則不會!
同時還看到一個:
发布TDateTimePicker同时修改日期和时间的解决方案
type TCDateTimePicker = class(TDateTimePicker) private procedure CNNotify(var Message: TWMNotify); message CN_NOTIFY; end;
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 TForm1.Button1Click(Sender: TObject); begin with TCDateTimePicker.Create(self) do begin Left := 100; Top := 100; Parent := Self; Format := ''''yyyy-MM-dd hh:mm:ss''''; Visible := true; end; end;
可以按上下鍵直接修改, 不錯! 不過要改到可以下拉面板也有時間選擇, 可能難一點!
btw: kylix 又說有新的clx要發布, 有點亂, 不是說停止開發了嗎?? 還有BCB, BCBX的新聞也有點亂, 是borland自己的產品定位還不清, 還是只不過傳言有誤??
|