Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MESSAGE CRACKERS

Status
Not open for further replies.

momon

Vendor
May 22, 2002
42
0
0
CA
I have the following code that works perfectly when compiled in 16-bit. When it is compiled in 32-bit, there is no response for a particular menu option. The code looks something like this:

//this part doesn't seem get executed, probably because the
//program is confused by WPARAM, LPARAM
LRESULT TTop20Wnd :: WMExportFile (WPARAM,LPARAM) {
char itemnumstr[4]="";

if (strlen (quotenum) < 2)
//continues
}

The response table looks like this

DEFINE_RESPONSE_TABLE1( TTop20Wnd, TChildWin )
EV_MESSAGE( WM_EXPORTFILE, WMExportFile),
EV_COMMAND( CM_REDESIGN, CMRedesign),
EV_COMMAND( CM_CHOOSE_DESIGN, CMChooseDesign),
END_RESPONSE_TABLE;


Now, how do I make this code portable using message crackers?

Thanks in advance.
 
DevGuide: Component writer's guide
Defining your own messages
A number of the standard components define messages for internal use. The most common reasons for defining messages are broadcasting information not covered by standard Windows messages and notification of state changes.
Defining a message is a two-step process. The steps are

1 Declaring a message identifier.
2 Declaring a message-structure type.

Declaring a message identifuier example:
A message identifier is an integer-sized constant. Windows reserves the messages below 1,024 for its own use, so when you declare your own messages you should start above that level.
The constant WM_APP represents the starting number for user-defined messages. When defining message identifiers, you should base them on WM_APP.
Be aware that some standard Windows controls use messages in the user-defined range. These include list boxes, combo boxes, edit boxes, and command buttons. If you derive a component from one of these and want to define a new message for it, be sure to check the MESSAGES.HPP file to see which messages Windows already defines for that control.

Example: User-defined messages
The following code shows two user-defined messages.
#define WM_MYFIRSTMESSAGE (WM_APP + 400)
#define WM_MYSECONDMESSAGE (WM_APP + 401)

Declaring a message-structure type Example:
Declaring a message-structure type
If you want to give useful names to the parameters of your message, you need to declare a message-structure type for that message. The message-structure is the type of the parameter passed to the message-handling method. If you do not use the message’s parameters, or if you want to use the old-style parameter notation (
wParam, lParam, and so on), you can use the default message-structure, TMessage.
To declare a message-structure type, follow these conventions:

1 Name the structure type after the message, preceded by a T.
2 Call the first data member in the structure Msg, of type TMsgParam.
3 Define the next two bytes to correspond to the Word parameter, and the next two bytes as unused.

Or
Define the next four bytes to correspond to the Longint parameter.

4 Add a final data member called Result, of type Longint.

Example: Message structure

For example, here is the message structure for all mouse messages, TWMKey:

struct TWMKey

{
Cardinal Msg; // first parameter is the message ID
Word CharCode; // this is the first wParam
Word Unused;
Longint KeyData; // this is the lParam
Longint Result; // this is the result data member
};
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top