p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > Visual Basic > VB 6 Visual Basic 6 > Pro VB 6
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Pro VB 6 For advanced Visual Basic coders working in version 6 (not .NET). Beginning-level questions will be redirected to other forums, including Beginning VB 6.

Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB 6 section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 11th, 2005, 11:06 AM
Registered User
 
Join Date: Nov 2005
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default DTM_SETSYSTEMTIME SendMessage

Anyone knows why a SendMessage/DTM_SETSYSTEMTIME fails across processes?[when the message is send from one process to the Date Time picker control in a different process, SendMessage returns 0 - indicating an error - and the picker remains unaffected]

Following is the code I had used to send

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Long) As Long

Private Declare Function GetLastError Lib "kernel32" () As Long

Private Const DTM_GETSYSTEMTIME = &H1001
Private Const DTM_SETSYSTEMTIME = &H1002
Private Const DTM_SETFORMAT = &H1032


Private Const GDT_VALID = 0
Private Type SYSTEMTIME
wYear As Integer
wMonth As Integer
wDayOfWeek As Integer
wDay As Integer
wHour As Integer
wMinute As Integer
wSecond As Integer
wMilliseconds As Integer
End Type

Private Sub Command1_Click()
Dim lngwhnd As Long
Dim lngwhnd_DTPick As Long
Dim lngErr As Long
Dim objSYS1 As SYSTEMTIME
Dim objSYS As SYSTEMTIME
Dim lngptr As Long

Dim str As String
objSYS.wYear = Year(Now) - 1
objSYS.wMonth = Month(Now) - 1
objSYS.wDay = Day(Now) - 1

lngwhnd = FindWindow(vbNullString, "DTPick")
lngwhnd_DTPick = FindWindowEx(lngwhnd, 0, "DTPicker20WndClass", vbNullString)

lngErr = SendMessage(lngwhnd_DTPick, DTM_GETSYSTEMTIME, GDT_VALID, objSYS)

lngErr = GetLastError

End Sub

I was able to set the date in the same process using the above code.

Also tried sending the LPARAM as pointer to the system date structure using the VarPtr function !! it didt work

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old November 18th, 2005, 04:37 PM
Friend of Wrox
Points: 914, Level: 11
Points: 914, Level: 11 Points: 914, Level: 11 Points: 914, Level: 11
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , .
Posts: 453
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma
Default

FindWindowEx internally calls GetWinfowText to retrieve the name of the window if the control is in the same process, if however the control belongs to some other process GetWinfowText retreivs only the caption of the window if any otherwise it returns NULL in which case there's nothing to compare the window name with. So make sure that u are able to find the window name and thus getting the window handle correctly before trying to send the control any messages.


Regards
Ankur Verma
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to SendMessage to an IE Dialog? DriveU C# 0 January 9th, 2007 02:57 AM
Sendmessage in flexgrid areejan2000 Crystal Reports 0 November 12th, 2005 02:18 AM



All times are GMT -4. The time now is 07:24 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc