Jump to content

question about converting


Recommended Posts

in c the messages are interpreted by the callback function

long CALLBACK _export MainWndProc (HWND hWnd, UINT message,WPARAM wParam, LPARAM lParam)

this is where in autoit we use

CODE
While 1

$Msg = GUIGetMsg()

Switch $Msg

Case $GUI_EVENT_CLOSE

Exit

EndSwitch

WEnd

i have a piece of c code where the lParam is used as parameter for another function.

Where do i get the value of lParam which is sent to the window.

I checked the getmsg function but it gives me no clues how to use this.

here is the source code in c i want to convert

its about the msg RTBM_DATA_ARRIVED when it is interpreted it uses lParam as parameter for the function RTBDataGetString

I like to know how i can convert this to autoit

CODE
long CALLBACK _export MainWndProc (HWND hWnd, UINT message,WPARAM wParam, LPARAM lParam)

{

/* Process the messages */

switch (message)

{

case WM_RTB_MESSAGE:

/* We are receiving a message from the RealTime Bridge.

* wParam tells us what it is. We will display some

* message according to it.

*/

switch (wParam)

{

case RTBM_LOGON_TRYING_PRIMARY:

strcpy (acMessage, "Trying the primary");

break;

case RTBM_LOGON_TRYING_SECONDARY:

strcpy (acMessage, "Trying the secondary");

break;

case RTBM_LOGON_COMPLETED:

strcpy (acMessage, "Completed the logon");

break;

case RTBM_ERROR:

ShowRTBErrorMessage (hWnd);

break;

case RTBM_DATA_ARRIVED:

{

char acTime [40];

/* lParam is the DataPacket ID.

* Get the time out of the data packet.

*/

RTBDataGetString (lParam, 0, 0, acTime, sizeof (acTime));

/* Free the data packet */

RTBFreePacket (lParam);

/* Create a message */

wsprintf (acMessage, "Hello World, it's %s on %s!",

(LPCSTR) acTime, (LPCSTR) acCallCenterName);

}

break;

}

/* Force repainting of the screen */

InvalidateRect (hWnd, NULL, TRUE);

return 0;

case WM_PAINT:

{

HDC hDC;

PAINTSTRUCT ps;

RECT rect;

/* Put the content of acMessage on the screen */

hDC = BeginPaint (hWnd, &ps);

GetClientRect (hWnd, &rect);

DrawText (hDC, acMessage, -1, &rect,

DT_SINGLELINE | DT_CENTER | DT_VCENTER);

EndPaint (hWnd, &ps);

}

return 0;

case WM_DESTROY: /* message: window being destroyed */

PostQuitMessage(0);

return 0;

}

return DefWindowProc (hWnd, message, wParam, lParam);

}

Edited by socratessa

Dont cry tomorrow about what you should have done yesterday. Just do it now.

Link to comment
Share on other sites

in c the messages are interpreted by the callback function

long CALLBACK _export MainWndProc (HWND hWnd, UINT message,WPARAM wParam, LPARAM lParam)

this is where in autoit we use

CODE
While 1

$Msg = GUIGetMsg()

Switch $Msg

Case $GUI_EVENT_CLOSE

Exit

EndSwitch

WEnd

i have a piece of c code where the lParam is used as parameter for another function.

Where do i get the value of lParam which is sent to the window.

I checked the getmsg function but it gives me no clues how to use this.

here is the source code in c i want to convert

its about the msg RTBM_DATA_ARRIVED when it is interpreted it uses lParam as parameter for the function RTBDataGetString

I like to know how i can convert this to autoit

CODE
long CALLBACK _export MainWndProc (HWND hWnd, UINT message,WPARAM wParam, LPARAM lParam)

{

/* Process the messages */

switch (message)

{

case WM_RTB_MESSAGE:

/* We are receiving a message from the RealTime Bridge.

* wParam tells us what it is. We will display some

* message according to it.

*/

switch (wParam)

{

case RTBM_LOGON_TRYING_PRIMARY:

strcpy (acMessage, "Trying the primary");

break;

case RTBM_LOGON_TRYING_SECONDARY:

strcpy (acMessage, "Trying the secondary");

break;

case RTBM_LOGON_COMPLETED:

strcpy (acMessage, "Completed the logon");

break;

case RTBM_ERROR:

ShowRTBErrorMessage (hWnd);

break;

case RTBM_DATA_ARRIVED:

{

char acTime [40];

/* lParam is the DataPacket ID.

* Get the time out of the data packet.

*/

RTBDataGetString (lParam, 0, 0, acTime, sizeof (acTime));

/* Free the data packet */

RTBFreePacket (lParam);

/* Create a message */

wsprintf (acMessage, "Hello World, it's %s on %s!",

(LPCSTR) acTime, (LPCSTR) acCallCenterName);

}

break;

}

/* Force repainting of the screen */

InvalidateRect (hWnd, NULL, TRUE);

return 0;

case WM_PAINT:

{

HDC hDC;

PAINTSTRUCT ps;

RECT rect;

/* Put the content of acMessage on the screen */

hDC = BeginPaint (hWnd, &ps);

GetClientRect (hWnd, &rect);

DrawText (hDC, acMessage, -1, &rect,

DT_SINGLELINE | DT_CENTER | DT_VCENTER);

EndPaint (hWnd, &ps);

}

return 0;

case WM_DESTROY: /* message: window being destroyed */

PostQuitMessage(0);

return 0;

}

return DefWindowProc (hWnd, message, wParam, lParam);

}

I don't know what the getmsg function is you refer to, but the function you need is GuiRegisterMsg.
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

I don't know what the getmsg function is you refer to, but the function you need is GuiRegisterMsg.

Its the autoit GuiGetMsg() function its a bit shorten since i found it difficult to descripe the matter i am searching for.

So its just an typing error. :)

Thx for the tip i will look at it.

Dont cry tomorrow about what you should have done yesterday. Just do it now.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...