Sign in to follow this  

Translation: Delphi procedure that initialize with message to C++

This topic is 2542 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I want to convert the traditional way that the Delphi recieves the messages from Windows to C++.

In Delphi, some components have the procedure:

// Prototype inside a class
procedure WMKeyDown(var Message: TWMKeyDown); message WM_KEYDOWN;

// Procedure block
procedure CLASSNAME.WMKeyDown(var Message: TWMKeyDown);
begin
// Code here
end;


But I don't want to traslate to this way:


LRESULT CALLBACK WndProc( HWND Handle, UINT Message, WPARAM wp, LPARAM lp )
{
switch(Message)
{
case WM_KEYDOWN:
// Code here
break;
}
return DefWindowProc(Handle, Message, wp, lp);
}


There is another way to traslate this code to C++, using some directive in the function prototype?

Share this post


Link to post
Share on other sites
Neither C nor C++ have any keywords or directives to make implementing message handlers easier or cleaner. I'm not sure what you're looking to do, but Win32 message callbacks look mostly like what you've posted there, not including the messed up switch statement.

Share this post


Link to post
Share on other sites

This topic is 2542 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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

Sign in to follow this