Indigo Rose Software

Professional Software Development Tools

 
Results 1 to 8 of 8
  1. #1
    Join Date
    Jun 2006
    Location
    UK SouthWest
    Posts
    420

    User32.dll and sendmessageA

    I've been looking at Worms excellent example of using user32.dll to send text between open windows in AMS as i want to make a program in another laguage that communicates with AMS but im not to sure how to use the 'SendMessageA" function.
    From Worms Code :
    Code:
    function SendTo(nHandle, sMessage)
    	-- set the text
    	DLL.CallFunction(_SystemFolder.."\\User32.dll", "SendMessageA", nHandle..",12,0,\"~||~"..sMessage.."\"", DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL)
    	-- send keypress to fire event
    	DLL.CallFunction(_SystemFolder.."\\User32.dll", "SendMessageA", nHandle..",256,0,13", DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL)
    end
    The syntax for the function call is;
    hwnd As Long,wMsg As Long,wParam As Long, lParam As Any
    How can i construct the line
    Code:
    nHandle..",12,0,\"~||~"..sMessage.."\""
    in another language like visual basic or VC++?
    Also would the DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL stay the same?

  2. #2
    Join Date
    Jul 2002
    Location
    USA
    Posts
    3,959
    You can do the same thing from VB

    Code:
    'Declare SendMessage
    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

  3. #3
    Join Date
    Jun 2006
    Location
    UK SouthWest
    Posts
    420
    Thanks i found the SendMessage function before its just i dont know what Lparam and wparam and i cant find any helpful info on the function .

    MSDN2
    Message..::.LParam Property

    Specifies the LParam field of the message.

  4. #4
    Join Date
    Jul 2002
    Location
    USA
    Posts
    3,959
    If you're looking to do the same as I did, simply use the same values as I did in the AMS app. If you're looking for more info on the parameters, all I can say is Google is your friend.

  5. #5
    Join Date
    Jun 2006
    Location
    UK SouthWest
    Posts
    420
    thanks, finding the simple info allways seems to be the hardest task.

  6. #6
    Join Date
    Jun 2006
    Location
    UK SouthWest
    Posts
    420
    I had another go at trying to get VB and AMS to talk to eachother tonight and ive worked out how the line
    Code:
    nHandle..",12,0,\"~||~"..sMessage.."\""
    works in AMS.(I didnt realise it was a mix of code and regular strings.) I see that it translates to
    Code:
    nHandle,12,0,"~||~AndSomeMessage"
    But im not sure if this has to be converted in anyway to work in visual basic ? Or would it be something simple like:
    Code:
    Call SendMessage(nHandle, 12, 0, "~||~AndSomeMessage")
    thanks

  7. #7
    Join Date
    Jun 2006
    Location
    UK SouthWest
    Posts
    420
    Is there anyone out there with enough VB experience to know the correct syntax for the code? Ive been trying to get this right for a while and im getting noware with it. Im a bit dyslexic so guessing the right syntax is a bit of a nightmare for me, but with an example to work from i have no problems
    Last edited by clueless; 06-09-2008 at 11:29 AM.

  8. #8
    Join Date
    May 2006
    Posts
    1,443
    actually ,
    i have no knowledge about VB
    but your question is a WINAPI question
    and any programmer can reply your question

    so :
    Code:
    SendMessage(HWND hWnd,UINT Msg, WPARAM wParam,LPARAM lParam);
    hWnd : Window Handle That You Send Message To
    Msg : A Predefined Message Or Registered By The RegisterWindowMessage()
    wParam : This Is A Message Specific Data , Can Be In Any Type
    (int,bool,string) And Must Be Converted To WPARAM
    lParam : Second Message Specific Data , Can Be In Any Type
    (int,bool,string) And Must Be Converted To LPARAM

    An Example In C++
    Code:
    set a new icon for a window
    
    HICON  icon = LoadIcon();
    SendMessage(hWnd,WM_SETICON, ICON_SMALL,(LPARAM)(LONG)icon);
    Another One :
    Code:
    set a new text for a window
    
    CString sz_newtitle;
    sz_newtitle = "hello world";
    SendMessage(hWnd,WM_SETTEXT, 0,(LPARAM)sz_newtitle);
    finally LPARAM and WPARAM are specific datas for message that you used
    and can be in any type

    good bye

Similar Threads

  1. user32.dll further described
    By usernameCasper in forum AutoPlay Media Studio 6.0
    Replies: 2
    Last Post: 12-22-2006, 07:32 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts