NO

Author Topic: [tool] Message Cracker Wizard  (Read 12786 times)

TBD

  • Guest
[tool] Message Cracker Wizard
« on: January 23, 2005, 07:32:32 PM »
Message Cracker Wizard

"Message Cracker Wizard is the tool to unleash the power of message crackers: a set of macros that are in the windowsx.h header file of almost every Windows C/C++ compiler making message handling and processing easier than ever"

... also works with PellesC Win32 wizard !

nitex

  • Guest
[tool] Message Cracker Wizard
« Reply #1 on: January 28, 2005, 07:21:28 PM »
Very useful tool.

Greets, Alex

nitex

  • Guest
[tool] Message Cracker Wizard
« Reply #2 on: January 29, 2005, 05:40:43 PM »
After playing a bit with your Message Cracker Wizard, i missed some options which would be very useful to have in your tool.

Quote
From the book Advanced Windows (Third Edition) by Jeffrey Richter

When using message crackers with dialog boxes, you should not use the HANDLE_MSG macro from Microsoft's WINDOWSX.H header file. The reason to avoid this macro is that it doesn't return TRUE or FALSE to indicate whether a message was handled by the dialog box procedure. As much as i hate to admit it, the previous two editions of this book made the mistake of using the HANDLE_MSG macro. I was very lucky that the applications in the previous editions worked correctly. I have corrected all of the applications in this edition to use the HANDLE_DLGMSG macro.

// the normal HANDLE_MSG macro in WINDOWSX.H does not work properly
// for dialog boxes because DlgProcs return a BOOL instead of an LRESULT
// (like WndProcs)
#define HANDLE_DLGMSG(hwnd, message, fn) \
    case (message): \
        return (SetDlgMsgResult(hwnd, message, \
            HANDLE_##message((hwnd), (wParam), (lParam), (fn))))


Anyway, your program has a place now in my developement library. Pehaps you could add a option to include a FORWARD_MESSAGE macro in the Message Processing Functions, this would help writing code for subclassing controls like this.

Code: [Select]
BOOL InstallExampleHandler(HWND hwnd)
{
// replace wndproc with new one
pfnOldWndProc = SubclassWindow(hwnd, ExampleWndProc);
}

static void UninstallExampleHandler(HWND hwnd)
{
// restore wndproc to old one
SubclassWindow(hwnd, pfnOldWndProc);
}

static LRESULT CALLBACK ExampleWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
HANDLE_MSG(hwnd, WM_DESTROY, Example_OnDestroy);
HANDLE_MSG(hwnd, WM_MOUSEMOVE, Example_OnMouseMove);
default:
return Example_DefProc(hwnd, msg, wParam, lParam);
}
}

static LRESULT Example_DefProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
// call old wndproc for messages not handled in ExampleWndProc()
return CallWindowProc(pfnOldWndProc, hwnd, msg, wParam, lParam);
}

static void Example_OnDestroy(HWND hwnd)
{
FORWARD_WM_DESTROY(hwnd, Example_DefProc);
UninstallExampleHandler(hwnd);
}

static void Example_OnMouseMove(HWND hwnd, int x, int y, UINT keyFlags)
{
// do some processing here

// forward WM_MOUSEMOVE to old wndproc
FORWARD_WM_MOUSEMOVE(hwnd, x, y, keyFlags, Example_DefProc);
}


A more complete example is the owner drawn menu written by Pelle.


Greets, Alex

TBD

  • Guest
[tool] Message Cracker Wizard
« Reply #3 on: January 29, 2005, 06:01:20 PM »
it is not my program  :mrgreen:
I just posted the link here.

on the website there is also the source, so you can modify to your needs.

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
[tool] Message Cracker Wizard
« Reply #4 on: January 29, 2005, 06:16:02 PM »
Quote from: "nitex"

Code: [Select]
#define HANDLE_DLGMSG(hwnd, message, fn) \
    case (message): \
        return (SetDlgMsgResult(hwnd, message, \
            HANDLE_##message((hwnd), (wParam), (lParam), (fn))))



Seems useful - I have added HANDLE_DLGMSG to windowsx.h. Will be in the next beta.

Pelle
/Pelle

nitex

  • Guest
[tool] Message Cracker Wizard
« Reply #5 on: January 29, 2005, 06:25:39 PM »
To TBD: Oh, sorry. The sourcecode is C++, i must have a look if it can be easily converted to C. I have no experience with C++.  #-o

To Pelle: Yes very useful, but using this macro with a WM_PAINT message and returning some boolean value makes the application hang. I had some problems with it while developing the PRF Viewer.

Alex

nitex

  • Guest
[tool] Message Cracker Wizard
« Reply #6 on: February 07, 2005, 06:39:28 PM »
I finally found the error with the WM_PAINT message. I had to change the messageloop to check for dialog messages.

czerny

  • Guest
Re: [tool] Message Cracker Wizard
« Reply #7 on: December 29, 2011, 01:28:18 AM »
I have made some changes to the Message Cracker Wizard to fit my needs.
Added WM_HELP and WM_NOTIFY message crackers, commented out 'case IDC_MAKEWNDPROC:', changed HANDLE_DLGMSG for Dialogs, reverse logic for adding comments, appended 'static' for *_WndProc/*_DlgProc and message functions.

czerny
                   
« Last Edit: January 03, 2012, 06:22:02 PM by czerny »

czerny

  • Guest
Re: [tool] Message Cracker Wizard
« Reply #8 on: January 02, 2012, 09:55:40 AM »
I have added WM_NOTIFY to mcw. czerny

CommonTater

  • Guest
Re: [tool] Message Cracker Wizard
« Reply #9 on: January 02, 2012, 12:17:38 PM »
Looks ok...

Couple of little issues ...
First thing after entering WinMain you need to call InitCommonControls(); to get the DLL loaded.

Also your manifest has problems...

The Name section in AssemblyIdentity is the program name without extension... so "mcw"

To run it on Vista or Win7 without the trust info section would probably trigger the UAC requiring user confirmation every time they start the program. 

Also the Manifest should be imported into the program's resources so there's no risk of the two files being separated.

Try it like this...
Code: [Select]
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
    version="2.1.0.0"
    processorArchitecture="X86"
    name="mcw"
    type="win32" />

<description>
windowsx.h Message Crackers Help Tool
</description>

<dependency>
    <dependentAssembly>
        <assemblyIdentity
            type="win32"
            name="Microsoft.Windows.Common-Controls"
            version="6.0.0.0"
            processorArchitecture="X86"
            publicKeyToken="6595b64144ccf1df"
            language="*"
        />
    </dependentAssembly>
</dependency>

<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel  level="asInvoker"
                                  uiAccess="false" />
      </requestedPrivileges>
    </security>
  </trustInfo>

</assembly>


Offline Stefan Pendl

  • Global Moderator
  • Member
  • *****
  • Posts: 582
    • Homepage
Re: [tool] Message Cracker Wizard
« Reply #10 on: January 02, 2012, 12:59:52 PM »
To run it on Vista or Win7 without the trust info section would probably trigger the UAC requiring user confirmation every time they start the program. 

The missing trust information will result in the tool using file system virtualization, which can lead to missing file errors and such.

See Step 6: Create and Embed an Application Manifest (UAC)
---
Stefan

Proud member of the UltraDefrag Development Team

czerny

  • Guest
Re: [tool] Message Cracker Wizard
« Reply #11 on: January 02, 2012, 01:02:53 PM »
Thank you for yout hints,

I will try to correct this. Hope I can do this right, because can not  test it.

czerny