以下的方法都无法发送成功
a = Format(Now, "yyyy M dd")
SendMessage 控件名柄, DTM_SETFORMAT, 0, ByVal aSendMessage 控件名柄, WM_SETTEXT, 0, ByVal a
a = Format(Now, "yyyy M dd")
SendMessage 控件名柄, DTM_SETFORMAT, 0, ByVal aSendMessage 控件名柄, WM_SETTEXT, 0, ByVal a
解决方案 »
- 在SQL SERVER 2000中,如何求日期和时间的差,SQL语句如何写?详细见正文:
- combobox的使用
- 高手:登陆密码要放在何处?该密码要可设置和修改,不使用大的后台数据库。有什么简单方便的方法吗
- set 工具栏上的某一按钮的图标=imagelist里的某一个图标,这句怎么写呀?
- 文本框输入变乱码问题
- vba来实现对word字体格式的控制
- imagecombo控件的STYLE属性
- 数据库数据转移
- 怎样更有效地进行打包?
- VB中的sendmessage函数功能很大,能具体跟我说说吗,我会很THANK YOU 的
- 100分求 DES加密/解密 算法的函数或Dll,能在VB中的实现!
- 如何判断一个字符串是否为正确的windows路径
C#代码
//===============================时间结构=======
/// <summary>
/// 时间类型
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public class SYSTEMTIME
{
public ushort wYear;
public ushort wMonth;
public ushort wDayOfWeek;
public ushort wDay;
public ushort wHour;
public ushort wMinute;
public ushort wSecond;
public ushort wMilliseconds;
}
//=============================================
[DllImport("user32.dll")]
public static extern int SetFocus(IntPtr hwnd);
[DllImport("user32.dll")]
public static extern int SendMessage(int hWnd, int msg, int wParam, SYSTEMTIME lparam);
[DllImport("user32.dll")]
public static extern int SendMessage(int hWnd, int msg, int wParam, int lparam);
[DllImport("user32.dll")]
public static extern int PostMessage(int hWnd, int msg, int wParam, int lparam);/// <summary>
/// 设置日期控件值
/// </summary>
/// <param name="dtpHwnd">日期控件句柄</param>
/// <param name="dt">日期值</param>
/// <returns>成功返回true 否则返回false</returns>
public static bool SetDateTimePickerValue(IntPtr dtpHwnd, DateTime dt)
{
SYSTEMTIME stT = new SYSTEMTIME();
stT.wYear = (ushort)dt.Year;
stT.wMonth = (ushort)dt.Month;
stT.wDay = (ushort)dt.Day;
stT.wHour = (ushort)0;
stT.wMinute = (ushort)0;
stT.wSecond = (ushort)0;
stT.wMilliseconds = (ushort)0;
int rr=SetFocus(dtpHwnd);
int jj=SetFocus(new IntPtr(rr));
int yy = SendMessage(dtpHwnd.ToInt32(), 0x0007, 0, 0);
int r = SendMessage(dtpHwnd.ToInt32(), 0x00001002, 0x00000000, stT);
int yyy = PostMessage(dtpHwnd.ToInt32(), 0x000F, 0, 0);
if (r == 1)
{
return true;
}
else
{
return false;
}
}
C++代码
//================
void __fastcall TForm1::Button1Click(TObject *Sender)
{
DWORD pid;
void *pAddr;
HANDLE hProcess;
SYSTEMTIME st;HWND hwndParent = FindWindow("TForm1", "Temp"); //这两行根据实际情况更改
HWND hwnd = FindWindowEx(hwndParent, NULL, "TDateTimePicker", NULL);if (hwnd != NULL)
{
GetWindowThreadProcessId(hwndParent, &pid);
hProcess = OpenProcess(PROCESS_VM_READ|PROCESS_VM_WRITE
|PROCESS_VM_OPERATION, FALSE, pid);
if (hProcess != NULL)
{
pAddr = VirtualAllocEx(hProcess, NULL, sizeof(SYSTEMTIME),
MEM_COMMIT, PAGE_READWRITE);
if (pAddr != NULL)
{
GetSystemTime(&st);
st.wHour = 9;
st.wMinute = 52;
st.wSecond = 32;if (WriteProcessMemory(hProcess, pAddr, &st, sizeof(SYSTEMTIME),
NULL))
{
SendMessage(hwnd, DTM_SETSYSTEMTIME, 0 , (LPARAM)pAddr);
}
VirtualFreeEx(hProcess, pAddr, 0, MEM_RELEASE);
}
CloseHandle(hProcess);
}
}
}